2 fbellini@cern.ch - last update on 09/09/2014
3 Macro to run the TOF QA trending by accessing the std QA output,
4 to be mainly used with the automatic scripts to fill the QA repository.
6 aliroot -l -b -q "MakeTrendingTOFQA.C(\"${fullpath}/QAresults.root\", ${run}, ...)
7 The macro produces a file containing the tree of trending variables and the main plots.
8 A feature that displays the plots in canvases must be enable when needed.
12 Int_t MakeTrendingTOFQA(char * runlist,
14 char *period="LHC10c",
15 char* pass="cpass1_pass4",
16 char* nameSuffix ="_barrel",
19 Bool_t saveHisto=kTRUE,
20 Bool_t includeStartTime=kTRUE,
25 printf("Invalid list of runs given as input: nothing done\n");
31 char trendFileName[100];
32 //Define trending output
34 sprintf(trendFileName,"treeTOFQA_%s_%s.root",period,pass);
36 sprintf(trendFileName,"treeTOFQA_QA%i_%s_%s.root",trainId,period,pass);
38 TFile * trendFile=new TFile(trendFileName,"recreate");
39 FILE * files = fopen(runlist, "r") ;
41 //create chain of treePostQA
42 Long64_t nentries=100000, firstentry=0;
43 TChain *chainTree = 0;
44 chainTree=new TChain("trendTree");
46 while (fscanf(files,"%d",&runNumber)==1 ){
50 if (!isMC) sprintf(infile,"alien:///alice/data/%i/%s/000%d/%s/QAresults%s.root",year,period,runNumber,pass,nameSuffix);
51 else sprintf(infile,"alien:///alice/sim/%i/%s/%d/QAresults%s.root",year,period,runNumber,nameSuffix);
53 if (!isMC) sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults%s.root",year,period,runNumber,pass,trainId,nameSuffix);
54 else sprintf(infile,"alien:///alice/sim/%i/%s/%d/QA%i/QAresults%s.root",year,period,runNumber,trainId,nameSuffix);
56 Printf("============== Opening QA file(s) for run %i =======================\n",runNumber);
59 if (MakeTrendingTOFQAv2(infile,runNumber,isMC,drawAll,kTRUE,"raw://", saveHisto, includeStartTime)==0){
61 } else Printf("Post analysis not run on QA output %s", infile);
63 Printf(":::: Processed %i runs", filesCounter);
67 //---------------------------------------------------------------------------------
68 Int_t MakeTrendingTOFQAv2(TString qafilename, //full path of the QA output; set IsOnGrid to prepend "alien://"
69 Int_t runNumber, // run number
70 Bool_t isMC=kFALSE, //MC flag, to disable meaningless checks
71 Bool_t drawAll = kFALSE, //enable display plots on canvas and save png
72 Bool_t IsOnGrid = kFALSE, //set to kTRUE to access files on the grid
73 TString ocdbStorage = "raw://",
74 Bool_t saveHisto=kTRUE, //set the default ocdb storage
75 Bool_t includeStartTime=kTRUE )
77 // macro to generate tree with TOF QA trending variables
78 // access qa PWGPP output files
80 Printf("Error - Invalid input file");
85 gStyle->SetCanvasColor(kWhite);
86 gStyle->SetFrameFillColor(kWhite);
87 gStyle->SetFrameBorderMode(0);
88 gStyle->SetCanvasBorderMode(0);
89 gStyle->SetTitleFillColor(kWhite);
90 gStyle->SetTitleBorderSize(0) ;
91 gStyle->SetTitleFont(42);
92 gStyle->SetTextFont(42);
93 gStyle->SetStatColor(kWhite);
94 gStyle->SetStatBorderSize(1);
95 TGaxis::SetMaxDigits(3);
96 gStyle->SetOptStat(10);
98 char defaultQAoutput[30]="QAresults.root";
99 TString treePostFileName=Form("trending_%i.root",runNumber);
101 if (IsOnGrid) TGrid::Connect("alien://");
102 TFile * fin = TFile::Open(qafilename,"r");
104 Printf("ERROR: QA output not found. Exiting...\n");
107 Printf("INFO: QA output file %s open. \n",fin->GetName());
110 //access histograms lists
111 char tofQAdirName[15]="TOF";
112 char genListName[15]="base_noPID";
113 char t0ListName[15]="timeZero_noPID";
114 char pidListName[15]="pid_noPID";
115 char trdListName[15]="trd_noPID";
116 char trgListName[15]="trigger_noPID";
117 char PIDqaListName[6]="PIDqa";
118 TDirectoryFile * tofQAdir=(TDirectoryFile*)fin->Get(tofQAdirName);
119 TDirectoryFile * pidQAdir=(TDirectoryFile*)fin->Get(PIDqaListName);
121 Printf("ERROR: TOF QA directory not present in input file.\n");
124 TList * generalList=(TList*)tofQAdir->Get(genListName);
125 TList *timeZeroList=(TList*)tofQAdir->Get(t0ListName);
126 TList *pidList=(TList*)tofQAdir->Get(pidListName);
129 printf("WARNING: PIDqa histograms not available\n");
131 TList *pidListT0=(TList*)pidQAdir->Get(PIDqaListName);
132 TList *tofPidListT0=(TList*)pidListT0->FindObject("TOF");
134 TList *trdList=(TList*)tofQAdir->Get(trdListName);
135 TList *trgList=(TList*)tofQAdir->Get(trgListName);
137 if (!generalList) Printf("WARNING: general QA histograms absent or not accessible\n");
138 if (!timeZeroList) Printf("WARNING: timeZero QA histograms absent or not accessible\n");
139 if (!pidList) Printf("WARNING: PID QA histograms absent or not accessible\n");
140 if (!trdList) Printf("WARNING: QA histograms for TRD checks absent or not accessible\n");
141 if (!trgList) Printf("WARNING: QA histograms for trigger absent or not accessible\n");
143 if ( (!generalList) && (!timeZeroList) && (!pidList) ){
144 printf("ERROR: no QA available \n");
148 Printf(":::: Getting post-analysis info for run %i",runNumber);
149 TFile * trendFile = new TFile(treePostFileName.Data(),"recreate");
151 Double_t avTime=-9999., peakTime=-9999., spreadTime=-9999., peakTimeErr=-9999., spreadTimeErr=-9999., negTimeRatio=-9999.,
152 avRawTime=-9999., peakRawTime=-9999., spreadRawTime=-9999., peakRawTimeErr=-9999., spreadRawTimeErr=-9999., avTot=-9999., peakTot=-9999.,spreadTot=-9999., peakTotErr=-9999.,spreadTotErr=-9999.,
153 orphansRatio=-9999., avL=-9999., negLratio=-9999.,
154 effPt1=-9999., effPt2=-9999., matchEffLinFit1Gev=-9999.,matchEffLinFit1GevErr=-9999.;
156 Double_t avPiDiffTime=-9999.,peakPiDiffTime=-9999., spreadPiDiffTime=-9999.,peakPiDiffTimeErr=-9999., spreadPiDiffTimeErr=-9999.;
158 Double_t avT0A=-9999.,peakT0A=-9999., spreadT0A=-9999.,peakT0AErr=-9999., spreadT0AErr=-9999.;
159 Double_t avT0C=-9999.,peakT0C=-9999., spreadT0C=-9999.,peakT0CErr=-9999., spreadT0CErr=-9999.;
160 Double_t avT0AC=-9999.,peakT0AC=-9999., spreadT0AC=-9999.,peakT0ACErr=-9999., spreadT0ACErr=-9999.;
161 Double_t avT0res=-9999.,peakT0res=-9999., spreadT0res=-9999.,peakT0resErr=-9999., spreadT0resErr=-9999.;
162 Double_t avT0fillRes=-9999.;
165 Float_t fractionEventsWHits=-9999.;
166 /*number of good (HW ok && efficient && !noisy) TOF channels from OCDB*/
167 Double_t goodChannelRatio=0.0;
168 Double_t goodChannelRatioInAcc=0.0;
170 TTree * ttree=new TTree("trending","tree of trending variables");
171 ttree->Branch("run",&runNumber,"run/I");
172 ttree->Branch("avMulti",&avMulti,"avMulti/F");
173 ttree->Branch("fractionEventsWHits",&fractionEventsWHits,"fractionEventsWHits/F");
174 ttree->Branch("goodChannelsRatio",&goodChannelRatio,"goodChannelRatio/D");
175 ttree->Branch("goodChannelsRatioInAcc",&goodChannelRatioInAcc,"goodChannelRatioInAcc/D");
176 ttree->Branch("avTime",&avTime,"avTime/D"); //mean time
177 ttree->Branch("peakTime",&peakTime,"peakTime/D"); //main peak time after fit
178 ttree->Branch("spreadTime",&spreadTime,"spreadTime/D"); //spread of main peak of time after fit
179 ttree->Branch("peakTimeErr",&peakTimeErr,"peakTimeErr/D"); //main peak time after fit error
180 ttree->Branch("spreadTimeErr",&spreadTimeErr,"spreadTimeErr/D"); //spread of main peak of time after fit error
181 ttree->Branch("negTimeRatio",&negTimeRatio,"negTimeRatio/D"); //negative time ratio
183 ttree->Branch("avRawTime",&avRawTime,"avRawTime/D"); //mean raw time
184 ttree->Branch("peakRawTime",&peakRawTime,"peakRawTime/D"); //mean peak of RAW TIME after fit
185 ttree->Branch("spreadRawTime",&spreadRawTime,"spreadRawTime/D"); //spread of main peak of raw time after fit
186 ttree->Branch("peakRawTimeErr",&peakRawTimeErr,"peakRawTimeErr/D"); //main peak raw time after fit error
187 ttree->Branch("spreadRawTimeErr",&spreadRawTimeErr,"spreadRawTimeErr/D"); //spread of raw main peak of time after fit error
189 ttree->Branch("avTot",&avTot,"avTot/D"); //main peak tot
190 ttree->Branch("peakTot",&peakTot,"peakTot/D"); // main peak of tot after fit
191 ttree->Branch("spreadTot",&spreadTot,"spreadTot/D"); //spread of main peak of tot after fit
192 ttree->Branch("peakTotErr",&peakTotErr,"peakTotErr/D"); // main peak of tot after fit
193 ttree->Branch("spreadTotErr",&spreadTotErr,"spreadTotErr/D"); //spread of main peak of tot after fit
195 ttree->Branch("orphansRatio",&orphansRatio,"orphansRatio/D"); //orphans ratio
197 ttree->Branch("avL",&avL,"avL/D"); //mean track length
198 ttree->Branch("negLratio",&negLratio,"negLratio/D");//ratio of tracks with track length <350 cm
199 ttree->Branch("effPt1",&effPt1,"effPt1/D");//matching eff at 1 GeV/c
200 ttree->Branch("effPt2",&effPt2,"effPt2/D"); //matching eff at 2 GeV/c
201 ttree->Branch("matchEffLinFit1Gev",&matchEffLinFit1Gev,"matchEffLinFit1Gev/D");//matching eff fit param
202 ttree->Branch("matchEffLinFit1GevErr",&matchEffLinFit1GevErr,"matchEffLinFit1GevErr/D");////matching eff fit param error
204 ttree->Branch("avPiDiffTime",&avPiDiffTime,"avPiDiffTime/D"); //mean t-texp
205 ttree->Branch("peakPiDiffTime",&peakPiDiffTime,"peakPiDiffTime/D"); //main peak t-texp after fit
206 ttree->Branch("spreadPiDiffTime",&spreadPiDiffTime,"spreadPiDiffTime/D"); //spread of main peak t-texp after fit
207 ttree->Branch("peakPiDiffTimeErr",&peakPiDiffTimeErr,"peakPiDiffTimeErr/D"); //main peak t-texp after fit error
208 ttree->Branch("spreadPiDiffTimeErr",&spreadPiDiffTimeErr,"spreadPiDiffTimeErr/D"); //spread of main peak of t-texp after fit error
210 ttree->Branch("avT0A",&avT0A,"avT0A/D"); //main peak t0A
211 ttree->Branch("peakT0A",&peakT0A,"peakT0A/D"); // main peak of t0A after fit
212 ttree->Branch("spreadT0A",&spreadT0A,"spreadTot/D"); //spread of main peak of t0A after fit
213 ttree->Branch("peakT0AErr",&peakT0AErr,"peakT0AErr/D"); // main peak of t0A after fit
214 ttree->Branch("spreadT0AErr",&spreadT0AErr,"spreadT0AErr/D"); //spread of main peak of t0A after fit
216 ttree->Branch("avT0C",&avT0C,"avT0C/D"); //main peak t0C
217 ttree->Branch("peakT0C",&peakT0C,"peakT0C/D"); // main peak of t0C after fit
218 ttree->Branch("spreadT0C",&spreadT0C,"spreadT0C/D"); //spread of main peak of t0C after fit
219 ttree->Branch("peakT0CErr",&peakT0CErr,"peakT0CErr/D"); // main peak of t0C after fit
220 ttree->Branch("spreadT0CErr",&spreadT0CErr,"spreadT0CErr/D"); //spread of main peak of t0C after fit
222 ttree->Branch("avT0AC",&avT0AC,"avT0AC/D"); //main peak t0AC
223 ttree->Branch("peakT0AC",&peakT0AC,"peakT0AC/D"); // main peak of t0AC after fit
224 ttree->Branch("spreadT0AC",&spreadT0AC,"spreadT0AC/D"); //spread of main peak of t0AC after fit
225 ttree->Branch("peakT0ACErr",&peakT0ACErr,"peakT0ACErr/D"); // main peak of t0AC after fit
226 ttree->Branch("spreadT0ACErr",&spreadT0ACErr,"spreadT0ACErr/D"); //spread of main peak of t0AC after fit
228 ttree->Branch("avT0res",&avT0res,"avT0res/D"); //main peak t0AC
229 ttree->Branch("peakT0res",&peakT0res,"peakT0res/D"); // main peak of t0AC after fit
230 ttree->Branch("spreadT0res",&spreadT0res,"spreadT0res/D"); //spread of main peak of t0AC after fit
231 ttree->Branch("peakT0resErr",&peakT0resErr,"peakT0resErr/D"); // main peak of t0AC after fit
232 ttree->Branch("spreadT0resErr",&spreadT0resErr,"spreadT0resErr/D"); //spread of main peak of t0AC after fit
233 ttree->Branch("avT0fillRes",&avT0fillRes,"avT0fillRes/D"); //t0 fill res
235 //save quantities for trending
236 goodChannelRatio=(Double_t)GetGoodTOFChannelsRatio(runNumber, kFALSE, ocdbStorage, kFALSE);
237 goodChannelRatioInAcc=(Double_t)GetGoodTOFChannelsRatio(runNumber, kFALSE, ocdbStorage, kTRUE);
239 //--------------------------------- Multiplicity ----------------------------------//
241 TH1F * hMulti = (TH1F*) generalList->FindObject("hTOFmulti_all");
242 TH1F* hFractionEventsWhits = new TH1F("hFractionEventsWhits","hFractionEventsWhits;fraction of events with hits (%)",200,0.,100.);
243 Float_t fraction=0.0;
244 if (hMulti->GetEntries()>0.0) {
245 fraction = ((Float_t) hMulti->GetBinContent(1))/((Float_t) hMulti->GetEntries());
246 avMulti = hMulti->GetMean();
247 } else { fraction=0.0; }
248 hFractionEventsWhits->Fill(fraction*100.);
250 //--------------------------------- T0F signal ----------------------------------//
251 TH1F * hRawTime = (TH1F*)generalList->FindObject("hRawTime_all");
252 if ((hRawTime)&&(hRawTime->GetEntries()>0)){
253 avRawTime=hRawTime->GetMean();
255 hRawTime->Fit("landau","RQ0","",200.,250.);
256 if (hRawTime->GetFunction("landau")) {
257 peakRawTime=(hRawTime->GetFunction("landau"))->GetParameter(1);
258 spreadRawTime=(hRawTime->GetFunction("landau"))->GetParameter(2);
259 peakRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(1);
260 spreadRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(2);
263 printf("Reminder: Raw time not available in MC simulated data.");
266 MakeUpHisto(hRawTime, "matched tracks", 21, kGreen+2);
268 TH1F * hTime = (TH1F*)generalList->FindObject("hTime_all");
269 if ((hTime)&&(hTime->GetEntries()>0)) {
270 avTime=hTime->GetMean();
271 hTime->Fit("landau","RQ0","",0.,50.);
272 if (hTime->GetFunction("landau")) {
273 peakTime=(hTime->GetFunction("landau"))->GetParameter(1);
274 spreadTime=(hTime->GetFunction("landau"))->GetParameter(2);
275 peakTimeErr=(hTime->GetFunction("landau"))->GetParError(1);
276 spreadTimeErr=(hTime->GetFunction("landau"))->GetParError(2);
277 negTimeRatio=((Double_t)hTime->Integral(1,3)*100.)/((Double_t)hTime->Integral());
279 MakeUpHisto(hTime, "matched tracks", 20, kBlue+2);
281 TLegend *lTime = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
282 lTime->SetTextSize(0.04281433);
283 lTime->AddEntry(hRawTime, "raw","L");
284 lTime->AddEntry(hTime, "ESD","L");
285 lTime->SetFillColor(kWhite);
286 lTime->SetShadowColor(0);
289 TH1F * hTot = (TH1F*)generalList->FindObject("hTot_all");
290 if ((hTot)&&(hTot->GetEntries()>0)){
291 avTot=hTot->GetMean();
292 hTot->Fit("gaus","","",0.,50.);
293 if (hTot->GetFunction("gaus")) {
294 peakTot=(hTot->GetFunction("gaus"))->GetParameter(1);
295 spreadTot=(hTot->GetFunction("gaus"))->GetParameter(2);
296 peakTotErr=(hTot->GetFunction("gaus"))->GetParError(1);
297 spreadTotErr=(hTot->GetFunction("gaus"))->GetParError(2);
300 MakeUpHisto(hTot, "matched tracks", 8, kViolet-3);
302 char orphansTxt[200];
303 if (hTot->GetEntries()>1){
304 orphansRatio=((Float_t) hTot->GetBinContent(1))/((Float_t) hTot->GetEntries()) ;
306 sprintf(orphansTxt,"orphans/matched = %4.2f%%",orphansRatio*100.);
307 TPaveText *tOrphans = new TPaveText(0.38,0.63,0.88,0.7, "NDC");
308 tOrphans->SetBorderSize(0);
309 tOrphans->SetTextSize(0.045);
310 tOrphans->SetFillColor(0); //white background
311 tOrphans->SetTextAlign(12);
312 tOrphans->SetTextColor(kViolet-3);
313 tOrphans->AddText(orphansTxt);
315 TH1F * hL=(TH1F*)generalList->FindObject("hMatchedL_all");
316 char negLengthTxt[200];
317 if (hL->GetEntries()>0){
319 negLratio=(hL->Integral(1,750))/((Float_t) hL->GetEntries()) ;
321 MakeUpHisto(hL, "matched tracks", 1, kBlue+2);
322 sprintf(negLengthTxt,"trk with L<350cm /matched = %4.2f%%", negLratio*100.);
323 TPaveText *tLength = new TPaveText(0.15,0.83,0.65,0.87, "NDC");
324 tLength->SetBorderSize(0);
325 tLength->SetTextSize(0.04);
326 tLength->SetFillColor(0); //white background
327 tLength->SetTextAlign(11);
328 tLength->SetTextColor(kOrange-3);
329 tLength->AddText(negLengthTxt);
331 //--------------------------------- residuals -------------------------------------//
332 TH2F* hDxPos4profile = (TH2F*) generalList->FindObject("hMatchedDxVsPt_all");
333 TH2F* hTOFmatchedDzVsStrip = (TH2F*)generalList->FindObject("hMatchedDzVsStrip_all");
335 //--------------------------------- matching eff ----------------------------------//
336 //matching as function of pT
337 TH1F * hMatchingVsPt = new TH1F("hMatchingVsPt","Matching probability vs. Pt; Pt(GeV/c); matching probability", 50, 0., 5. );
338 TH1F * hDenom = (TH1F*)generalList->FindObject("hPrimaryPt_all");
341 hMatchingVsPt=(TH1F*) generalList->FindObject("hMatchedPt_all")->Clone();
342 hMatchingVsPt->Sumw2();
343 // hMatchingVsPt->Rebin(5);
345 hMatchingVsPt->Divide(hDenom);
346 hMatchingVsPt->GetYaxis()->SetTitle("matching efficiency");
347 hMatchingVsPt->SetTitle("TOF matching efficiency as function of transverse momentum");
348 hMatchingVsPt->GetYaxis()->SetRangeUser(0,1.2);
351 if (hMatchingVsPt->GetEntries()>0){
352 hMatchingVsPt->Fit("pol0","","",1.0,10.);
353 hMatchingVsPt->Draw();
354 if (hMatchingVsPt->GetFunction("pol0")){
355 matchEffLinFit1Gev=(hMatchingVsPt->GetFunction("pol0"))->GetParameter(0);
356 matchEffLinFit1GevErr=(hMatchingVsPt->GetFunction("pol0"))->GetParError(0);
357 //printf("Matching efficiency fit param is %f +- %f\n",matchEffLinFit1Gev,matchEffLinFit1GevErr );
360 printf("WARNING: matching efficiency plot has 0 entries. Skipped!\n");
362 MakeUpHisto(hMatchingVsPt, "efficiency", 1, kBlue+2);
364 //matching as function of eta
365 TH1F * hMatchingVsEta = new TH1F("hMatchingVsEta","Matching probability vs. #\Eta; #\Eta; matching probability", 20, -1., 1.);
367 hDenom=(TH1F*)generalList->FindObject("hPrimaryEta_all");
370 hMatchingVsEta=(TH1F*) generalList->FindObject("hMatchedEta_all")->Clone();
371 hMatchingVsEta->Sumw2();
372 // hMatchingVsEta->Rebin(5);
374 hMatchingVsEta->Divide(hDenom);
375 hMatchingVsEta->GetXaxis()->SetRangeUser(-1,1);
376 hMatchingVsEta->GetYaxis()->SetTitle("matching efficiency");
377 hMatchingVsEta->GetYaxis()->SetRangeUser(0,1.2);
378 hMatchingVsEta->SetTitle("TOF matching efficiency as function of pseudorapidity");
380 MakeUpHisto(hMatchingVsEta, "efficiency", 1, kBlue+2);
382 //matching as function of phi
383 TH1F * hMatchingVsPhi = new TH1F("hMatchingVsPhi","Matching probability vs. Phi; Phi(rad); matching probability", 628, 0., 6.28);
385 hDenom=(TH1F*)generalList->FindObject("hPrimaryPhi_all");
388 hMatchingVsPhi=(TH1F*) generalList->FindObject("hMatchedPhi_all")->Clone();
389 // hMatchingVsPhi->Rebin(2);
391 hMatchingVsPhi->Sumw2();
392 hMatchingVsPhi->Divide(hDenom);
393 hMatchingVsPhi->GetYaxis()->SetTitle("matching efficiency");
394 hMatchingVsPhi->SetTitle("TOF matching efficiency as function of phi");
395 hMatchingVsPhi->GetYaxis()->SetRangeUser(0,1.2);
397 MakeUpHisto(hMatchingVsPhi, "efficiency", 1, kBlue+2);
406 hDxPos4profile->Write();
407 hTOFmatchedDzVsStrip->Write();
408 hMatchingVsPt->Write();
409 hMatchingVsEta->Write();
410 hMatchingVsPhi->Write();
415 //--------------------------------- t-texp ----------------------------------//
416 TH2F * hBetaP=(TH2F*)pidList->FindObject("hMatchedBetaVsP_all");
417 if (hBetaP) hBetaP->GetYaxis()->SetRangeUser(0.,1.2);
419 TH1F * hMass=(TH1F*)pidList->FindObject("hMatchedMass_all");
420 MakeUpHisto(hMass, "tracks", 1, kBlue+2);
421 // hMass->SetFillColor(kAzure+10);
422 // hMass->SetFillStyle(1001);
426 TH1F * hPionDiff=(TH1F*)pidList->FindObject("hExpTimePi_all");
427 if ((hPionDiff)&&(hPionDiff->GetEntries()>0)) {
428 avPiDiffTime=hPionDiff->GetMean();
429 hPionDiff->Fit("gaus","","",-1000.,500.);
430 if (hPionDiff->GetFunction("gaus")){
431 peakPiDiffTime=(hPionDiff->GetFunction("gaus"))->GetParameter(1);
432 spreadPiDiffTime=(hPionDiff->GetFunction("gaus"))->GetParameter(2);
433 peakPiDiffTimeErr=(hPionDiff->GetFunction("gaus"))->GetParError(1);
434 spreadPiDiffTimeErr=(hPionDiff->GetFunction("gaus"))->GetParError(2);
435 // printf("Main peak t-t_exp (gaus): mean = %f +- %f\n",peakPiDiffTime,peakPiDiffTimeErr );
436 // printf("Main peak t-t_exp (gaus): spread = %f +- %f\n",spreadPiDiffTime,spreadPiDiffTimeErr );
440 TH1F * hDiffTimeT0fillPion=(TH1F*)pidList->FindObject("hExpTimePiFillSub_all");
441 TH1F * hDiffTimeT0TOFPion1GeV=(TH1F*)pidList->FindObject("hExpTimePiT0Sub1GeV_all");
442 TH2F * hDiffTimePi=(TH2F*)pidList->FindObject("hExpTimePiVsP_all");
443 hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
444 hDiffTimePi->GetYaxis()->SetRangeUser(-5000.,5000.);
447 TH2F * hDiffTimeKa=(TH2F*)pidList->FindObject("hExpTimeKaVsP_all");
448 hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
449 hDiffTimeKa->GetYaxis()->SetRangeUser(-5000.,5000.);
452 TH2F * hDiffTimePro=(TH2F*)pidList->FindObject("hExpTimeProVsP_all");
453 hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");
454 hDiffTimePro->GetYaxis()->SetRangeUser(-5000.,5000.);
461 hDiffTimeT0fillPion->Write();
462 hDiffTimeT0TOFPion1GeV->Write();
463 hDiffTimePi->Write();
464 hDiffTimeKa->Write();
465 hDiffTimePro->Write();
468 //--------------------------------- NSigma PID from TOF QA ----------------------------------//
469 TH2F * hSigmaPi=(TH2F*)pidList->FindObject("hTOFpidSigmaPi_all");
470 hSigmaPi->GetYaxis()->SetRangeUser(-5.,5.);
471 hSigmaPi->GetXaxis()->SetRangeUser(0.2,10.);
472 hSigmaPi->FitSlicesY();
473 TH1D * hSigmaPi_1 = (TH1D*)gDirectory->Get("hTOFpidSigmaPi_all_1");
474 TH1D * hSigmaPi_2 = (TH1D*)gDirectory->Get("hTOFpidSigmaPi_all_2");
475 //hSigmaPiT0->SetName("hSigmaPiT0");
476 hSigmaPi_1->SetLineColor(1);
477 hSigmaPi_1->SetLineWidth(2);
478 hSigmaPi_2->SetLineColor(2);
479 hSigmaPi_2->SetLineWidth(2);
481 TH2F * hSigmaKa=(TH2F*)pidList->FindObject("hTOFpidSigmaKa_all");
482 hSigmaKa->GetYaxis()->SetRangeUser(-5.,5.);
483 hSigmaKa->GetXaxis()->SetRangeUser(0.2,10.);
484 hSigmaKa->FitSlicesY();
485 TH1D * hSigmaKa_1 = (TH1D*)gDirectory->Get("hTOFpidSigmaKa_all_1");
486 TH1D * hSigmaKa_2 = (TH1D*)gDirectory->Get("hTOFpidSigmaKa_all_2");
487 //hSigmaKaT0->SetName("hSigmaKaT0");
488 hSigmaKa_1->SetLineColor(1);
489 hSigmaKa_1->SetLineWidth(2);
490 hSigmaKa_2->SetLineColor(2);
491 hSigmaKa_2->SetLineWidth(2);
493 TH2F * hSigmaPro=(TH2F*)pidList->FindObject("hTOFpidSigmaPro_all");
494 hSigmaPro->GetYaxis()->SetRangeUser(-5.,5.);
495 hSigmaPro->GetXaxis()->SetRangeUser(0.2,10.);
496 hSigmaPro->FitSlicesY();
497 TH1D * hSigmaPro_1 = (TH1D*)gDirectory->Get("hTOFpidSigmaPro_all_1");
498 TH1D * hSigmaPro_2 = (TH1D*)gDirectory->Get("hTOFpidSigmaPro_all_2");
499 //hSigmaProT0->SetName("hSigmaProT0");
500 hSigmaPro_1->SetLineColor(1);
501 hSigmaPro_1->SetLineWidth(2);
502 hSigmaPro_2->SetLineColor(2);
503 hSigmaPro_2->SetLineWidth(2);
505 TString plotDir(".");
507 TCanvas *cPidPerformance3= new TCanvas("cPidPerformance3","summary of pid performance - sigmas",1200,500);
508 cPidPerformance3->Divide(3,1);
509 cPidPerformance3->cd(1);
514 hSigmaPi->Draw("colz");
515 hSigmaPi_1->Draw("same");
516 hSigmaPi_2->Draw("same");
517 cPidPerformance3->cd(2);
520 hSigmaKa->Draw("colz");
521 hSigmaKa_1->Draw("same");
522 hSigmaKa_2->Draw("same");
523 cPidPerformance3->cd(3);
526 hSigmaPro->Draw("colz");
527 hSigmaPro_1->Draw("same");
528 hSigmaPro_2->Draw("same");
530 cPidPerformance3->Print(Form("%s/%i_PID_sigmas.png", plotDir.Data(), runNumber));
538 //--------------------------------- NSigma PID from PIDqa ----------------------------------//
539 TH2F * hSigmaPiT0 = 0x0;
540 TH2F * hSigmaKaT0 = 0x0;
541 TH2F * hSigmaProT0 = 0x0;
542 if(includeStartTime && pidQAdir){
544 hSigmaPiT0=(TH2F*)tofPidListT0->FindObject("hNsigmaP_TOF_pion");
545 hSigmaPiT0->GetYaxis()->SetRangeUser(-5.,5.);
546 hSigmaPiT0->GetXaxis()->SetRangeUser(0.2,10.);
547 hSigmaPiT0->FitSlicesY();
549 TH1D * hSigmaPiT0_1 = (TH1D*)gDirectory->Get("hNsigmaP_TOF_pion_1");
550 TH1D * hSigmaPiT0_2 = (TH1D*)gDirectory->Get("hNsigmaP_TOF_pion_2");
551 //hSigmaPiT0->SetName("hSigmaPiT0");
552 hSigmaPiT0_1->SetLineColor(1);
553 hSigmaPiT0_1->SetLineWidth(2);
554 hSigmaPiT0_2->SetLineColor(2);
555 hSigmaPiT0_2->SetLineWidth(2);
558 hSigmaKaT0=(TH2F*)tofPidListT0->FindObject("hNsigmaP_TOF_kaon");
559 hSigmaKaT0->GetYaxis()->SetRangeUser(-5.,5.);
560 hSigmaKaT0->GetXaxis()->SetRangeUser(0.2,10.);
561 hSigmaKaT0->FitSlicesY();
562 TH1D * hSigmaKaT0_1 = (TH1D*)gDirectory->Get("hNsigmaP_TOF_kaon_1");
563 TH1D * hSigmaKaT0_2 = (TH1D*)gDirectory->Get("hNsigmaP_TOF_kaon_2");
564 hSigmaKaT0_1->SetLineColor(1);
565 hSigmaKaT0_1->SetLineWidth(2);
566 hSigmaKaT0_2->SetLineColor(2);
567 hSigmaKaT0_2->SetLineWidth(2);
570 hSigmaProT0 = (TH2F*)tofPidListT0->FindObject("hNsigmaP_TOF_proton");
571 hSigmaProT0->GetYaxis()->SetRangeUser(-5.,5.);
572 hSigmaProT0->GetXaxis()->SetRangeUser(0.2,10.);
573 hSigmaProT0->FitSlicesY();
574 TH1D * hSigmaProT0_1 = (TH1D*)gDirectory->Get("hNsigmaP_TOF_proton_1");
575 TH1D * hSigmaProT0_2 = (TH1D*)gDirectory->Get("hNsigmaP_TOF_proton_2");
576 hSigmaProT0_1->SetLineColor(1);
577 hSigmaProT0_1->SetLineWidth(2);
578 hSigmaProT0_2->SetLineColor(2);
579 hSigmaProT0_2->SetLineWidth(2);
582 TLine *l1=new TLine(0.,0.,5.,0.);
583 TLine *l2=new TLine(0.,1.,5.,1.);
584 TCanvas *cPidPerformance3T0 = new TCanvas("cPidPerformance3T0","PID performance from PIDqa - sigmas - with StartTime",1200,500);
585 cPidPerformance3T0->Divide(3,1);
586 cPidPerformance3T0->cd(1);
591 hSigmaPiT0->Draw("colz");
592 hSigmaPiT0_1->Draw("same");
593 hSigmaPiT0_2->Draw("same");
596 cPidPerformance3T0->cd(2);
601 hSigmaKaT0->Draw("colz");
602 hSigmaKaT0_1->Draw("same");
603 hSigmaKaT0_2->Draw("same");
606 cPidPerformance3T0->cd(3);
611 hSigmaProT0->Draw("colz");
612 hSigmaProT0_1->Draw("same");
613 hSigmaProT0_2->Draw("same");
616 cPidPerformance3T0->Print(Form("%s/%i_PID_sigmasStartTime.png", plotDir.Data(), runNumber));
622 hSigmaProT0->Write();
623 hSigmaPiT0_1->Write();
624 hSigmaKaT0_1->Write();
625 hSigmaProT0_1->Write();
626 hSigmaPiT0_2->Write();
627 hSigmaKaT0_2->Write();
628 hSigmaProT0_2->Write();
632 //--------------------------------- T0 detector ----------------------------------//
634 TH1F*hT0A=(TH1F*)timeZeroList->FindObject("hT0A");
635 if ((hT0A)&&(hT0A->GetEntries()>0)) {
636 avT0A = hT0A->GetMean();
637 hT0A->Fit("gaus","RQ0", "", -1000., 1000.);
638 if (hT0A->GetFunction("gaus")) {
639 peakT0A=(hT0A->GetFunction("gaus"))->GetParameter(1);
640 spreadT0A=(hT0A->GetFunction("gaus"))->GetParameter(2);
641 peakT0AErr=(hT0A->GetFunction("gaus"))->GetParError(1);
642 spreadT0AErr=(hT0A->GetFunction("gaus"))->GetParError(2);
643 // printf("Main peak T0A(gaus): mean = %f +- %f\n",peakT0A,peakT0AErr );
644 // printf("Main peak T0A (gaus): spread = %f +- %f\n",spreadT0A,spreadT0AErr );
645 //add integral of main peak over total
648 MakeUpHisto(hT0A, "events", 8, kBlue);
651 TH1F*hT0C=(TH1F*)timeZeroList->FindObject("hT0C");
652 if ((hT0C)&&(hT0C->GetEntries()>0)) {
653 avT0C=hT0C->GetMean();
654 hT0C->Fit("gaus","RQ0","", -1000., 1000.);
655 if (hT0C->GetFunction("gaus")) {
656 peakT0C=(hT0C->GetFunction("gaus"))->GetParameter(1);
657 spreadT0C=(hT0C->GetFunction("gaus"))->GetParameter(2);
658 peakT0CErr=(hT0C->GetFunction("gaus"))->GetParError(1);
659 spreadT0CErr=(hT0C->GetFunction("gaus"))->GetParError(2);
660 // printf("Main peak T0C(gaus): mean = %f +- %f\n",peakT0C,peakT0CErr );
661 // printf("Main peak T0C (gaus): spread = %f +- %f\n",spreadT0C,spreadT0CErr );
662 //add integral of main peak over total
665 MakeUpHisto(hT0C, "events", 8, kGreen+1);
668 TH1F*hT0AC=(TH1F*)timeZeroList->FindObject("hT0AC");
669 if ((hT0AC)&&(hT0AC->GetEntries()>0)) {
670 avT0AC=hT0AC->GetMean();
671 hT0AC->Fit("gaus","RQ0", "",-1000., 1000.);
672 if (hT0AC->GetFunction("gaus")) {
673 peakT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(1);
674 spreadT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(2);
675 peakT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(1);
676 spreadT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(2);
677 // printf("Main peak T0AC(gaus): mean = %f +- %f\n",peakT0AC,peakT0ACErr );
678 // printf("Main peak T0AC (gaus): spread = %f +- %f\n",spreadT0AC,spreadT0ACErr );
681 MakeUpHisto(hT0AC, "events", 8, kRed+1);
684 TLegend *lT0 = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
685 lT0->SetTextSize(0.041);
686 lT0->AddEntry(hT0AC, "T0 A&C","L");
687 lT0->AddEntry(hT0A, "T0 A","L");
688 lT0->AddEntry(hT0C, "T0 C","L");
689 lT0->SetFillColor(kWhite);
690 lT0->SetShadowColor(0);
692 TH1F*hT0res=(TH1F*)timeZeroList->FindObject("hT0DetRes");
693 if ((hT0res)&&(hT0res->GetEntries()>0)) {
694 avT0res=hT0res->GetMean();
696 if (hT0res->GetFunction("gaus")) {
697 peakT0res=(hT0res->GetFunction("gaus"))->GetParameter(1);
698 spreadT0res=(hT0res->GetFunction("gaus"))->GetParameter(2);
699 peakT0resErr=(hT0res->GetFunction("gaus"))->GetParError(1);
700 spreadT0resErr=(hT0res->GetFunction("gaus"))->GetParError(2);
701 // printf("Main peak T0res(gaus): mean = %f +- %f\n",peakT0res,peakT0resErr );
702 // printf("Main peak T0res (gaus): spread = %f +- %f\n",spreadT0res,spreadT0resErr );
703 //add integral of main peak over total
706 TH1F*hT0fillRes=(TH1F*)timeZeroList->FindObject("hT0fillRes");
707 if ((hT0fillRes)&&(hT0fillRes->GetEntries()>0)) {
708 avT0fillRes=hT0fillRes->GetMean();
719 //Fill tree and save to file
721 printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
727 // TLegend * lSigmaPid=new TLegend(0.75,0.75,0.95,0.95,"#sigma_{PID}");
728 // lSigmaPid->AddEntry(profSigmaPi,"#pi^{#pm}","l");
729 // lSigmaPid->AddEntry(profSigmaKa,"K^{#pm}","l");
730 // lSigmaPid->AddEntry(profSigmaPro,"p^{#pm}","l");
732 // TString plotDir(Form("Plots_run%d",runNumber));
733 // gSystem->Exec(Form("mkdir %s",plotDir.Data()));
734 TCanvas *cTrackProperties= new TCanvas("cTrackProperties","summary of matched tracks properties", 1200, 500);
735 cTrackProperties->Divide(3,1);
736 cTrackProperties->cd(1);
739 hRawTime ->Draw("same");
741 cTrackProperties->cd(2);
745 cTrackProperties->cd(3);
750 // TCanvas *cResiduals= new TCanvas("residuals","residuals", 900,500);
751 // cResiduals->Divide(2,1);
752 // cResiduals->cd(1);
754 // hDxPos4profile->GetYaxis()->SetRangeUser(-5.,5.);
755 // hDxPos4profile->Draw("colz");
756 // // profDxPos->SetLineColor(kRed);
757 // // profDxPos->Draw("same");
758 // cResiduals->cd(2);
760 // hDxNeg4profile->GetYaxis()->SetRangeUser(-5.,5.);
761 // hDxNeg4profile->Draw("colz");
762 // // profDxNeg->SetLineColor(kBlue);
763 // // profDxNeg->Draw("same");
765 TCanvas* cProfile = new TCanvas("cProfile","cProfile",50,50, 750,550);
768 hTOFmatchedDzVsStrip->Draw("colz");
769 Int_t binmin = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(-3);
770 Int_t binmax = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(3);
771 TProfile* hDzProfile = (TProfile*)hTOFmatchedDzVsStrip->ProfileX("hDzProfile",binmin, binmax);
772 hDzProfile->SetLineWidth(3);
773 hDzProfile->Draw("same");
775 TCanvas *cMatchingPerformance= new TCanvas("cMatchingPerformance","summary of matching performance",1200,500);
776 cMatchingPerformance->Divide(3,1);
777 cMatchingPerformance->cd(1);
778 hMatchingVsPt->Draw();
779 cMatchingPerformance->cd(2);
780 hMatchingVsEta->Draw();
781 cMatchingPerformance->cd(3);
782 hMatchingVsPhi->Draw();
784 TCanvas *cPidPerformance= new TCanvas("cPidPerformance","summary of pid performance", 900,500);
785 cPidPerformance->Divide(2,1);
786 cPidPerformance->cd(1);
788 hBetaP->Draw("colz");
789 cPidPerformance->cd(2);
793 TCanvas *cPidPerformance2= new TCanvas("cPidPerformance2","summary of pid performance - expected times", 1200, 500);
794 cPidPerformance2->Divide(3,1);
795 cPidPerformance2->cd(1);
797 hDiffTimePi->Draw("colz");
798 cPidPerformance2->cd(2);
800 hDiffTimeKa->Draw("colz");
801 cPidPerformance2->cd(3);
803 hDiffTimePro->Draw("colz");
805 TCanvas *cT0detector= new TCanvas("cT0detector","T0 detector",800,600);
806 cT0detector->Divide(2,1);
810 hT0AC->SetTitle("timeZero measured by T0 detector");
817 cTrackProperties->Print(Form("%s/%i_TrackProperties.png",plotDir.Data(), runNumber));
818 cProfile->Print(Form("%s/%i_ProfileDZvsStripNumber.png",plotDir.Data(), runNumber));
819 cMatchingPerformance->Print(Form("%s/%i_Matching.png",plotDir.Data(), runNumber));
820 cPidPerformance->Print(Form("%s/%i_PID.png",plotDir.Data(), runNumber));
821 cPidPerformance2->Print(Form("%s/%i_PID_ExpTimes.png",plotDir.Data(), runNumber));
822 cT0detector->Print(Form("%s/%i_T0Detector.png",plotDir.Data(), runNumber));
823 //cPidPerformanceTh->Print(Form("%s/PID_theoreticalTimes.png",plotDir.Data()));
824 //cResiduals->Print(Form("%s/%i_Residuals.png",plotDir.Data(), runNumber));
831 //----------------------------------------------------------
832 Double_t GetGoodTOFChannelsRatio(Int_t run = -1, Bool_t saveMap = kFALSE, TString OCDBstorage = "raw://", Bool_t inEta08 = kFALSE)
835 It retrieves from OCDB the number of good (= efficient && not noisy && HW ok) TOF channels.
836 Optionally is saves the channel map
839 printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): invalid run number. Please set a run number.\n");
843 AliCDBManager *cdb = AliCDBManager::Instance();
844 cdb->SetDefaultStorage(OCDBstorage.Data());
847 AliCDBEntry *cdbe = cdb->Get("TOF/Calib/Status");
849 printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): OCDB entry not available. Please, try again.\n");
853 AliTOFChannelOnlineStatusArray *array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
854 TH2F *hOkMap = new TH2F("hOkMap", "Ok map (!noisy & !problematic & efficient);sector;strip", 72, 0., 18., 91, 0., 91.);
855 TH2F *hOkMapInAcceptance = new TH2F("hOkMapInAcceptance",Form( "Good channels in |#eta|<0.8 - run %i;sector;strip",run), 72, 0., 18., 91, 0., 91.);
856 AliTOFcalibHisto calibHisto;
857 calibHisto.LoadCalibHisto();
860 Int_t sector, sectorStrip, padx, fea;
861 Float_t hitmapx, hitmapy;
862 for (Int_t i = 0; i < array->GetSize(); i++) {
863 sector = calibHisto.GetCalibMap(AliTOFcalibHisto::kSector, i);
864 sectorStrip = calibHisto.GetCalibMap(AliTOFcalibHisto::kSectorStrip, i);
865 padx = calibHisto.GetCalibMap(AliTOFcalibHisto::kPadX, i);
867 hitmapx = sector + ((Double_t)(3 - fea) + 0.5) / 4.;
868 hitmapy = sectorStrip;
869 if ( !(array->GetNoiseStatus(i) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad) &&
870 (calib.IsChannelEnabled(i,kTRUE,kTRUE))) {
871 hOkMap->Fill(hitmapx,hitmapy);
872 /* 3 strips / side excluded from norm. factor to consider |eta|<0.8 */
873 if (sectorStrip>2 && sectorStrip<89) hOkMapInAcceptance->Fill(hitmapx,hitmapy);
876 Int_t nOk = (Int_t) hOkMap->GetEntries();
877 Int_t nOkInAcc = (Int_t) hOkMapInAcceptance->GetEntries();
878 Double_t ratioOk = nOk/152928.;
879 /* 96 channels * 6 strips * 18 modules excluded from norm. factor to consider |eta|<0.8 */
880 Double_t ratioOkInAcc = nOkInAcc/(152928.-6.*18.*96.);
882 hOkMap->SaveAs(Form("run%i_OKChannelsMap.root",run));
883 hOkMapInAcceptance->SaveAs(Form("run%i_OKChannelsInAccMap.root",run));
885 cout << "### Run " << run << ": TOF channels ok = " << nOk << "/ total 152928 channels = " << ratioOk*100. << "% of whole TOF" << endl;
886 cout << "### Run " << run << ": TOF channels in acc. ok = " << nOkInAcc << "/ total 142560 channels = " << ratioOkInAcc*100. << "% of whole TOF" << endl;
894 //----------------------------------------------------------
895 void MakeUpHisto(TH1* histo, TString titleY, Int_t marker=20, Color_t color=kBlue+2)
898 histo->SetMarkerStyle(marker);
899 histo->SetMarkerSize(0.7);
900 histo->SetMarkerColor(color);
901 histo->SetLineColor(color);
902 histo->SetFillColor(kWhite);
903 histo->SetFillStyle(0);
904 histo->GetYaxis()->SetTitle(titleY.Data());
905 histo->GetYaxis()->SetTitleOffset(1.35);
906 histo->GetXaxis()->SetLabelSize(0.03);