]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/macrosQA/MakeTrendingTOFQA.C
Added flag for MC qa
[u/mrichter/AliRoot.git] / TOF / macrosQA / MakeTrendingTOFQA.C
CommitLineData
6c125480 1/*
2fbellini@cern.ch, last update on 09/01/2012
3- added flag for displaying reduced n. of trending plots
4- now producing tree run by run
5- new method to produce trending plots from list of trees
6*/
7
b14f7aae 8Int_t MakeTrendingTOFQA(char * runlist, Int_t year=2011, char *period="LHC11h", char* pass="pass1",Bool_t isMC=kFALSE,Int_t trainId=0, Bool_t displayAll=kFALSE){
7cc410ff 9 Int_t filesCounter=0;
3d9550f8 10
7cc410ff 11 if (!runlist) {
12 printf("Invalid list of runs given as input: nothing done\n");
13 return 1;
14 }
15 Int_t runNumber;
16 char infile[300];
17 char postFileName[20];
6c125480 18 char treePostFileName[20];
3d9550f8 19
7cc410ff 20 char trendFileName[100];
21 //Define trending output
22 if (trainId==0){
23 sprintf(trendFileName,"treeTOFQA_%s_%s.root",period,pass);
24 }else{
25 sprintf(trendFileName,"treeTOFQA_QA%i_%s_%s.root",trainId,period,pass);
26 }
27 TFile * trendFile=new TFile(trendFileName,"recreate");
6c125480 28 FILE * files = fopen(runlist, "r") ;
7cc410ff 29
6c125480 30 //create chain of treePostQA
31 Long64_t nentries=100000, firstentry=0;
32 TChain *chainTree = 0;
33 chainTree=new TChain("trendTree");
34
35 while (fscanf(files,"%d",&runNumber)==1 ){
36
37 //get QAtrain output
38 if (trainId==0){
b14f7aae 39 if (!isMC) sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QAresults.root",year,period,runNumber,pass);
40 else sprintf(infile,"alien:///alice/sim/%i/%s/%d/QAresults.root",year,period,runNumber);
6c125480 41 } else{
b14f7aae 42 if (!isMC) sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults.root",year,period,runNumber,pass,trainId);
43 else sprintf(infile,"alien:///alice/sim/%i/%s/%d/QA%i/QAresults.root",year,period,runNumber,trainId);
6c125480 44 }
b14f7aae 45
6c125480 46 Printf("============== Opening QA file(s) for run %i =======================\n",runNumber);
47
48 //run post-analysis
b14f7aae 49 if (RunESDQApostAnalysis(infile,runNumber,isMC,kTRUE)==0){
6c125480 50 filesCounter++;
51 sprintf(postFileName,"postQA_%i.root",runNumber);
52 sprintf(treePostFileName,"treePostQA_%i.root",runNumber);
53
b14f7aae 54 if (MakePostQAtree(runNumber, isMC, postFileName, treePostFileName)==0){
6c125480 55 chainTree->Add(treePostFileName);
56 Printf("Tree chain has now %d entries ",(Int_t)chainTree->GetEntries());
57 } else {
58 Printf("Could not get tree with trending quantities for run %i: SKIPPING",runNumber);
59 }
60 } else
61 Printf("Post analysis not run on QA output %s", infile);
62 }
63 return MakeTrendingFromTreeWithErrors(chainTree, trendFileName, displayAll);
64}
65//-----------------------------------------------------------
66Int_t MakeTrendingHistoFromTreeList(char * fileList, Bool_t displayAll=kFALSE){
7cc410ff 67
6c125480 68 Int_t filesCounter=0;
3d9550f8 69
6c125480 70 if (!fileList) {
71 printf("Invalid list of runs given as input: nothing done\n");
72 return 1;
73 }
74 char infile[300];
75 char trendFileName[100];
76 //Define trending output
77 sprintf(trendFileName,"trendingHistoTOFQA_%s.root",fileList);
78 TFile * trendFile=new TFile(trendFileName,"recreate");
79 FILE * files = fopen(fileList, "r") ;
3d9550f8 80
6c125480 81 //create chain of treePostQA
82 Long64_t nentries=100000, firstentry=0;
83 TChain *chainTree =new TChain("trendTree");
3d9550f8 84
6c125480 85 while (fscanf(files,"%s",&infile)==1 ){
86 if (!TFile::Open(infile,"r"))
87 Printf("Error: cannot open file %s", infile);
88 Printf("============== Adding QA tree file %s to the chain",infile);
89 filesCounter++;
90 chainTree->Add(infile);
91 }
92 return MakeTrendingFromTreeWithErrors(chainTree, trendFileName, displayAll);
3d9550f8 93}
94
95//______________________________________________________________________________
6c125480 96Int_t MakeTrendingFromTreeWithErrors(TChain * fin,char* trendFileName=NULL, Bool_t displayAll=kFALSE){
3d9550f8 97
7cc410ff 98 if (!trendFileName)
99 return 3;
6c125480 100
7cc410ff 101 if (!fin)
102 return 4;
6c125480 103
7cc410ff 104 Int_t runNumber;
105 Double_t avTime=0., peakTime=0., spreadTime=0., peakTimeErr=0., spreadTimeErr=0.,negTimeRatio=0.,
106 avRawTime=0., peakRawTime=0., spreadRawTime=0., peakRawTimeErr=0., spreadRawTimeErr=0.,
107 avTot=0., peakTot=0.,spreadTot=0., peakTotErr=0.,spreadTotErr=0.,
108 orphansRatio=0., avL=0., negLratio=0.,
109 effPt1=0., effPt2=0., matchEffLinFit1Gev=0.,matchEffLinFit1GevErr=0.;
110 Double_t avDiffTime=0.,peakDiffTime=0., spreadDiffTime=0.,peakDiffTimeErr=0., spreadDiffTimeErr=0.,avT0fillRes=0.;
3d9550f8 111
7cc410ff 112 Double_t avT0A=0.,peakT0A=0., spreadT0A=0.,peakT0AErr=0., spreadT0AErr=0.;
113 Double_t avT0C=0.,peakT0C=0., spreadT0C=0.,peakT0CErr=0., spreadT0CErr=0.;
114 Double_t avT0AC=0.,peakT0AC=0., spreadT0AC=0.,peakT0ACErr=0., spreadT0ACErr=0.;
115 Double_t avT0res=0.,peakT0res=0., spreadT0res=0.,peakT0resErr=0., spreadT0resErr=0.;
116 Int_t avMulti=0;
117 Float_t fractionEventsWHits=0;
3d9550f8 118
6c125480 119 TTree * ttree = (TTree*) fin->CloneTree();
7cc410ff 120 ttree->SetBranchAddress("run",&runNumber);
3d9550f8 121
7cc410ff 122 ttree->SetBranchAddress("avTime",&avTime); //mean time
123 ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit
124 ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit
125 ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error
126 ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error
3d9550f8 127
7cc410ff 128 ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio
3d9550f8 129
7cc410ff 130 ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time
131 ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit
132 ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit
133 ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw time after fit error
134 ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of raw main peak of time after fit error
3d9550f8 135
7cc410ff 136 ttree->SetBranchAddress("avTot",&avTot); //main peak tot
137 ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit
138 ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit
139 ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit
140 ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit
3d9550f8 141
7cc410ff 142 ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio
3d9550f8 143
7cc410ff 144 ttree->SetBranchAddress("avL",&avL); //mean track length
145 ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm
3d9550f8 146
7cc410ff 147 ttree->SetBranchAddress("effPt1",&effPt1);//matching eff at 1 GeV/c
148 ttree->SetBranchAddress("effPt2",&effPt2); //matching eff at 2 GeV/c
149 ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param
150 ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error
3d9550f8 151
7cc410ff 152 ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp
153 ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit
154 ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit
155 ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error
156 ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error
3d9550f8 157
7cc410ff 158 ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A
159 ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit
160 ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit
161 ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit
162 ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit
3d9550f8 163
7cc410ff 164 ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C
165 ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit
166 ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit
167 ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit
168 ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit
3d9550f8 169
7cc410ff 170 ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC
171 ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit
172 ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit
173 ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit
174 ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit
3d9550f8 175
7cc410ff 176 ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC
177 ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit
178 ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit
179 ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit
180 ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit
181 ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res
182
183 Int_t nRuns=ttree->GetEntries();
184 TList lista;
3d9550f8 185
6c125480 186 TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 187 hAvDiffTimeVsRun->SetDrawOption("E1");
188 hAvDiffTimeVsRun->SetMarkerStyle(20);
189 hAvDiffTimeVsRun->SetMarkerColor(kBlue);
190 // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
191
6c125480 192 TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;run; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. );
7cc410ff 193 hPeakDiffTimeVsRun->SetDrawOption("E1");
194 hPeakDiffTimeVsRun->SetMarkerStyle(20);
195 hPeakDiffTimeVsRun->SetMarkerColor(kBlue);
3d9550f8 196
6c125480 197 TH1F * hSpreadDiffTimeVsRun=new TH1F("hSpreadDiffTimeVsRun","#sigma(t-t_{exp}) (gaussian fit);run; #sigma(t^{TOF}-t_{exp,#pi}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
7cc410ff 198 hSpreadDiffTimeVsRun->SetDrawOption("E1");
199 hSpreadDiffTimeVsRun->SetMarkerStyle(20);
200 hSpreadDiffTimeVsRun->SetMarkerColor(kBlue);
201
6c125480 202 TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;run;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 203 hAvTimeVsRun->SetDrawOption("E1");
204 hAvTimeVsRun->SetMarkerStyle(20);
205 hAvTimeVsRun->SetMarkerColor(kBlue);
206 // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
207
6c125480 208 TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);run;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. );
7cc410ff 209 hPeakTimeVsRun->SetDrawOption("E1");
210 hPeakTimeVsRun->SetMarkerStyle(20);
211 hPeakTimeVsRun->SetMarkerColor(kBlue);
3d9550f8 212
6c125480 213 TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);run; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
7cc410ff 214 hSpreadTimeVsRun->SetDrawOption("E1");
215 hSpreadTimeVsRun->SetMarkerStyle(20);
216 hSpreadTimeVsRun->SetMarkerColor(kBlue);
3d9550f8 217
6c125480 218 TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};run;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 219 hAvRawTimeVsRun->SetDrawOption("E1");
220 hAvRawTimeVsRun->SetMarkerStyle(21);
221 hAvRawTimeVsRun->SetMarkerColor(kGreen);
222
6c125480 223 TH1F * hPeakRawTimeVsRun=new TH1F("hPeakRawTimeVsRun","Peak value of raw t^{TOF} (landau fit);run;t_{peak,raw}^{TOF} (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 224 hPeakRawTimeVsRun->SetDrawOption("E1");
225 hPeakRawTimeVsRun->SetMarkerStyle(21);
226 hPeakRawTimeVsRun->SetMarkerColor(kGreen);
227
6c125480 228 TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);run;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
7cc410ff 229 hSpreadRawTimeVsRun->SetDrawOption("E1");
230 hSpreadRawTimeVsRun->SetMarkerStyle(21);
231 hSpreadRawTimeVsRun->SetMarkerColor(kGreen);
3d9550f8 232
6c125480 233 TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
7cc410ff 234 hAvTotVsRun->SetDrawOption("E1");
235 hAvTotVsRun->SetMarkerStyle(22);
3d9550f8 236
6c125480 237 TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);run;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
7cc410ff 238 hPeakTotVsRun->SetDrawOption("E1");
239 hPeakTotVsRun->SetMarkerStyle(22);
3d9550f8 240
6c125480 241 TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
7cc410ff 242 hSpreadTotVsRun->SetDrawOption("E1");
243 hSpreadTotVsRun->SetMarkerStyle(22);
3d9550f8 244
6c125480 245 TH1F * hNegTimeRatioVsRun=new TH1F("hNegTimeRatioVsRun","Ratio of tracks with t^{TOF}<12.5 ns; run; ratio of tracks with t^{TOF}<12.5 ns (%)",nRuns, 0., nRuns);//, 100, 0. , 100.);
7cc410ff 246 hNegTimeRatioVsRun->SetDrawOption("E");
247
6c125480 248 TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); run; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
7cc410ff 249 hOrphansRatioVsRun->SetDrawOption("E");
250
6c125480 251 TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;run; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.);
7cc410ff 252 hMeanLVsRun->SetDrawOption("E");
6c125480 253 TH1F * hNegLRatioVsRun=new TH1F("hNegLRatioVsRun","Ratio of tracks with L<350 cm;run; ratio of tracks with L<350 cm (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
7cc410ff 254 hNegLRatioVsRun->SetDrawOption("E");
6c125480 255 TH1F * hMatchEffVsRun=new TH1F("hMatchEffVsRun","Matching efficiency (linear fit for p_{T}>1.0 GeV/c);run;matching efficiency (pT>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.);
7cc410ff 256 hMatchEffVsRun->SetDrawOption("E");
6c125480 257 TH1F * hMatchEffVsRun1=new TH1F("hMatchEffVsRun1","Matching efficiency (value for p_{T}=1.0 GeV/c);run;matching efficiency (pT=1.0 GeV/c)",nRuns, 0., nRuns);
7cc410ff 258 hMatchEffVsRun1->SetDrawOption("E");
6c125480 259 TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);run;t0A (ps)",nRuns,0., nRuns);
260 TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);run;t0AC (ps)",nRuns,0., nRuns);
261 TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);run;t0AC (ps)",nRuns,0., nRuns);
262 TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;run;t0_spread (ps)",nRuns,0., nRuns);
3d9550f8 263
7cc410ff 264 lista.Add(hAvDiffTimeVsRun);
265 lista.Add(hPeakDiffTimeVsRun);
266 lista.Add(hSpreadDiffTimeVsRun);
267 lista.Add(hAvTimeVsRun);
268 lista.Add(hPeakTimeVsRun);
269 lista.Add(hSpreadTimeVsRun);
270 lista.Add( hAvRawTimeVsRun);
271 lista.Add( hPeakRawTimeVsRun);
272 lista.Add( hSpreadRawTimeVsRun);
273 lista.Add( hAvTotVsRun);
274 lista.Add( hPeakTotVsRun);
275 lista.Add( hSpreadTotVsRun);
276 lista.Add( hNegTimeRatioVsRun);
277 lista.Add( hOrphansRatioVsRun);
278 lista.Add( hMeanLVsRun);
279 lista.Add( hNegLRatioVsRun);
280 lista.Add( hMatchEffVsRun);
281 lista.Add(hPeakT0AVsRun);
282 lista.Add(hPeakT0CVsRun);
283 lista.Add(hPeakT0ACVsRun);
284 lista.Add(hT0fillResVsRun);
285 char runlabel[6];
3d9550f8 286
7cc410ff 287 for (Int_t irun=0;irun<nRuns;irun++){
288 ttree->GetEntry(irun);
3d9550f8 289
7cc410ff 290 sprintf(runlabel,"%i",runNumber);
3d9550f8 291
7cc410ff 292 hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime);
293 hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 294
7cc410ff 295 hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime);
296 hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr);
297 hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 298
7cc410ff 299 hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime);
300 hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr);
301 hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 302
7cc410ff 303 hAvTimeVsRun->SetBinContent(irun+1, avTime);
304 hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 305
7cc410ff 306 hPeakTimeVsRun->SetBinContent(irun+1,peakTime);
307 hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr);
308 hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 309
7cc410ff 310 hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime);
311 hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr);
312 hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 313
7cc410ff 314 hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime);
315 hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 316
7cc410ff 317 hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime);
318 hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr);
319 hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 320
7cc410ff 321 hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime);
322 hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr);
323 hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 324
db768bb3 325 hAvTotVsRun->SetBinContent(irun+1,avTot);
7cc410ff 326 hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 327
db768bb3 328 hPeakTotVsRun->SetBinContent(irun+1,peakTot);
7cc410ff 329 hPeakTotVsRun->SetBinError(irun+1,peakTotErr);
330 hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 331
db768bb3 332 hSpreadTotVsRun->SetBinContent(irun+1,spreadTot);
7cc410ff 333 hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr);
334 hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 335
db768bb3 336 hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio);
7cc410ff 337 hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 338
db768bb3 339 hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio);
7cc410ff 340 hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 341
db768bb3 342 hMeanLVsRun->SetBinContent(irun+1,avL);
7cc410ff 343 hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 344
db768bb3 345 hNegLRatioVsRun->SetBinContent(irun+1,negLratio);
7cc410ff 346 hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 347
db768bb3 348 hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev);
7cc410ff 349 hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr);
350 hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 351
7cc410ff 352 hPeakT0AVsRun->SetBinContent(irun+1,peakT0A);
353 hPeakT0AVsRun->SetBinError(irun+1,spreadT0A);
354 hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 355
7cc410ff 356 hPeakT0CVsRun->SetBinContent(irun+1,peakT0C);
357 hPeakT0CVsRun->SetBinError(irun+1,spreadT0C);
358 hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 359
7cc410ff 360 hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC);
361 hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC);
362 hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
363
364 hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes);
365 hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 366
7cc410ff 367 }
3d9550f8 368
7cc410ff 369 char outfilename[200];
370 sprintf(outfilename, "trend_%s",trendFileName);
371 TFile * fout=new TFile(outfilename,"recreate");
372 fout->cd();
373 lista.Write();
374 fout->Close();
375
376 TString plotDir(Form("PlotsTrending"));
377 gSystem->Exec(Form("mkdir %s",plotDir.Data()));
378
7cc410ff 379 TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,750,550);
380 hPeakDiffTimeVsRun->Draw();
80956e04 381 cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.png",plotDir.Data()));
7cc410ff 382
383 TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,750,550);
384 hSpreadDiffTimeVsRun->Draw();
80956e04 385 cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.png",plotDir.Data()));
7cc410ff 386
7cc410ff 387 TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun", 50,50,750,550);
388 hMatchEffVsRun->Draw();
80956e04 389 cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.png",plotDir.Data()));
7cc410ff 390
391 TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,750,550);
392 hPeakT0AVsRun->Draw();
393 cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data()));
394
395 TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,750,550);
396 hPeakT0CVsRun->Draw();
397 cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data()));
398
399 TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,750,550);
400 hPeakT0ACVsRun->Draw();
401 cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data()));
402
403 TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,750,550);
404 hT0fillResVsRun->Draw();
405 cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data()));
406
6c125480 407 if (displayAll) {
408 TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,750,550);
409 gPad->SetGridx();
410 gPad->SetGridy();
411 hAvDiffTimeVsRun->Draw();
412 cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data()));
413
414 TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,750,550);
415 hAvTimeVsRun->Draw();
416 cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data()));
417
418 TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,750,550);
419 hPeakTimeVsRun->Draw();
420 cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data()));
421
422 TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,750,550);
423 hSpreadTimeVsRun->Draw();
424 cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data()));
425
426 TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,750,550);
427 hAvRawTimeVsRun->Draw();
428 cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data()));
429
430 TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,750,550);
431 hPeakRawTimeVsRun->Draw();
432 cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data()));
433
434 TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,750,550);
435 hSpreadRawTimeVsRun->Draw();
436 cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data()));
437
438 TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,750,550);
439 hAvTotVsRun->Draw();
440 cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data()));
441
442 TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,750,550);
443 hPeakTotVsRun->Draw();
444 cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data()));
445
446 TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,750,550);
447 hSpreadTotVsRun->Draw();
448 cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data()));
449
450 TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,750,550);
451 hNegTimeRatioVsRun->Draw();
452 cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data()));
453
454 TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,750,550);
455 hOrphansRatioVsRun->Draw();
456 cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data()));
457
458 TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,750,550);
459 hMeanLVsRun->Draw();
460 cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data()));
461
462 TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,750,550);
463 hNegLRatioVsRun->Draw();
464 cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data()));
465 }
466
7cc410ff 467 return 0;
3d9550f8 468}
469
6c125480 470//-------------------------------------------------------------------------
b14f7aae 471Int_t MakePostQAtree(Int_t runNumber, Bool_t isMC=kFALSE, char * postFileName="postQA.0.root",char * treePostFileName="treePostQA.0.root"){
6c125480 472
473 TFile *postfile=TFile::Open(postFileName);
474 if (!postfile) {
475 printf("Post-analysis output not found - cannot perform trending analysis. Exiting.");
476 return -1;
477 }
478 Printf("============== Getting post-analysis info for run %i ===============\n",runNumber);
479 TFile * trendFile=new TFile(treePostFileName,"recreate");
480
481 Double_t avTime=-9999., peakTime=-9999., spreadTime=-9999., peakTimeErr=-9999., spreadTimeErr=-9999., negTimeRatio=-9999.,
482 avRawTime=-9999., peakRawTime=-9999., spreadRawTime=-9999., peakRawTimeErr=-9999., spreadRawTimeErr=-9999.,
483 avTot=-9999., peakTot=-9999.,spreadTot=-9999., peakTotErr=-9999.,spreadTotErr=-9999.,
484 orphansRatio=-9999., avL=-9999., negLratio=-9999.,
485 effPt1=-9999., effPt2=-9999., matchEffLinFit1Gev=-9999.,matchEffLinFit1GevErr=-9999.;
486
487 Double_t avPiDiffTime=-9999.,peakPiDiffTime=-9999., spreadPiDiffTime=-9999.,peakPiDiffTimeErr=-9999., spreadPiDiffTimeErr=-9999.;
488
489 Double_t avT0A=-9999.,peakT0A=-9999., spreadT0A=-9999.,peakT0AErr=-9999., spreadT0AErr=-9999.;
490 Double_t avT0C=-9999.,peakT0C=-9999., spreadT0C=-9999.,peakT0CErr=-9999., spreadT0CErr=-9999.;
491 Double_t avT0AC=-9999.,peakT0AC=-9999., spreadT0AC=-9999.,peakT0ACErr=-9999., spreadT0ACErr=-9999.;
492 Double_t avT0res=-9999.,peakT0res=-9999., spreadT0res=-9999.,peakT0resErr=-9999., spreadT0resErr=-9999.;
493 Double_t avT0fillRes=-9999.;
494
495 Int_t avMulti=0;
496 Float_t fractionEventsWHits=-9999.;
497
498 TTree * ttree=new TTree("trendTree","tree of trending variables");
499 ttree->Branch("run",&runNumber,"run/I");
500 ttree->Branch("avMulti",&avMulti,"avMulti/I");
501 ttree->Branch("fractionEventsWHits",&fractionEventsWHits,"fractionEventsWHits/F");
502 ttree->Branch("avTime",&avTime,"avTime/D"); //mean time
503 ttree->Branch("peakTime",&peakTime,"peakTime/D"); //main peak time after fit
504 ttree->Branch("spreadTime",&spreadTime,"spreadTime/D"); //spread of main peak of time after fit
505 ttree->Branch("peakTimeErr",&peakTimeErr,"peakTimeErr/D"); //main peak time after fit error
506 ttree->Branch("spreadTimeErr",&spreadTimeErr,"spreadTimeErr/D"); //spread of main peak of time after fit error
507 ttree->Branch("negTimeRatio",&negTimeRatio,"negTimeRatio/D"); //negative time ratio
508
509 ttree->Branch("avRawTime",&avRawTime,"avRawTime/D"); //mean raw time
510 ttree->Branch("peakRawTime",&peakRawTime,"peakRawTime/D"); //mean peak of RAW TIME after fit
511 ttree->Branch("spreadRawTime",&spreadRawTime,"spreadRawTime/D"); //spread of main peak of raw time after fit
512 ttree->Branch("peakRawTimeErr",&peakRawTimeErr,"peakRawTimeErr/D"); //main peak raw time after fit error
513 ttree->Branch("spreadRawTimeErr",&spreadRawTimeErr,"spreadRawTimeErr/D"); //spread of raw main peak of time after fit error
514
515 ttree->Branch("avTot",&avTot,"avTot/D"); //main peak tot
516 ttree->Branch("peakTot",&peakTot,"peakTot/D"); // main peak of tot after fit
517 ttree->Branch("spreadTot",&spreadTot,"spreadTot/D"); //spread of main peak of tot after fit
518 ttree->Branch("peakTotErr",&peakTotErr,"peakTotErr/D"); // main peak of tot after fit
519 ttree->Branch("spreadTotErr",&spreadTotErr,"spreadTotErr/D"); //spread of main peak of tot after fit
520
521 ttree->Branch("orphansRatio",&orphansRatio,"orphansRatio/D"); //orphans ratio
522
523 ttree->Branch("avL",&avL,"avL/D"); //mean track length
524 ttree->Branch("negLratio",&negLratio,"negLratio/D");//ratio of tracks with track length <350 cm
6c125480 525 ttree->Branch("effPt1",&effPt1,"effPt1/D");//matching eff at 1 GeV/c
526 ttree->Branch("effPt2",&effPt2,"effPt2/D"); //matching eff at 2 GeV/c
527 ttree->Branch("matchEffLinFit1Gev",&matchEffLinFit1Gev,"matchEffLinFit1Gev/D");//matching eff fit param
528 ttree->Branch("matchEffLinFit1GevErr",&matchEffLinFit1GevErr,"matchEffLinFit1GevErr/D");////matching eff fit param error
529
530 ttree->Branch("avPiDiffTime",&avPiDiffTime,"avPiDiffTime/D"); //mean t-texp
531 ttree->Branch("peakPiDiffTime",&peakPiDiffTime,"peakPiDiffTime/D"); //main peak t-texp after fit
532 ttree->Branch("spreadPiDiffTime",&spreadPiDiffTime,"spreadPiDiffTime/D"); //spread of main peak t-texp after fit
533 ttree->Branch("peakPiDiffTimeErr",&peakPiDiffTimeErr,"peakPiDiffTimeErr/D"); //main peak t-texp after fit error
534 ttree->Branch("spreadPiDiffTimeErr",&spreadPiDiffTimeErr,"spreadPiDiffTimeErr/D"); //spread of main peak of t-texp after fit error
535
536 ttree->Branch("avT0A",&avT0A,"avT0A/D"); //main peak t0A
537 ttree->Branch("peakT0A",&peakT0A,"peakT0A/D"); // main peak of t0A after fit
538 ttree->Branch("spreadT0A",&spreadT0A,"spreadTot/D"); //spread of main peak of t0A after fit
539 ttree->Branch("peakT0AErr",&peakT0AErr,"peakT0AErr/D"); // main peak of t0A after fit
540 ttree->Branch("spreadT0AErr",&spreadT0AErr,"spreadT0AErr/D"); //spread of main peak of t0A after fit
541
542 ttree->Branch("avT0C",&avT0C,"avT0C/D"); //main peak t0C
543 ttree->Branch("peakT0C",&peakT0C,"peakT0C/D"); // main peak of t0C after fit
544 ttree->Branch("spreadT0C",&spreadT0C,"spreadT0C/D"); //spread of main peak of t0C after fit
545 ttree->Branch("peakT0CErr",&peakT0CErr,"peakT0CErr/D"); // main peak of t0C after fit
546 ttree->Branch("spreadT0CErr",&spreadT0CErr,"spreadT0CErr/D"); //spread of main peak of t0C after fit
547
548 ttree->Branch("avT0AC",&avT0AC,"avT0AC/D"); //main peak t0AC
549 ttree->Branch("peakT0AC",&peakT0AC,"peakT0AC/D"); // main peak of t0AC after fit
550 ttree->Branch("spreadT0AC",&spreadT0AC,"spreadT0AC/D"); //spread of main peak of t0AC after fit
551 ttree->Branch("peakT0ACErr",&peakT0ACErr,"peakT0ACErr/D"); // main peak of t0AC after fit
552 ttree->Branch("spreadT0ACErr",&spreadT0ACErr,"spreadT0ACErr/D"); //spread of main peak of t0AC after fit
553
554 ttree->Branch("avT0res",&avT0res,"avT0res/D"); //main peak t0AC
555 ttree->Branch("peakT0res",&peakT0res,"peakT0res/D"); // main peak of t0AC after fit
556 ttree->Branch("spreadT0res",&spreadT0res,"spreadT0res/D"); //spread of main peak of t0AC after fit
557 ttree->Branch("peakT0resErr",&peakT0resErr,"peakT0resErr/D"); // main peak of t0AC after fit
558 ttree->Branch("spreadT0resErr",&spreadT0resErr,"spreadT0resErr/D"); //spread of main peak of t0AC after fit
559 ttree->Branch("avT0fillRes",&avT0fillRes,"avT0fillRes/D"); //t0 fill res
560
561 //postfile->ls();
562 //save quantities for trending
563
564 //--------------------------------- Multiplicity ----------------------------------//
565 TH1F*hMulti=(TH1F*)postfile->Get("hTOFmatchedPerEvt");
566 if ((hMulti)&&(hMulti->GetEntries()>0)) {
567 avMulti=hMulti->GetMean();
568 }
569
570 //--------------------------------- T0F signal ----------------------------------//
571
572 TH1F*hTime=(TH1F*)postfile->Get("hTOFmatchedESDtime");
573 if ((hTime)&&(hTime->GetEntries()>0)) {
574 avTime=hTime->GetMean();
575 hTime->Fit("landau","","",0.,50.);
576 peakTime=(hTime->GetFunction("landau"))->GetParameter(1);
577 spreadTime=(hTime->GetFunction("landau"))->GetParameter(2);
578 peakTimeErr=(hTime->GetFunction("landau"))->GetParError(1);
579 spreadTimeErr=(hTime->GetFunction("landau"))->GetParError(2);
580
581 negTimeRatio=((Double_t)hTime->Integral(1,3)*100.)/((Double_t)hTime->Integral());
582 printf("Main peak time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
583 printf("Main peak time (landau): spread = %f +- %f\n",spreadTime,spreadTimeErr );
584 printf("Ratio of tracks with time<12.5 ns / total = %f\n",negTimeRatio );
585
586 //add integral of main peak over total
587 }
588 printf("---------------------------------------------------------------- \n");
589 TH1F * hRawTime = (TH1F*)postfile->Get("hTOFmatchedESDrawTime");
590 if ((hRawTime)&&(hRawTime->GetEntries()>0)){
591 avRawTime=hRawTime->GetMean();
b14f7aae 592 if (!isMC){
593 hRawTime->Fit("landau","","",200.,250.);
594 peakRawTime=(hRawTime->GetFunction("landau"))->GetParameter(1);
595 spreadRawTime=(hRawTime->GetFunction("landau"))->GetParameter(2);
596 peakRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(1);
597 spreadRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(2);
598 printf("Main peak raw time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
599 printf("Main peak raw time (landau): spread = %f +- %f\n",spreadRawTime,spreadRawTimeErr );
600 } else {
601 printf("Reminder: Raw time not available in MC simulated data.");
602 }
6c125480 603 }
604
605 printf("---------------------------------------------------------------- \n");
606
607 TH1F * hTot = (TH1F*)postfile->Get("hTOFmatchedESDToT");
608 if ((hTot)&&(hTot->GetEntries()>0)){
609 avTot=hTot->GetMean();
610 hTot->Fit("gaus","","",0.,50.);
611 peakTot=(hTot->GetFunction("gaus"))->GetParameter(1);
612 spreadTot=(hTot->GetFunction("gaus"))->GetParameter(2);
613 peakTotErr=(hTot->GetFunction("gaus"))->GetParError(1);
614 spreadTotErr=(hTot->GetFunction("gaus"))->GetParError(2);
615 printf("Main peak ToT (gaus): mean = %f +- %f\n",peakTot,peakTotErr );
616 printf("Main peak ToT (gaus): spread = %f +- %f\n",spreadTot,spreadTotErr );
617 }
618 printf("---------------------------------------------------------------- \n");
619 TH1F * hOrphansRatio=(TH1F*)postfile->Get("hOrphansRatio");
620 if (hOrphansRatio)
621 orphansRatio=hOrphansRatio->GetMean();
622
623 TH1F * hL=(TH1F*)postfile->Get("hTOFmatchedESDtrkLength");
624 if (hL)
625 avL=hL->GetMean();
626
627 TH1F *hLnegRatio =(TH1F*)postfile->Get("hLnegRatio");
628 if (hLnegRatio)
629 negLratio=hLnegRatio->GetMean();
630
631 //--------------------------------- matching eff ----------------------------------//
632
633 //Double_t linFitEff1Param[3]={0.,0.,0.};
634 TH1F *hMatchingVsPt =(TH1F*)postfile->Get("hTOFmatchedESDPt");
635 if (hMatchingVsPt) {
636 if (hMatchingVsPt->GetEntries()>0){
637 hMatchingVsPt->Fit("pol0","","",1.0,5.);
638 hMatchingVsPt->Draw();
639 if (hMatchingVsPt->GetFunction("pol0")){
640 matchEffLinFit1Gev=(hMatchingVsPt->GetFunction("pol0"))->GetParameter(0);
641 matchEffLinFit1GevErr=(hMatchingVsPt->GetFunction("pol0"))->GetParError(0);
642 printf("Matching efficiency fit param is %f +- %f\n",matchEffLinFit1Gev,matchEffLinFit1GevErr );
643 }
644 } else {
645 printf("WARNING: matching efficiency plot has 0 entries. Skipped!\n");
646 }
647 } else {
648 printf("WARNING: cannot retrieve matching efficiency plot\n");
649 }
650
651 //--------------------------------- t-texp ----------------------------------//
652
653 TH1F*hPiDiffTime=(TH1F*)postfile->Get("hTOFmatchedExpTimePi");
654 if ((hPiDiffTime)&&(hPiDiffTime->GetEntries()>0)) {
655 avPiDiffTime=hPiDiffTime->GetMean();
656 hPiDiffTime->Fit("gaus","","",-1000.,500.);
657 if (hPiDiffTime->GetFunction("gaus")){
658 peakPiDiffTime=(hPiDiffTime->GetFunction("gaus"))->GetParameter(1);
659 spreadPiDiffTime=(hPiDiffTime->GetFunction("gaus"))->GetParameter(2);
660 peakPiDiffTimeErr=(hPiDiffTime->GetFunction("gaus"))->GetParError(1);
661 spreadPiDiffTimeErr=(hPiDiffTime->GetFunction("gaus"))->GetParError(2);
662 printf("Main peak t-t_exp (gaus): mean = %f +- %f\n",peakPiDiffTime,peakPiDiffTimeErr );
663 printf("Main peak t-t_exp (gaus): spread = %f +- %f\n",spreadPiDiffTime,spreadPiDiffTimeErr );
664 }
665 }
666 //--------------------------------- T0 detector ----------------------------------//
667
668 TH1F*hT0A=(TH1F*)postfile->Get("hEventT0DetA");
669 if ((hT0A)&&(hT0A->GetEntries()>0)) {
670 avhT0A=hT0A->GetMean();
671 hT0A->Fit("gaus");
672 peakT0A=(hT0A->GetFunction("gaus"))->GetParameter(1);
673 spreadT0A=(hT0A->GetFunction("gaus"))->GetParameter(2);
674 peakT0AErr=(hT0A->GetFunction("gaus"))->GetParError(1);
675 spreadT0AErr=(hT0A->GetFunction("gaus"))->GetParError(2);
676 printf("Main peak T0A(gaus): mean = %f +- %f\n",peakT0A,peakT0AErr );
677 printf("Main peak T0A (gaus): spread = %f +- %f\n",spreadT0A,spreadT0AErr );
678 //add integral of main peak over total
679 }
680
681 TH1F*hT0C=(TH1F*)postfile->Get("hEventT0DetC");
682 if ((hT0C)&&(hT0C->GetEntries()>0)) {
683 avhT0C=hT0C->GetMean();
684 hT0C->Fit("gaus");
685 peakT0C=(hT0C->GetFunction("gaus"))->GetParameter(1);
686 spreadT0C=(hT0C->GetFunction("gaus"))->GetParameter(2);
687 peakT0CErr=(hT0C->GetFunction("gaus"))->GetParError(1);
688 spreadT0CErr=(hT0C->GetFunction("gaus"))->GetParError(2);
689 printf("Main peak T0C(gaus): mean = %f +- %f\n",peakT0C,peakT0CErr );
690 printf("Main peak T0C (gaus): spread = %f +- %f\n",spreadT0C,spreadT0CErr );
691 //add integral of main peak over total
692 }
693
694 TH1F*hT0AC=(TH1F*)postfile->Get("hEventT0DetAND");
695 if ((hT0AC)&&(hT0AC->GetEntries()>0)) {
696 avhT0AC=hT0AC->GetMean();
697 hT0AC->Fit("gaus");
698 peakT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(1);
699 spreadT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(2);
700 peakT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(1);
701 spreadT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(2);
702 printf("Main peak T0AC(gaus): mean = %f +- %f\n",peakT0AC,peakT0ACErr );
703 printf("Main peak T0AC (gaus): spread = %f +- %f\n",spreadT0AC,spreadT0ACErr );
704 }
705
706 TH1F*hT0res=(TH1F*)postfile->Get("hT0DetRes");
707 if ((hT0res)&&(hT0res->GetEntries()>0)) {
708 avhT0res=hT0res->GetMean();
709 hT0res->Fit("gaus");
710 peakT0res=(hT0res->GetFunction("gaus"))->GetParameter(1);
711 spreadT0res=(hT0res->GetFunction("gaus"))->GetParameter(2);
712 peakT0resErr=(hT0res->GetFunction("gaus"))->GetParError(1);
713 spreadT0resErr=(hT0res->GetFunction("gaus"))->GetParError(2);
714 printf("Main peak T0res(gaus): mean = %f +- %f\n",peakT0res,peakT0resErr );
715 printf("Main peak T0res (gaus): spread = %f +- %f\n",spreadT0res,spreadT0resErr );
716 //add integral of main peak over total
717 }
718
719 TH1F*hT0fillRes=(TH1F*)postfile->Get("hT0fillRes");
720 if ((hT0fillRes)&&(hT0fillRes->GetEntries()>0)) {
721 avT0fillRes=hT0fillRes->GetMean();
722 }
723
724 ttree->Fill();
725 printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
726 if (postfile->IsOpen()) {
727 printf("Trying to close\n");
728 postfile->Close();
729 }
730
731 trendFile->cd();
732 ttree->Write();
733 trendFile->Close();
734 return 0;
735}
736
3d9550f8 737//------------------------------------------------------------------------------------
738
b14f7aae 739Int_t RunESDQApostAnalysis(char *qafilename=NULL, Int_t runNumber=-1, Bool_t isMC=kFALSE, Bool_t IsOnGrid=kFALSE, Bool_t canvasE=kFALSE) {
3d9550f8 740
7cc410ff 741 Bool_t debug=kFALSE;
3d9550f8 742
2bfe5463 743 /*access qa PWGPP output files - saved locally or on grid as specified by the second argument */
3d9550f8 744
7cc410ff 745 char defaultQAoutput[30]="QAresults.root";
746 if (IsOnGrid) TGrid::Connect("alien://");
747 TFile * fin= TFile::Open(qafilename,"r");
748 printf("Opening file %s\n",qafilename);
749 if (!fin) {
750 printf("ERROR: QA output not found. Exiting with status -1\n");
751 return -1;
752 } else {
753 printf("INFO: QA output file %s open. \n",fin->GetName());
754 }
3d9550f8 755
756
7cc410ff 757 //access histograms lists
758 char tofQAdirName[15]="TOF_Performance";
759 char genListName[15]="cGeneralTOFqa";
760 char t0ListName[15]="cTimeZeroTOFqa";
761 char pidListName[15]="cPIDTOFqa";
762 char posListName[15]="cPositiveTOFqa";
763 char negListName[15]="cNegativeTOFqa";
3d9550f8 764
7cc410ff 765 TDirectoryFile * tofQAdir=(TDirectoryFile*)fin->Get(tofQAdirName);
766 if(debug){
767 printf("------------------------------------------------------------------\n");
768 tofQAdir->ls();
769 printf("------------------------------------------------------------------\n");
770 }
3d9550f8 771
7cc410ff 772 TList * generalList=(TList*)tofQAdir->Get(genListName);
773 TList *timeZeroList=(TList*)tofQAdir->Get(t0ListName);
774 TList *pidList=(TList*)tofQAdir->Get(pidListName);
775 TList *posList=(TList*)tofQAdir->Get(posListName);
776 TList *negList=(TList*)tofQAdir->Get(negListName);
777
778 if (!generalList) printf("WARNING: general QA histograms absent or not accessible\n");
779 if (!timeZeroList) printf("WARNING: timeZero QA histograms absent or not accessible\n");
780 if (!pidList) printf("WARNING: PID QA histograms absent or not accessible\n");
781 if (!posList) printf("WARNING: general QA histograms for positive tracks absent or not accessible\n");
782 if (!negList) printf("WARNING: general QA histograms for negative tracks absent or not accessible\n");
783
784 if ( (!generalList) && (!timeZeroList) && (!pidList) ){
785 printf("ERROR: no QA available \n");
786 return 1;
787 }
3d9550f8 788
7cc410ff 789 if (debug){
790 generalList->ls();
791 printf("------------------------------------------------------------------\n");
792 timeZeroList->ls();
793 printf("------------------------------------------------------------------\n");
794 pidList->ls();
795 printf("------------------------------------------------------------------\n");
796 }
797
798 /*set graphic style*/
799 gStyle->SetCanvasColor(kWhite);
800 gStyle->SetFrameFillColor(kWhite);
801 gStyle->SetFrameBorderMode(0);
802 gStyle->SetCanvasBorderMode(0);
803 gStyle->SetTitleFillColor(kWhite);
804 gStyle->SetTitleBorderSize(0) ;
805 gStyle->SetTitleFont(42);
806 gStyle->SetTextFont(42);
807 //gStyle->SetPalette(1);
808 gStyle->SetStatColor(kWhite);
809 gStyle->SetStatBorderSize(1);
810 gStyle->SetOptStat(0);
3d9550f8 811
7cc410ff 812 //DEFINE OUTPUT FILE
813 char outfilename[60];
814 sprintf(outfilename,"postQA_%i.root",runNumber);
815 TFile * fout=new TFile(outfilename,"recreate");
816
817 TH1I* hRunNumber=new TH1I("hRunNumber","hRunNumber;run",1,runNumber,runNumber+1);
818 hRunNumber->Fill(runNumber);
819
820 //-------------------------------------------------------------
821 /*GENERAL MONITOR - MULTIPLICITY*/
822 TH1F*hMulti= (TH1F*) generalList->At(0);
823
824 TH1F* hFractionEventsWhits=new TH1F("hFractionEventsWhits","hFractionEventsWhits;fraction of events with hits (%)",200,0.,100.);
825 Float_t fraction=0.0;
826 if (hMulti->GetEntries()>0.0) fraction=((Float_t) hMulti->GetBinContent(1))/((Float_t) hMulti->GetEntries());
827 else fraction=0.0;
828 hFractionEventsWhits->Fill(fraction*100.);
829
830 //-------------------------------------------------------------
831 /*GENERAL MONITOR - TIMING AND GEOMETRY*/
832 TH1F * hTime = (TH1F*) generalList->At(1);
833 hTime->SetMarkerStyle(8);
834 hTime->SetMarkerSize(0.7);
835 hTime->SetMarkerColor(kBlue);
836 hTime->SetLineColor(kBlue);
837 hTime->SetFillColor(kBlue);
838 hTime->SetFillStyle(3001);
839 hTime->Rebin(2);
840 hTime->GetYaxis()->SetTitle("matched tracks");
841 hTime->GetYaxis()->SetTitleOffset(1.35);
3d9550f8 842
7cc410ff 843 TH1F * hRawTime = (TH1F*) generalList->At(2);
844 hRawTime->SetMarkerStyle(21);
845 hRawTime->SetMarkerSize(0.7);
846 hRawTime->SetMarkerColor(kGreen);
847 hRawTime->SetLineColor(kGreen);
848 hRawTime->SetFillColor(kGreen);
849 hRawTime->SetFillStyle(3001);
850 hRawTime->Rebin(2);
851 hRawTime->GetYaxis()->SetTitle("matched tracks");
852 hRawTime->GetYaxis()->SetTitleOffset(1.35);
3d9550f8 853
7cc410ff 854 TLegend *lTime = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
855 lTime->SetTextSize(0.04281433);
856 lTime->AddEntry(hRawTime, "raw","L");
857 lTime->AddEntry(hTime, "ESD","L");
858 lTime->SetFillColor(kWhite);
859 lTime->SetShadowColor(0);
860
861 TH1F * hTot = (TH1F*) generalList->At(3);
862 hTot->SetMarkerStyle(8);
863 hTot->SetMarkerSize(0.7);
864 hTot->SetMarkerColor(kViolet-3);
865 hTot->SetLineColor(kViolet-3);
866 hTot->SetFillColor(kViolet-3);
867 hTot->SetFillStyle(3001);
868 //hTime->SetDrawOption();
869 hTot->GetYaxis()->SetTitle("matched tracks");
870 hTot->GetYaxis()->SetTitleOffset(1.35);
3d9550f8 871
872
7cc410ff 873 char orphansTxt[200];
874 Float_t orphansRatio=0.0;
875 if (hTot->GetEntries()>1){
876 orphansRatio=((Float_t) hTot->GetBinContent(1))/((Float_t) hTot->GetEntries()) ;
877 }
878 sprintf(orphansTxt,"orphans/matched tracks = %.4f ",orphansRatio);
879 TH1F * hOrphansRatio=new TH1F("hOrphansRatio","Percentage of signals with only leading edge; percentage (%)",1000,0.,100.);
880 hOrphansRatio->Fill(orphansRatio*100.);
881
882
883 TPaveText *tOrphans = new TPaveText(0.38,0.63,0.88,0.7, "NDC");
884 //NDC sets coords relative to pad
885 tOrphans->SetBorderSize(0);
886 tOrphans->SetTextSize(0.045);
887 tOrphans->SetFillColor(0); //white background
888 tOrphans->SetTextAlign(12);
889 tOrphans->SetTextColor(kViolet-3);
890 tOrphans->AddText(orphansTxt);
3d9550f8 891
7cc410ff 892 TH1F * hL = (TH1F*) generalList->At(4);
893 hL->SetMarkerStyle(8);
894 hL->SetMarkerSize(0.7);
895 hL->SetMarkerColor(kOrange-3);
896 hL->SetLineColor(kOrange-3);
897 hL->SetFillColor(kOrange-3);
898 hL->SetFillStyle(3001);
899 //hTime->SetDrawOption();
900 hL->GetYaxis()->SetTitle("matched tracks");
901 hL->GetYaxis()->SetTitleOffset(1.35);
902
903 char negLengthTxt[200];
904 Float_t negLengthRatio=0.0;
905 if (hL->GetEntries()>1){
906 negLengthRatio=(hL->Integral(1,750))/((Float_t) hL->GetEntries()) ;
907 }
908 sprintf(negLengthTxt,"tracks with L<350cm /matched tracks = %.5f ",negLengthRatio);
909 TH1F * hLnegRatio=new TH1F("hLnegRatio","Ratio of TOF-matched tracks with L<350cm; ratio (%)",10000,0.,100.);
910 hLnegRatio->Fill(negLengthRatio*100);
3d9550f8 911
912
913
7cc410ff 914 TPaveText *tLength = new TPaveText(0.15,0.83,0.65,0.87, "NDC");
915 //NDC sets coords relative to pad
916 tLength->SetBorderSize(0);
917 tLength->SetTextSize(0.04);
918 tLength->SetFillColor(0); //white background
919 tLength->SetTextAlign(11);
920 tLength->SetTextColor(kOrange-3);
921 tLength->AddText(negLengthTxt);
3d9550f8 922
7cc410ff 923 if (canvasE){
924 TCanvas *cTrackProperties= new TCanvas("cTrackProperties","summary of matched tracks properties",900,900);
925 cTrackProperties->Divide(2,2);
926 cTrackProperties->cd(1);
927 gPad->SetLogy();
928 gPad->SetGridx();
929 gPad->SetGridy();
930 hTime->Draw("BAR");
931 hRawTime ->Draw("BARsame");
932 lTime->Draw();
933 cTrackProperties->cd(2);
934 gPad->SetGridx();
935 gPad->SetGridy();
936 gPad->SetLogy();
937 hTot->Draw("BAR");
938 tOrphans->Draw();
939 cTrackProperties->cd(3);
940 gPad->SetGridx();
941 gPad->SetGridy();
942 gPad->SetLogy();
943 hL->Draw("BAR");
944 tLength->Draw();
945 }
946 fout->cd();
947 hRunNumber->Write();
948 hMulti->Write();
949 hFractionEventsWhits->Write();
950 hTime->Write();
951 hRawTime->Write();
952 hTot->Write();
953 hOrphansRatio->Write();
954 hL->Write();
955 hLnegRatio->Write();
3d9550f8 956
7cc410ff 957 TH2F* hDxPos4profile = (TH2F*) generalList->At(14);
958 TH2F* hDxNeg4profile = (TH2F*) generalList->At(13);
3d9550f8 959
7cc410ff 960 char profilename[30];
961 const Int_t ybinMin = 0;
962 const Int_t ybinMax =hDxPos4profile->GetYaxis()->GetNbins() ;
963 sprintf(profilename,"profDxPos");
964 TProfile * profDxPos = (TProfile*)hDxPos4profile->ProfileX(profilename, ybinMin,ybinMax);
965 sprintf(profilename,"profDxNeg");
966 profDxPos->SetLineWidth(2);
967 TProfile * profDxNeg = (TProfile*)hDxNeg4profile->ProfileX(profilename, ybinMin, ybinMax);
968 profDxNeg->SetLineWidth(2);
3d9550f8 969
7cc410ff 970 TH1 *profRatioPosOverNegDx = (TH1*) profDxPos->Clone();
971 profRatioPosOverNegDx->SetName("profRatioPosOverNegDx");
972 profRatioPosOverNegDx->Divide((TH1*) profDxNeg);
973 profRatioPosOverNegDx->GetYaxis()->SetRangeUser(-5.,5.);
974 profRatioPosOverNegDx->GetXaxis()->SetRangeUser(0.,2.);
975 if (canvasE){
976 TCanvas *residuals= new TCanvas("residuals","residuals",900,450);
977 residuals->Divide(2,1);
978 residuals->cd(1);
979 gPad->SetGridx();
980 gPad->SetGridy();
981 hDxPos4profile->GetYaxis()->SetRangeUser(-5.,5.);
982 hDxPos4profile->Draw("colz");
983 profDxPos->SetLineColor(kRed);
984 profDxPos ->Draw("same");
985 residuals->cd(2);
986 gPad->SetGridx();
987 gPad->SetGridy();
988 hDxNeg4profile->GetYaxis()->SetRangeUser(-5.,5.);
989 hDxNeg4profile->Draw("colz");
990 profDxNeg->SetLineColor(kBlue);
991 profDxNeg->Draw("same");
992 }
993
994 fout->cd();
995 hDxPos4profile->Write();
996 hDxNeg4profile->Write();
997 profDxPos->Write();
998 profDxNeg->Write();
999 profRatioPosOverNegDx->Write();
1000 //-------------------------------------------------------------
1001 /* T0 DETECTOR MONITOR*/
1002
1003 TH1F * hT0AC = (TH1F*) timeZeroList->At(0);
1004 hT0AC->SetMarkerStyle(8);
1005 hT0AC->SetMarkerSize(0.7);
1006 hT0AC->SetMarkerColor(kRed);
1007 hT0AC->SetLineColor(kRed);
1008 hT0AC->SetFillColor(kRed);
1009 hT0AC->SetFillStyle(1001);
1010 hT0AC->Rebin(2);
1011 hT0AC->GetYaxis()->SetTitle("events");
1012 hT0AC->GetYaxis()->SetTitleOffset(1.35);
1013 hT0AC->GetXaxis()->SetLabelSize(0.03);
3d9550f8 1014
7cc410ff 1015 TH1F * hT0A = (TH1F*) timeZeroList->At(1);
1016 hT0A->SetMarkerStyle(8);
1017 hT0A->SetMarkerSize(0.7);
1018 hT0A->SetMarkerColor(kBlue);
1019 hT0A->SetLineColor(kBlue);
1020 hT0A->SetFillColor(kBlue);
1021 hT0A->SetFillStyle(1001);
1022 hT0A->Rebin(2);
1023 hT0A->GetYaxis()->SetTitle("events");
1024 hT0A->GetYaxis()->SetTitleOffset(1.35);
1025 hT0A->GetXaxis()->SetLabelSize(0.03);
1026
1027 TH1F * hT0C = (TH1F*) timeZeroList->At(2);
1028 hT0C->SetMarkerStyle(8);
1029 hT0C->SetMarkerSize(0.7);
1030 hT0C->SetMarkerColor(kGreen);
1031 hT0C->SetLineColor(kGreen);
1032 hT0C->SetFillColor(kGreen);
1033 hT0C->SetFillStyle(1001);
1034 hT0C->Rebin(2);
1035 hT0C->GetYaxis()->SetTitle("events");
1036 hT0C->GetYaxis()->SetTitleOffset(1.35);
1037 hT0C->GetXaxis()->SetLabelSize(0.03);
3d9550f8 1038
7cc410ff 1039 TLegend *lT0 = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
1040 lT0->SetTextSize(0.041);
1041 lT0->AddEntry(hT0AC, "T0 A&C","L");
1042 lT0->AddEntry(hT0A, "T0 A","L");
1043 lT0->AddEntry(hT0C, "T0 C","L");
1044 lT0->SetFillColor(kWhite);
1045 lT0->SetShadowColor(0);
3d9550f8 1046
7cc410ff 1047 TH1F * hT0res = (TH1F*) timeZeroList->At(3);
1048 hT0res->GetXaxis()->SetLabelSize(0.03);
1049 if (canvasE){
1050 TCanvas *cT0detector= new TCanvas("cT0detector","T0 detector",900,450);
1051 cT0detector->Divide(2,1);
1052 cT0detector->cd(1);
1053 gPad->SetGridx();
1054 gPad->SetGridy();
1055 hT0AC->Draw("BAR");
1056 hT0AC->SetTitle("timeZero measured by T0 detector");
1057 hT0A ->Draw("BARsame");
1058 hT0C ->Draw("BARsame");
1059 lT0->Draw();
1060 cT0detector->cd(2);
1061 gPad->SetGridx();
1062 gPad->SetGridy();
1063 // gPad->SetLogy();
1064 hT0res->Draw();
1065 // myText1->Draw();
1066 // cTrackProperties->cd(3);
1067 // gPad->SetLogy();
1068 // hL->Draw("BAR");
1069 // myText2->Draw();
1070 }
1071
1072 TH1F * hT0fillRes = (TH1F*) timeZeroList->At(8);
1073 hT0fillRes->GetXaxis()->SetLabelSize(0.03);
1074
1075 fout->cd();
1076 hT0AC->Write();
1077 hT0A->Write();
1078 hT0C->Write();
1079 hT0res->Write();
1080 hT0fillRes->Write();
1081 lT0->Write();
3d9550f8 1082
1083
7cc410ff 1084 //-------------------------------------------------------------
1085 /*MATCHING EFFICIENCY MONITOR*/
3d9550f8 1086
7cc410ff 1087 //TH1F * hMatchingVsP =new TH1F("hMatchingVsP","Matching probability vs. P; P(GeV/c); matching probability", 50, 0., 5. );
3d9550f8 1088
7cc410ff 1089 TH1F * hMatchingVsPt =new TH1F("hMatchingVsPt","Matching probability vs. Pt; Pt(GeV/c); matching probability", 50, 0., 5. );
3d9550f8 1090
7cc410ff 1091 TH1F * hMatchingVsEta =new TH1F("hMatchingVsEta","Matching probability vs. #\Eta; #\Eta; matching probability", 20, -1., 1.);
3d9550f8 1092
7cc410ff 1093 TH1F * hMatchingVsPhi =new TH1F("hMatchingVsPhi","Matching probability vs. Phi; Phi(rad); matching probability", 628, 0., 6.28);
3d9550f8 1094
7cc410ff 1095 /*/matching as function of p
1096 TH1F * hDenom=(TH1F*)generalList->At(9);
1097 if (hDenom) {
1098 hMatchingVsP=(TH1F*) generalList->At(5);
1099 hMatchingVsP->Rebin(5);
1100 hDenom->Rebin(5);
1101 hMatchingVsP->Divide(hDenom);
1102 hMatchingVsP->GetYaxis()->SetTitle("matching efficiency");
1103 hMatchingVsP->SetTitle("TOF matching efficiency as function of momentum");
1104 }*/
3d9550f8 1105
7cc410ff 1106 //matching as function of pT
3d9550f8 1107
7cc410ff 1108 // hDenom->Clear();
1109 TH1F * hDenom=(TH1F*)generalList->At(10);
1110 if (hDenom) {
1111 hMatchingVsPt=(TH1F*) generalList->At(6);
1112 hMatchingVsPt->Rebin(5);
1113 hDenom->Rebin(5);
1114 hMatchingVsPt->Divide(hDenom);
1115 hMatchingVsPt->GetYaxis()->SetTitle("matching efficiency");
1116 hMatchingVsPt->SetTitle("TOF matching efficiency as function of transverse momentum");
1117 hMatchingVsPt->GetYaxis()->SetRangeUser(0,1.2);
1118 }
3d9550f8 1119
7cc410ff 1120 //matching as function of eta
1121 hDenom->Clear();
1122 hDenom=(TH1F*)generalList->At(11);
1123 if (hDenom) {
1124 hMatchingVsEta=(TH1F*) generalList->At(7);
1125 hMatchingVsEta->Rebin(5);
1126 hDenom->Rebin(5);
1127 hMatchingVsEta->Divide(hDenom);
1128 hMatchingVsEta->GetXaxis()->SetRangeUser(-1,1);
1129 hMatchingVsEta->GetYaxis()->SetTitle("matching efficiency");
1130 hMatchingVsEta->GetYaxis()->SetRangeUser(0,1.2);
1131 hMatchingVsEta->SetTitle("TOF matching efficiency as function of pseudorapidity");
1132 }
1133 //matching as function of phi
1134 hDenom->Clear();
1135 hDenom=(TH1F*)generalList->At(12);
1136 if (hDenom) {
1137 hMatchingVsPhi=(TH1F*) generalList->At(8);
1138 //hMatchingVsPhi->Rebin(5);
1139 //hDenom->Rebin(5);
1140 hMatchingVsPhi->Divide(hDenom);
1141 hMatchingVsPhi->GetYaxis()->SetTitle("matching efficiency");
1142 hMatchingVsPhi->SetTitle("TOF matching efficiency as function of phi");
1143 hMatchingVsPhi->GetYaxis()->SetRangeUser(0,1.2);
1144 }
1145 if ( canvasE){
1146 TCanvas *cMatchingPerformance= new TCanvas("cMatchingPerformance","summary of matching performance",700,400);
1147 cMatchingPerformance->Divide(2,2);
1148 cMatchingPerformance->cd(1);
1149 gPad->SetGridx();
1150 gPad->SetGridy();
1151 hMatchingVsPt->Draw();
1152 cMatchingPerformance->cd(2);
1153 gPad->SetGridx();
1154 gPad->SetGridy();
1155 hMatchingVsEta->Draw();
1156 cMatchingPerformance->cd(3);
1157 gPad->SetGridx();
1158 gPad->SetGridy();
1159 hMatchingVsPhi->Draw();
1160 }
1161 fout->cd();
1162 hMatchingVsPt->Write();
1163 hMatchingVsEta->Write();
1164 hMatchingVsPhi->Write();
3d9550f8 1165
7cc410ff 1166 //----------------------------------------------------
1167 /* PID PERFORMANCE MONITOR */
1168
1169 TH2F * hBetaP=(TH2F*)pidList->At(0);
1170 hBetaP->GetYaxis()->SetRangeUser(0.,1.2);
1171 TH1F * hMass=(TH1F*)pidList->At(1);
1172 //hMass->SetMarkerColor(kBlue);
1173 //hMass->SetLineColor(kBlue);
1174 hMass->SetFillColor(kAzure+10);
1175 hMass->SetFillStyle(1001);
1176 hMass->Rebin(2);
1177 hMass->GetYaxis()->SetTitle("tracks");
1178 hMass->GetYaxis()->SetTitleOffset(1.35);
1179 hMass->GetXaxis()->SetLabelSize(0.03);
1180
1181 TH1F * hPionDiff=(TH1F*)pidList->At(3);
3d9550f8 1182
1183
7cc410ff 1184 TH2F * hDiffTimePi=(TH2F*)pidList->At(4);
1185 hDiffTimePi->GetYaxis()->SetRangeUser(-2000.,2000.);
6c125480 1186 hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
1187 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
7cc410ff 1188 sprintf(profilename,"profDiffTimePi");
3d9550f8 1189
7cc410ff 1190 TProfile * profDiffTimePi = (TProfile*)hDiffTimePi->ProfileX(profilename, 490, 510);
1191 profDiffTimePi->SetLineWidth(2);
1192 profDiffTimePi->SetLineColor(kRed+2);
1193
1194 TH2F * hDiffTimePiTh=(TH2F*)pidList->At(6);
1195 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1196 sprintf(profilename,"profDiffTimePiTh");
1197 hDiffTimePiTh->GetYaxis()->SetRangeUser(-2000.,2000.);
3d9550f8 1198
7cc410ff 1199 TProfile * profDiffTimePiTh = (TProfile*)hDiffTimePiTh->ProfileX(profilename, 490, 510);
1200 profDiffTimePiTh->SetLineWidth(2);
1201 profDiffTimePiTh->SetLineColor(kRed+2);
1202
1203 TH2F * hDiffTimeKa=(TH2F*)pidList->At(9);
1204 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
6c125480 1205 hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
7cc410ff 1206 sprintf(profilename,"profDiffTimeKa");
1207 hDiffTimeKa->GetYaxis()->SetRangeUser(-2000.,2000.);
3d9550f8 1208
7cc410ff 1209 TProfile * profDiffTimeKa = (TProfile*)hDiffTimeKa->ProfileX(profilename, 490, 510);
1210 profDiffTimeKa->SetLineWidth(2);
1211 profDiffTimeKa->SetLineColor(kBlue);
1212
1213 TH2F * hDiffTimeKaTh=(TH2F*)pidList->At(11);
1214 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1215 sprintf(profilename,"profDiffTimeKaTh");
1216 hDiffTimeKaTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1217 TProfile * profDiffTimeKaTh = (TProfile*)hDiffTimeKaTh->ProfileX(profilename, 490, 510);
1218 profDiffTimeKaTh->SetLineWidth(2);
1219 profDiffTimeKaTh->SetLineColor(kBlue);
3d9550f8 1220
7cc410ff 1221 TH2F * hDiffTimePro=(TH2F*)pidList->At(14);
1222 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1223 sprintf(profilename,"profDiffTimePro");
6c125480 1224 hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");
7cc410ff 1225 hDiffTimePro->GetYaxis()->SetRangeUser(-2000.,2000.);
1226 TProfile * profDiffTimePro = (TProfile*)hDiffTimePro->ProfileX(profilename, 490, 510);
1227 profDiffTimePro->SetLineWidth(2);
1228 profDiffTimePro->SetLineColor(kGreen+2);
1229
1230 TH2F * hDiffTimeProTh=(TH2F*)pidList->At(16);
1231 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1232 sprintf(profilename,"profDiffTimeProTh");
1233 hDiffTimeProTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1234 TProfile * profDiffTimeProTh = (TProfile*)hDiffTimeProTh->ProfileX(profilename, 490, 510);
1235 profDiffTimeProTh->SetLineWidth(2);
1236 profDiffTimeProTh->SetLineColor(kGreen+2);
1237
1238 if (canvasE){
1239 TCanvas *cPidPerformance= new TCanvas("cPidPerformance","summary of pid performance",800,800);
1240 cPidPerformance->Divide(2,1);
1241 cPidPerformance->cd(1);
1242 gPad->SetGridy();
1243 gPad->SetGridx();
1244 gPad->SetLogz();
1245 hBetaP->Draw("colz");
3d9550f8 1246
7cc410ff 1247 cPidPerformance->cd(2);
1248 gPad->SetGridx();
1249 gPad->SetGridy();
1250 gPad->SetLogy();
1251 hMass->Draw("HIST BAR");
3d9550f8 1252
7cc410ff 1253 TLegend * lPid=new TLegend(0.75,0.75,0.95,0.95,"PID");
1254 lPid->AddEntry(profDiffTimePi,"#pi^{#pm}","l");
1255 lPid->AddEntry(profDiffTimeKa,"K^{#pm}","l");
1256 lPid->AddEntry(profDiffTimePro,"p^{#pm}","l");
1257
1258 gStyle->SetOptStat(10);
1259 TCanvas *cPidPerformance2= new TCanvas("cPidPerformance2","summary of pid performance - tracking",700,700);
1260 cPidPerformance2->Divide(2,2);
1261 cPidPerformance2->cd(1);
1262 gPad->SetLogz();
1263 gPad->SetGridx();
1264 gPad->SetGridy();
1265 hDiffTimePi->Draw("colz");
1266 // profDiffTimePi->Draw("same");
3d9550f8 1267
7cc410ff 1268 cPidPerformance2->cd(2);
1269 gPad->SetLogz();
1270 gPad->SetGridx();
1271 gPad->SetGridy();
1272 hDiffTimeKa->Draw("colz");
1273 //profDiffTimeKa->Draw("same");
1274 cPidPerformance2->cd(3);
1275 gPad->SetLogz();
1276 hDiffTimePro->Draw("colz");
1277 // profDiffTimePro->Draw("same");
3d9550f8 1278
7cc410ff 1279 // cPidPerformance2->cd(4);
1280 // profDiffTimePi->Draw();
1281 // profDiffTimeKa->Draw("same");
1282 // profDiffTimePro->Draw("same");
1283 // lPid->Draw("same");
3d9550f8 1284
7cc410ff 1285 TCanvas *cPidPerformanceTh= new TCanvas("cPidPerformanceTh","summary of pid performance - theoretical times",700,700);
1286 cPidPerformanceTh->Divide(2,2);
1287 cPidPerformanceTh->cd(1);
1288 gPad->SetLogz();
1289 gPad->SetGridx();
1290 gPad->SetGridy();
1291 hDiffTimePiTh->Draw("colz");
1292 profDiffTimePiTh->Draw("same");
1293 cPidPerformanceTh->cd(2);
1294 gPad->SetLogz();
1295 gPad->SetGridx();
1296 gPad->SetGridy();
1297 hDiffTimeKaTh->Draw("colz");
1298 profDiffTimeKaTh->Draw("same");
1299 cPidPerformanceTh->cd(3);
1300 gPad->SetLogz();
1301 gPad->SetGridx();
1302 gPad->SetGridy();
1303 hDiffTimeProTh->Draw("colz");
1304 profDiffTimeProTh->Draw("same");
1305 // cPidPerformanceTh->cd(4);
1306 // profDiffTimePiTh->Draw();
1307 // profDiffTimeKaTh->Draw("same");
1308 // profDiffTimeProTh->Draw("same");
1309 // lPid->Draw("same");
1310 }
3d9550f8 1311
7cc410ff 1312 TH1F * hPionDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePi");
1313 TH1F * hKaonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimeKa");
1314 TH1F * hProtonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePro");
3d9550f8 1315
1316
7cc410ff 1317 fout->cd();
1318 hPionDiff->Write();
1319 hKaonDiff->Write();
1320 hProtonDiff->Write();
1321
1322 hBetaP->Write();
1323 hMass->Write();
1324 hDiffTimePi->Write();
1325 profDiffTimePi->Write();
1326 hDiffTimeKa->Write();
1327 profDiffTimeKa->Write();
1328 hDiffTimePro->Write();
1329 profDiffTimePro->Write();
1330 //lPid->Draw();
1331 hDiffTimePiTh->Write();
1332 profDiffTimePiTh->Write();
1333 hDiffTimeKaTh->Write();
1334 profDiffTimeKaTh->Write();
1335 hDiffTimeProTh->Write();
1336 profDiffTimeProTh->Write();
3d9550f8 1337
7cc410ff 1338 //SIGMAS PID
1339 TH2F * hSigmaPi=(TH2F*)pidList->At(7);
1340 sprintf(profilename,"profSigmaPi");
1341 hSigmaPi->GetYaxis()->SetRangeUser(-5.,5.);
1342 TProfile * profSigmaPi = (TProfile*)hSigmaPi->ProfileX(profilename);
1343 profSigmaPi->SetLineWidth(2);
1344 profSigmaPi->SetLineColor(kRed+2);
1345
1346 TH2F * hSigmaKa=(TH2F*)pidList->At(12);
1347 sprintf(profilename,"profSigmaKa");
1348 hSigmaKa->GetYaxis()->SetRangeUser(-5.,5.);
1349 TProfile * profSigmaKa = (TProfile*)hSigmaKa->ProfileX(profilename);
1350 profSigmaKa->SetLineWidth(2);
1351 profSigmaKa->SetLineColor(kBlue);
1352
1353 TH2F * hSigmaPro=(TH2F*)pidList->At(17);
1354 sprintf(profilename,"profSigmaPro");
1355 hSigmaPro->GetYaxis()->SetRangeUser(-5.,5.);
1356 TProfile * profSigmaPro = (TProfile*)hSigmaPro->ProfileX(profilename);
1357 profSigmaPro->SetLineWidth(2);
1358 profSigmaPro->SetLineColor(kGreen+2);
1359
1360
1361 if (canvasE){
1362
1363 TLegend * lSigmaPid=new TLegend(0.75,0.75,0.95,0.95,"#sigma_{PID}");
1364 lSigmaPid->AddEntry(profSigmaPi,"#pi^{#pm}","l");
1365 lSigmaPid->AddEntry(profSigmaKa,"K^{#pm}","l");
1366 lSigmaPid->AddEntry(profSigmaPro,"p^{#pm}","l");
1367
1368 TCanvas *cPidPerformance3= new TCanvas("cPidPerformance3","summary of pid performance - sigmas",1200,400);
1369 cPidPerformance3->Divide(3,1);
1370 cPidPerformance3->cd(1);
1371 gPad->SetLogz();
1372 gPad->SetGridx();
1373 gPad->SetGridy();
1374
1375 hSigmaPi->Draw("colz");
1376 profSigmaPi->Draw("same");
1377
1378 cPidPerformance3->cd(2);
1379 gPad->SetLogz();
1380 gPad->SetGridx();
1381 gPad->SetGridy();
1382 hSigmaKa->Draw("colz");
1383 profSigmaKa->Draw("same");
1384
1385 cPidPerformance3->cd(3);
1386 gPad->SetGridx();
1387 gPad->SetGridy();
1388 gPad->SetLogz();
1389 hSigmaPro->Draw("colz");
1390 profSigmaPro->Draw("same");
1391 }
1392
1393 fout->cd();
1394 hSigmaPi->Write();
1395 profSigmaPi->Write();
1396 hSigmaKa->Write();
1397 profSigmaKa->Write();
1398 hSigmaPro->Write();
1399 profSigmaPro->Write();
1400
2e4f8a9f 1401 TH2F* hTOFmatchedDzVsStrip = (TH2F*)generalList->FindObject("hTOFmatchedDzVsStrip");
1402
7cc410ff 1403 if (canvasE){
7cc410ff 1404 TCanvas* cProfile = new TCanvas("cProfile","cProfile",50,50,750,550);
1405 gStyle->SetOptStat(0);
1406 hTOFmatchedDzVsStrip->Draw("colz");
1407 Int_t binmin = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(-3);
1408 Int_t binmax = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(3);
1409 TProfile* hDzProfile = (TProfile*)hTOFmatchedDzVsStrip->ProfileX("hDzProfile",binmin, binmax);
1410 hDzProfile->SetLineWidth(3);
1411 hDzProfile->Draw("same");
1412 cProfile->SetGridx();
1413 cProfile->SetGridy();
1414 TString plotDir(Form("Plots_run%d",runNumber));
1415 gSystem->Exec(Form("mkdir %s",plotDir.Data()));
1416 cPidPerformance3->Print(Form("%s/PID_sigmas.png",plotDir.Data()));
1417 cPidPerformance->Print(Form("%s/PID.png",plotDir.Data()));
6c125480 1418 cPidPerformanceTh->Print(Form("%s/PID_theoreticalTimes.png",plotDir.Data()));
7cc410ff 1419 cPidPerformance2->Print(Form("%s/PID_ExpTimes.png",plotDir.Data()));
1420 cMatchingPerformance->Print(Form("%s/Matching.png",plotDir.Data()));
1421 cT0detector->Print(Form("%s/T0Detector.png",plotDir.Data()));
1422 cTrackProperties->Print(Form("%s/TrackProperties.png",plotDir.Data()));
1423 residuals->Print(Form("%s/Residuals.png",plotDir.Data()));
1424 cProfile->Print(Form("%s/ProfileDZvsStripNumber.png",plotDir.Data()));
1425 }
2e4f8a9f 1426 fout->cd();
1427 hTOFmatchedDzVsStrip->Write();
7cc410ff 1428
1429 return 0;
3d9550f8 1430}
1431
1432//----------------------------------------------------------
1433char * SetQAtrainOutputName(Int_t run=0,Int_t year=2011,char *period="LHC11a", char* pass="cpass1",Int_t trainId=76){
1434
7cc410ff 1435 char infile[200];
1436 sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults.root",year,period,runNumber,pass,trainId);
1437 return infile;
3d9550f8 1438
1439}
1440
1441
1442