2 fbellini@cern.ch - last update on 21/02/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.
11 Int_t MakeTrendingTOFQA(TString qafilename, //full path of the QA output; set IsOnGrid to prepend "alien://"
12 Int_t runNumber, // run number
13 Bool_t isMC=kFALSE, //MC flag, to disable meaningless checks
14 Bool_t canvasE = kFALSE, //enable display plots on canvas and save png
15 Bool_t IsOnGrid = kFALSE) //set to kTRUE to access files on the grid
17 // macro to generate tree with TOF QA trending variables
18 // access qa PWGPP output files
20 Printf("Error - Invalid input file");
25 gStyle->SetCanvasColor(kWhite);
26 gStyle->SetFrameFillColor(kWhite);
27 gStyle->SetFrameBorderMode(0);
28 gStyle->SetCanvasBorderMode(0);
29 gStyle->SetTitleFillColor(kWhite);
30 gStyle->SetTitleBorderSize(0) ;
31 gStyle->SetTitleFont(42);
32 gStyle->SetTextFont(42);
33 gStyle->SetStatColor(kWhite);
34 gStyle->SetStatBorderSize(1);
35 TGaxis::SetMaxDigits(3);
36 gStyle->SetOptStat(10);
38 char defaultQAoutput[30]="QAresults.root";
39 char * treePostFileName="trending.root";
41 if (IsOnGrid) TGrid::Connect("alien://");
42 TFile * fin = TFile::Open(qafilename,"r");
44 Printf("ERROR: QA output not found. Exiting...\n");
47 Printf("INFO: QA output file %s open. \n",fin->GetName());
50 //access histograms lists
51 char tofQAdirName[15]="TOF_Performance";
52 char genListName[15]="cGeneralTOFqa";
53 char t0ListName[15]="cTimeZeroTOFqa";
54 char pidListName[15]="cPIDTOFqa";
55 char posListName[15]="cPositiveTOFqa";
56 char negListName[15]="cNegativeTOFqa";
58 TDirectoryFile * tofQAdir=(TDirectoryFile*)fin->Get(tofQAdirName);
60 Printf("ERROR: TOF QA directory not present in input file.\n");
63 TList * generalList=(TList*)tofQAdir->Get(genListName);
64 TList *timeZeroList=(TList*)tofQAdir->Get(t0ListName);
65 TList *pidList=(TList*)tofQAdir->Get(pidListName);
66 TList *posList=(TList*)tofQAdir->Get(posListName);
67 TList *negList=(TList*)tofQAdir->Get(negListName);
69 if (!generalList) Printf("WARNING: general QA histograms absent or not accessible\n");
70 if (!timeZeroList) Printf("WARNING: timeZero QA histograms absent or not accessible\n");
71 if (!pidList) Printf("WARNING: PID QA histograms absent or not accessible\n");
72 if (!posList) Printf("WARNING: general QA histograms for positive tracks absent or not accessible\n");
73 if (!negList) Printf("WARNING: general QA histograms for negative tracks absent or not accessible\n");
75 if ( (!generalList) && (!timeZeroList) && (!pidList) ){
76 printf("ERROR: no QA available \n");
80 Printf(":::: Getting post-analysis info for run %i",runNumber);
81 TFile * trendFile = new TFile(treePostFileName,"recreate");
83 Double_t avTime=-9999., peakTime=-9999., spreadTime=-9999., peakTimeErr=-9999., spreadTimeErr=-9999., negTimeRatio=-9999.,
84 avRawTime=-9999., peakRawTime=-9999., spreadRawTime=-9999., peakRawTimeErr=-9999., spreadRawTimeErr=-9999., avTot=-9999., peakTot=-9999.,spreadTot=-9999., peakTotErr=-9999.,spreadTotErr=-9999.,
85 orphansRatio=-9999., avL=-9999., negLratio=-9999.,
86 effPt1=-9999., effPt2=-9999., matchEffLinFit1Gev=-9999.,matchEffLinFit1GevErr=-9999.;
88 Double_t avPiDiffTime=-9999.,peakPiDiffTime=-9999., spreadPiDiffTime=-9999.,peakPiDiffTimeErr=-9999., spreadPiDiffTimeErr=-9999.;
90 Double_t avT0A=-9999.,peakT0A=-9999., spreadT0A=-9999.,peakT0AErr=-9999., spreadT0AErr=-9999.;
91 Double_t avT0C=-9999.,peakT0C=-9999., spreadT0C=-9999.,peakT0CErr=-9999., spreadT0CErr=-9999.;
92 Double_t avT0AC=-9999.,peakT0AC=-9999., spreadT0AC=-9999.,peakT0ACErr=-9999., spreadT0ACErr=-9999.;
93 Double_t avT0res=-9999.,peakT0res=-9999., spreadT0res=-9999.,peakT0resErr=-9999., spreadT0resErr=-9999.;
94 Double_t avT0fillRes=-9999.;
97 Float_t fractionEventsWHits=-9999.;
98 /*number of good (HW ok && efficient && !noisy) TOF channels from OCDB*/
99 Double_t goodChannelRatio=0.0;
101 TTree * ttree=new TTree("trending","tree of trending variables");
102 ttree->Branch("run",&runNumber,"run/I");
103 ttree->Branch("avMulti",&avMulti,"avMulti/F");
104 ttree->Branch("fractionEventsWHits",&fractionEventsWHits,"fractionEventsWHits/F");
105 ttree->Branch("goodChannelsRatio",&goodChannelRatio,"goodChannelRatio/D");
106 ttree->Branch("avTime",&avTime,"avTime/D"); //mean time
107 ttree->Branch("peakTime",&peakTime,"peakTime/D"); //main peak time after fit
108 ttree->Branch("spreadTime",&spreadTime,"spreadTime/D"); //spread of main peak of time after fit
109 ttree->Branch("peakTimeErr",&peakTimeErr,"peakTimeErr/D"); //main peak time after fit error
110 ttree->Branch("spreadTimeErr",&spreadTimeErr,"spreadTimeErr/D"); //spread of main peak of time after fit error
111 ttree->Branch("negTimeRatio",&negTimeRatio,"negTimeRatio/D"); //negative time ratio
113 ttree->Branch("avRawTime",&avRawTime,"avRawTime/D"); //mean raw time
114 ttree->Branch("peakRawTime",&peakRawTime,"peakRawTime/D"); //mean peak of RAW TIME after fit
115 ttree->Branch("spreadRawTime",&spreadRawTime,"spreadRawTime/D"); //spread of main peak of raw time after fit
116 ttree->Branch("peakRawTimeErr",&peakRawTimeErr,"peakRawTimeErr/D"); //main peak raw time after fit error
117 ttree->Branch("spreadRawTimeErr",&spreadRawTimeErr,"spreadRawTimeErr/D"); //spread of raw main peak of time after fit error
119 ttree->Branch("avTot",&avTot,"avTot/D"); //main peak tot
120 ttree->Branch("peakTot",&peakTot,"peakTot/D"); // main peak of tot after fit
121 ttree->Branch("spreadTot",&spreadTot,"spreadTot/D"); //spread of main peak of tot after fit
122 ttree->Branch("peakTotErr",&peakTotErr,"peakTotErr/D"); // main peak of tot after fit
123 ttree->Branch("spreadTotErr",&spreadTotErr,"spreadTotErr/D"); //spread of main peak of tot after fit
125 ttree->Branch("orphansRatio",&orphansRatio,"orphansRatio/D"); //orphans ratio
127 ttree->Branch("avL",&avL,"avL/D"); //mean track length
128 ttree->Branch("negLratio",&negLratio,"negLratio/D");//ratio of tracks with track length <350 cm
129 ttree->Branch("effPt1",&effPt1,"effPt1/D");//matching eff at 1 GeV/c
130 ttree->Branch("effPt2",&effPt2,"effPt2/D"); //matching eff at 2 GeV/c
131 ttree->Branch("matchEffLinFit1Gev",&matchEffLinFit1Gev,"matchEffLinFit1Gev/D");//matching eff fit param
132 ttree->Branch("matchEffLinFit1GevErr",&matchEffLinFit1GevErr,"matchEffLinFit1GevErr/D");////matching eff fit param error
134 ttree->Branch("avPiDiffTime",&avPiDiffTime,"avPiDiffTime/D"); //mean t-texp
135 ttree->Branch("peakPiDiffTime",&peakPiDiffTime,"peakPiDiffTime/D"); //main peak t-texp after fit
136 ttree->Branch("spreadPiDiffTime",&spreadPiDiffTime,"spreadPiDiffTime/D"); //spread of main peak t-texp after fit
137 ttree->Branch("peakPiDiffTimeErr",&peakPiDiffTimeErr,"peakPiDiffTimeErr/D"); //main peak t-texp after fit error
138 ttree->Branch("spreadPiDiffTimeErr",&spreadPiDiffTimeErr,"spreadPiDiffTimeErr/D"); //spread of main peak of t-texp after fit error
140 ttree->Branch("avT0A",&avT0A,"avT0A/D"); //main peak t0A
141 ttree->Branch("peakT0A",&peakT0A,"peakT0A/D"); // main peak of t0A after fit
142 ttree->Branch("spreadT0A",&spreadT0A,"spreadTot/D"); //spread of main peak of t0A after fit
143 ttree->Branch("peakT0AErr",&peakT0AErr,"peakT0AErr/D"); // main peak of t0A after fit
144 ttree->Branch("spreadT0AErr",&spreadT0AErr,"spreadT0AErr/D"); //spread of main peak of t0A after fit
146 ttree->Branch("avT0C",&avT0C,"avT0C/D"); //main peak t0C
147 ttree->Branch("peakT0C",&peakT0C,"peakT0C/D"); // main peak of t0C after fit
148 ttree->Branch("spreadT0C",&spreadT0C,"spreadT0C/D"); //spread of main peak of t0C after fit
149 ttree->Branch("peakT0CErr",&peakT0CErr,"peakT0CErr/D"); // main peak of t0C after fit
150 ttree->Branch("spreadT0CErr",&spreadT0CErr,"spreadT0CErr/D"); //spread of main peak of t0C after fit
152 ttree->Branch("avT0AC",&avT0AC,"avT0AC/D"); //main peak t0AC
153 ttree->Branch("peakT0AC",&peakT0AC,"peakT0AC/D"); // main peak of t0AC after fit
154 ttree->Branch("spreadT0AC",&spreadT0AC,"spreadT0AC/D"); //spread of main peak of t0AC after fit
155 ttree->Branch("peakT0ACErr",&peakT0ACErr,"peakT0ACErr/D"); // main peak of t0AC after fit
156 ttree->Branch("spreadT0ACErr",&spreadT0ACErr,"spreadT0ACErr/D"); //spread of main peak of t0AC after fit
158 ttree->Branch("avT0res",&avT0res,"avT0res/D"); //main peak t0AC
159 ttree->Branch("peakT0res",&peakT0res,"peakT0res/D"); // main peak of t0AC after fit
160 ttree->Branch("spreadT0res",&spreadT0res,"spreadT0res/D"); //spread of main peak of t0AC after fit
161 ttree->Branch("peakT0resErr",&peakT0resErr,"peakT0resErr/D"); // main peak of t0AC after fit
162 ttree->Branch("spreadT0resErr",&spreadT0resErr,"spreadT0resErr/D"); //spread of main peak of t0AC after fit
163 ttree->Branch("avT0fillRes",&avT0fillRes,"avT0fillRes/D"); //t0 fill res
165 //save quantities for trending
166 goodChannelRatio=(Double_t)GetGoodTOFChannelsRatio(runNumber);
168 //--------------------------------- Multiplicity ----------------------------------//
170 TH1F * hMulti = (TH1F*) generalList->FindObject("hTOFmatchedPerEvt");
171 TH1F* hFractionEventsWhits = new TH1F("hFractionEventsWhits","hFractionEventsWhits;fraction of events with hits (%)",200,0.,100.);
172 Float_t fraction=0.0;
173 if (hMulti->GetEntries()>0.0) {
174 fraction = ((Float_t) hMulti->GetBinContent(1))/((Float_t) hMulti->GetEntries());
175 avMulti = hMulti->GetMean();
177 hFractionEventsWhits->Fill(fraction*100.);
179 //--------------------------------- T0F signal ----------------------------------//
180 TH1F * hRawTime = (TH1F*)generalList->FindObject("hTOFmatchedESDrawTime");
181 if ((hRawTime)&&(hRawTime->GetEntries()>0)){
182 avRawTime=hRawTime->GetMean();
184 hRawTime->Fit("landau","RQ0","",200.,250.);
185 peakRawTime=(hRawTime->GetFunction("landau"))->GetParameter(1);
186 spreadRawTime=(hRawTime->GetFunction("landau"))->GetParameter(2);
187 peakRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(1);
188 spreadRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(2);
189 printf("Main peak raw time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
190 printf("Main peak raw time (landau): spread = %f +- %f\n",spreadRawTime,spreadRawTimeErr );
192 printf("Reminder: Raw time not available in MC simulated data.");
195 MakeUpHisto(hRawTime, "matched tracks", 21, kGreen+2);
198 TH1F * hTime = (TH1F*)generalList->FindObject("hTOFmatchedESDtime");
199 if ((hTime)&&(hTime->GetEntries()>0)) {
200 avTime=hTime->GetMean();
201 hTime->Fit("landau","RQ0","",0.,50.);
202 peakTime=(hTime->GetFunction("landau"))->GetParameter(1);
203 spreadTime=(hTime->GetFunction("landau"))->GetParameter(2);
204 peakTimeErr=(hTime->GetFunction("landau"))->GetParError(1);
205 spreadTimeErr=(hTime->GetFunction("landau"))->GetParError(2);
206 negTimeRatio=((Double_t)hTime->Integral(1,3)*100.)/((Double_t)hTime->Integral());
207 printf("Main peak time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
208 printf("Main peak time (landau): spread = %f +- %f\n",spreadTime,spreadTimeErr );
209 printf("Ratio of tracks with time<12.5 ns / total = %f\n",negTimeRatio );
210 MakeUpHisto(hTime, "matched tracks", 20, kBlue+2);
213 TLegend *lTime = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
214 lTime->SetTextSize(0.04281433);
215 lTime->AddEntry(hRawTime, "raw","L");
216 lTime->AddEntry(hTime, "ESD","L");
217 lTime->SetFillColor(kWhite);
218 lTime->SetShadowColor(0);
221 TH1F * hTot = (TH1F*)generalList->FindObject("hTOFmatchedESDToT");
222 if ((hTot)&&(hTot->GetEntries()>0)){
223 avTot=hTot->GetMean();
224 hTot->Fit("gaus","","",0.,50.);
225 peakTot=(hTot->GetFunction("gaus"))->GetParameter(1);
226 spreadTot=(hTot->GetFunction("gaus"))->GetParameter(2);
227 peakTotErr=(hTot->GetFunction("gaus"))->GetParError(1);
228 spreadTotErr=(hTot->GetFunction("gaus"))->GetParError(2);
229 printf("Main peak ToT (gaus): mean = %f +- %f\n",peakTot,peakTotErr );
230 printf("Main peak ToT (gaus): spread = %f +- %f\n",spreadTot,spreadTotErr );
232 MakeUpHisto(hTot, "matched tracks", 8, kViolet-3);
234 char orphansTxt[200];
235 if (hTot->GetEntries()>1){
236 orphansRatio=((Float_t) hTot->GetBinContent(1))/((Float_t) hTot->GetEntries()) ;
238 sprintf(orphansTxt,"orphans/matched = %4.2f%%",orphansRatio*100.);
239 TPaveText *tOrphans = new TPaveText(0.38,0.63,0.88,0.7, "NDC");
240 tOrphans->SetBorderSize(0);
241 tOrphans->SetTextSize(0.045);
242 tOrphans->SetFillColor(0); //white background
243 tOrphans->SetTextAlign(12);
244 tOrphans->SetTextColor(kViolet-3);
245 tOrphans->AddText(orphansTxt);
247 TH1F * hL=(TH1F*)generalList->FindObject("hTOFmatchedESDtrkLength");
248 char negLengthTxt[200];
249 if (hL->GetEntries()>0){
251 negLratio=(hL->Integral(1,750))/((Float_t) hL->GetEntries()) ;
253 MakeUpHisto(hL, "matched tracks", 1, kBlue+2);
254 sprintf(negLengthTxt,"trk with L<350cm /matched = %4.2f%%", negLratio*100.);
255 TPaveText *tLength = new TPaveText(0.15,0.83,0.65,0.87, "NDC");
256 tLength->SetBorderSize(0);
257 tLength->SetTextSize(0.04);
258 tLength->SetFillColor(0); //white background
259 tLength->SetTextAlign(11);
260 tLength->SetTextColor(kOrange-3);
261 tLength->AddText(negLengthTxt);
263 //--------------------------------- residuals -------------------------------------//
264 TH2F* hDxPos4profile = (TH2F*) generalList->FindObject("hTOFmatchedDxVsPtPos");
265 TH2F* hDxNeg4profile = (TH2F*) generalList->FindObject("hTOFmatchedDxVsPtNeg");
266 const Int_t ybinMin = 0;
267 const Int_t ybinMax = hDxPos4profile->GetYaxis()->GetNbins() ;
268 TProfile * profDxPos = (TProfile*)hDxPos4profile->ProfileX("profDxPos", ybinMin,ybinMax);
269 profDxPos->SetLineWidth(2);
270 TProfile * profDxNeg = (TProfile*)hDxNeg4profile->ProfileX("profDxNeg", ybinMin, ybinMax);
271 profDxNeg->SetLineWidth(2);
273 TH1 *profRatioPosOverNegDx = (TH1*) profDxPos->Clone();
274 profRatioPosOverNegDx->SetName("profRatioPosOverNegDx");
275 profRatioPosOverNegDx->Divide((TH1*) profDxNeg);
276 profRatioPosOverNegDx->GetYaxis()->SetRangeUser(-5.,5.);
277 profRatioPosOverNegDx->GetXaxis()->SetRangeUser(0.,2.);
279 TH2F* hTOFmatchedDzVsStrip = (TH2F*)generalList->FindObject("hTOFmatchedDzVsStrip");
282 // hTOFmatchedDzVsStrip->Write();
283 // hDxPos4profile->Write();
284 // hDxNeg4profile->Write();
285 // profDxPos->Write();
286 // profDxNeg->Write();
287 // profRatioPosOverNegDx->Write();
289 //--------------------------------- matching eff ----------------------------------//
290 //matching as function of pT
291 TH1F * hMatchingVsPt = new TH1F("hMatchingVsPt","Matching probability vs. Pt; Pt(GeV/c); matching probability", 50, 0., 5. );
292 TH1F * hDenom = (TH1F*)generalList->FindObject("hESDprimaryTrackPt");
294 hMatchingVsPt=(TH1F*) generalList->FindObject("hTOFmatchedESDPt")->Clone();
295 hMatchingVsPt->Rebin(5);
297 hMatchingVsPt->Divide(hDenom);
298 hMatchingVsPt->GetYaxis()->SetTitle("matching efficiency");
299 hMatchingVsPt->SetTitle("TOF matching efficiency as function of transverse momentum");
300 hMatchingVsPt->GetYaxis()->SetRangeUser(0,1.2);
303 if (hMatchingVsPt->GetEntries()>0){
304 hMatchingVsPt->Fit("pol0","","",1.0,10.);
305 hMatchingVsPt->Draw();
306 if (hMatchingVsPt->GetFunction("pol0")){
307 matchEffLinFit1Gev=(hMatchingVsPt->GetFunction("pol0"))->GetParameter(0);
308 matchEffLinFit1GevErr=(hMatchingVsPt->GetFunction("pol0"))->GetParError(0);
309 printf("Matching efficiency fit param is %f +- %f\n",matchEffLinFit1Gev,matchEffLinFit1GevErr );
312 printf("WARNING: matching efficiency plot has 0 entries. Skipped!\n");
314 MakeUpHisto(hMatchingVsPt, "efficiency", 1, kBlue+2);
316 //matching as function of eta
317 TH1F * hMatchingVsEta =new TH1F("hMatchingVsEta","Matching probability vs. #\Eta; #\Eta; matching probability", 20, -1., 1.);
319 hDenom=(TH1F*)generalList->FindObject("hTOFprimaryESDeta");
321 hMatchingVsEta=(TH1F*) generalList->FindObject("hTOFmatchedESDeta")->Clone();
322 hMatchingVsEta->Rebin(5);
324 hMatchingVsEta->Divide(hDenom);
325 hMatchingVsEta->GetXaxis()->SetRangeUser(-1,1);
326 hMatchingVsEta->GetYaxis()->SetTitle("matching efficiency");
327 hMatchingVsEta->GetYaxis()->SetRangeUser(0,1.2);
328 hMatchingVsEta->SetTitle("TOF matching efficiency as function of pseudorapidity");
330 MakeUpHisto(hMatchingVsEta, "efficiency", 1, kBlue+2);
333 //matching as function of phi
334 TH1F * hMatchingVsPhi = new TH1F("hMatchingVsPhi","Matching probability vs. Phi; Phi(rad); matching probability", 628, 0., 6.28);
336 hDenom=(TH1F*)generalList->FindObject("hTOFprimaryESDphi");
338 hMatchingVsPhi=(TH1F*) generalList->FindObject("hTOFmatchedESDphi")->Clone();
339 hMatchingVsPhi->Rebin(2);
341 hMatchingVsPhi->Divide(hDenom);
342 hMatchingVsPhi->GetYaxis()->SetTitle("matching efficiency");
343 hMatchingVsPhi->SetTitle("TOF matching efficiency as function of phi");
344 hMatchingVsPhi->GetYaxis()->SetRangeUser(0,1.2);
346 MakeUpHisto(hMatchingVsPhi, "efficiency", 1, kBlue+2);
349 // hMatchingVsPt->Write();
350 // hMatchingVsEta->Write();
351 // hMatchingVsPhi->Write();
354 //--------------------------------- t-texp ----------------------------------//
355 TH2F * hBetaP=(TH2F*)pidList->FindObject("hTOFmatchedESDpVsBeta");
356 if (hBetaP) hBetaP->GetYaxis()->SetRangeUser(0.,1.2);
358 TH1F * hMass=(TH1F*)pidList->FindObject("hTOFmatchedMass");
359 MakeUpHisto(hMass, "tracks", 1, kBlue+2);
360 // hMass->SetFillColor(kAzure+10);
361 // hMass->SetFillStyle(1001);
365 TH2F * hDiffTimeT0TOFPion1GeV=(TH2F*)pidList->FindObject("hTOFmatchedTimePion1GeV");
366 TH1F * hPionDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePi");
367 TH1F * hKaonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimeKa");
368 TH1F * hProtonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePro");
369 if ((hPionDiff)&&(hPionDiff->GetEntries()>0)) {
370 avPiDiffTime=hPionDiff->GetMean();
371 hPionDiff->Fit("gaus","","",-1000.,500.);
372 if (hPionDiff->GetFunction("gaus")){
373 peakPiDiffTime=(hPionDiff->GetFunction("gaus"))->GetParameter(1);
374 spreadPiDiffTime=(hPionDiff->GetFunction("gaus"))->GetParameter(2);
375 peakPiDiffTimeErr=(hPionDiff->GetFunction("gaus"))->GetParError(1);
376 spreadPiDiffTimeErr=(hPionDiff->GetFunction("gaus"))->GetParError(2);
377 printf("Main peak t-t_exp (gaus): mean = %f +- %f\n",peakPiDiffTime,peakPiDiffTimeErr );
378 printf("Main peak t-t_exp (gaus): spread = %f +- %f\n",spreadPiDiffTime,spreadPiDiffTimeErr );
382 TH2F * hDiffTimePi=(TH2F*)pidList->FindObject("hTOFmatchedExpTimePiVsP");
383 hDiffTimePi->GetYaxis()->SetRangeUser(-5000.,5000.);
384 hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
386 // TProfile * profDiffTimePi = (TProfile*)hDiffTimePi->ProfileX("profDiffTimePi", 490, 510);
387 // if (profDiffTimePi){
388 // profDiffTimePi->SetLineWidth(2);
389 // profDiffTimePi->SetLineColor(kRed+2);
393 TH2F * hDiffTimeKa=(TH2F*)pidList->FindObject("hTOFmatchedExpTimeKaVsP");
394 hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
395 hDiffTimeKa->GetYaxis()->SetRangeUser(-5000.,5000.);
397 // TProfile * profDiffTimeKa = (TProfile*)hDiffTimeKa->ProfileX("profDiffTimeKa", 490, 510);
398 // if (profDiffTimeKa) {
399 // profDiffTimeKa->SetLineWidth(2);
400 // profDiffTimeKa->SetLineColor(kBlue);
404 TH2F * hDiffTimePro=(TH2F*)pidList->FindObject("hTOFmatchedExpTimeProVsP");
405 hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");
406 hDiffTimePro->GetYaxis()->SetRangeUser(-5000.,5000.);
408 // TProfile * profDiffTimePro = (TProfile*)hDiffTimePro->ProfileX("profDiffTimePro", 490, 510);
409 // if (profDiffTimePro) {
410 // profDiffTimePro->SetLineWidth(2);
411 // profDiffTimePro->SetLineColor(kGreen+2);
415 TH2F * hDiffTimePiTh=(TH2F*)pidList->FindObject("hTOFtheoreticalExpTimePiVsP");
416 hDiffTimePiTh->GetYaxis()->SetRangeUser(-2000.,2000.);
418 TProfile * profDiffTimePiTh = (TProfile*)hDiffTimePiTh->ProfileX("profDiffTimePiTh", 490, 510);
419 if (profDiffTimePiTh) {
420 profDiffTimePiTh->SetLineWidth(2);
421 profDiffTimePiTh->SetLineColor(kRed+2);
424 TH2F * hDiffTimeKaTh=(TH2F*)pidList->FindObject("hTOFtheoreticalExpTimeKaVsP");
425 hDiffTimeKaTh->GetYaxis()->SetRangeUser(-2000.,2000.);
427 TProfile * profDiffTimeKaTh = (TProfile*)hDiffTimeKaTh->ProfileX("profDiffTimeKaTh", 490, 510);
428 if (profDiffTimeKaTh) {
429 profDiffTimeKaTh->SetLineWidth(2);
430 profDiffTimeKaTh->SetLineColor(kBlue);
433 TH2F * hDiffTimeProTh=(TH2F*)pidList->FindObject("hTOFtheoreticalExpTimePro");
434 hDiffTimeProTh->GetYaxis()->SetRangeUser(-2000.,2000.);
436 TProfile * profDiffTimeProTh = (TProfile*)hDiffTimeProTh->ProfileX("profDiffTimeProTh", 490, 510);
437 if (profDiffTimeProTh) {
438 profDiffTimeProTh->SetLineWidth(2);
439 profDiffTimeProTh->SetLineColor(kGreen+2);
441 TLegend * lPid=new TLegend(0.75,0.75,0.95,0.95,"PID");
442 lPid->AddEntry(profDiffTimePi,"#pi^{#pm}","l");
443 lPid->AddEntry(profDiffTimeKa,"K^{#pm}","l");
444 lPid->AddEntry(profDiffTimePro,"p^{#pm}","l");
447 TCanvas *cPidPerformanceTh= new TCanvas("cPidPerformanceTh","summary of pid performance - theoretical times",700,700);
448 cPidPerformanceTh->Divide(2,2);
449 cPidPerformanceTh->cd(1);
453 hDiffTimePiTh->Draw("colz");
454 profDiffTimePiTh->Draw("same");
455 cPidPerformanceTh->cd(2);
459 hDiffTimeKaTh->Draw("colz");
460 profDiffTimeKaTh->Draw("same");
461 cPidPerformanceTh->cd(3);
465 hDiffTimeProTh->Draw("colz");
466 profDiffTimeProTh->Draw("same");
471 hProtonDiff->Write();
474 hDiffTimeT0TOFPion1GeV->Write();
475 hDiffTimePi->Write();
476 profDiffTimePi->Write();
477 hDiffTimeKa->Write();
478 profDiffTimeKa->Write();
479 hDiffTimePro->Write();
480 profDiffTimePro->Write();
482 hDiffTimePiTh->Write();
483 profDiffTimePiTh->Write();
484 hDiffTimeKaTh->Write();
485 profDiffTimeKaTh->Write();
486 hDiffTimeProTh->Write();
487 profDiffTimeProTh->Write();
490 TH2F * hSigmaPi=(TH2F*)pidList->FindObject("hTOFExpSigmaPi");
491 hSigmaPi->GetYaxis()->SetRangeUser(-5.,5.);
492 TProfile * profSigmaPi = (TProfile*)hSigmaPi->ProfileX("profSigmaPi");
493 profSigmaPi->SetLineWidth(2);
494 profSigmaPi->SetLineColor(kRed+2);
496 TH2F * hSigmaKa=(TH2F*)pidList->FindObject("hTOFExpSigmaKa");
497 hSigmaKa->GetYaxis()->SetRangeUser(-5.,5.);
498 TProfile * profSigmaKa = (TProfile*)hSigmaKa->ProfileX("profSigmaKa");
499 profSigmaKa->SetLineWidth(2);
500 profSigmaKa->SetLineColor(kBlue);
502 TH2F * hSigmaPro=(TH2F*)pidList->FindObject("hTOFExpSigmaPro");
503 hSigmaPro->GetYaxis()->SetRangeUser(-5.,5.);
504 TProfile * profSigmaPro = (TProfile*)hSigmaPro->ProfileX("profSigmaPro");
505 profSigmaPro->SetLineWidth(2);
506 profSigmaPro->SetLineColor(kGreen+2);
509 // hSigmaPi->Write();
510 // profSigmaPi->Write();
511 // hSigmaKa->Write();
512 // profSigmaKa->Write();
513 // hSigmaPro->Write();
514 // profSigmaPro->Write();
516 //--------------------------------- T0 detector ----------------------------------//
518 TH1F*hT0A=(TH1F*)timeZeroList->FindObject("hEventT0DetA");
519 if ((hT0A)&&(hT0A->GetEntries()>0)) {
520 avT0A = hT0A->GetMean();
521 hT0A->Fit("gaus","RQ0", "", -1000., 1000.);
522 peakT0A=(hT0A->GetFunction("gaus"))->GetParameter(1);
523 spreadT0A=(hT0A->GetFunction("gaus"))->GetParameter(2);
524 peakT0AErr=(hT0A->GetFunction("gaus"))->GetParError(1);
525 spreadT0AErr=(hT0A->GetFunction("gaus"))->GetParError(2);
526 printf("Main peak T0A(gaus): mean = %f +- %f\n",peakT0A,peakT0AErr );
527 printf("Main peak T0A (gaus): spread = %f +- %f\n",spreadT0A,spreadT0AErr );
528 //add integral of main peak over total
530 MakeUpHisto(hT0A, "events", 8, kBlue);
533 TH1F*hT0C=(TH1F*)timeZeroList->FindObject("hEventT0DetC");
534 if ((hT0C)&&(hT0C->GetEntries()>0)) {
535 avT0C=hT0C->GetMean();
536 hT0C->Fit("gaus","RQ0","", -1000., 1000.);
537 peakT0C=(hT0C->GetFunction("gaus"))->GetParameter(1);
538 spreadT0C=(hT0C->GetFunction("gaus"))->GetParameter(2);
539 peakT0CErr=(hT0C->GetFunction("gaus"))->GetParError(1);
540 spreadT0CErr=(hT0C->GetFunction("gaus"))->GetParError(2);
541 printf("Main peak T0C(gaus): mean = %f +- %f\n",peakT0C,peakT0CErr );
542 printf("Main peak T0C (gaus): spread = %f +- %f\n",spreadT0C,spreadT0CErr );
543 //add integral of main peak over total
545 MakeUpHisto(hT0C, "events", 8, kGreen+1);
548 TH1F*hT0AC=(TH1F*)timeZeroList->FindObject("hEventT0DetAND");
549 if ((hT0AC)&&(hT0AC->GetEntries()>0)) {
550 avT0AC=hT0AC->GetMean();
551 hT0AC->Fit("gaus","RQ0", "",-1000., 1000.);
552 peakT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(1);
553 spreadT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(2);
554 peakT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(1);
555 spreadT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(2);
556 printf("Main peak T0AC(gaus): mean = %f +- %f\n",peakT0AC,peakT0ACErr );
557 printf("Main peak T0AC (gaus): spread = %f +- %f\n",spreadT0AC,spreadT0ACErr );
559 MakeUpHisto(hT0AC, "events", 8, kRed+1);
562 TLegend *lT0 = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
563 lT0->SetTextSize(0.041);
564 lT0->AddEntry(hT0AC, "T0 A&C","L");
565 lT0->AddEntry(hT0A, "T0 A","L");
566 lT0->AddEntry(hT0C, "T0 C","L");
567 lT0->SetFillColor(kWhite);
568 lT0->SetShadowColor(0);
570 TH1F*hT0res=(TH1F*)timeZeroList->FindObject("hT0DetRes");
571 if ((hT0res)&&(hT0res->GetEntries()>0)) {
572 avT0res=hT0res->GetMean();
574 peakT0res=(hT0res->GetFunction("gaus"))->GetParameter(1);
575 spreadT0res=(hT0res->GetFunction("gaus"))->GetParameter(2);
576 peakT0resErr=(hT0res->GetFunction("gaus"))->GetParError(1);
577 spreadT0resErr=(hT0res->GetFunction("gaus"))->GetParError(2);
578 printf("Main peak T0res(gaus): mean = %f +- %f\n",peakT0res,peakT0resErr );
579 printf("Main peak T0res (gaus): spread = %f +- %f\n",spreadT0res,spreadT0resErr );
580 //add integral of main peak over total
583 TH1F*hT0fillRes=(TH1F*)timeZeroList->FindObject("hT0fillRes");
584 if ((hT0fillRes)&&(hT0fillRes->GetEntries()>0)) {
585 avT0fillRes=hT0fillRes->GetMean();
593 // hT0fillRes->Write();
596 //Fill tree and save to file
598 printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
604 // TString plotDir(Form("Plots_run%d",runNumber));
605 // gSystem->Exec(Form("mkdir %s",plotDir.Data()));
606 TString plotDir(".");
608 TCanvas *cTrackProperties= new TCanvas("cTrackProperties","summary of matched tracks properties", 1200, 500);
609 cTrackProperties->Divide(3,1);
610 cTrackProperties->cd(1);
613 hRawTime ->Draw("same");
615 cTrackProperties->cd(2);
619 cTrackProperties->cd(3);
624 TCanvas *cResiduals= new TCanvas("residuals","residuals", 900,500);
625 cResiduals->Divide(2,1);
628 hDxPos4profile->GetYaxis()->SetRangeUser(-5.,5.);
629 hDxPos4profile->Draw("colz");
630 profDxPos->SetLineColor(kRed);
631 profDxPos ->Draw("same");
634 hDxNeg4profile->GetYaxis()->SetRangeUser(-5.,5.);
635 hDxNeg4profile->Draw("colz");
636 profDxNeg->SetLineColor(kBlue);
637 profDxNeg->Draw("same");
639 TCanvas* cProfile = new TCanvas("cProfile","cProfile",50,50, 750,550);
642 hTOFmatchedDzVsStrip->Draw("colz");
643 Int_t binmin = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(-3);
644 Int_t binmax = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(3);
645 TProfile* hDzProfile = (TProfile*)hTOFmatchedDzVsStrip->ProfileX("hDzProfile",binmin, binmax);
646 hDzProfile->SetLineWidth(3);
647 hDzProfile->Draw("same");
649 TCanvas *cMatchingPerformance= new TCanvas("cMatchingPerformance","summary of matching performance",1200,500);
650 cMatchingPerformance->Divide(3,1);
651 cMatchingPerformance->cd(1);
652 hMatchingVsPt->Draw();
653 cMatchingPerformance->cd(2);
654 hMatchingVsEta->Draw();
655 cMatchingPerformance->cd(3);
656 hMatchingVsPhi->Draw();
658 TCanvas *cPidPerformance= new TCanvas("cPidPerformance","summary of pid performance", 900,500);
659 cPidPerformance->Divide(2,1);
660 cPidPerformance->cd(1);
662 hBetaP->Draw("colz");
663 cPidPerformance->cd(2);
665 hMass->Draw("HIST ");
667 TCanvas *cPidPerformance2= new TCanvas("cPidPerformance2","summary of pid performance - expected times", 1200, 500);
668 cPidPerformance2->Divide(3,1);
669 cPidPerformance2->cd(1);
671 hDiffTimePi->Draw("colz");
672 //profDiffTimePi->Draw("same");
673 cPidPerformance2->cd(2);
675 hDiffTimeKa->Draw("colz");
676 //profDiffTimeKa->Draw("same");
677 cPidPerformance2->cd(3);
679 hDiffTimePro->Draw("colz");
680 //profDiffTimePro->Draw("same");
682 TLegend * lSigmaPid=new TLegend(0.75,0.75,0.95,0.95,"#sigma_{PID}");
683 lSigmaPid->AddEntry(profSigmaPi,"#pi^{#pm}","l");
684 lSigmaPid->AddEntry(profSigmaKa,"K^{#pm}","l");
685 lSigmaPid->AddEntry(profSigmaPro,"p^{#pm}","l");
686 TCanvas *cPidPerformance3= new TCanvas("cPidPerformance3","summary of pid performance - sigmas",1200,500);
687 cPidPerformance3->Divide(3,1);
688 cPidPerformance3->cd(1);
690 hSigmaPi->Draw("colz");
691 profSigmaPi->Draw("same");
692 cPidPerformance3->cd(2);
694 hSigmaKa->Draw("colz");
695 profSigmaKa->Draw("same");
696 cPidPerformance3->cd(3);
698 hSigmaPro->Draw("colz");
699 profSigmaPro->Draw("same");
701 TCanvas *cT0detector= new TCanvas("cT0detector","T0 detector",800,600);
702 cT0detector->Divide(2,1);
706 hT0AC->SetTitle("timeZero measured by T0 detector");
713 cPidPerformance3->Print(Form("%s/%i_PID_sigmas.png", plotDir.Data(), runNumber));
714 cPidPerformance->Print(Form("%s/%i_PID.png",plotDir.Data(), runNumber));
715 //cPidPerformanceTh->Print(Form("%s/PID_theoreticalTimes.png",plotDir.Data()));
716 cPidPerformance2->Print(Form("%s/%i_PID_ExpTimes.png",plotDir.Data(), runNumber));
717 cMatchingPerformance->Print(Form("%s/%i_Matching.png",plotDir.Data(), runNumber));
718 cTrackProperties->Print(Form("%s/%i_TrackProperties.png",plotDir.Data(), runNumber));
719 cResiduals->Print(Form("%s/%i_Residuals.png",plotDir.Data(), runNumber));
720 cProfile->Print(Form("%s/%i_ProfileDZvsStripNumber.png",plotDir.Data(), runNumber));
721 cT0detector->Print(Form("%s/%i_T0Detector.png",plotDir.Data(), runNumber));
728 //----------------------------------------------------------
729 Double_t GetGoodTOFChannelsRatio(Int_t run = -1, Bool_t saveMap = kFALSE, TString OCDBstorage = "raw://")
732 It retrieves from OCDB the number of good (= efficient && not noisy && HW ok) TOF channels.
733 Optionally is saves the channel map
736 printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): invalid run number. Please set a run number.\n");
740 AliCDBManager *cdb = AliCDBManager::Instance();
741 cdb->SetDefaultStorage(OCDBstorage.Data());
744 AliCDBEntry *cdbe = cdb->Get("TOF/Calib/Status");
746 printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): OCDB entry not available. Please, try again.\n");
750 AliTOFChannelOnlineStatusArray *array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
751 TH2F *hOkMap = new TH2F("hOkMap", "Ok map (!noisy & !problematic & efficient);sector;strip", 72, 0., 18., 91, 0., 91.);
753 AliTOFcalibHisto calibHisto;
754 calibHisto.LoadCalibHisto();
757 Int_t sector, sectorStrip, padx, fea;
758 Float_t hitmapx, hitmapy;
759 for (Int_t i = 0; i < array->GetSize(); i++) {
760 sector = calibHisto.GetCalibMap(AliTOFcalibHisto::kSector, i);
761 sectorStrip = calibHisto.GetCalibMap(AliTOFcalibHisto::kSectorStrip, i);
762 padx = calibHisto.GetCalibMap(AliTOFcalibHisto::kPadX, i);
764 hitmapx = sector + ((Double_t)(3 - fea) + 0.5) / 4.;
765 hitmapy = sectorStrip;
766 if ( !(array->GetNoiseStatus(i) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad) &&
767 (calib.IsChannelEnabled(i,kTRUE,kTRUE)))
768 hOkMap->Fill(hitmapx,hitmapy);
770 Int_t nOk=(Int_t) hOkMap->GetEntries();
771 Double_t ratioOk=nOk/152928.;
772 if (saveMap) hOkMap->SaveAs(Form("run%i_OKChannelsMap.root",run));
773 cout << "### Run " << run << ": TOF channels ok = " << nOk << "/ total 152928 channels = " << ratioOk*100. << "% of whole TOF" << endl;
777 //----------------------------------------------------------
778 void MakeUpHisto(TH1* histo, TString titleY, Int_t marker=20, Color_t color=kBlue+2)
781 histo->SetMarkerStyle(marker);
782 histo->SetMarkerSize(0.7);
783 histo->SetMarkerColor(color);
784 histo->SetLineColor(color);
785 histo->SetFillColor(kWhite);
786 histo->SetFillStyle(0);
787 histo->GetYaxis()->SetTitle(titleY.Data());
788 histo->GetYaxis()->SetTitleOffset(1.35);
789 histo->GetXaxis()->SetLabelSize(0.03);