2 fbellini@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
8 Int_t MakeTrendingTOFQA(char * runlist, Int_t year=2012, char *period="LHC12a", char* pass="cpass1", char* nameSuffix ="_barrel",Bool_t isMC=kFALSE,Int_t trainId=0, Bool_t displayAll=kFALSE){
12 printf("Invalid list of runs given as input: nothing done\n");
17 char postFileName[20];
18 char treePostFileName[20];
20 char trendFileName[100];
21 //Define trending output
23 sprintf(trendFileName,"treeTOFQA_%s_%s.root",period,pass);
25 sprintf(trendFileName,"treeTOFQA_QA%i_%s_%s.root",trainId,period,pass);
27 TFile * trendFile=new TFile(trendFileName,"recreate");
28 FILE * files = fopen(runlist, "r") ;
30 //create chain of treePostQA
31 Long64_t nentries=100000, firstentry=0;
32 TChain *chainTree = 0;
33 chainTree=new TChain("trendTree");
35 while (fscanf(files,"%d",&runNumber)==1 ){
39 if (!isMC) sprintf(infile,"alien:///alice/data/%i/%s/000%d/%s/QAresults%s.root",year,period,runNumber,pass,nameSuffix);
40 else sprintf(infile,"alien:///alice/sim/%i/%s/%d/QAresults%s.root",year,period,runNumber,nameSuffix);
42 if (!isMC) sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults%s.root",year,period,runNumber,pass,trainId,nameSuffix);
43 else sprintf(infile,"alien:///alice/sim/%i/%s/%d/QA%i/QAresults%s.root",year,period,runNumber,trainId,nameSuffix);
46 Printf("============== Opening QA file(s) for run %i =======================\n",runNumber);
49 if (RunESDQApostAnalysis(infile,runNumber,isMC,kTRUE)==0){
51 sprintf(postFileName,"postQA_%i.root",runNumber);
52 sprintf(treePostFileName,"treePostQA_%i.root",runNumber);
54 if (MakePostQAtree(runNumber, isMC, postFileName, treePostFileName)==0){
55 chainTree->Add(treePostFileName);
56 Printf("Tree chain has now %d entries ",(Int_t)chainTree->GetEntries());
58 Printf("Could not get tree with trending quantities for run %i: SKIPPING",runNumber);
61 Printf("Post analysis not run on QA output %s", infile);
63 return MakeTrendingFromTreeWithErrors(chainTree, trendFileName, displayAll);
65 //-----------------------------------------------------------
66 Int_t MakeTrendingHistoFromTreeList(char * fileList, Bool_t displayAll=kFALSE){
71 printf("Invalid list of runs given as input: nothing done\n");
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") ;
81 //create chain of treePostQA
82 Long64_t nentries=100000, firstentry=0;
83 TChain *chainTree =new TChain("trendTree");
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);
90 chainTree->Add(infile);
92 return MakeTrendingFromTreeWithErrors(chainTree, trendFileName, displayAll);
95 //______________________________________________________________________________
96 Int_t MakeTrendingFromTreeWithErrors(TChain * fin,char* trendFileName=NULL, Bool_t displayAll=kFALSE){
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.;
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.;
117 Float_t fractionEventsWHits=0.0;
118 Double_t goodChannelRatio=0.0;
120 TTree * ttree = (TTree*) fin->CloneTree();
121 ttree->SetBranchAddress("run",&runNumber);
122 ttree->SetBranchAddress("goodChannelsRatio",&goodChannelRatio);
123 ttree->SetBranchAddress("avTime",&avTime); //mean time
124 ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit
125 ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit
126 ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error
127 ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error
129 ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio
131 ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time
132 ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit
133 ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit
134 ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw time after fit error
135 ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of raw main peak of time after fit error
137 ttree->SetBranchAddress("avTot",&avTot); //main peak tot
138 ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit
139 ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit
140 ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit
141 ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit
143 ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio
145 ttree->SetBranchAddress("avL",&avL); //mean track length
146 ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm
148 ttree->SetBranchAddress("effPt1",&effPt1);//matching eff at 1 GeV/c
149 ttree->SetBranchAddress("effPt2",&effPt2); //matching eff at 2 GeV/c
150 ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param
151 ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error
153 ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp
154 ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit
155 ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit
156 ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error
157 ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error
159 ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A
160 ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit
161 ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit
162 ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit
163 ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit
165 ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C
166 ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit
167 ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit
168 ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit
169 ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit
171 ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC
172 ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit
173 ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit
174 ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit
175 ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit
177 ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC
178 ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit
179 ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit
180 ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit
181 ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit
182 ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res
184 Int_t nRuns=ttree->GetEntries();
187 TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.);
188 hAvDiffTimeVsRun->SetDrawOption("E1");
189 hAvDiffTimeVsRun->SetMarkerStyle(20);
190 hAvDiffTimeVsRun->SetMarkerColor(kBlue);
191 // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
193 TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;run; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. );
194 hPeakDiffTimeVsRun->SetDrawOption("E1");
195 hPeakDiffTimeVsRun->SetMarkerStyle(20);
196 hPeakDiffTimeVsRun->SetMarkerColor(kBlue);
198 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.);
199 hSpreadDiffTimeVsRun->SetDrawOption("E1");
200 hSpreadDiffTimeVsRun->SetMarkerStyle(20);
201 hSpreadDiffTimeVsRun->SetMarkerColor(kBlue);
203 TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;run;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
204 hAvTimeVsRun->SetDrawOption("E1");
205 hAvTimeVsRun->SetMarkerStyle(20);
206 hAvTimeVsRun->SetMarkerColor(kBlue);
207 // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
209 TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);run;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. );
210 hPeakTimeVsRun->SetDrawOption("E1");
211 hPeakTimeVsRun->SetMarkerStyle(20);
212 hPeakTimeVsRun->SetMarkerColor(kBlue);
214 TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);run; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
215 hSpreadTimeVsRun->SetDrawOption("E1");
216 hSpreadTimeVsRun->SetMarkerStyle(20);
217 hSpreadTimeVsRun->SetMarkerColor(kBlue);
219 TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};run;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
220 hAvRawTimeVsRun->SetDrawOption("E1");
221 hAvRawTimeVsRun->SetMarkerStyle(21);
222 hAvRawTimeVsRun->SetMarkerColor(kGreen);
224 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.);
225 hPeakRawTimeVsRun->SetDrawOption("E1");
226 hPeakRawTimeVsRun->SetMarkerStyle(21);
227 hPeakRawTimeVsRun->SetMarkerColor(kGreen);
229 TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);run;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
230 hSpreadRawTimeVsRun->SetDrawOption("E1");
231 hSpreadRawTimeVsRun->SetMarkerStyle(21);
232 hSpreadRawTimeVsRun->SetMarkerColor(kGreen);
234 TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
235 hAvTotVsRun->SetDrawOption("E1");
236 hAvTotVsRun->SetMarkerStyle(22);
238 TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);run;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
239 hPeakTotVsRun->SetDrawOption("E1");
240 hPeakTotVsRun->SetMarkerStyle(22);
242 TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
243 hSpreadTotVsRun->SetDrawOption("E1");
244 hSpreadTotVsRun->SetMarkerStyle(22);
246 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.);
247 hNegTimeRatioVsRun->SetDrawOption("E");
249 TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); run; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
250 hOrphansRatioVsRun->SetDrawOption("E");
252 TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;run; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.);
253 hMeanLVsRun->SetDrawOption("E");
254 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.);
255 hNegLRatioVsRun->SetDrawOption("E");
256 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.);
257 hMatchEffVsRun->SetDrawOption("E");
258 TH1F * hMatchEffVsRunNormToGoodCh=new TH1F("hMatchEffVsRunNormToGoodCh","Matching efficiency normalized to percentage of TOF good channels;run;matching efficiency (pT>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.);
259 hMatchEffVsRunNormToGoodCh->SetDrawOption("E");
261 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);
262 hMatchEffVsRun1->SetDrawOption("E");
263 TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);run;t0A (ps)",nRuns,0., nRuns);
264 TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);run;t0AC (ps)",nRuns,0., nRuns);
265 TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);run;t0AC (ps)",nRuns,0., nRuns);
266 TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;run;t0_spread (ps)",nRuns,0., nRuns);
270 lista.Add(hAvDiffTimeVsRun);
271 lista.Add(hPeakDiffTimeVsRun);
272 lista.Add(hSpreadDiffTimeVsRun);
273 lista.Add(hAvTimeVsRun);
274 lista.Add(hPeakTimeVsRun);
275 lista.Add(hSpreadTimeVsRun);
276 lista.Add( hAvRawTimeVsRun);
277 lista.Add( hPeakRawTimeVsRun);
278 lista.Add( hSpreadRawTimeVsRun);
279 lista.Add( hAvTotVsRun);
280 lista.Add( hPeakTotVsRun);
281 lista.Add( hSpreadTotVsRun);
282 lista.Add( hNegTimeRatioVsRun);
283 lista.Add( hOrphansRatioVsRun);
284 lista.Add( hMeanLVsRun);
285 lista.Add( hNegLRatioVsRun);
286 lista.Add( hMatchEffVsRun);
287 lista.Add(hMatchEffVsRunNormToGoodCh);
288 lista.Add(hPeakT0AVsRun);
289 lista.Add(hPeakT0CVsRun);
290 lista.Add(hPeakT0ACVsRun);
291 lista.Add(hT0fillResVsRun);
294 for (Int_t irun=0;irun<nRuns;irun++){
295 ttree->GetEntry(irun);
297 sprintf(runlabel,"%i",runNumber);
299 hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime);
300 hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
302 hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime);
303 hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr);
304 hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
306 hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime);
307 hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr);
308 hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
310 hAvTimeVsRun->SetBinContent(irun+1, avTime);
311 hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
313 hPeakTimeVsRun->SetBinContent(irun+1,peakTime);
314 hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr);
315 hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
317 hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime);
318 hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr);
319 hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
321 hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime);
322 hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
324 hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime);
325 hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr);
326 hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
328 hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime);
329 hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr);
330 hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
332 hAvTotVsRun->SetBinContent(irun+1,avTot);
333 hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
335 hPeakTotVsRun->SetBinContent(irun+1,peakTot);
336 hPeakTotVsRun->SetBinError(irun+1,peakTotErr);
337 hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
339 hSpreadTotVsRun->SetBinContent(irun+1,spreadTot);
340 hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr);
341 hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
343 hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio);
344 hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
346 hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio);
347 hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
349 hMeanLVsRun->SetBinContent(irun+1,avL);
350 hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
352 hNegLRatioVsRun->SetBinContent(irun+1,negLratio);
353 hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
355 hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev);
356 hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr);
357 hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
358 hMatchEffVsRun->SetLineColor(kRed);
359 hMatchEffVsRun->SetLineWidth(2);
361 if (goodChannelRatio>0)
362 hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatio);
364 hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1, 0.0);
365 hMatchEffVsRunNormToGoodCh->SetBinError(irun+1,matchEffLinFit1GevErr);
366 hMatchEffVsRunNormToGoodCh->GetXaxis()->SetBinLabel(irun+1,runlabel);
367 hMatchEffVsRunNormToGoodCh->SetLineColor(kBlue);
368 hMatchEffVsRunNormToGoodCh->SetLineWidth(2);
370 hPeakT0AVsRun->SetBinContent(irun+1,peakT0A);
371 hPeakT0AVsRun->SetBinError(irun+1,spreadT0A);
372 hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
374 hPeakT0CVsRun->SetBinContent(irun+1,peakT0C);
375 hPeakT0CVsRun->SetBinError(irun+1,spreadT0C);
376 hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
378 hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC);
379 hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC);
380 hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
382 hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes);
383 hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
387 char outfilename[200];
388 sprintf(outfilename, "trend_%s",trendFileName);
389 TFile * fout=new TFile(outfilename,"recreate");
394 TString plotDir(Form("PlotsTrending"));
395 gSystem->Exec(Form("mkdir %s",plotDir.Data()));
397 TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,750,550);
398 hPeakDiffTimeVsRun->GetYaxis()->SetRangeUser(-50.,50.);
399 hPeakDiffTimeVsRun->Draw();
400 cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.png",plotDir.Data()));
402 TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,750,550);
403 hSpreadDiffTimeVsRun->GetYaxis()->SetRangeUser(200.,400.);
404 hSpreadDiffTimeVsRun->Draw();
405 cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.png",plotDir.Data()));
407 TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun",50, 50, 750,550);
408 hMatchEffVsRun->GetYaxis()->SetRangeUser(0.,1.);
409 hMatchEffVsRun->Draw();
410 cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.png",plotDir.Data()));
412 TCanvas* cMatchEffNormToGoodCh = new TCanvas("cMatchEffNormToGoodCh","cMatchEffNormToGoodCh",50, 50,750,550);
413 hMatchEffVsRunNormToGoodCh->GetYaxis()->SetRangeUser(0.,1.);
414 hMatchEffVsRunNormToGoodCh->Draw();
415 cMatchEffNormToGoodCh->Print(Form("%s/cMatchEffNormToGoodCh.png",plotDir.Data()));
417 TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,750,550);
418 hPeakT0AVsRun->Draw();
419 cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data()));
421 TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,750,550);
422 hPeakT0CVsRun->Draw();
423 cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data()));
425 TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,750,550);
426 hPeakT0ACVsRun->Draw();
427 cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data()));
429 TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,750,550);
430 hT0fillResVsRun->Draw();
431 cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data()));
434 TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,750,550);
437 hAvDiffTimeVsRun->Draw();
438 cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data()));
440 TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,750,550);
441 hAvTimeVsRun->Draw();
442 cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data()));
444 TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,750,550);
445 hPeakTimeVsRun->Draw();
446 cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data()));
448 TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,750,550);
449 hSpreadTimeVsRun->Draw();
450 cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data()));
452 TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,750,550);
453 hAvRawTimeVsRun->Draw();
454 cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data()));
456 TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,750,550);
457 hPeakRawTimeVsRun->Draw();
458 cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data()));
460 TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,750,550);
461 hSpreadRawTimeVsRun->Draw();
462 cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data()));
464 TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,750,550);
466 cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data()));
468 TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,750,550);
469 hPeakTotVsRun->Draw();
470 cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data()));
472 TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,750,550);
473 hSpreadTotVsRun->Draw();
474 cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data()));
476 TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,750,550);
477 hNegTimeRatioVsRun->Draw();
478 cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data()));
480 TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,750,550);
481 hOrphansRatioVsRun->Draw();
482 cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data()));
484 TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,750,550);
486 cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data()));
488 TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,750,550);
489 hNegLRatioVsRun->Draw();
490 cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data()));
496 //-------------------------------------------------------------------------
497 Int_t MakePostQAtree(Int_t runNumber, Bool_t isMC=kFALSE, char * postFileName="postQA.0.root",char * treePostFileName="treePostQA.0.root"){
499 TFile *postfile=TFile::Open(postFileName);
501 printf("Post-analysis output not found - cannot perform trending analysis. Exiting.");
504 Printf("============== Getting post-analysis info for run %i ===============\n",runNumber);
505 TFile * trendFile=new TFile(treePostFileName,"recreate");
507 Double_t avTime=-9999., peakTime=-9999., spreadTime=-9999., peakTimeErr=-9999., spreadTimeErr=-9999., negTimeRatio=-9999.,
508 avRawTime=-9999., peakRawTime=-9999., spreadRawTime=-9999., peakRawTimeErr=-9999., spreadRawTimeErr=-9999.,
509 avTot=-9999., peakTot=-9999.,spreadTot=-9999., peakTotErr=-9999.,spreadTotErr=-9999.,
510 orphansRatio=-9999., avL=-9999., negLratio=-9999.,
511 effPt1=-9999., effPt2=-9999., matchEffLinFit1Gev=-9999.,matchEffLinFit1GevErr=-9999.;
513 Double_t avPiDiffTime=-9999.,peakPiDiffTime=-9999., spreadPiDiffTime=-9999.,peakPiDiffTimeErr=-9999., spreadPiDiffTimeErr=-9999.;
515 Double_t avT0A=-9999.,peakT0A=-9999., spreadT0A=-9999.,peakT0AErr=-9999., spreadT0AErr=-9999.;
516 Double_t avT0C=-9999.,peakT0C=-9999., spreadT0C=-9999.,peakT0CErr=-9999., spreadT0CErr=-9999.;
517 Double_t avT0AC=-9999.,peakT0AC=-9999., spreadT0AC=-9999.,peakT0ACErr=-9999., spreadT0ACErr=-9999.;
518 Double_t avT0res=-9999.,peakT0res=-9999., spreadT0res=-9999.,peakT0resErr=-9999., spreadT0resErr=-9999.;
519 Double_t avT0fillRes=-9999.;
522 Float_t fractionEventsWHits=-9999.;
523 /*number of good (HW ok && efficient && !noisy) TOF channels from OCDB*/
524 Double_t goodChannelRatio=0.0;
526 TTree * ttree=new TTree("trendTree","tree of trending variables");
527 ttree->Branch("run",&runNumber,"run/I");
528 ttree->Branch("avMulti",&avMulti,"avMulti/I");
529 ttree->Branch("fractionEventsWHits",&fractionEventsWHits,"fractionEventsWHits/F");
530 ttree->Branch("goodChannelsRatio",&goodChannelRatio,"goodChannelRatio/D");
531 ttree->Branch("avTime",&avTime,"avTime/D"); //mean time
532 ttree->Branch("peakTime",&peakTime,"peakTime/D"); //main peak time after fit
533 ttree->Branch("spreadTime",&spreadTime,"spreadTime/D"); //spread of main peak of time after fit
534 ttree->Branch("peakTimeErr",&peakTimeErr,"peakTimeErr/D"); //main peak time after fit error
535 ttree->Branch("spreadTimeErr",&spreadTimeErr,"spreadTimeErr/D"); //spread of main peak of time after fit error
536 ttree->Branch("negTimeRatio",&negTimeRatio,"negTimeRatio/D"); //negative time ratio
538 ttree->Branch("avRawTime",&avRawTime,"avRawTime/D"); //mean raw time
539 ttree->Branch("peakRawTime",&peakRawTime,"peakRawTime/D"); //mean peak of RAW TIME after fit
540 ttree->Branch("spreadRawTime",&spreadRawTime,"spreadRawTime/D"); //spread of main peak of raw time after fit
541 ttree->Branch("peakRawTimeErr",&peakRawTimeErr,"peakRawTimeErr/D"); //main peak raw time after fit error
542 ttree->Branch("spreadRawTimeErr",&spreadRawTimeErr,"spreadRawTimeErr/D"); //spread of raw main peak of time after fit error
544 ttree->Branch("avTot",&avTot,"avTot/D"); //main peak tot
545 ttree->Branch("peakTot",&peakTot,"peakTot/D"); // main peak of tot after fit
546 ttree->Branch("spreadTot",&spreadTot,"spreadTot/D"); //spread of main peak of tot after fit
547 ttree->Branch("peakTotErr",&peakTotErr,"peakTotErr/D"); // main peak of tot after fit
548 ttree->Branch("spreadTotErr",&spreadTotErr,"spreadTotErr/D"); //spread of main peak of tot after fit
550 ttree->Branch("orphansRatio",&orphansRatio,"orphansRatio/D"); //orphans ratio
552 ttree->Branch("avL",&avL,"avL/D"); //mean track length
553 ttree->Branch("negLratio",&negLratio,"negLratio/D");//ratio of tracks with track length <350 cm
554 ttree->Branch("effPt1",&effPt1,"effPt1/D");//matching eff at 1 GeV/c
555 ttree->Branch("effPt2",&effPt2,"effPt2/D"); //matching eff at 2 GeV/c
556 ttree->Branch("matchEffLinFit1Gev",&matchEffLinFit1Gev,"matchEffLinFit1Gev/D");//matching eff fit param
557 ttree->Branch("matchEffLinFit1GevErr",&matchEffLinFit1GevErr,"matchEffLinFit1GevErr/D");////matching eff fit param error
559 ttree->Branch("avPiDiffTime",&avPiDiffTime,"avPiDiffTime/D"); //mean t-texp
560 ttree->Branch("peakPiDiffTime",&peakPiDiffTime,"peakPiDiffTime/D"); //main peak t-texp after fit
561 ttree->Branch("spreadPiDiffTime",&spreadPiDiffTime,"spreadPiDiffTime/D"); //spread of main peak t-texp after fit
562 ttree->Branch("peakPiDiffTimeErr",&peakPiDiffTimeErr,"peakPiDiffTimeErr/D"); //main peak t-texp after fit error
563 ttree->Branch("spreadPiDiffTimeErr",&spreadPiDiffTimeErr,"spreadPiDiffTimeErr/D"); //spread of main peak of t-texp after fit error
565 ttree->Branch("avT0A",&avT0A,"avT0A/D"); //main peak t0A
566 ttree->Branch("peakT0A",&peakT0A,"peakT0A/D"); // main peak of t0A after fit
567 ttree->Branch("spreadT0A",&spreadT0A,"spreadTot/D"); //spread of main peak of t0A after fit
568 ttree->Branch("peakT0AErr",&peakT0AErr,"peakT0AErr/D"); // main peak of t0A after fit
569 ttree->Branch("spreadT0AErr",&spreadT0AErr,"spreadT0AErr/D"); //spread of main peak of t0A after fit
571 ttree->Branch("avT0C",&avT0C,"avT0C/D"); //main peak t0C
572 ttree->Branch("peakT0C",&peakT0C,"peakT0C/D"); // main peak of t0C after fit
573 ttree->Branch("spreadT0C",&spreadT0C,"spreadT0C/D"); //spread of main peak of t0C after fit
574 ttree->Branch("peakT0CErr",&peakT0CErr,"peakT0CErr/D"); // main peak of t0C after fit
575 ttree->Branch("spreadT0CErr",&spreadT0CErr,"spreadT0CErr/D"); //spread of main peak of t0C after fit
577 ttree->Branch("avT0AC",&avT0AC,"avT0AC/D"); //main peak t0AC
578 ttree->Branch("peakT0AC",&peakT0AC,"peakT0AC/D"); // main peak of t0AC after fit
579 ttree->Branch("spreadT0AC",&spreadT0AC,"spreadT0AC/D"); //spread of main peak of t0AC after fit
580 ttree->Branch("peakT0ACErr",&peakT0ACErr,"peakT0ACErr/D"); // main peak of t0AC after fit
581 ttree->Branch("spreadT0ACErr",&spreadT0ACErr,"spreadT0ACErr/D"); //spread of main peak of t0AC after fit
583 ttree->Branch("avT0res",&avT0res,"avT0res/D"); //main peak t0AC
584 ttree->Branch("peakT0res",&peakT0res,"peakT0res/D"); // main peak of t0AC after fit
585 ttree->Branch("spreadT0res",&spreadT0res,"spreadT0res/D"); //spread of main peak of t0AC after fit
586 ttree->Branch("peakT0resErr",&peakT0resErr,"peakT0resErr/D"); // main peak of t0AC after fit
587 ttree->Branch("spreadT0resErr",&spreadT0resErr,"spreadT0resErr/D"); //spread of main peak of t0AC after fit
588 ttree->Branch("avT0fillRes",&avT0fillRes,"avT0fillRes/D"); //t0 fill res
591 //save quantities for trending
592 goodChannelRatio=(Double_t)GetGoodTOFChannelsRatio(runNumber);
594 //--------------------------------- Multiplicity ----------------------------------//
595 TH1F*hMulti=(TH1F*)postfile->Get("hTOFmatchedPerEvt");
596 if ((hMulti)&&(hMulti->GetEntries()>0)) {
597 avMulti=hMulti->GetMean();
600 //--------------------------------- T0F signal ----------------------------------//
602 TH1F*hTime=(TH1F*)postfile->Get("hTOFmatchedESDtime");
603 if ((hTime)&&(hTime->GetEntries()>0)) {
604 avTime=hTime->GetMean();
605 hTime->Fit("landau","","",0.,50.);
606 peakTime=(hTime->GetFunction("landau"))->GetParameter(1);
607 spreadTime=(hTime->GetFunction("landau"))->GetParameter(2);
608 peakTimeErr=(hTime->GetFunction("landau"))->GetParError(1);
609 spreadTimeErr=(hTime->GetFunction("landau"))->GetParError(2);
611 negTimeRatio=((Double_t)hTime->Integral(1,3)*100.)/((Double_t)hTime->Integral());
612 printf("Main peak time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
613 printf("Main peak time (landau): spread = %f +- %f\n",spreadTime,spreadTimeErr );
614 printf("Ratio of tracks with time<12.5 ns / total = %f\n",negTimeRatio );
616 //add integral of main peak over total
618 printf("---------------------------------------------------------------- \n");
619 TH1F * hRawTime = (TH1F*)postfile->Get("hTOFmatchedESDrawTime");
620 if ((hRawTime)&&(hRawTime->GetEntries()>0)){
621 avRawTime=hRawTime->GetMean();
623 hRawTime->Fit("landau","","",200.,250.);
624 peakRawTime=(hRawTime->GetFunction("landau"))->GetParameter(1);
625 spreadRawTime=(hRawTime->GetFunction("landau"))->GetParameter(2);
626 peakRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(1);
627 spreadRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(2);
628 printf("Main peak raw time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
629 printf("Main peak raw time (landau): spread = %f +- %f\n",spreadRawTime,spreadRawTimeErr );
631 printf("Reminder: Raw time not available in MC simulated data.");
635 printf("---------------------------------------------------------------- \n");
637 TH1F * hTot = (TH1F*)postfile->Get("hTOFmatchedESDToT");
638 if ((hTot)&&(hTot->GetEntries()>0)){
639 avTot=hTot->GetMean();
640 hTot->Fit("gaus","","",0.,50.);
641 peakTot=(hTot->GetFunction("gaus"))->GetParameter(1);
642 spreadTot=(hTot->GetFunction("gaus"))->GetParameter(2);
643 peakTotErr=(hTot->GetFunction("gaus"))->GetParError(1);
644 spreadTotErr=(hTot->GetFunction("gaus"))->GetParError(2);
645 printf("Main peak ToT (gaus): mean = %f +- %f\n",peakTot,peakTotErr );
646 printf("Main peak ToT (gaus): spread = %f +- %f\n",spreadTot,spreadTotErr );
648 printf("---------------------------------------------------------------- \n");
649 TH1F * hOrphansRatio=(TH1F*)postfile->Get("hOrphansRatio");
651 orphansRatio=hOrphansRatio->GetMean();
653 TH1F * hL=(TH1F*)postfile->Get("hTOFmatchedESDtrkLength");
657 TH1F *hLnegRatio =(TH1F*)postfile->Get("hLnegRatio");
659 negLratio=hLnegRatio->GetMean();
661 //--------------------------------- matching eff ----------------------------------//
663 //Double_t linFitEff1Param[3]={0.,0.,0.};
664 TH1F *hMatchingVsPt =(TH1F*)postfile->Get("hTOFmatchedESDPt");
666 if (hMatchingVsPt->GetEntries()>0){
667 hMatchingVsPt->Fit("pol0","","",1.0,5.);
668 hMatchingVsPt->Draw();
669 if (hMatchingVsPt->GetFunction("pol0")){
670 matchEffLinFit1Gev=(hMatchingVsPt->GetFunction("pol0"))->GetParameter(0);
671 matchEffLinFit1GevErr=(hMatchingVsPt->GetFunction("pol0"))->GetParError(0);
672 printf("Matching efficiency fit param is %f +- %f\n",matchEffLinFit1Gev,matchEffLinFit1GevErr );
675 printf("WARNING: matching efficiency plot has 0 entries. Skipped!\n");
678 printf("WARNING: cannot retrieve matching efficiency plot\n");
681 //--------------------------------- t-texp ----------------------------------//
683 TH1F*hPiDiffTime=(TH1F*)postfile->Get("hTOFmatchedExpTimePi");
684 if ((hPiDiffTime)&&(hPiDiffTime->GetEntries()>0)) {
685 avPiDiffTime=hPiDiffTime->GetMean();
686 hPiDiffTime->Fit("gaus","","",-1000.,500.);
687 if (hPiDiffTime->GetFunction("gaus")){
688 peakPiDiffTime=(hPiDiffTime->GetFunction("gaus"))->GetParameter(1);
689 spreadPiDiffTime=(hPiDiffTime->GetFunction("gaus"))->GetParameter(2);
690 peakPiDiffTimeErr=(hPiDiffTime->GetFunction("gaus"))->GetParError(1);
691 spreadPiDiffTimeErr=(hPiDiffTime->GetFunction("gaus"))->GetParError(2);
692 printf("Main peak t-t_exp (gaus): mean = %f +- %f\n",peakPiDiffTime,peakPiDiffTimeErr );
693 printf("Main peak t-t_exp (gaus): spread = %f +- %f\n",spreadPiDiffTime,spreadPiDiffTimeErr );
696 //--------------------------------- T0 detector ----------------------------------//
698 TH1F*hT0A=(TH1F*)postfile->Get("hEventT0DetA");
699 if ((hT0A)&&(hT0A->GetEntries()>0)) {
700 avhT0A=hT0A->GetMean();
702 peakT0A=(hT0A->GetFunction("gaus"))->GetParameter(1);
703 spreadT0A=(hT0A->GetFunction("gaus"))->GetParameter(2);
704 peakT0AErr=(hT0A->GetFunction("gaus"))->GetParError(1);
705 spreadT0AErr=(hT0A->GetFunction("gaus"))->GetParError(2);
706 printf("Main peak T0A(gaus): mean = %f +- %f\n",peakT0A,peakT0AErr );
707 printf("Main peak T0A (gaus): spread = %f +- %f\n",spreadT0A,spreadT0AErr );
708 //add integral of main peak over total
711 TH1F*hT0C=(TH1F*)postfile->Get("hEventT0DetC");
712 if ((hT0C)&&(hT0C->GetEntries()>0)) {
713 avhT0C=hT0C->GetMean();
715 peakT0C=(hT0C->GetFunction("gaus"))->GetParameter(1);
716 spreadT0C=(hT0C->GetFunction("gaus"))->GetParameter(2);
717 peakT0CErr=(hT0C->GetFunction("gaus"))->GetParError(1);
718 spreadT0CErr=(hT0C->GetFunction("gaus"))->GetParError(2);
719 printf("Main peak T0C(gaus): mean = %f +- %f\n",peakT0C,peakT0CErr );
720 printf("Main peak T0C (gaus): spread = %f +- %f\n",spreadT0C,spreadT0CErr );
721 //add integral of main peak over total
724 TH1F*hT0AC=(TH1F*)postfile->Get("hEventT0DetAND");
725 if ((hT0AC)&&(hT0AC->GetEntries()>0)) {
726 avhT0AC=hT0AC->GetMean();
728 peakT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(1);
729 spreadT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(2);
730 peakT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(1);
731 spreadT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(2);
732 printf("Main peak T0AC(gaus): mean = %f +- %f\n",peakT0AC,peakT0ACErr );
733 printf("Main peak T0AC (gaus): spread = %f +- %f\n",spreadT0AC,spreadT0ACErr );
736 TH1F*hT0res=(TH1F*)postfile->Get("hT0DetRes");
737 if ((hT0res)&&(hT0res->GetEntries()>0)) {
738 avhT0res=hT0res->GetMean();
740 peakT0res=(hT0res->GetFunction("gaus"))->GetParameter(1);
741 spreadT0res=(hT0res->GetFunction("gaus"))->GetParameter(2);
742 peakT0resErr=(hT0res->GetFunction("gaus"))->GetParError(1);
743 spreadT0resErr=(hT0res->GetFunction("gaus"))->GetParError(2);
744 printf("Main peak T0res(gaus): mean = %f +- %f\n",peakT0res,peakT0resErr );
745 printf("Main peak T0res (gaus): spread = %f +- %f\n",spreadT0res,spreadT0resErr );
746 //add integral of main peak over total
749 TH1F*hT0fillRes=(TH1F*)postfile->Get("hT0fillRes");
750 if ((hT0fillRes)&&(hT0fillRes->GetEntries()>0)) {
751 avT0fillRes=hT0fillRes->GetMean();
755 printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
756 if (postfile->IsOpen()) {
757 printf("Trying to close\n");
767 //------------------------------------------------------------------------------------
769 Int_t RunESDQApostAnalysis(char *qafilename=NULL, Int_t runNumber=-1, Bool_t isMC=kFALSE, Bool_t IsOnGrid=kFALSE, Bool_t canvasE=kFALSE) {
773 /*access qa PWGPP output files - saved locally or on grid as specified by the second argument */
775 char defaultQAoutput[30]="QAresults.root";
776 if (IsOnGrid) TGrid::Connect("alien://");
777 TFile * fin= TFile::Open(qafilename,"r");
778 printf("Opening file %s\n",qafilename);
780 printf("ERROR: QA output not found. Exiting with status -1\n");
783 printf("INFO: QA output file %s open. \n",fin->GetName());
787 //access histograms lists
788 char tofQAdirName[15]="TOF_Performance";
789 char genListName[15]="cGeneralTOFqa";
790 char t0ListName[15]="cTimeZeroTOFqa";
791 char pidListName[15]="cPIDTOFqa";
792 char posListName[15]="cPositiveTOFqa";
793 char negListName[15]="cNegativeTOFqa";
795 TDirectoryFile * tofQAdir=(TDirectoryFile*)fin->Get(tofQAdirName);
797 printf("------------------------------------------------------------------\n");
799 printf("------------------------------------------------------------------\n");
802 TList * generalList=(TList*)tofQAdir->Get(genListName);
803 TList *timeZeroList=(TList*)tofQAdir->Get(t0ListName);
804 TList *pidList=(TList*)tofQAdir->Get(pidListName);
805 TList *posList=(TList*)tofQAdir->Get(posListName);
806 TList *negList=(TList*)tofQAdir->Get(negListName);
808 if (!generalList) printf("WARNING: general QA histograms absent or not accessible\n");
809 if (!timeZeroList) printf("WARNING: timeZero QA histograms absent or not accessible\n");
810 if (!pidList) printf("WARNING: PID QA histograms absent or not accessible\n");
811 if (!posList) printf("WARNING: general QA histograms for positive tracks absent or not accessible\n");
812 if (!negList) printf("WARNING: general QA histograms for negative tracks absent or not accessible\n");
814 if ( (!generalList) && (!timeZeroList) && (!pidList) ){
815 printf("ERROR: no QA available \n");
821 printf("------------------------------------------------------------------\n");
823 printf("------------------------------------------------------------------\n");
825 printf("------------------------------------------------------------------\n");
828 /*set graphic style*/
829 gStyle->SetCanvasColor(kWhite);
830 gStyle->SetFrameFillColor(kWhite);
831 gStyle->SetFrameBorderMode(0);
832 gStyle->SetCanvasBorderMode(0);
833 gStyle->SetTitleFillColor(kWhite);
834 gStyle->SetTitleBorderSize(0) ;
835 gStyle->SetTitleFont(42);
836 gStyle->SetTextFont(42);
837 //gStyle->SetPalette(1);
838 gStyle->SetStatColor(kWhite);
839 gStyle->SetStatBorderSize(1);
840 gStyle->SetOptStat(0);
843 char outfilename[60];
844 sprintf(outfilename,"postQA_%i.root",runNumber);
845 TFile * fout=new TFile(outfilename,"recreate");
847 TH1I* hRunNumber=new TH1I("hRunNumber","hRunNumber;run",1,runNumber,runNumber+1);
848 hRunNumber->Fill(runNumber);
850 //-------------------------------------------------------------
851 /*GENERAL MONITOR - MULTIPLICITY*/
852 TH1F*hMulti= (TH1F*) generalList->At(0);
854 TH1F* hFractionEventsWhits=new TH1F("hFractionEventsWhits","hFractionEventsWhits;fraction of events with hits (%)",200,0.,100.);
855 Float_t fraction=0.0;
856 if (hMulti->GetEntries()>0.0) fraction=((Float_t) hMulti->GetBinContent(1))/((Float_t) hMulti->GetEntries());
858 hFractionEventsWhits->Fill(fraction*100.);
860 //-------------------------------------------------------------
861 /*GENERAL MONITOR - TIMING AND GEOMETRY*/
862 TH1F * hTime = (TH1F*) generalList->At(1);
863 hTime->SetMarkerStyle(8);
864 hTime->SetMarkerSize(0.7);
865 hTime->SetMarkerColor(kBlue);
866 hTime->SetLineColor(kBlue);
867 hTime->SetFillColor(kBlue);
868 hTime->SetFillStyle(3001);
870 hTime->GetYaxis()->SetTitle("matched tracks");
871 hTime->GetYaxis()->SetTitleOffset(1.35);
873 TH1F * hRawTime = (TH1F*) generalList->At(2);
874 hRawTime->SetMarkerStyle(21);
875 hRawTime->SetMarkerSize(0.7);
876 hRawTime->SetMarkerColor(kGreen);
877 hRawTime->SetLineColor(kGreen);
878 hRawTime->SetFillColor(kGreen);
879 hRawTime->SetFillStyle(3001);
881 hRawTime->GetYaxis()->SetTitle("matched tracks");
882 hRawTime->GetYaxis()->SetTitleOffset(1.35);
884 TLegend *lTime = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
885 lTime->SetTextSize(0.04281433);
886 lTime->AddEntry(hRawTime, "raw","L");
887 lTime->AddEntry(hTime, "ESD","L");
888 lTime->SetFillColor(kWhite);
889 lTime->SetShadowColor(0);
891 TH1F * hTot = (TH1F*) generalList->At(3);
892 hTot->SetMarkerStyle(8);
893 hTot->SetMarkerSize(0.7);
894 hTot->SetMarkerColor(kViolet-3);
895 hTot->SetLineColor(kViolet-3);
896 hTot->SetFillColor(kViolet-3);
897 hTot->SetFillStyle(3001);
898 //hTime->SetDrawOption();
899 hTot->GetYaxis()->SetTitle("matched tracks");
900 hTot->GetYaxis()->SetTitleOffset(1.35);
903 char orphansTxt[200];
904 Float_t orphansRatio=0.0;
905 if (hTot->GetEntries()>1){
906 orphansRatio=((Float_t) hTot->GetBinContent(1))/((Float_t) hTot->GetEntries()) ;
908 sprintf(orphansTxt,"orphans/matched tracks = %.4f ",orphansRatio);
909 TH1F * hOrphansRatio=new TH1F("hOrphansRatio","Percentage of signals with only leading edge; percentage (%)",1000,0.,100.);
910 hOrphansRatio->Fill(orphansRatio*100.);
913 TPaveText *tOrphans = new TPaveText(0.38,0.63,0.88,0.7, "NDC");
914 //NDC sets coords relative to pad
915 tOrphans->SetBorderSize(0);
916 tOrphans->SetTextSize(0.045);
917 tOrphans->SetFillColor(0); //white background
918 tOrphans->SetTextAlign(12);
919 tOrphans->SetTextColor(kViolet-3);
920 tOrphans->AddText(orphansTxt);
922 TH1F * hL = (TH1F*) generalList->At(4);
923 hL->SetMarkerStyle(8);
924 hL->SetMarkerSize(0.7);
925 hL->SetMarkerColor(kOrange-3);
926 hL->SetLineColor(kOrange-3);
927 hL->SetFillColor(kOrange-3);
928 hL->SetFillStyle(3001);
929 //hTime->SetDrawOption();
930 hL->GetYaxis()->SetTitle("matched tracks");
931 hL->GetYaxis()->SetTitleOffset(1.35);
933 char negLengthTxt[200];
934 Float_t negLengthRatio=0.0;
935 if (hL->GetEntries()>1){
936 negLengthRatio=(hL->Integral(1,750))/((Float_t) hL->GetEntries()) ;
938 sprintf(negLengthTxt,"tracks with L<350cm /matched tracks = %.5f ",negLengthRatio);
939 TH1F * hLnegRatio=new TH1F("hLnegRatio","Ratio of TOF-matched tracks with L<350cm; ratio (%)",10000,0.,100.);
940 hLnegRatio->Fill(negLengthRatio*100);
944 TPaveText *tLength = new TPaveText(0.15,0.83,0.65,0.87, "NDC");
945 //NDC sets coords relative to pad
946 tLength->SetBorderSize(0);
947 tLength->SetTextSize(0.04);
948 tLength->SetFillColor(0); //white background
949 tLength->SetTextAlign(11);
950 tLength->SetTextColor(kOrange-3);
951 tLength->AddText(negLengthTxt);
954 TCanvas *cTrackProperties= new TCanvas("cTrackProperties","summary of matched tracks properties",900,900);
955 cTrackProperties->Divide(2,2);
956 cTrackProperties->cd(1);
961 hRawTime ->Draw("BARsame");
963 cTrackProperties->cd(2);
969 cTrackProperties->cd(3);
979 hFractionEventsWhits->Write();
983 hOrphansRatio->Write();
987 TH2F* hDxPos4profile = (TH2F*) generalList->At(14);
988 TH2F* hDxNeg4profile = (TH2F*) generalList->At(13);
990 char profilename[30];
991 const Int_t ybinMin = 0;
992 const Int_t ybinMax =hDxPos4profile->GetYaxis()->GetNbins() ;
993 sprintf(profilename,"profDxPos");
994 TProfile * profDxPos = (TProfile*)hDxPos4profile->ProfileX(profilename, ybinMin,ybinMax);
995 sprintf(profilename,"profDxNeg");
996 profDxPos->SetLineWidth(2);
997 TProfile * profDxNeg = (TProfile*)hDxNeg4profile->ProfileX(profilename, ybinMin, ybinMax);
998 profDxNeg->SetLineWidth(2);
1000 TH1 *profRatioPosOverNegDx = (TH1*) profDxPos->Clone();
1001 profRatioPosOverNegDx->SetName("profRatioPosOverNegDx");
1002 profRatioPosOverNegDx->Divide((TH1*) profDxNeg);
1003 profRatioPosOverNegDx->GetYaxis()->SetRangeUser(-5.,5.);
1004 profRatioPosOverNegDx->GetXaxis()->SetRangeUser(0.,2.);
1006 TCanvas *residuals= new TCanvas("residuals","residuals",900,450);
1007 residuals->Divide(2,1);
1011 hDxPos4profile->GetYaxis()->SetRangeUser(-5.,5.);
1012 hDxPos4profile->Draw("colz");
1013 profDxPos->SetLineColor(kRed);
1014 profDxPos ->Draw("same");
1018 hDxNeg4profile->GetYaxis()->SetRangeUser(-5.,5.);
1019 hDxNeg4profile->Draw("colz");
1020 profDxNeg->SetLineColor(kBlue);
1021 profDxNeg->Draw("same");
1025 hDxPos4profile->Write();
1026 hDxNeg4profile->Write();
1029 profRatioPosOverNegDx->Write();
1030 //-------------------------------------------------------------
1031 /* T0 DETECTOR MONITOR*/
1033 TH1F * hT0AC = (TH1F*) timeZeroList->At(0);
1034 hT0AC->SetMarkerStyle(8);
1035 hT0AC->SetMarkerSize(0.7);
1036 hT0AC->SetMarkerColor(kRed);
1037 hT0AC->SetLineColor(kRed);
1038 hT0AC->SetFillColor(kRed);
1039 hT0AC->SetFillStyle(1001);
1041 hT0AC->GetYaxis()->SetTitle("events");
1042 hT0AC->GetYaxis()->SetTitleOffset(1.35);
1043 hT0AC->GetXaxis()->SetLabelSize(0.03);
1045 TH1F * hT0A = (TH1F*) timeZeroList->At(1);
1046 hT0A->SetMarkerStyle(8);
1047 hT0A->SetMarkerSize(0.7);
1048 hT0A->SetMarkerColor(kBlue);
1049 hT0A->SetLineColor(kBlue);
1050 hT0A->SetFillColor(kBlue);
1051 hT0A->SetFillStyle(1001);
1053 hT0A->GetYaxis()->SetTitle("events");
1054 hT0A->GetYaxis()->SetTitleOffset(1.35);
1055 hT0A->GetXaxis()->SetLabelSize(0.03);
1057 TH1F * hT0C = (TH1F*) timeZeroList->At(2);
1058 hT0C->SetMarkerStyle(8);
1059 hT0C->SetMarkerSize(0.7);
1060 hT0C->SetMarkerColor(kGreen);
1061 hT0C->SetLineColor(kGreen);
1062 hT0C->SetFillColor(kGreen);
1063 hT0C->SetFillStyle(1001);
1065 hT0C->GetYaxis()->SetTitle("events");
1066 hT0C->GetYaxis()->SetTitleOffset(1.35);
1067 hT0C->GetXaxis()->SetLabelSize(0.03);
1069 TLegend *lT0 = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
1070 lT0->SetTextSize(0.041);
1071 lT0->AddEntry(hT0AC, "T0 A&C","L");
1072 lT0->AddEntry(hT0A, "T0 A","L");
1073 lT0->AddEntry(hT0C, "T0 C","L");
1074 lT0->SetFillColor(kWhite);
1075 lT0->SetShadowColor(0);
1077 TH1F * hT0res = (TH1F*) timeZeroList->At(3);
1078 hT0res->GetXaxis()->SetLabelSize(0.03);
1080 TCanvas *cT0detector= new TCanvas("cT0detector","T0 detector",900,450);
1081 cT0detector->Divide(2,1);
1086 hT0AC->SetTitle("timeZero measured by T0 detector");
1087 hT0A ->Draw("BARsame");
1088 hT0C ->Draw("BARsame");
1096 // cTrackProperties->cd(3);
1102 TH1F * hT0fillRes = (TH1F*) timeZeroList->At(8);
1103 hT0fillRes->GetXaxis()->SetLabelSize(0.03);
1110 hT0fillRes->Write();
1114 //-------------------------------------------------------------
1115 /*MATCHING EFFICIENCY MONITOR*/
1117 //TH1F * hMatchingVsP =new TH1F("hMatchingVsP","Matching probability vs. P; P(GeV/c); matching probability", 50, 0., 5. );
1119 TH1F * hMatchingVsPt =new TH1F("hMatchingVsPt","Matching probability vs. Pt; Pt(GeV/c); matching probability", 50, 0., 5. );
1121 TH1F * hMatchingVsEta =new TH1F("hMatchingVsEta","Matching probability vs. #\Eta; #\Eta; matching probability", 20, -1., 1.);
1123 TH1F * hMatchingVsPhi =new TH1F("hMatchingVsPhi","Matching probability vs. Phi; Phi(rad); matching probability", 628, 0., 6.28);
1125 /*/matching as function of p
1126 TH1F * hDenom=(TH1F*)generalList->At(9);
1128 hMatchingVsP=(TH1F*) generalList->At(5);
1129 hMatchingVsP->Rebin(5);
1131 hMatchingVsP->Divide(hDenom);
1132 hMatchingVsP->GetYaxis()->SetTitle("matching efficiency");
1133 hMatchingVsP->SetTitle("TOF matching efficiency as function of momentum");
1136 //matching as function of pT
1139 TH1F * hDenom=(TH1F*)generalList->At(10);
1141 hMatchingVsPt=(TH1F*) generalList->At(6);
1142 hMatchingVsPt->Rebin(5);
1144 hMatchingVsPt->Divide(hDenom);
1145 hMatchingVsPt->GetYaxis()->SetTitle("matching efficiency");
1146 hMatchingVsPt->SetTitle("TOF matching efficiency as function of transverse momentum");
1147 hMatchingVsPt->GetYaxis()->SetRangeUser(0,1.2);
1150 //matching as function of eta
1152 hDenom=(TH1F*)generalList->At(11);
1154 hMatchingVsEta=(TH1F*) generalList->At(7);
1155 hMatchingVsEta->Rebin(5);
1157 hMatchingVsEta->Divide(hDenom);
1158 hMatchingVsEta->GetXaxis()->SetRangeUser(-1,1);
1159 hMatchingVsEta->GetYaxis()->SetTitle("matching efficiency");
1160 hMatchingVsEta->GetYaxis()->SetRangeUser(0,1.2);
1161 hMatchingVsEta->SetTitle("TOF matching efficiency as function of pseudorapidity");
1163 //matching as function of phi
1165 hDenom=(TH1F*)generalList->At(12);
1167 hMatchingVsPhi=(TH1F*) generalList->At(8);
1168 //hMatchingVsPhi->Rebin(5);
1170 hMatchingVsPhi->Divide(hDenom);
1171 hMatchingVsPhi->GetYaxis()->SetTitle("matching efficiency");
1172 hMatchingVsPhi->SetTitle("TOF matching efficiency as function of phi");
1173 hMatchingVsPhi->GetYaxis()->SetRangeUser(0,1.2);
1176 TCanvas *cMatchingPerformance= new TCanvas("cMatchingPerformance","summary of matching performance",700,400);
1177 cMatchingPerformance->Divide(2,2);
1178 cMatchingPerformance->cd(1);
1181 hMatchingVsPt->Draw();
1182 cMatchingPerformance->cd(2);
1185 hMatchingVsEta->Draw();
1186 cMatchingPerformance->cd(3);
1189 hMatchingVsPhi->Draw();
1192 hMatchingVsPt->Write();
1193 hMatchingVsEta->Write();
1194 hMatchingVsPhi->Write();
1196 //----------------------------------------------------
1197 /* PID PERFORMANCE MONITOR */
1199 TH2F * hBetaP=(TH2F*)pidList->At(0);
1200 hBetaP->GetYaxis()->SetRangeUser(0.,1.2);
1201 TH1F * hMass=(TH1F*)pidList->At(1);
1202 //hMass->SetMarkerColor(kBlue);
1203 //hMass->SetLineColor(kBlue);
1204 hMass->SetFillColor(kAzure+10);
1205 hMass->SetFillStyle(1001);
1207 hMass->GetYaxis()->SetTitle("tracks");
1208 hMass->GetYaxis()->SetTitleOffset(1.35);
1209 hMass->GetXaxis()->SetLabelSize(0.03);
1211 TH1F * hPionDiff=(TH1F*)pidList->At(3);
1214 TH2F * hDiffTimePi=(TH2F*)pidList->At(4);
1215 hDiffTimePi->GetYaxis()->SetRangeUser(-2000.,2000.);
1216 hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
1217 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1218 sprintf(profilename,"profDiffTimePi");
1220 TProfile * profDiffTimePi = (TProfile*)hDiffTimePi->ProfileX(profilename, 490, 510);
1221 profDiffTimePi->SetLineWidth(2);
1222 profDiffTimePi->SetLineColor(kRed+2);
1224 TH2F * hDiffTimePiTh=(TH2F*)pidList->At(6);
1225 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1226 sprintf(profilename,"profDiffTimePiTh");
1227 hDiffTimePiTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1229 TProfile * profDiffTimePiTh = (TProfile*)hDiffTimePiTh->ProfileX(profilename, 490, 510);
1230 profDiffTimePiTh->SetLineWidth(2);
1231 profDiffTimePiTh->SetLineColor(kRed+2);
1233 TH2F * hDiffTimeKa=(TH2F*)pidList->At(9);
1234 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1235 hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
1236 sprintf(profilename,"profDiffTimeKa");
1237 hDiffTimeKa->GetYaxis()->SetRangeUser(-2000.,2000.);
1239 TProfile * profDiffTimeKa = (TProfile*)hDiffTimeKa->ProfileX(profilename, 490, 510);
1240 profDiffTimeKa->SetLineWidth(2);
1241 profDiffTimeKa->SetLineColor(kBlue);
1243 TH2F * hDiffTimeKaTh=(TH2F*)pidList->At(11);
1244 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1245 sprintf(profilename,"profDiffTimeKaTh");
1246 hDiffTimeKaTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1247 TProfile * profDiffTimeKaTh = (TProfile*)hDiffTimeKaTh->ProfileX(profilename, 490, 510);
1248 profDiffTimeKaTh->SetLineWidth(2);
1249 profDiffTimeKaTh->SetLineColor(kBlue);
1251 TH2F * hDiffTimePro=(TH2F*)pidList->At(14);
1252 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1253 sprintf(profilename,"profDiffTimePro");
1254 hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");
1255 hDiffTimePro->GetYaxis()->SetRangeUser(-2000.,2000.);
1256 TProfile * profDiffTimePro = (TProfile*)hDiffTimePro->ProfileX(profilename, 490, 510);
1257 profDiffTimePro->SetLineWidth(2);
1258 profDiffTimePro->SetLineColor(kGreen+2);
1260 TH2F * hDiffTimeProTh=(TH2F*)pidList->At(16);
1261 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1262 sprintf(profilename,"profDiffTimeProTh");
1263 hDiffTimeProTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1264 TProfile * profDiffTimeProTh = (TProfile*)hDiffTimeProTh->ProfileX(profilename, 490, 510);
1265 profDiffTimeProTh->SetLineWidth(2);
1266 profDiffTimeProTh->SetLineColor(kGreen+2);
1269 TCanvas *cPidPerformance= new TCanvas("cPidPerformance","summary of pid performance",800,800);
1270 cPidPerformance->Divide(2,1);
1271 cPidPerformance->cd(1);
1275 hBetaP->Draw("colz");
1277 cPidPerformance->cd(2);
1281 hMass->Draw("HIST BAR");
1283 TLegend * lPid=new TLegend(0.75,0.75,0.95,0.95,"PID");
1284 lPid->AddEntry(profDiffTimePi,"#pi^{#pm}","l");
1285 lPid->AddEntry(profDiffTimeKa,"K^{#pm}","l");
1286 lPid->AddEntry(profDiffTimePro,"p^{#pm}","l");
1288 gStyle->SetOptStat(10);
1289 TCanvas *cPidPerformance2= new TCanvas("cPidPerformance2","summary of pid performance - tracking",700,700);
1290 cPidPerformance2->Divide(2,2);
1291 cPidPerformance2->cd(1);
1295 hDiffTimePi->Draw("colz");
1296 // profDiffTimePi->Draw("same");
1298 cPidPerformance2->cd(2);
1302 hDiffTimeKa->Draw("colz");
1303 //profDiffTimeKa->Draw("same");
1304 cPidPerformance2->cd(3);
1306 hDiffTimePro->Draw("colz");
1307 // profDiffTimePro->Draw("same");
1309 // cPidPerformance2->cd(4);
1310 // profDiffTimePi->Draw();
1311 // profDiffTimeKa->Draw("same");
1312 // profDiffTimePro->Draw("same");
1313 // lPid->Draw("same");
1315 TCanvas *cPidPerformanceTh= new TCanvas("cPidPerformanceTh","summary of pid performance - theoretical times",700,700);
1316 cPidPerformanceTh->Divide(2,2);
1317 cPidPerformanceTh->cd(1);
1321 hDiffTimePiTh->Draw("colz");
1322 profDiffTimePiTh->Draw("same");
1323 cPidPerformanceTh->cd(2);
1327 hDiffTimeKaTh->Draw("colz");
1328 profDiffTimeKaTh->Draw("same");
1329 cPidPerformanceTh->cd(3);
1333 hDiffTimeProTh->Draw("colz");
1334 profDiffTimeProTh->Draw("same");
1335 // cPidPerformanceTh->cd(4);
1336 // profDiffTimePiTh->Draw();
1337 // profDiffTimeKaTh->Draw("same");
1338 // profDiffTimeProTh->Draw("same");
1339 // lPid->Draw("same");
1342 TH1F * hPionDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePi");
1343 TH1F * hKaonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimeKa");
1344 TH1F * hProtonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePro");
1346 TH2F * hDiffTimeT0TOFPion1GeV=(TH2F*)pidList->FindObject("hTOFmatchedTimePion1GeV");
1351 hProtonDiff->Write();
1354 hDiffTimeT0TOFPion1GeV->Write();
1355 hDiffTimePi->Write();
1356 profDiffTimePi->Write();
1357 hDiffTimeKa->Write();
1358 profDiffTimeKa->Write();
1359 hDiffTimePro->Write();
1360 profDiffTimePro->Write();
1362 hDiffTimePiTh->Write();
1363 profDiffTimePiTh->Write();
1364 hDiffTimeKaTh->Write();
1365 profDiffTimeKaTh->Write();
1366 hDiffTimeProTh->Write();
1367 profDiffTimeProTh->Write();
1370 TH2F * hSigmaPi=(TH2F*)pidList->At(7);
1371 sprintf(profilename,"profSigmaPi");
1372 hSigmaPi->GetYaxis()->SetRangeUser(-5.,5.);
1373 TProfile * profSigmaPi = (TProfile*)hSigmaPi->ProfileX(profilename);
1374 profSigmaPi->SetLineWidth(2);
1375 profSigmaPi->SetLineColor(kRed+2);
1377 TH2F * hSigmaKa=(TH2F*)pidList->At(12);
1378 sprintf(profilename,"profSigmaKa");
1379 hSigmaKa->GetYaxis()->SetRangeUser(-5.,5.);
1380 TProfile * profSigmaKa = (TProfile*)hSigmaKa->ProfileX(profilename);
1381 profSigmaKa->SetLineWidth(2);
1382 profSigmaKa->SetLineColor(kBlue);
1384 TH2F * hSigmaPro=(TH2F*)pidList->At(17);
1385 sprintf(profilename,"profSigmaPro");
1386 hSigmaPro->GetYaxis()->SetRangeUser(-5.,5.);
1387 TProfile * profSigmaPro = (TProfile*)hSigmaPro->ProfileX(profilename);
1388 profSigmaPro->SetLineWidth(2);
1389 profSigmaPro->SetLineColor(kGreen+2);
1394 TLegend * lSigmaPid=new TLegend(0.75,0.75,0.95,0.95,"#sigma_{PID}");
1395 lSigmaPid->AddEntry(profSigmaPi,"#pi^{#pm}","l");
1396 lSigmaPid->AddEntry(profSigmaKa,"K^{#pm}","l");
1397 lSigmaPid->AddEntry(profSigmaPro,"p^{#pm}","l");
1399 TCanvas *cPidPerformance3= new TCanvas("cPidPerformance3","summary of pid performance - sigmas",1200,400);
1400 cPidPerformance3->Divide(3,1);
1401 cPidPerformance3->cd(1);
1406 hSigmaPi->Draw("colz");
1407 profSigmaPi->Draw("same");
1409 cPidPerformance3->cd(2);
1413 hSigmaKa->Draw("colz");
1414 profSigmaKa->Draw("same");
1416 cPidPerformance3->cd(3);
1420 hSigmaPro->Draw("colz");
1421 profSigmaPro->Draw("same");
1426 profSigmaPi->Write();
1428 profSigmaKa->Write();
1430 profSigmaPro->Write();
1432 TH2F* hTOFmatchedDzVsStrip = (TH2F*)generalList->FindObject("hTOFmatchedDzVsStrip");
1435 TCanvas* cProfile = new TCanvas("cProfile","cProfile",50,50,750,550);
1436 gStyle->SetOptStat(0);
1437 hTOFmatchedDzVsStrip->Draw("colz");
1438 Int_t binmin = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(-3);
1439 Int_t binmax = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(3);
1440 TProfile* hDzProfile = (TProfile*)hTOFmatchedDzVsStrip->ProfileX("hDzProfile",binmin, binmax);
1441 hDzProfile->SetLineWidth(3);
1442 hDzProfile->Draw("same");
1443 cProfile->SetGridx();
1444 cProfile->SetGridy();
1445 TString plotDir(Form("Plots_run%d",runNumber));
1446 gSystem->Exec(Form("mkdir %s",plotDir.Data()));
1447 cPidPerformance3->Print(Form("%s/PID_sigmas.png",plotDir.Data()));
1448 cPidPerformance->Print(Form("%s/PID.png",plotDir.Data()));
1449 cPidPerformanceTh->Print(Form("%s/PID_theoreticalTimes.png",plotDir.Data()));
1450 cPidPerformance2->Print(Form("%s/PID_ExpTimes.png",plotDir.Data()));
1451 cMatchingPerformance->Print(Form("%s/Matching.png",plotDir.Data()));
1452 cT0detector->Print(Form("%s/T0Detector.png",plotDir.Data()));
1453 cTrackProperties->Print(Form("%s/TrackProperties.png",plotDir.Data()));
1454 residuals->Print(Form("%s/Residuals.png",plotDir.Data()));
1455 cProfile->Print(Form("%s/ProfileDZvsStripNumber.png",plotDir.Data()));
1458 hTOFmatchedDzVsStrip->Write();
1463 //----------------------------------------------------------
1464 char * SetQAtrainOutputName(Int_t run=0,Int_t year=2011,char *period="LHC11a", char* pass="cpass1",Int_t trainId=76){
1467 sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults.root",year,period,runNumber,pass,trainId);
1472 //----------------------------------------------------------
1473 Double_t GetGoodTOFChannelsRatio(Int_t run, Bool_t saveMap = kFALSE)
1476 It retrieves from OCDB the number of good (= efficient && not noisy && HW ok) TOF channels.
1477 Optionally is saves the channel map
1480 printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): invalid run number. Please set a run number.\n");
1484 AliCDBManager *cdb = AliCDBManager::Instance();
1485 cdb->SetDefaultStorage("raw://");
1488 AliCDBEntry *cdbe = cdb->Get("TOF/Calib/Status");
1490 printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): OCDB entry not available. Please, try again.\n");
1494 AliTOFChannelOnlineStatusArray *array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
1495 TH2F *hOkMap = new TH2F("hOkMap", "Ok map (!noisy & !problematic & efficient);sector;strip", 72, 0., 18., 91, 0., 91.);
1497 AliTOFcalibHisto calibHisto;
1498 calibHisto.LoadCalibHisto();
1501 Int_t sector, sectorStrip, padx, fea;
1502 Float_t hitmapx, hitmapy;
1503 for (Int_t i = 0; i < array->GetSize(); i++) {
1504 sector = calibHisto.GetCalibMap(AliTOFcalibHisto::kSector, i);
1505 sectorStrip = calibHisto.GetCalibMap(AliTOFcalibHisto::kSectorStrip, i);
1506 padx = calibHisto.GetCalibMap(AliTOFcalibHisto::kPadX, i);
1508 hitmapx = sector + ((Double_t)(3 - fea) + 0.5) / 4.;
1509 hitmapy = sectorStrip;
1510 if ( !(array->GetNoiseStatus(i) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad) &&
1511 (calib.IsChannelEnabled(i,kTRUE,kTRUE)))
1512 hOkMap->Fill(hitmapx,hitmapy);
1514 Int_t nOk=(Int_t) hOkMap->GetEntries();
1515 Double_t ratioOk=nOk/152928.;
1516 if (saveMap) hOkMap->SaveAs(Form("run%i_OKChannelsMap.root",run));
1517 cout << "### Run " << run << ": TOF channels ok = " << nOk << "/ total 152928 channels = " << ratioOk*100. << "% of whole TOF" << endl;