]>
Commit | Line | Data |
---|---|---|
21fba467 | 1 | // $Id$ |
2 | /* | |
3 | * Drawing macro for reading the THnSparse output of the | |
4 | * HLT/QA/tasks/AliAnalysisTaskHLTCentralBarrel.cxx task. | |
5 | * | |
0b342e78 | 6 | * The cuts are user defined around lines 160-165 as arguments of the |
c5bbc97b | 7 | * function cutStsudies(...). |
8 | * | |
21fba467 | 9 | * The input file contains information about the run number |
10 | * and date that will appear in the canvas title. | |
11 | * | |
12 | * The cuts are turned into strings and incorporated in the | |
13 | * name of the output file, which contains canvases with event | |
14 | * and track properties for HLT and offline. | |
15 | * | |
16 | * Since the run information is available, there will be a new | |
17 | * folder created and the canvas ROOT files will be saved in there. | |
18 | * | |
c5bbc97b | 19 | * The macro should be compiled before running: |
20 | * | |
21 | * root[0] .L drawTHnSparse.C++ | |
b1ab272c | 22 | * root[1] drawTHnSparse("HLT-OFFLINE-CentralBarrel-comparison.root") |
c5bbc97b | 23 | * |
21fba467 | 24 | * @ingroup alihlt_qa |
25 | * @author Kalliopi.Kanaki@ift.uib.no | |
26 | */ | |
27 | ||
c5bbc97b | 28 | #if !defined(__CINT__) || defined(__MAKECINT__) |
29 | #include "TSystem.h" | |
30 | #include "TROOT.h" | |
31 | #include "TFile.h" | |
32 | #include "TString.h" | |
33 | #include "TList.h" | |
34 | #include "THnSparse.h" | |
35 | #include "TCanvas.h" | |
36 | #include "TText.h" | |
37 | #include "TPaveText.h" | |
38 | #include "TPaveStats.h" | |
39 | #include "TH1D.h" | |
40 | #include "TH2D.h" | |
0b342e78 | 41 | #include "TH3D.h" |
c5bbc97b | 42 | #include "TLegend.h" |
43 | #include "TStyle.h" | |
88179f19 | 44 | #include "TPad.h" |
c5bbc97b | 45 | #include <iostream> |
88179f19 | 46 | #include <cstdlib> |
c5bbc97b | 47 | using std::endl; |
48 | #endif | |
49 | ||
88179f19 | 50 | //---------- forward declerations ---------------// |
0b342e78 | 51 | TString cutStudies( TString folder, THnSparse* htrackHLT, THnSparse* htrackOFF, TText* hText, |
c5bbc97b | 52 | double minEta, double maxEta, |
53 | int minTrackMult,int maxTrackMult, | |
54 | double minPt, double maxPt, | |
55 | double minDCAr, double maxDCAr, | |
56 | double minDCAz, double maxDCAz, | |
57 | int minTPCclus, int maxTPCclus, | |
58 | int minITSclus, int maxITSclus, | |
d99d5e30 | 59 | int vs, float vz, |
60 | float minCent, float maxCent | |
c5bbc97b | 61 | ); |
62 | void printStats(TH1D *hlt, TH1D *off); | |
63 | void defineYaxisMax(TH1D *hlt, TH1D *off); | |
0b342e78 | 64 | void printLegend(TH1D *hlt, TH1D *off); |
65 | void plot2D( THnSparse* h, TText *hText, TString folder, | |
d99d5e30 | 66 | double minEta, double maxEta, |
67 | double minPt, double maxPt, | |
68 | double minDCAr, double maxDCAr, | |
69 | double minDCAz, double maxDCAz, | |
70 | int minTPCclus, int maxTPCclus, | |
71 | int minITSclus, int maxITSclus, | |
72 | int minTrackMult, int maxTrackMult, | |
73 | int vs, float vz, | |
74 | float minCent, float maxCent | |
75 | ); | |
0b342e78 | 76 | void plotEventQuantities(THnSparse* heventHLT, THnSparse* heventOFF, TText* hText, TString folder); |
c5bbc97b | 77 | TString fix1DTitle(const char* c); |
78 | TString fix2DTitle(const char* c1, const char* c2); | |
79 | TString cutsToString( double minEta, double maxEta, | |
80 | double minPt, double maxPt, | |
81 | double minDCAr, double maxDCAr, | |
82 | double minDCAz, double maxDCAz, | |
83 | int minTPCclus, int maxTPCclus, | |
84 | int minITSclus, int maxITSclus, | |
85 | int minTrackMult, int maxTrackMult, | |
d99d5e30 | 86 | int vs, float vz |
87 | //float minCent, float maxCent | |
c5bbc97b | 88 | ); |
0b342e78 | 89 | void plotTrackQuantities( THnSparse* htrackHLT, THnSparse* htrackOFF, |
90 | TText* hText, TString folder, | |
91 | double minEta, double maxEta, | |
92 | double minPt, double maxPt, | |
93 | double minDCAr, double maxDCAr, | |
94 | double minDCAz, double maxDCAz, | |
95 | int minTPCclus, int maxTPCclus, | |
96 | int minITSclus, int maxITSclus, | |
97 | int minTrackMult, int maxTrackMult, | |
98 | int vs, float vz, | |
99 | float minCent, float maxCent | |
c5bbc97b | 100 | ); |
88179f19 | 101 | |
102 | vector<TString> outputNames; | |
c5bbc97b | 103 | |
104 | //------------------------------------------------------------------// | |
0b342e78 | 105 | |
d99d5e30 | 106 | void drawTHnSparse(TString inputFile="HLT-OFFLINE-CentralBarrel-comparison.root"){ |
c5c3a9ed | 107 | |
21fba467 | 108 | gROOT->SetStyle("Plain"); |
109 | gStyle->SetPalette(1); | |
0b342e78 | 110 | gStyle->SetOptStat("emr"); |
d99d5e30 | 111 | gStyle->SetTitleX(gStyle->GetPadLeftMargin()); |
21fba467 | 112 | TH1::AddDirectory(kFALSE); |
113 | ||
114 | TFile *file = TFile::Open(inputFile); | |
115 | if(!file){ | |
c5bbc97b | 116 | printf("Error: No file %s in folder.\n", inputFile.Data()); |
21fba467 | 117 | return; |
118 | } | |
21fba467 | 119 | TList *list = static_cast<TList*>(file->Get("esd_thnsparse")); |
120 | if(!list){ | |
c5bbc97b | 121 | printf("Error: No List contained in file %s.\n", inputFile.Data()); |
21fba467 | 122 | return; |
123 | } | |
c5bbc97b | 124 | THnSparseF *heventHLT = (THnSparseF*)list->FindObject("fEventHLT"); |
21fba467 | 125 | if(!heventHLT){ |
c5bbc97b | 126 | printf("Error: There is no HLT THnSparse object in file %s\n", inputFile.Data()); |
d99d5e30 | 127 | return; |
21fba467 | 128 | } |
c5bbc97b | 129 | THnSparseF *heventOFF = (THnSparseF*)list->FindObject("fEventOFF"); |
21fba467 | 130 | if(!heventOFF){ |
c5bbc97b | 131 | printf("Error: There is no OFF THnSparse object in file %s\n", inputFile.Data()); |
d99d5e30 | 132 | return; |
21fba467 | 133 | } |
c5bbc97b | 134 | THnSparseF *htrackHLT = (THnSparseF*)list->FindObject("fTrackHLT"); |
21fba467 | 135 | if(!htrackHLT){ |
136 | printf("Error: No HLT THnSparse object found\n"); | |
137 | return; | |
138 | } | |
c5bbc97b | 139 | THnSparseF *htrackOFF = (THnSparseF*)list->FindObject("fTrackOFF"); |
21fba467 | 140 | if(!htrackOFF){ |
141 | printf("Error: No OFF THnSparse object found\n"); | |
142 | return; | |
143 | } | |
e5f150ee | 144 | |
c5bbc97b | 145 | TText *hText = (TText*)list->FindObject("text"); |
21fba467 | 146 | if(!hText) printf("No hText\n"); |
0b342e78 | 147 | |
21fba467 | 148 | TString folder = hText->GetTitle(); |
149 | folder.ReplaceAll(" ",""); | |
0b342e78 | 150 | folder.ReplaceAll(",","_"); |
151 | gSystem->Exec("mkdir "+folder); // create a folder whose name contains run number and date of run | |
c5c3a9ed | 152 | |
0b342e78 | 153 | if(heventHLT->GetEntries()>0 || heventOFF->GetEntries()>0) plotEventQuantities(heventHLT,heventOFF,hText,folder); |
154 | ||
155 | int counter=0; | |
156 | // counts how many times the function cutStudies() is called | |
157 | // if more than once, then it creates and fills the canvas with the overlapping hlt distributions for the various sets of cuts | |
c5c3a9ed | 158 | |
0b342e78 | 159 | TString s = ""; // eta mult pt DCAr DCAz TPCclus ITSclus vertexStatus |vertexZ| |
160 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -2, 2, 0, 2000, 0, 5, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
161 | /* | |
162 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 5, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
163 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 5, -7, 7, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
164 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 5, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
165 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 5, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
166 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 5, -3, 3, -3, 3, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
167 | */ | |
168 | ||
169 | if(counter>=2){ | |
170 | TString tmp = "overlaid HLT track distributions for "; | |
171 | tmp += hText->GetTitle(); | |
172 | TCanvas *ovHLT = new TCanvas("ovHLT",tmp,1100,900); | |
173 | ovHLT->Divide(3,3); | |
d99d5e30 | 174 | |
0b342e78 | 175 | tmp = "overlaid OFF track distributions for "; |
176 | tmp += hText->GetTitle(); | |
177 | TCanvas *ovOFF = new TCanvas("ovOFF",tmp,1100,900); | |
178 | ovOFF->Divide(3,3); | |
d99d5e30 | 179 | |
0b342e78 | 180 | TCanvas *ca; TFile *ff; TPad *pad; |
181 | TH1D *hlt[outputNames.size()]; | |
182 | TH1D *off[outputNames.size()]; | |
183 | ||
184 | for(int j=1; j<10; j++){ // loop over the pads of the canvas "ov" with dimension 3x3 | |
185 | for(UInt_t i=0; i<outputNames.size(); i++){ // loop over the files with different sets of cuts | |
186 | ||
187 | ff = TFile::Open(outputNames[i].Data()); | |
188 | if(!ff || ff->IsZombie()){ | |
189 | printf("Non-existent, corrupted or zombie file %s\n", outputNames[i].Data()); | |
190 | return; | |
191 | } | |
192 | ca = (TCanvas*)ff->GetObjectUnchecked("can3"); | |
193 | if(!ca){ | |
194 | printf("Empty canvas in file %s.\n", outputNames[i].Data()); | |
195 | continue; | |
196 | } | |
197 | pad = (TPad*)ca->GetListOfPrimitives()->FindObject(Form("can3_%d",j)); | |
198 | if(!pad){ | |
199 | printf("Empty pad in canvas %s.\n", ca->GetName()); | |
200 | continue; | |
201 | } | |
202 | hlt[i] =(TH1D*)pad->FindObject(Form("fTrackHLT_proj_%d",j-1)); | |
203 | off[i] =(TH1D*)pad->FindObject(Form("fTrackOFF_proj_%d",j-1)); | |
204 | if(!hlt[i] || !off[i]){ | |
205 | printf("Empty histogram for i=%d, file %s.\n", i, outputNames[i].Data()); | |
206 | continue; | |
207 | } | |
208 | ovHLT->cd(j); | |
209 | if(i==0){ | |
210 | TPaveStats *st = (TPaveStats*)hlt[i]->FindObject("stats"); | |
211 | st->SetTextColor(kBlack); | |
212 | hlt[i]->Draw(); | |
213 | } | |
214 | else { | |
215 | hlt[i]->SetLineColor(i+1); | |
216 | defineYaxisMax(hlt[0], hlt[i]); | |
217 | hlt[i]->Draw("sames"); | |
218 | } | |
219 | if(i>0) printStats(hlt[i-1], hlt[i]); | |
220 | ||
221 | ovOFF->cd(j); | |
222 | if(i==0){ | |
223 | off[i]->SetLineColor(kBlack); | |
224 | TPaveStats *st = (TPaveStats*)off[i]->FindObject("stats"); | |
225 | st->SetTextColor(kBlack); | |
226 | off[i]->Draw(); | |
227 | } | |
228 | else { | |
229 | off[i]->SetLineColor(i+1); | |
230 | defineYaxisMax(off[0], off[i]); | |
231 | off[i]->Draw("sames"); | |
232 | } | |
233 | if(i>0) printStats(off[i-1], off[i]); | |
234 | ||
235 | ff->Close(); | |
236 | } // end of loop over files | |
237 | } // end of loop over canvas pads | |
238 | file->Close(); | |
239 | ovHLT->SaveAs(folder+"/overlaid_HLT_track_cuts.root"); | |
240 | ovHLT->SaveAs(folder+"/overlaid_HLT_track_cuts.png"); | |
241 | ovOFF->SaveAs(folder+"/overlaid_OFF_track_cuts.root"); | |
242 | ovOFF->SaveAs(folder+"/overlaid_OFF_track_cuts.png"); | |
243 | delete ovHLT; | |
244 | delete ovOFF; | |
245 | } // end if for counter>=2 | |
246 | return; | |
c5c3a9ed | 247 | } |
248 | ||
d99d5e30 | 249 | // ============== main function for filling the track properties, 1D and 2D ================ // |
250 | ||
0b342e78 | 251 | TString cutStudies( TString folder, |
c5bbc97b | 252 | THnSparse* htrackHLT, THnSparse* htrackOFF, TText* hText, |
253 | double minEta, double maxEta, | |
254 | int minTrackMult,int maxTrackMult, | |
255 | double minPt, double maxPt, | |
256 | double minDCAr, double maxDCAr, | |
257 | double minDCAz, double maxDCAz, | |
258 | int minTPCclus, int maxTPCclus, | |
259 | int minITSclus, int maxITSclus, | |
d99d5e30 | 260 | int vs, float vz, |
261 | float minCent, float maxCent | |
262 | ){ | |
0b342e78 | 263 | |
264 | plotTrackQuantities(htrackHLT, htrackOFF, hText, folder, | |
265 | minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, minITSclus, maxITSclus, | |
266 | minTrackMult, maxTrackMult, vs, vz, minCent, maxCent); | |
267 | ||
268 | if(htrackHLT->GetEntries()>0) plot2D(htrackHLT, hText, folder, minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, minITSclus, maxITSclus, | |
269 | minTrackMult, maxTrackMult, vs, vz, minCent, maxCent); | |
270 | ||
271 | if(htrackOFF->GetEntries()>0) plot2D(htrackOFF, hText, folder, minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, minITSclus, maxITSclus, | |
272 | minTrackMult, maxTrackMult, vs, vz, minCent, maxCent); | |
273 | ||
274 | TString cuts = cutsToString(minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, | |
275 | minITSclus, maxITSclus, minTrackMult, maxTrackMult, vs, vz); | |
276 | ||
277 | return folder+"/track_properties_"+cuts+".root"; // same name as the one produced by plotTrackQuantities internally | |
278 | } | |
279 | ||
280 | void plotEventQuantities(THnSparse* heventHLT, THnSparse* heventOFF, TText* hText, TString folder){ | |
281 | ||
282 | TString tmp = "vertex event properties for "; | |
283 | tmp += hText->GetTitle(); | |
284 | TCanvas *can1 = new TCanvas("can1",tmp,1200,700); | |
285 | can1->Divide(3,2); | |
286 | ||
287 | heventHLT->GetAxis(8)->SetRangeUser(1,1); // select events with existing primary vertex | |
288 | heventOFF->GetAxis(8)->SetRangeUser(1,1); | |
289 | TH1D *hlt = NULL; | |
290 | TH1D *off = NULL; | |
291 | ||
292 | for(int i=0; i<6; i++){ // loop for HLT/OFF primary and SPD vertex xyz | |
293 | can1->cd(i+1); | |
294 | hlt = heventHLT->Projection(i); if(!hlt){ printf("plotEventQuantities: empty HLT histogram, projection %d\n",i); continue; } | |
295 | off = heventOFF->Projection(i); if(!off){ printf("plotEventQuantities: empty OFF histogram, projection %d\n",i); continue; } | |
296 | off->SetLineColor(2); | |
297 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(i)->GetTitle())); | |
298 | off->SetTitle(fix1DTitle(heventOFF->Projection(i)->GetTitle())); | |
299 | TString s = hlt->GetTitle(); | |
300 | if(s.Contains("primary")){ | |
301 | s+=" (cm)"; | |
302 | hlt->SetXTitle(s); | |
303 | off->SetXTitle(s); | |
304 | } | |
305 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
306 | ||
307 | if(hlt->GetEntries()>0) hlt->Draw(); | |
308 | if(off->GetEntries()>0) off->Draw("sames"); | |
309 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
310 | if(off->GetEntries()>0 && i==0 ) printLegend(hlt,off); | |
311 | } | |
312 | ||
313 | tmp = "general event properties for "; | |
314 | tmp += hText->GetTitle(); | |
315 | TCanvas *can2 = new TCanvas("can2",tmp,1200,700); | |
316 | can2->Divide(3,2); | |
c5c3a9ed | 317 | |
0b342e78 | 318 | can2->cd(1); // track multiplicity |
319 | hlt = heventHLT->Projection(7); | |
320 | off = heventOFF->Projection(7); | |
321 | off->SetLineColor(2); | |
322 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(7)->GetTitle())); | |
323 | off->SetTitle(fix1DTitle(heventOFF->Projection(7)->GetTitle())); | |
324 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
325 | if(hlt->GetEntries()>0) hlt->Draw(); | |
326 | if(off->GetEntries()>0){ off->Draw("sames"); printLegend(hlt,off); } | |
327 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
328 | ||
329 | can2->cd(2); // number of contributors | |
330 | hlt = heventHLT->Projection(6); | |
331 | off = heventOFF->Projection(6); | |
332 | off->SetLineColor(2); | |
333 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(6)->GetTitle())); | |
334 | off->SetTitle(fix1DTitle(heventOFF->Projection(6)->GetTitle())); | |
335 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
336 | if(hlt->GetEntries()>0) hlt->Draw(); | |
337 | if(off->GetEntries()>0) off->Draw("sames"); | |
338 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
339 | ||
340 | can2->cd(3); // vertex status | |
341 | hlt = heventHLT->Projection(8); | |
342 | off = heventOFF->Projection(8); | |
343 | off->SetLineColor(2); | |
344 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(8)->GetTitle())); | |
345 | off->SetTitle(fix1DTitle(heventOFF->Projection(8)->GetTitle())); | |
346 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
347 | if(hlt->GetEntries()>0) hlt->Draw(); | |
348 | if(off->GetEntries()>0) off->Draw("sames"); | |
349 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
350 | ||
351 | can2->cd(4); // # of contributors vs. track multiplicity for HLT | |
352 | TH2D *h = heventHLT->Projection(6,7); | |
353 | TString s1 = fix2DTitle(heventHLT->Projection(6)->GetTitle(), heventHLT->Projection(7)->GetTitle()); s1+=" (HLT)"; | |
354 | h->SetTitle(s1); | |
355 | h->Draw("colz"); | |
356 | ||
357 | can2->cd(5); // # of contributors vs. track multiplicity for OFF | |
358 | TH2D *o = heventOFF->Projection(6,7); | |
359 | s1 = fix2DTitle(heventOFF->Projection(6)->GetTitle(), heventOFF->Projection(7)->GetTitle()); s1+=" (OFF)"; | |
360 | o->SetTitle(s1); | |
361 | o->Draw("colz"); | |
362 | ||
363 | if(heventHLT->GetNdimensions()==10){ | |
364 | can2->cd(6); | |
365 | off = heventOFF->Projection(9); // V0 centrality, taken from the offline ESD | |
366 | off->SetTitle(fix1DTitle(heventOFF->Projection(9)->GetTitle())); | |
367 | off->SetLineColor(2); | |
368 | off->Draw(); | |
369 | } | |
370 | ||
371 | can1->SaveAs(folder+"/vertex_event_properties.root"); | |
372 | can1->SaveAs(folder+"/vertex_event_properties.png"); | |
373 | can2->SaveAs(folder+"/general_event_properties.root"); | |
374 | can2->SaveAs(folder+"/general_event_properties.png"); | |
375 | delete can1; | |
376 | delete can2; | |
377 | return; | |
378 | } | |
379 | ||
380 | void plotTrackQuantities( THnSparse* htrackHLT, THnSparse* htrackOFF, | |
381 | TText* hText, TString folder, | |
382 | double minEta, double maxEta, | |
383 | double minPt, double maxPt, | |
384 | double minDCAr, double maxDCAr, | |
385 | double minDCAz, double maxDCAz, | |
386 | int minTPCclus, int maxTPCclus, | |
387 | int minITSclus, int maxITSclus, | |
388 | int minTrackMult, int maxTrackMult, | |
389 | int vs, float vz, | |
390 | float minCent, float maxCent | |
391 | ) | |
392 | { | |
393 | ||
394 | htrackHLT->GetAxis(0)->SetRangeUser(minPt,maxPt); | |
395 | htrackHLT->GetAxis(1)->SetRangeUser(minTPCclus,maxTPCclus); | |
396 | htrackHLT->GetAxis(3)->SetRangeUser(minEta, maxEta); | |
397 | htrackHLT->GetAxis(5)->SetRangeUser(minDCAr, maxDCAr); | |
398 | htrackHLT->GetAxis(6)->SetRangeUser(minDCAz, maxDCAz); | |
399 | htrackHLT->GetAxis(8)->SetRangeUser(minITSclus, maxITSclus); | |
400 | htrackHLT->GetAxis(9)->SetRangeUser(minTrackMult, maxTrackMult); | |
401 | if(vs!=2) htrackHLT->GetAxis(10)->SetRangeUser(vs,vs); | |
402 | htrackHLT->GetAxis(11)->SetRangeUser(-TMath::Abs(vz), TMath::Abs(vz)); | |
403 | if(htrackHLT->GetNdimensions()==13) htrackHLT->GetAxis(12)->SetRangeUser(minCent, maxCent); | |
404 | ||
405 | htrackOFF->GetAxis(0)->SetRangeUser(minPt,maxPt); | |
406 | htrackOFF->GetAxis(1)->SetRangeUser(minTPCclus,maxTPCclus); | |
407 | htrackOFF->GetAxis(3)->SetRangeUser(minEta, maxEta); | |
408 | htrackOFF->GetAxis(5)->SetRangeUser(minDCAr, maxDCAr); | |
409 | htrackOFF->GetAxis(6)->SetRangeUser(minDCAz, maxDCAz); | |
410 | htrackOFF->GetAxis(8)->SetRangeUser(minITSclus, maxITSclus); | |
411 | htrackOFF->GetAxis(9)->SetRangeUser(minTrackMult, maxTrackMult); | |
412 | if(vs!=2) htrackOFF->GetAxis(10)->SetRangeUser(vs,vs); | |
413 | htrackOFF->GetAxis(11)->SetRangeUser(-TMath::Abs(vz), TMath::Abs(vz)); | |
414 | if(htrackOFF->GetNdimensions()==13) htrackOFF->GetAxis(12)->SetRangeUser(minCent, maxCent); | |
415 | ||
416 | TString tmp = ""; | |
417 | tmp += "track properties for "; | |
418 | tmp+=hText->GetTitle(); | |
419 | TCanvas *can3 = new TCanvas("can3",tmp,1100,900); | |
420 | can3->Divide(3,3); | |
421 | // the first 9 track related variables filled in the THnSparse | |
422 | // 0 1 2 3 4 5 6 7 8 | |
423 | // pt TPCcl theta eta phi DCAr DCAz charge ITScl | |
c5c3a9ed | 424 | |
0b342e78 | 425 | TH1D *hlt = NULL; |
426 | TH1D *off = NULL; | |
427 | ||
428 | for(int i=0; i<9; i++){ | |
429 | hlt = htrackHLT->Projection(i); if(!hlt){ printf("plotTrackQuantities: empty HLT histogram for projection %d\n",i); continue; } | |
430 | off = htrackOFF->Projection(i); if(!off){ printf("plotTrackQuantities: empty OFF histogram for projection %d\n",i); continue; } | |
431 | hlt->SetTitle(fix1DTitle(htrackHLT->Projection(i)->GetTitle())); | |
432 | off->SetTitle(fix1DTitle(htrackOFF->Projection(i)->GetTitle())); // is necessary in cases where only offline data is available | |
433 | ||
434 | TString s = hlt->GetTitle(); | |
435 | if(s.Contains("p_")){ | |
436 | s+=" (GeV/c)"; | |
437 | hlt->SetXTitle(s); | |
438 | } | |
439 | else if(s.Contains("theta") || s.Contains("phi")){ | |
440 | s+=" (rad)"; | |
441 | hlt->SetXTitle(s); | |
442 | } | |
443 | else if(s.Contains("DCA")){ | |
444 | s+=" (cm)"; | |
445 | hlt->SetXTitle(s); | |
446 | } | |
447 | ||
448 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
449 | off->SetLineColor(2); | |
450 | ||
451 | can3->cd(i+1); | |
452 | if(hlt->GetEntries()>0) hlt->Draw(); | |
453 | if(off->GetEntries()>0) off->Draw("sames"); | |
454 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
455 | if(off->GetEntries()>0 && i==0 ) printLegend(hlt,off); | |
456 | ||
457 | if(hlt->GetEntries()>0 && i==0){ | |
458 | TPaveText *pave = new TPaveText(25,5600,140,36400); | |
459 | pave->SetFillColor(kWhite); | |
460 | pave->SetLineColor(kWhite); | |
461 | pave->SetShadowColor(kWhite); | |
462 | s=""; s+=minEta; s+=" < eta < "; s+=maxEta; pave->AddText(s); | |
463 | s=""; s+=minPt; s+=" < pt (GeV/c) < "; s+=maxPt; pave->AddText(s); | |
464 | s=""; s+=minTrackMult; s+=" < track mult < "; s+=maxTrackMult; pave->AddText(s); | |
465 | s=""; s+=minDCAr; s+=" < DCAr (cm) < "; s+=maxDCAr; pave->AddText(s); | |
466 | s=""; s+=minDCAz; s+=" < DCAz (cm) < "; s+=maxDCAz; pave->AddText(s); | |
467 | s=""; s+=minTPCclus; s+=" < TPC clusters/track < "; s+=maxTPCclus; pave->AddText(s); | |
468 | s=""; s+=minITSclus; s+=" < ITS clusters/track < "; s+=maxITSclus; pave->AddText(s); | |
469 | if(vs!=2) { s=""; s+="vertex status "; s+=vs; pave->AddText(s); } | |
470 | pave->Draw(); | |
471 | can3->Update(); | |
472 | } | |
473 | } | |
c5c3a9ed | 474 | TString cuts = cutsToString(minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, |
d99d5e30 | 475 | minITSclus, maxITSclus, minTrackMult, maxTrackMult, vs, vz); |
21fba467 | 476 | |
0b342e78 | 477 | can3->SaveAs(folder+"/track_properties_"+cuts+".root"); |
478 | can3->SaveAs(folder+"/track_properties_"+cuts+".png"); | |
479 | delete can3; | |
480 | ||
481 | return; | |
21fba467 | 482 | } |
483 | ||
0b342e78 | 484 | //====================== for 2D track distributions ===============================// |
21fba467 | 485 | |
0b342e78 | 486 | void plot2D( THnSparse* h, TText *hText, TString folder, |
21fba467 | 487 | double minEta, double maxEta, |
488 | double minPt, double maxPt, | |
489 | double minDCAr, double maxDCAr, | |
490 | double minDCAz, double maxDCAz, | |
491 | int minTPCclus, int maxTPCclus, | |
492 | int minITSclus, int maxITSclus, | |
493 | int minTrackMult, int maxTrackMult, | |
d99d5e30 | 494 | int vs, float vz, |
495 | float minCent, float maxCent | |
21fba467 | 496 | ) |
21fba467 | 497 | { |
21fba467 | 498 | h->GetAxis(0)->SetRangeUser(minPt,maxPt); |
499 | h->GetAxis(1)->SetRangeUser(minTPCclus,maxTPCclus); | |
500 | h->GetAxis(3)->SetRangeUser(minEta, maxEta); | |
501 | h->GetAxis(5)->SetRangeUser(minDCAr, maxDCAr); | |
502 | h->GetAxis(6)->SetRangeUser(minDCAz, maxDCAz); | |
d99d5e30 | 503 | h->GetAxis(8)->SetRangeUser(minITSclus, maxITSclus); |
504 | h->GetAxis(9)->SetRangeUser(minTrackMult, maxTrackMult); | |
505 | if(vs!=2) h->GetAxis(10)->SetRangeUser(vs,vs); | |
506 | h->GetAxis(11)->SetRangeUser(-TMath::Abs(vz), TMath::Abs(vz)); | |
507 | if(h->GetNdimensions()==13) h->GetAxis(12)->SetRangeUser(minCent, maxCent); | |
21fba467 | 508 | |
0b342e78 | 509 | TString name = h->GetName(); |
510 | TString tmp = ""; | |
511 | if(name.Contains("HLT")) tmp = "HLT 2-D track distributions for "; | |
512 | else tmp = "OFF 2-D track distributions for "; | |
513 | ||
514 | tmp += hText->GetTitle(); | |
515 | TCanvas *can4 = new TCanvas("can4",tmp,1200,800); | |
516 | can4->Divide(4,2); | |
517 | ||
518 | can4->cd(1); | |
d99d5e30 | 519 | TH2D *ht = h->Projection(1,0); // TPC clusters/track vs. pt |
56ce6b77 | 520 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(0)->GetTitle())); |
2de8763b | 521 | |
c5bbc97b | 522 | TString s = ""; |
523 | s = fix1DTitle(h->Projection(0)->GetTitle())+" (GeV/c)"; | |
2de8763b | 524 | ht->SetXTitle(s); |
56ce6b77 | 525 | ht->Draw("colz"); |
526 | ||
0b342e78 | 527 | can4->cd(2); |
d99d5e30 | 528 | ht = h->Projection(1,3); // TPC clusters/track vs. eta |
56ce6b77 | 529 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(3)->GetTitle())); |
530 | ht->Draw("colz"); | |
531 | ||
0b342e78 | 532 | can4->cd(3); |
d99d5e30 | 533 | ht = h->Projection(1,5); // TPC clusters/track vs. DCAr |
56ce6b77 | 534 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(5)->GetTitle())); |
c5bbc97b | 535 | s = fix1DTitle(h->Projection(5)->GetTitle())+" (cm)"; |
2de8763b | 536 | ht->SetXTitle(s); |
56ce6b77 | 537 | ht->Draw("colz"); |
538 | ||
0b342e78 | 539 | can4->cd(4); |
d99d5e30 | 540 | ht = h->Projection(1,6); // TPC clusters/track vs. DCAz |
56ce6b77 | 541 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(6)->GetTitle())); |
c5bbc97b | 542 | s = fix1DTitle(h->Projection(6)->GetTitle())+" (cm)"; |
2de8763b | 543 | ht->SetXTitle(s); |
56ce6b77 | 544 | ht->Draw("colz"); |
21fba467 | 545 | |
0b342e78 | 546 | can4->cd(5); |
d99d5e30 | 547 | ht = h->Projection(5,0); // DCAr vs. pt |
548 | ht->SetTitle(fix2DTitle(h->Projection(5)->GetTitle(), h->Projection(0)->GetTitle())); | |
c5bbc97b | 549 | s = fix1DTitle(h->Projection(0)->GetTitle())+" (GeV/c)"; |
2de8763b | 550 | ht->SetXTitle(s); |
d99d5e30 | 551 | s = fix1DTitle(h->Projection(5)->GetTitle())+" (cm)"; |
2de8763b | 552 | ht->SetYTitle(s); |
56ce6b77 | 553 | ht->Draw("colz"); |
554 | ||
0b342e78 | 555 | can4->cd(6); |
d99d5e30 | 556 | ht = h->Projection(6,3); // DCAz vs. pt |
56ce6b77 | 557 | ht->SetTitle(fix2DTitle(h->Projection(6)->GetTitle(), h->Projection(3)->GetTitle())); |
c5bbc97b | 558 | s = fix1DTitle(h->Projection(6)->GetTitle())+" (cm)"; |
2de8763b | 559 | ht->SetYTitle(s); |
56ce6b77 | 560 | ht->Draw("colz"); |
561 | ||
0b342e78 | 562 | can4->cd(7); |
d99d5e30 | 563 | ht = h->Projection(3,0); // eta vs. pt |
56ce6b77 | 564 | ht->SetTitle(fix2DTitle(h->Projection(3)->GetTitle(), h->Projection(0)->GetTitle())); |
c5bbc97b | 565 | s = fix1DTitle(h->Projection(0)->GetTitle())+" (GeV/c)"; |
2de8763b | 566 | ht->SetXTitle(s); |
56ce6b77 | 567 | ht->Draw("colz"); |
568 | ||
0b342e78 | 569 | can4->cd(8); |
d99d5e30 | 570 | ht = h->Projection(3,4); // eta vs. phi |
56ce6b77 | 571 | ht->SetTitle(fix2DTitle(h->Projection(3)->GetTitle(), h->Projection(4)->GetTitle())); |
c5bbc97b | 572 | s = fix1DTitle(h->Projection(4)->GetTitle())+" (rad)"; |
2de8763b | 573 | ht->SetXTitle(s); |
0b342e78 | 574 | ht->Draw("colz"); |
21fba467 | 575 | |
0b342e78 | 576 | TString cuts = cutsToString(minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, |
577 | minITSclus, maxITSclus, minTrackMult, maxTrackMult, vs, vz); | |
578 | if(name.Contains("HLT")){ | |
579 | can4->SaveAs(folder+"/HLT_2D_track_correlations_"+cuts+".root"); | |
580 | can4->SaveAs(folder+"/HLT_2D_track_correlations_"+cuts+".png"); | |
581 | } else { | |
582 | can4->SaveAs(folder+"/OFF_2D_track_correlations_"+cuts+".root"); | |
583 | can4->SaveAs(folder+"/OFF_2D_track_correlations_"+cuts+".png"); | |
584 | } | |
585 | delete can4; | |
56ce6b77 | 586 | return; |
587 | } | |
588 | ||
15c6e37d | 589 | TString cutsToString( double minEta, double maxEta, |
590 | double minPt, double maxPt, | |
591 | double minDCAr, double maxDCAr, | |
592 | double minDCAz, double maxDCAz, | |
593 | int minTPCclus, int maxTPCclus, | |
594 | int minITSclus, int maxITSclus, | |
595 | int minTrackMult, int maxTrackMult, | |
d99d5e30 | 596 | int vs, float vz |
597 | // float minCent, float maxCent | |
15c6e37d | 598 | ) |
599 | { | |
15c6e37d | 600 | TString cuts = ""; |
d99d5e30 | 601 | char s[300]; sprintf(s, "eta%2g_%2g_Pt%2g_%2g_TM%d_%d_DCAr%2g_%2g_DCAz%2g_%2g_TPCclus%d_%d_ITSclus%d_%d_Zvertex%2g", |
602 | minEta,maxEta,minPt,maxPt,minTrackMult,maxTrackMult,minDCAr,maxDCAr,minDCAz,maxDCAz,minTPCclus,maxTPCclus,minITSclus,maxITSclus,vz); | |
b1ab272c | 603 | cuts = s; cuts.ReplaceAll(" ",""); |
604 | ||
d99d5e30 | 605 | if(vs!=2){ |
b1ab272c | 606 | char v[10]; |
d99d5e30 | 607 | sprintf(v, "_VS%d",vs); |
b1ab272c | 608 | cuts+=v; |
609 | } | |
15c6e37d | 610 | return cuts; |
611 | } | |
d99d5e30 | 612 | |
613 | void printStats(TH1D *hlt, TH1D *off){ | |
614 | gPad->Update(); | |
615 | TPaveStats *st1 = (TPaveStats*)hlt->FindObject("stats"); | |
616 | st1->SetLineColor(0); | |
0b342e78 | 617 | st1->SetTextSize(7); |
618 | st1->SetTextFont(8); | |
d99d5e30 | 619 | |
620 | gPad->Update(); | |
621 | TPaveStats *st2 = (TPaveStats*)off->FindObject("stats"); | |
622 | st2->SetY2NDC(st1->GetY1NDC()-0.05); | |
623 | st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC())); | |
624 | st2->SetLineColor(0); | |
625 | st2->SetTextColor(off->GetLineColor()); | |
626 | st2->SetFillStyle(0); | |
0b342e78 | 627 | st2->SetTextSize(7); |
628 | st2->SetTextFont(8); | |
d99d5e30 | 629 | st2->Draw(); |
630 | } | |
631 | ||
632 | void defineYaxisMax(TH1D *hlt, TH1D *off){ | |
633 | if(hlt->GetMaximum() > off->GetMaximum()) off->SetMaximum(1.1*hlt->GetMaximum()); | |
634 | else hlt->SetMaximum(1.1*off->GetMaximum()); | |
635 | } | |
636 | ||
0b342e78 | 637 | void printLegend(TH1D *hlt, TH1D *off){ |
638 | TLegend *l = new TLegend(0.6,0.6,0.8,0.8); | |
d99d5e30 | 639 | l->SetFillColor(10); |
640 | l->SetLineColor(10); | |
641 | l->AddEntry(hlt, "HLT", "l"); | |
642 | l->AddEntry(off, "OFF", "l"); | |
643 | l->Draw("same"); | |
644 | } | |
0b342e78 | 645 | |
646 | TString fix1DTitle(const char* c){ | |
647 | TString tmp = c; | |
648 | tmp.ReplaceAll("projection ",""); | |
649 | return tmp; | |
650 | } | |
651 | ||
652 | TString fix2DTitle(const char* c1, const char* c2){ | |
653 | TString tmp = fix1DTitle(c1)+" vs."+fix1DTitle(c2); | |
654 | return tmp; | |
655 | } |