#include <TH2.h> #include <TStyle.h> #include <TCanvas.h> #include <iostream> #include "TCanvas.h" #include "TGraphErrors.h" #include "TF1.h" #include "TMath.h" #include "TChain.h" #include "TH1D.h" #include "string" #include "stdio.h" void plot(int run) { TCanvas *canwa= new TCanvas("plot", "plot", 800, 600); canwa->cd(1); string num[14] = {"475","476" , "477" , "487" , "488" ,"489" , "491" , "496" , "497", "500", "517", "525", "527", "528"}; string txt = ".txt"; for(int i=0;i<14;++i) { double x[9]; double y[9]; double ex[9]; double ey[9]; double z[9]={0.,1.,2.,3.,4.,5.,6.,7.,8.}; double ez[9]={0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5}; float mean, sigma, dummy; FILE *f; string tmp = num[i]+".txt"; cout<<tmp<<endl; f=fopen(tmp.c_str(), "r"); for(int j=0;j<18;++j) { char str1 [80]; char str2 [80]; char str3 [80]; char str4 [80]; char str5 [80]; char str6 [80]; char str7 [80]; char str8 [80]; fscanf(f,"%s %s %s %s %s %s %f %s %f %s %f", str1,str2,str3,str4,str5,str6, &mean, str7, &dummy, str8, &sigma); cout<<j<<" "<<mean<<endl; if((j/2)*2 ==j) x[j/2]=mean; if((j/2)*2 ==j) ex[j/2]=sigma; if((j/2)*2 ==j) x[j/2]=mean; if((j/2)*2 ==j) ex[j/2]=sigma; if((j/2)*2 !=j) y[j/2]=mean; if((j/2)*2 !=j) ey[j/2]=sigma; } fclose(f); //// now making plot TGraphErrors *gr = new TGraphErrors(9,z,x,ez,ex); gr->Draw("AP SAME"); canwa->Update(); string tmp2=num[i]+"x.png"; canwa->SaveAs(tmp2.c_str()); gr = new TGraphErrors(9,z,y,ez,ey); gr->Draw("AP SAME"); canwa->Update(); tmp2=num[i]+"y.png"; canwa->SaveAs(tmp2.c_str()); delete gr; } return; } //####################################################################### //####################################################################### //####################################################################### void plot2( int layer) { TCanvas *canwa= new TCanvas("plot", "plot", 800, 600); canwa->cd(1); string num[14] = {"475","476" , "477" , "487" , "488" ,"489" , "491" , "496" , "497", "500", "517", "525", "527", "528"}; string txt = ".txt"; for(int i=0;i<14;++i) { /* double x[9]; double y[9]; double ex[9]; double ey[9]; double z[9]={0.,1.,2.,3.,4.,5.,6.,7.,8.}; double ez[9]={0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5}; */ double x[14]; double y[14]; double ex[14]; double ey[14]; double runs[14]={0.,1.,2.,3.,4.,5.,6.,7.,8., 9., 10., 11., 12., 13.}; double drun[14]={0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; float mean, sigma, dummy; FILE *f; string tmp = num[i]+".txt"; cout<<tmp<<endl; f=fopen(tmp.c_str(), "r"); for(int j=0;j<18;++j) { char str1 [80]; char str2 [80]; char str3 [80]; char str4 [80]; char str5 [80]; char str6 [80]; char str7 [80]; char str8 [80]; fscanf(f,"%s %s %s %s %s %s %f %s %f %s %f", str1,str2,str3,str4,str5,str6, &mean, str7, &dummy, str8, &sigma); cout<<j<<" "<<mean<<endl; if(j/2 != layer) continue; if((j/2)*2 ==j) ex[i]=sigma; if((j/2)*2 ==j) x[i]=mean; if((j/2)*2 !=j) y[i]=mean; if((j/2)*2 !=j) ey[i]=sigma; cout<<x[i]<<" "<<y[i]<<endl; } fclose(f); //// now making plot if(i ==13){ TGraphErrors *gr = new TGraphErrors(14,runs,x,drun,ex); gr->Draw("AP"); canwa->Update(); string tmp2="layer8x.png"; canwa->SaveAs(tmp2.c_str()); gr = new TGraphErrors(14,runs,y,drun,ey); gr->Draw("AP"); canwa->Update(); tmp2="layer8y.png"; canwa->SaveAs(tmp2.c_str()); delete gr; } } return; }