]>
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); | |
38faad18 | 63 | void defineYaxisMax(TH1D *h1, TH1D *h2); |
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); |
8dfb6a5c | 154 | else { |
155 | if(heventHLT->GetEntries()==0) printf("\nThe HLT event THnSparse contains 0 entries\n"); | |
156 | if(heventOFF->GetEntries()==0) printf("\nThe OFF event THnSparse contains 0 entries\n"); | |
157 | } | |
0b342e78 | 158 | |
38faad18 | 159 | int counter = 0; |
0b342e78 | 160 | // counts how many times the function cutStudies() is called |
161 | // if more than once, then it creates and fills the canvas with the overlapping hlt distributions for the various sets of cuts | |
c5c3a9ed | 162 | |
0b342e78 | 163 | TString s = ""; // eta mult pt DCAr DCAz TPCclus ITSclus vertexStatus |vertexZ| |
38faad18 | 164 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -2, 2, 0, 2000, 0, 10, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; |
0b342e78 | 165 | /* |
38faad18 | 166 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 10, -10, 10, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; |
167 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 10, -7, 7, -10, 10, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
168 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0, 10, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
169 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 10, -7, 7, -7, 7, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
170 | s = cutStudies(folder, htrackHLT, htrackOFF, hText, -1, 1, 0, 2000, 0.25, 10, -3, 3, -3, 3, 0, 200, 0, 6, 2, 10, 0, 100); outputNames.push_back(s); counter++; | |
0b342e78 | 171 | */ |
172 | ||
173 | if(counter>=2){ | |
174 | TString tmp = "overlaid HLT track distributions for "; | |
175 | tmp += hText->GetTitle(); | |
176 | TCanvas *ovHLT = new TCanvas("ovHLT",tmp,1100,900); | |
177 | ovHLT->Divide(3,3); | |
d99d5e30 | 178 | |
0b342e78 | 179 | tmp = "overlaid OFF track distributions for "; |
180 | tmp += hText->GetTitle(); | |
181 | TCanvas *ovOFF = new TCanvas("ovOFF",tmp,1100,900); | |
182 | ovOFF->Divide(3,3); | |
d99d5e30 | 183 | |
0b342e78 | 184 | TCanvas *ca; TFile *ff; TPad *pad; |
185 | TH1D *hlt[outputNames.size()]; | |
186 | TH1D *off[outputNames.size()]; | |
187 | ||
188 | for(int j=1; j<10; j++){ // loop over the pads of the canvas "ov" with dimension 3x3 | |
189 | for(UInt_t i=0; i<outputNames.size(); i++){ // loop over the files with different sets of cuts | |
190 | ||
191 | ff = TFile::Open(outputNames[i].Data()); | |
192 | if(!ff || ff->IsZombie()){ | |
193 | printf("Non-existent, corrupted or zombie file %s\n", outputNames[i].Data()); | |
194 | return; | |
195 | } | |
196 | ca = (TCanvas*)ff->GetObjectUnchecked("can3"); | |
197 | if(!ca){ | |
198 | printf("Empty canvas in file %s.\n", outputNames[i].Data()); | |
199 | continue; | |
200 | } | |
201 | pad = (TPad*)ca->GetListOfPrimitives()->FindObject(Form("can3_%d",j)); | |
202 | if(!pad){ | |
203 | printf("Empty pad in canvas %s.\n", ca->GetName()); | |
204 | continue; | |
205 | } | |
206 | hlt[i] =(TH1D*)pad->FindObject(Form("fTrackHLT_proj_%d",j-1)); | |
207 | off[i] =(TH1D*)pad->FindObject(Form("fTrackOFF_proj_%d",j-1)); | |
208 | if(!hlt[i] || !off[i]){ | |
209 | printf("Empty histogram for i=%d, file %s.\n", i, outputNames[i].Data()); | |
210 | continue; | |
211 | } | |
212 | ovHLT->cd(j); | |
213 | if(i==0){ | |
214 | TPaveStats *st = (TPaveStats*)hlt[i]->FindObject("stats"); | |
215 | st->SetTextColor(kBlack); | |
216 | hlt[i]->Draw(); | |
217 | } | |
218 | else { | |
219 | hlt[i]->SetLineColor(i+1); | |
220 | defineYaxisMax(hlt[0], hlt[i]); | |
221 | hlt[i]->Draw("sames"); | |
222 | } | |
223 | if(i>0) printStats(hlt[i-1], hlt[i]); | |
224 | ||
225 | ovOFF->cd(j); | |
226 | if(i==0){ | |
227 | off[i]->SetLineColor(kBlack); | |
228 | TPaveStats *st = (TPaveStats*)off[i]->FindObject("stats"); | |
229 | st->SetTextColor(kBlack); | |
230 | off[i]->Draw(); | |
231 | } | |
232 | else { | |
233 | off[i]->SetLineColor(i+1); | |
234 | defineYaxisMax(off[0], off[i]); | |
235 | off[i]->Draw("sames"); | |
236 | } | |
237 | if(i>0) printStats(off[i-1], off[i]); | |
238 | ||
239 | ff->Close(); | |
240 | } // end of loop over files | |
241 | } // end of loop over canvas pads | |
242 | file->Close(); | |
243 | ovHLT->SaveAs(folder+"/overlaid_HLT_track_cuts.root"); | |
244 | ovHLT->SaveAs(folder+"/overlaid_HLT_track_cuts.png"); | |
245 | ovOFF->SaveAs(folder+"/overlaid_OFF_track_cuts.root"); | |
246 | ovOFF->SaveAs(folder+"/overlaid_OFF_track_cuts.png"); | |
247 | delete ovHLT; | |
248 | delete ovOFF; | |
249 | } // end if for counter>=2 | |
250 | return; | |
c5c3a9ed | 251 | } |
252 | ||
d99d5e30 | 253 | // ============== main function for filling the track properties, 1D and 2D ================ // |
254 | ||
0b342e78 | 255 | TString cutStudies( TString folder, |
c5bbc97b | 256 | THnSparse* htrackHLT, THnSparse* htrackOFF, TText* hText, |
257 | double minEta, double maxEta, | |
258 | int minTrackMult,int maxTrackMult, | |
259 | double minPt, double maxPt, | |
260 | double minDCAr, double maxDCAr, | |
261 | double minDCAz, double maxDCAz, | |
262 | int minTPCclus, int maxTPCclus, | |
263 | int minITSclus, int maxITSclus, | |
d99d5e30 | 264 | int vs, float vz, |
265 | float minCent, float maxCent | |
266 | ){ | |
0b342e78 | 267 | |
268 | plotTrackQuantities(htrackHLT, htrackOFF, hText, folder, | |
269 | minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, minITSclus, maxITSclus, | |
270 | minTrackMult, maxTrackMult, vs, vz, minCent, maxCent); | |
271 | ||
272 | if(htrackHLT->GetEntries()>0) plot2D(htrackHLT, hText, folder, minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, minITSclus, maxITSclus, | |
273 | minTrackMult, maxTrackMult, vs, vz, minCent, maxCent); | |
274 | ||
275 | if(htrackOFF->GetEntries()>0) plot2D(htrackOFF, hText, folder, minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, minITSclus, maxITSclus, | |
276 | minTrackMult, maxTrackMult, vs, vz, minCent, maxCent); | |
277 | ||
278 | TString cuts = cutsToString(minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, | |
279 | minITSclus, maxITSclus, minTrackMult, maxTrackMult, vs, vz); | |
280 | ||
281 | return folder+"/track_properties_"+cuts+".root"; // same name as the one produced by plotTrackQuantities internally | |
282 | } | |
283 | ||
284 | void plotEventQuantities(THnSparse* heventHLT, THnSparse* heventOFF, TText* hText, TString folder){ | |
285 | ||
286 | TString tmp = "vertex event properties for "; | |
287 | tmp += hText->GetTitle(); | |
288 | TCanvas *can1 = new TCanvas("can1",tmp,1200,700); | |
289 | can1->Divide(3,2); | |
290 | ||
291 | heventHLT->GetAxis(8)->SetRangeUser(1,1); // select events with existing primary vertex | |
292 | heventOFF->GetAxis(8)->SetRangeUser(1,1); | |
293 | TH1D *hlt = NULL; | |
294 | TH1D *off = NULL; | |
295 | ||
296 | for(int i=0; i<6; i++){ // loop for HLT/OFF primary and SPD vertex xyz | |
297 | can1->cd(i+1); | |
298 | hlt = heventHLT->Projection(i); if(!hlt){ printf("plotEventQuantities: empty HLT histogram, projection %d\n",i); continue; } | |
299 | off = heventOFF->Projection(i); if(!off){ printf("plotEventQuantities: empty OFF histogram, projection %d\n",i); continue; } | |
300 | off->SetLineColor(2); | |
301 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(i)->GetTitle())); | |
302 | off->SetTitle(fix1DTitle(heventOFF->Projection(i)->GetTitle())); | |
303 | TString s = hlt->GetTitle(); | |
304 | if(s.Contains("primary")){ | |
305 | s+=" (cm)"; | |
306 | hlt->SetXTitle(s); | |
307 | off->SetXTitle(s); | |
308 | } | |
309 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
310 | ||
311 | if(hlt->GetEntries()>0) hlt->Draw(); | |
312 | if(off->GetEntries()>0) off->Draw("sames"); | |
313 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
314 | if(off->GetEntries()>0 && i==0 ) printLegend(hlt,off); | |
315 | } | |
316 | ||
317 | tmp = "general event properties for "; | |
318 | tmp += hText->GetTitle(); | |
319 | TCanvas *can2 = new TCanvas("can2",tmp,1200,700); | |
320 | can2->Divide(3,2); | |
c5c3a9ed | 321 | |
0b342e78 | 322 | can2->cd(1); // track multiplicity |
323 | hlt = heventHLT->Projection(7); | |
324 | off = heventOFF->Projection(7); | |
325 | off->SetLineColor(2); | |
326 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(7)->GetTitle())); | |
327 | off->SetTitle(fix1DTitle(heventOFF->Projection(7)->GetTitle())); | |
328 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
329 | if(hlt->GetEntries()>0) hlt->Draw(); | |
330 | if(off->GetEntries()>0){ off->Draw("sames"); printLegend(hlt,off); } | |
331 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
332 | ||
333 | can2->cd(2); // number of contributors | |
334 | hlt = heventHLT->Projection(6); | |
335 | off = heventOFF->Projection(6); | |
336 | off->SetLineColor(2); | |
337 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(6)->GetTitle())); | |
338 | off->SetTitle(fix1DTitle(heventOFF->Projection(6)->GetTitle())); | |
339 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
340 | if(hlt->GetEntries()>0) hlt->Draw(); | |
341 | if(off->GetEntries()>0) off->Draw("sames"); | |
342 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
343 | ||
344 | can2->cd(3); // vertex status | |
345 | hlt = heventHLT->Projection(8); | |
346 | off = heventOFF->Projection(8); | |
347 | off->SetLineColor(2); | |
348 | hlt->SetTitle(fix1DTitle(heventHLT->Projection(8)->GetTitle())); | |
349 | off->SetTitle(fix1DTitle(heventOFF->Projection(8)->GetTitle())); | |
350 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
351 | if(hlt->GetEntries()>0) hlt->Draw(); | |
352 | if(off->GetEntries()>0) off->Draw("sames"); | |
353 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
354 | ||
355 | can2->cd(4); // # of contributors vs. track multiplicity for HLT | |
356 | TH2D *h = heventHLT->Projection(6,7); | |
357 | TString s1 = fix2DTitle(heventHLT->Projection(6)->GetTitle(), heventHLT->Projection(7)->GetTitle()); s1+=" (HLT)"; | |
358 | h->SetTitle(s1); | |
359 | h->Draw("colz"); | |
360 | ||
361 | can2->cd(5); // # of contributors vs. track multiplicity for OFF | |
362 | TH2D *o = heventOFF->Projection(6,7); | |
363 | s1 = fix2DTitle(heventOFF->Projection(6)->GetTitle(), heventOFF->Projection(7)->GetTitle()); s1+=" (OFF)"; | |
364 | o->SetTitle(s1); | |
365 | o->Draw("colz"); | |
366 | ||
367 | if(heventHLT->GetNdimensions()==10){ | |
368 | can2->cd(6); | |
369 | off = heventOFF->Projection(9); // V0 centrality, taken from the offline ESD | |
370 | off->SetTitle(fix1DTitle(heventOFF->Projection(9)->GetTitle())); | |
371 | off->SetLineColor(2); | |
372 | off->Draw(); | |
373 | } | |
374 | ||
375 | can1->SaveAs(folder+"/vertex_event_properties.root"); | |
376 | can1->SaveAs(folder+"/vertex_event_properties.png"); | |
377 | can2->SaveAs(folder+"/general_event_properties.root"); | |
378 | can2->SaveAs(folder+"/general_event_properties.png"); | |
379 | delete can1; | |
380 | delete can2; | |
381 | return; | |
382 | } | |
383 | ||
384 | void plotTrackQuantities( THnSparse* htrackHLT, THnSparse* htrackOFF, | |
385 | TText* hText, TString folder, | |
386 | double minEta, double maxEta, | |
387 | double minPt, double maxPt, | |
388 | double minDCAr, double maxDCAr, | |
389 | double minDCAz, double maxDCAz, | |
390 | int minTPCclus, int maxTPCclus, | |
391 | int minITSclus, int maxITSclus, | |
392 | int minTrackMult, int maxTrackMult, | |
393 | int vs, float vz, | |
394 | float minCent, float maxCent | |
395 | ) | |
396 | { | |
397 | ||
398 | htrackHLT->GetAxis(0)->SetRangeUser(minPt,maxPt); | |
399 | htrackHLT->GetAxis(1)->SetRangeUser(minTPCclus,maxTPCclus); | |
400 | htrackHLT->GetAxis(3)->SetRangeUser(minEta, maxEta); | |
401 | htrackHLT->GetAxis(5)->SetRangeUser(minDCAr, maxDCAr); | |
402 | htrackHLT->GetAxis(6)->SetRangeUser(minDCAz, maxDCAz); | |
403 | htrackHLT->GetAxis(8)->SetRangeUser(minITSclus, maxITSclus); | |
404 | htrackHLT->GetAxis(9)->SetRangeUser(minTrackMult, maxTrackMult); | |
405 | if(vs!=2) htrackHLT->GetAxis(10)->SetRangeUser(vs,vs); | |
406 | htrackHLT->GetAxis(11)->SetRangeUser(-TMath::Abs(vz), TMath::Abs(vz)); | |
407 | if(htrackHLT->GetNdimensions()==13) htrackHLT->GetAxis(12)->SetRangeUser(minCent, maxCent); | |
408 | ||
409 | htrackOFF->GetAxis(0)->SetRangeUser(minPt,maxPt); | |
410 | htrackOFF->GetAxis(1)->SetRangeUser(minTPCclus,maxTPCclus); | |
411 | htrackOFF->GetAxis(3)->SetRangeUser(minEta, maxEta); | |
412 | htrackOFF->GetAxis(5)->SetRangeUser(minDCAr, maxDCAr); | |
413 | htrackOFF->GetAxis(6)->SetRangeUser(minDCAz, maxDCAz); | |
414 | htrackOFF->GetAxis(8)->SetRangeUser(minITSclus, maxITSclus); | |
415 | htrackOFF->GetAxis(9)->SetRangeUser(minTrackMult, maxTrackMult); | |
416 | if(vs!=2) htrackOFF->GetAxis(10)->SetRangeUser(vs,vs); | |
417 | htrackOFF->GetAxis(11)->SetRangeUser(-TMath::Abs(vz), TMath::Abs(vz)); | |
418 | if(htrackOFF->GetNdimensions()==13) htrackOFF->GetAxis(12)->SetRangeUser(minCent, maxCent); | |
419 | ||
420 | TString tmp = ""; | |
421 | tmp += "track properties for "; | |
422 | tmp+=hText->GetTitle(); | |
423 | TCanvas *can3 = new TCanvas("can3",tmp,1100,900); | |
424 | can3->Divide(3,3); | |
425 | // the first 9 track related variables filled in the THnSparse | |
426 | // 0 1 2 3 4 5 6 7 8 | |
427 | // pt TPCcl theta eta phi DCAr DCAz charge ITScl | |
c5c3a9ed | 428 | |
0b342e78 | 429 | TH1D *hlt = NULL; |
430 | TH1D *off = NULL; | |
431 | ||
432 | for(int i=0; i<9; i++){ | |
433 | hlt = htrackHLT->Projection(i); if(!hlt){ printf("plotTrackQuantities: empty HLT histogram for projection %d\n",i); continue; } | |
434 | off = htrackOFF->Projection(i); if(!off){ printf("plotTrackQuantities: empty OFF histogram for projection %d\n",i); continue; } | |
435 | hlt->SetTitle(fix1DTitle(htrackHLT->Projection(i)->GetTitle())); | |
436 | off->SetTitle(fix1DTitle(htrackOFF->Projection(i)->GetTitle())); // is necessary in cases where only offline data is available | |
437 | ||
438 | TString s = hlt->GetTitle(); | |
439 | if(s.Contains("p_")){ | |
440 | s+=" (GeV/c)"; | |
441 | hlt->SetXTitle(s); | |
442 | } | |
443 | else if(s.Contains("theta") || s.Contains("phi")){ | |
444 | s+=" (rad)"; | |
445 | hlt->SetXTitle(s); | |
446 | } | |
447 | else if(s.Contains("DCA")){ | |
448 | s+=" (cm)"; | |
449 | hlt->SetXTitle(s); | |
450 | } | |
451 | ||
452 | if(off->GetEntries()>0) defineYaxisMax(hlt, off); | |
453 | off->SetLineColor(2); | |
454 | ||
455 | can3->cd(i+1); | |
456 | if(hlt->GetEntries()>0) hlt->Draw(); | |
457 | if(off->GetEntries()>0) off->Draw("sames"); | |
458 | if(hlt->GetEntries()>0 && off->GetEntries()>0) printStats(hlt, off); | |
459 | if(off->GetEntries()>0 && i==0 ) printLegend(hlt,off); | |
460 | ||
461 | if(hlt->GetEntries()>0 && i==0){ | |
462 | TPaveText *pave = new TPaveText(25,5600,140,36400); | |
463 | pave->SetFillColor(kWhite); | |
464 | pave->SetLineColor(kWhite); | |
465 | pave->SetShadowColor(kWhite); | |
466 | s=""; s+=minEta; s+=" < eta < "; s+=maxEta; pave->AddText(s); | |
467 | s=""; s+=minPt; s+=" < pt (GeV/c) < "; s+=maxPt; pave->AddText(s); | |
468 | s=""; s+=minTrackMult; s+=" < track mult < "; s+=maxTrackMult; pave->AddText(s); | |
469 | s=""; s+=minDCAr; s+=" < DCAr (cm) < "; s+=maxDCAr; pave->AddText(s); | |
470 | s=""; s+=minDCAz; s+=" < DCAz (cm) < "; s+=maxDCAz; pave->AddText(s); | |
471 | s=""; s+=minTPCclus; s+=" < TPC clusters/track < "; s+=maxTPCclus; pave->AddText(s); | |
472 | s=""; s+=minITSclus; s+=" < ITS clusters/track < "; s+=maxITSclus; pave->AddText(s); | |
473 | if(vs!=2) { s=""; s+="vertex status "; s+=vs; pave->AddText(s); } | |
474 | pave->Draw(); | |
475 | can3->Update(); | |
476 | } | |
477 | } | |
c5c3a9ed | 478 | TString cuts = cutsToString(minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, |
d99d5e30 | 479 | minITSclus, maxITSclus, minTrackMult, maxTrackMult, vs, vz); |
21fba467 | 480 | |
0b342e78 | 481 | can3->SaveAs(folder+"/track_properties_"+cuts+".root"); |
482 | can3->SaveAs(folder+"/track_properties_"+cuts+".png"); | |
483 | delete can3; | |
484 | ||
485 | return; | |
21fba467 | 486 | } |
487 | ||
0b342e78 | 488 | //====================== for 2D track distributions ===============================// |
21fba467 | 489 | |
0b342e78 | 490 | void plot2D( THnSparse* h, TText *hText, TString folder, |
21fba467 | 491 | double minEta, double maxEta, |
492 | double minPt, double maxPt, | |
493 | double minDCAr, double maxDCAr, | |
494 | double minDCAz, double maxDCAz, | |
495 | int minTPCclus, int maxTPCclus, | |
496 | int minITSclus, int maxITSclus, | |
497 | int minTrackMult, int maxTrackMult, | |
d99d5e30 | 498 | int vs, float vz, |
499 | float minCent, float maxCent | |
21fba467 | 500 | ) |
21fba467 | 501 | { |
21fba467 | 502 | h->GetAxis(0)->SetRangeUser(minPt,maxPt); |
503 | h->GetAxis(1)->SetRangeUser(minTPCclus,maxTPCclus); | |
504 | h->GetAxis(3)->SetRangeUser(minEta, maxEta); | |
505 | h->GetAxis(5)->SetRangeUser(minDCAr, maxDCAr); | |
506 | h->GetAxis(6)->SetRangeUser(minDCAz, maxDCAz); | |
d99d5e30 | 507 | h->GetAxis(8)->SetRangeUser(minITSclus, maxITSclus); |
508 | h->GetAxis(9)->SetRangeUser(minTrackMult, maxTrackMult); | |
509 | if(vs!=2) h->GetAxis(10)->SetRangeUser(vs,vs); | |
510 | h->GetAxis(11)->SetRangeUser(-TMath::Abs(vz), TMath::Abs(vz)); | |
511 | if(h->GetNdimensions()==13) h->GetAxis(12)->SetRangeUser(minCent, maxCent); | |
21fba467 | 512 | |
0b342e78 | 513 | TString name = h->GetName(); |
514 | TString tmp = ""; | |
515 | if(name.Contains("HLT")) tmp = "HLT 2-D track distributions for "; | |
516 | else tmp = "OFF 2-D track distributions for "; | |
517 | ||
518 | tmp += hText->GetTitle(); | |
519 | TCanvas *can4 = new TCanvas("can4",tmp,1200,800); | |
520 | can4->Divide(4,2); | |
521 | ||
522 | can4->cd(1); | |
d99d5e30 | 523 | TH2D *ht = h->Projection(1,0); // TPC clusters/track vs. pt |
56ce6b77 | 524 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(0)->GetTitle())); |
2de8763b | 525 | |
c5bbc97b | 526 | TString s = ""; |
527 | s = fix1DTitle(h->Projection(0)->GetTitle())+" (GeV/c)"; | |
2de8763b | 528 | ht->SetXTitle(s); |
56ce6b77 | 529 | ht->Draw("colz"); |
530 | ||
0b342e78 | 531 | can4->cd(2); |
d99d5e30 | 532 | ht = h->Projection(1,3); // TPC clusters/track vs. eta |
56ce6b77 | 533 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(3)->GetTitle())); |
534 | ht->Draw("colz"); | |
535 | ||
0b342e78 | 536 | can4->cd(3); |
d99d5e30 | 537 | ht = h->Projection(1,5); // TPC clusters/track vs. DCAr |
56ce6b77 | 538 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(5)->GetTitle())); |
c5bbc97b | 539 | s = fix1DTitle(h->Projection(5)->GetTitle())+" (cm)"; |
2de8763b | 540 | ht->SetXTitle(s); |
56ce6b77 | 541 | ht->Draw("colz"); |
542 | ||
0b342e78 | 543 | can4->cd(4); |
d99d5e30 | 544 | ht = h->Projection(1,6); // TPC clusters/track vs. DCAz |
56ce6b77 | 545 | ht->SetTitle(fix2DTitle(h->Projection(1)->GetTitle(), h->Projection(6)->GetTitle())); |
c5bbc97b | 546 | s = fix1DTitle(h->Projection(6)->GetTitle())+" (cm)"; |
2de8763b | 547 | ht->SetXTitle(s); |
56ce6b77 | 548 | ht->Draw("colz"); |
21fba467 | 549 | |
0b342e78 | 550 | can4->cd(5); |
d99d5e30 | 551 | ht = h->Projection(5,0); // DCAr vs. pt |
552 | ht->SetTitle(fix2DTitle(h->Projection(5)->GetTitle(), h->Projection(0)->GetTitle())); | |
c5bbc97b | 553 | s = fix1DTitle(h->Projection(0)->GetTitle())+" (GeV/c)"; |
2de8763b | 554 | ht->SetXTitle(s); |
d99d5e30 | 555 | s = fix1DTitle(h->Projection(5)->GetTitle())+" (cm)"; |
2de8763b | 556 | ht->SetYTitle(s); |
56ce6b77 | 557 | ht->Draw("colz"); |
558 | ||
0b342e78 | 559 | can4->cd(6); |
d99d5e30 | 560 | ht = h->Projection(6,3); // DCAz vs. pt |
56ce6b77 | 561 | ht->SetTitle(fix2DTitle(h->Projection(6)->GetTitle(), h->Projection(3)->GetTitle())); |
c5bbc97b | 562 | s = fix1DTitle(h->Projection(6)->GetTitle())+" (cm)"; |
2de8763b | 563 | ht->SetYTitle(s); |
56ce6b77 | 564 | ht->Draw("colz"); |
565 | ||
0b342e78 | 566 | can4->cd(7); |
d99d5e30 | 567 | ht = h->Projection(3,0); // eta vs. pt |
56ce6b77 | 568 | ht->SetTitle(fix2DTitle(h->Projection(3)->GetTitle(), h->Projection(0)->GetTitle())); |
c5bbc97b | 569 | s = fix1DTitle(h->Projection(0)->GetTitle())+" (GeV/c)"; |
2de8763b | 570 | ht->SetXTitle(s); |
56ce6b77 | 571 | ht->Draw("colz"); |
572 | ||
0b342e78 | 573 | can4->cd(8); |
d99d5e30 | 574 | ht = h->Projection(3,4); // eta vs. phi |
56ce6b77 | 575 | ht->SetTitle(fix2DTitle(h->Projection(3)->GetTitle(), h->Projection(4)->GetTitle())); |
c5bbc97b | 576 | s = fix1DTitle(h->Projection(4)->GetTitle())+" (rad)"; |
2de8763b | 577 | ht->SetXTitle(s); |
0b342e78 | 578 | ht->Draw("colz"); |
21fba467 | 579 | |
0b342e78 | 580 | TString cuts = cutsToString(minEta, maxEta, minPt, maxPt, minDCAr, maxDCAr, minDCAz, maxDCAz, minTPCclus, maxTPCclus, |
581 | minITSclus, maxITSclus, minTrackMult, maxTrackMult, vs, vz); | |
582 | if(name.Contains("HLT")){ | |
583 | can4->SaveAs(folder+"/HLT_2D_track_correlations_"+cuts+".root"); | |
584 | can4->SaveAs(folder+"/HLT_2D_track_correlations_"+cuts+".png"); | |
585 | } else { | |
586 | can4->SaveAs(folder+"/OFF_2D_track_correlations_"+cuts+".root"); | |
587 | can4->SaveAs(folder+"/OFF_2D_track_correlations_"+cuts+".png"); | |
588 | } | |
589 | delete can4; | |
56ce6b77 | 590 | return; |
591 | } | |
592 | ||
15c6e37d | 593 | TString cutsToString( double minEta, double maxEta, |
594 | double minPt, double maxPt, | |
595 | double minDCAr, double maxDCAr, | |
596 | double minDCAz, double maxDCAz, | |
597 | int minTPCclus, int maxTPCclus, | |
598 | int minITSclus, int maxITSclus, | |
599 | int minTrackMult, int maxTrackMult, | |
d99d5e30 | 600 | int vs, float vz |
601 | // float minCent, float maxCent | |
15c6e37d | 602 | ) |
603 | { | |
15c6e37d | 604 | TString cuts = ""; |
d99d5e30 | 605 | 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", |
606 | minEta,maxEta,minPt,maxPt,minTrackMult,maxTrackMult,minDCAr,maxDCAr,minDCAz,maxDCAz,minTPCclus,maxTPCclus,minITSclus,maxITSclus,vz); | |
b1ab272c | 607 | cuts = s; cuts.ReplaceAll(" ",""); |
608 | ||
d99d5e30 | 609 | if(vs!=2){ |
b1ab272c | 610 | char v[10]; |
d99d5e30 | 611 | sprintf(v, "_VS%d",vs); |
b1ab272c | 612 | cuts+=v; |
613 | } | |
15c6e37d | 614 | return cuts; |
615 | } | |
d99d5e30 | 616 | |
617 | void printStats(TH1D *hlt, TH1D *off){ | |
618 | gPad->Update(); | |
619 | TPaveStats *st1 = (TPaveStats*)hlt->FindObject("stats"); | |
620 | st1->SetLineColor(0); | |
0b342e78 | 621 | st1->SetTextSize(7); |
622 | st1->SetTextFont(8); | |
d99d5e30 | 623 | |
624 | gPad->Update(); | |
625 | TPaveStats *st2 = (TPaveStats*)off->FindObject("stats"); | |
626 | st2->SetY2NDC(st1->GetY1NDC()-0.05); | |
627 | st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC())); | |
628 | st2->SetLineColor(0); | |
629 | st2->SetTextColor(off->GetLineColor()); | |
630 | st2->SetFillStyle(0); | |
0b342e78 | 631 | st2->SetTextSize(7); |
632 | st2->SetTextFont(8); | |
d99d5e30 | 633 | st2->Draw(); |
38faad18 | 634 | return; |
d99d5e30 | 635 | } |
636 | ||
38faad18 | 637 | void defineYaxisMax(TH1D *h1, TH1D *h2){ |
638 | //Y axis | |
639 | if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum()); | |
640 | else h1->SetMaximum(1.1*h2->GetMaximum()); | |
641 | ||
642 | h1->SetMinimum(0); | |
643 | h2->SetMinimum(0); | |
644 | ||
645 | // X axis | |
646 | double xmin, xmax; | |
647 | if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1); | |
648 | else xmin = h2->GetBinLowEdge(1); | |
649 | if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1); | |
650 | else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1); | |
651 | ||
652 | h2->SetAxisRange(xmin, xmax, "X"); | |
653 | return; | |
d99d5e30 | 654 | } |
655 | ||
0b342e78 | 656 | void printLegend(TH1D *hlt, TH1D *off){ |
38faad18 | 657 | TLegend *l = new TLegend(0.5,0.5,0.7,0.7); |
d99d5e30 | 658 | l->SetFillColor(10); |
659 | l->SetLineColor(10); | |
660 | l->AddEntry(hlt, "HLT", "l"); | |
661 | l->AddEntry(off, "OFF", "l"); | |
662 | l->Draw("same"); | |
38faad18 | 663 | return; |
d99d5e30 | 664 | } |
0b342e78 | 665 | |
666 | TString fix1DTitle(const char* c){ | |
667 | TString tmp = c; | |
668 | tmp.ReplaceAll("projection ",""); | |
669 | return tmp; | |
670 | } | |
671 | ||
672 | TString fix2DTitle(const char* c1, const char* c2){ | |
673 | TString tmp = fix1DTitle(c1)+" vs."+fix1DTitle(c2); | |
674 | return tmp; | |
675 | } |