ATLAS Offline Software
Loading...
Searching...
No Matches
EgammaARTmonitoring_plotsMaker.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
4#
5
6import sys
7from ROOT import (gDirectory, gROOT, gStyle, kTRUE,
8 TCanvas, TFile, TLegend, TPad, kBlack, kBlue,
9 kRed, kGreen, kOrange, kCyan, kPink, kGray)
10
11# gROOT.SetBatch(kTRUE)
12gStyle.SetOptStat(0)
13
14cluster_list = [
15 {'name': 'clusterAll', 'title': 'Clusters - Inclusive'},
16 {'name': 'cluster10GeV', 'title': 'Clusters - 10 GeV'},
17 {'name': 'clusterPromptAll', 'title': 'Clusters from Prompt - Inclusive'},
18 {'name': 'clusterPrompt10GeV', 'title': 'Clusters from Prompt - 10 GeV'},
19]
20
21cluster_list_photon = [
22 {'name': 'clusterUnconvPhoton',
23 'title': 'Clusters Unconverted Photons'},
24 {'name': 'clusterConvPhoton',
25 'title': 'Clusters Converted Photons'},
26 {'name': 'clusterConvPhotonSi',
27 'title': 'Clusters Converted Photons - Si'},
28 {'name': 'clusterConvPhotonSiSi',
29 'title': 'Clusters Converted Photons - SiSi'},
30 {'name': 'clusterConvPhotonTRT',
31 'title': 'Clusters Converted Photons - TRT'},
32 {'name': 'clusterConvPhotonTRTTRT',
33 'title': 'Clusters Converted Photons - TRTTRT'},
34 {'name': 'clusterConvPhotonSiTRT',
35 'title': 'Clusters Converted Photons - SiTRT'},
36]
37
38photon_cluster_list = [
39 {'name': 'clusterUnconvPhoton',
40 'title': 'Clusters Unconverted Photons'},
41 {'name': 'clusterConvPhoton',
42 'title': 'Clusters Converted Photons'},
43 {'name': 'clusterConvPhotonSi',
44 'title': 'Clusters Converted Photons - Si'},
45 {'name': 'clusterConvPhotonSiSi',
46 'title': 'Clusters Converted Photons - SiSi'},
47 {'name': 'clusterConvPhotonTRT',
48 'title': 'Clusters Converted Photons - TRT'},
49 {'name': 'clusterConvPhotonTRTTRT',
50 'title': 'Clusters Converted Photons - TRTTRT'},
51 {'name': 'clusterConvPhotonSiTRT',
52 'title': 'Clusters Converted Photons - SiTRT'},
53
54]
55
56
57electron_comparison_list = [
58 {'name': 'showerShapesAll',
59 'title': 'Shower Shape - Inclusive'},
60 {'name': 'showerShapes10GeV',
61 'title': 'Shower Shape - 10 GeV'},
62 {'name': 'isolationAll',
63 'title': 'Isolation'},
64 {'name': 'recoElectronAll',
65 'title': 'Reconstructed Electron'},
66 {'name': 'truthRecoElectronLooseLH',
67 'title': 'Reconstructed Electron LooseLH'},
68 {'name': 'truthRecoElectronMediumLH',
69 'title': 'Reconstructed Electron MediumLH'},
70 {'name': 'truthRecoElectronTightLH',
71 'title': 'Reconstructed Electron TightLH'},
72 {'name': 'truthElectronAll',
73 'title': 'True Electron'},
74 {'name': 'truthPromptElectronAll',
75 'title': 'True Prompt Electron'},
76 {'name': 'truthElectronRecoElectronAll',
77 'title': 'True Electron Reconstructed as Electron'},
78 {'name': 'truthPromptElectronWithTrack',
79 'title': 'True Prompt Electron with Track'},
80 {'name': 'truthPromptElectronWithGSFTrack',
81 'title': 'True Prompt Electron with GSFTrack'},
82 {'name': 'truthPromptElectronWithReco',
83 'title': 'True Prompt Electron with Reco Electron'},
84 {'name': 'trackingEfficiency',
85 'title': 'Tracking Efficiency'},
86 {'name': 'GSFEfficiency',
87 'title': 'GSF Efficiency'},
88 {'name': 'matchingEfficiency',
89 'title': 'Matching Efficiency'},
90 {'name': 'reconstructionEfficiency',
91 'title': 'Reconstruction Efficiency'},
92 {'name': 'recoElectronLooseLHEfficiency',
93 'title': 'Reconstructed Electron LooseLH Efficiency'},
94 {'name': 'recoElectronMediumLHEfficiency',
95 'title': 'Reconstructed Electron MediumLH Efficiency'},
96 {'name': 'recoElectronTightLHEfficiency',
97 'title': 'Reconstructed Electron TightLH Efficiency'},
98]
99
100photon_comparison_list = [
101 {'name': 'recoPhotonAll',
102 'title': 'Reconstructed Photon'},
103 {'name': 'truthPhotonRecoPhoton',
104 'title': 'True photon reconstructed as photon'},
105 {'name': 'truthConvPhoton',
106 'title': 'True converted photon'},
107 {'name': 'truthConvRecoConv',
108 'title': 'True conversion reconstructed as converted photon'},
109 {'name': 'truthConvRecoConv1Si',
110 'title': 'True conversion reconstructed as 1 Si conv'},
111 {'name': 'truthConvRecoConv1TRT',
112 'title': 'True conversion reconstructed as 1 TRT conv'},
113 {'name': 'truthConvRecoConv2Si',
114 'title': 'True conversion reconstructed as Si-Si conv'},
115 {'name': 'truthConvRecoConv2TRT',
116 'title': 'True conversion reconstructed as TRT-TRT conv'},
117 {'name': 'truthConvRecoConv2SiTRT',
118 'title': 'True conversion reconstructed as Si-TRT conv'},
119 {'name': 'truthConvRecoUnconv',
120 'title': 'True conversion reconstructed as unconverted photon'},
121 {'name': 'truthUnconvPhoton', 'title': 'True unconverted photon'},
122 {'name': 'truthUnconvRecoConv',
123 'title': 'True unconverted reconstructed as conv photon'},
124 {'name': 'truthUnconvRecoUnconv',
125 'title': 'True unconverted reconstructed as unconverted photon'},
126 {'name': 'showerShapesAll',
127 'title': 'Shower Shape - Inclusive'},
128 {'name': 'showerShapes10GeV',
129 'title': 'Shower Shape - 10 GeV'},
130 {'name': 'isolationAll',
131 'title': 'Isolation'},
132 {'name': 'recoPhotonUnconvLooseLH',
133 'title': 'Unconverted Photon LooseLH'},
134 {'name': 'recoPhotonUnconvTightLH',
135 'title': 'Unconverted Photon TightLH'},
136 {'name': 'recoPhotonConvLooseLH',
137 'title': 'Converted Photon LooseLH'},
138 {'name': 'recoPhotonConvTightLH',
139 'title': 'Converted Photon TightLH'},
140 {'name': 'recoPhotonUnconvIsoFixedCutTight',
141 'title': 'FixedCutTight Unconverted Photon'},
142 {'name': 'recoPhotonUnconvIsoFixedCutTightCaloOnly',
143 'title': 'FixedCutTightCaloOnly Unconverted Photon'},
144 {'name': 'recoPhotonUnconvIsoFixedCutLoose',
145 'title': 'FixedCutLoose Unconverted Photon'},
146 {'name': 'recoPhotonConvIsoFixedCutTight',
147 'title': 'FixedCutTight Converted Photon'},
148 {'name': 'recoPhotonConvIsoFixedCutTightCaloOnly',
149 'title': 'FixedCutTightCaloOnly Converted Photon'},
150 {'name': 'recoPhotonConvIsoFixedCutLoose',
151 'title': 'FixedCutLoose Converted Photon'},
152 {'name': 'truthPhotonUnconvRecoUnconvEfficiency',
153 'title': 'True Conv #rightarrow Conv'},
154 {'name': 'truthPhotonRecoConvEfficiency',
155 'title': 'True Conv #rightarrow Conv'},
156 {'name': 'recoPhotonUnconvIsoFixedCutTightEfficiency',
157 'title': 'True Conv #rightarrow Conv'},
158 {'name': 'recoPhotonUnconvIsoFixedCutTightCaloOnlyEfficiency',
159 'title': 'True Conv #rightarrow Conv'},
160 {'name': 'recoPhotonUnconvIsoFixedCutLooseEfficiency',
161 'title': 'True Conv #rightarrow Conv'},
162 {'name': 'recoPhotonConvIsoFixedCutTightEfficiency',
163 'title': 'True Conv #rightarrow Conv'},
164 {'name': 'recoPhotonConvIsoFixedCutTightCaloOnlyEfficiency',
165 'title': 'True Conv #rightarrow Conv'},
166 {'name': 'recoPhotonConvIsoFixedCutLooseEfficiency',
167 'title': 'True Conv #rightarrow Conv'},
168 {'name': 'recoPhotonUnconvLooseLHEfficiency',
169 'title': 'Unconverted Photon LooseLH Efficiency'},
170 {'name': 'recoPhotonUnconvTightLHEfficiency',
171 'title': 'Unconverted Photon TightLH Efficiency'},
172 {'name': 'recoPhotonConvLooseLHEfficiency',
173 'title': 'Converted Photon LooseLH Efficiency'},
174 {'name': 'recoPhotonConvTightLHEfficiency',
175 'title': 'Converted Photon TightLH Efficiency'},
176]
177
178photon_fraction_list = [
179 {'name': 'truthPhotonConvRecoConvEfficiency',
180 'color': kBlack, 'title': 'True Conv #rightarrow Conv'},
181 {'name': 'truthPhotonConvRecoConv1SiEfficiency', 'color': kBlue +
182 2, 'title': 'True Conv #rightarrow 1 Si Conv'},
183 {'name': 'truthPhotonConvRecoConv1TRTEfficiency', 'color': kRed +
184 2, 'title': 'True Conv #rightarrow 1 TRT Conv'},
185 {'name': 'truthPhotonConvRecoConv2SiEfficiency', 'color': kGreen +
186 2, 'title': 'True Conv #rightarrow Si-Si Conv'},
187 {'name': 'truthPhotonConvRecoConv2TRTEfficiency', 'color': kOrange + 2,
188 'title': 'True Conv #rightarrow TRT-TRT Conv'},
189 {'name': 'truthPhotonConvRecoConv2SiTRTEfficiency', 'color': kCyan + 2,
190 'title': 'True Conv #rightarrow Si-TRT Conv'},
191 {'name': 'truthPhotonConvRecoUnconvEfficiency',
192 'color': kPink + 2, 'title': 'True Conv #rightarrow Unconv'}
193]
194
195photonfake_fraction_list = [
196 {'name': 'truthPhotonUnconvRecoConvEfficiency',
197 'color': kBlack, 'title': 'True Unconv #rightarrow Conv'},
198 {'name': 'truthPhotonUnconvRecoConv1SiEfficiency', 'color': kBlue +
199 2, 'title': 'True Unconv #rightarrow 1 Si Conv'},
200 {'name': 'truthPhotonUnconvRecoConv1TRTEfficiency', 'color': kRed +
201 2, 'title': 'True Unconv #rightarrow 1 TRT Conv'},
202 {'name': 'truthPhotonUnconvRecoConv2SiEfficiency', 'color': kGreen +
203 2, 'title': 'True Unconv #rightarrow Si-Si Conv'},
204 {'name': 'truthPhotonUnconvRecoConv2TRTEfficiency', 'color': kOrange + 2,
205 'title': 'True Unconv #rightarrow TRT-TRT Conv'},
206 {'name': 'truthPhotonUnconvRecoConv2SiTRTEfficiency', 'color': kCyan + 2,
207 'title': 'True Unconv #rightarrow Si-TRT Conv'},
208]
209
210photon_efficiency_list = [
211 {'name': 'truthPhotonRecoPhotonEfficiency',
212 'color': kBlack, 'title': 'All photons'},
213 {'name': 'truthPhotonRecoPhotonOrElectronEfficiency', 'color': kGreen + 2,
214 'title': 'All photons + electrons'},
215 {'name': 'truthPhotonConvRecoEfficiency', 'color': kRed,
216 'title': 'True converted'},
217 {'name': 'truthPhotonUnconvRecoEfficiency', 'color': kBlue,
218 'title': 'True unconverted'}
219]
220
221photon_conversion_list = [
222 {'name': 'truthConvRecoConv2Si', 'color': kGreen +
223 2, 'title': 'True Conv #rightarrow Si-Si Conv'},
224 {'name': 'truthConvRecoConv1Si', 'color': kBlue +
225 2, 'title': 'True Conv #rightarrow 1 Si Conv'},
226 {'name': 'truthConvRecoConv1TRT', 'color': kRed +
227 2, 'title': 'True Conv #rightarrow 1 TRT Conv'},
228 {'name': 'truthConvRecoConv2TRT', 'color': kOrange +
229 2, 'title': 'True Conv #rightarrow TRT-TRT Conv'},
230 {'name': 'truthConvRecoConv2SiTRT', 'color': kCyan +
231 2, 'title': 'True Conv #rightarrow Si-TRT Conv'},
232]
233
234photon_track_list = [
235 {'name': 'InDetTracks', 'color': kBlack,
236 'title': 'All tracks'},
237 {'name': 'InDetTracksMatchElectron', 'color': kOrange,
238 'title': 'Matched to true electrons'},
239 {'name': 'InDetTracksNotElectron', 'color': kBlue,
240 'title': 'Not matched to true electrons'},
241 {'name': 'InDetTracksMatchPion', 'color': kGreen +
242 2, 'title': 'Matched to true Pion'},
243 {'name': 'InDetTracksNotMatched', 'color': kCyan +
244 2, 'title': 'Not matched to truth'}
245]
246
247photon_trackTRT_list = [
248 {'name': 'InDetTracksTRT', 'color': kBlack,
249 'title': 'All tracks'},
250 {'name': 'InDetTracksTRTMatchElectron', 'color': kOrange,
251 'title': 'Matched to true electrons'},
252 {'name': 'InDetTracksTRTNotElectron', 'color': kBlue,
253 'title': 'Not matched to true electrons'},
254 {'name': 'InDetTracksTRTMatchPion', 'color': kGreen +
255 2, 'title': 'Matched to true Pion'},
256 {'name': 'InDetTracksTRTNotMatched', 'color': kCyan +
257 2, 'title': 'Not matched to truth'}
258]
259
260photon_trackhighpT_list = [
261 {'name': 'InDetTrackshighpT', 'color': kBlack,
262 'title': 'All tracks'},
263 {'name': 'InDetTracksMatchElectronhighpT', 'color': kOrange,
264 'title': 'Matched to true electrons'},
265 {'name': 'InDetTracksNotElectronhighpT', 'color': kBlue,
266 'title': 'Not matched to true electrons'},
267 {'name': 'InDetTracksMatchPionhighpT', 'color': kGreen +
268 2, 'title': 'Matched to true Pion'},
269 {'name': 'InDetTracksNotMatchedhighpT', 'color': kCyan +
270 2, 'title': 'Not matched to truth'}
271]
272
273photon_trackTRThighpT_list = [
274 {'name': 'InDetTracksTRThighpT', 'color': kBlack,
275 'title': 'All tracks'},
276 {'name': 'InDetTracksTRTMatchElectronhighpT', 'color': kOrange,
277 'title': 'Matched to true electrons'},
278 {'name': 'InDetTracksTRTNotElectronhighpT', 'color': kBlue,
279 'title': 'Not matched to true electrons'},
280 {'name': 'InDetTracksTRTMatchPionhighpT', 'color': kGreen +
281 2, 'title': 'Matched to true Pion'},
282 {'name': 'InDetTracksTRTNotMatchedhighpT', 'color': kCyan +
283 2, 'title': 'Not matched to truth'}
284]
285
286
287def get_key_names(file, directory=""):
288 """
289 Function to get the key elements name from a given directory
290 :param file: TFile
291 :param directory: Directory
292 :return:
293 """
294 file.cd(directory)
295 return [key.GetName() for key in gDirectory.GetListOfKeys()]
296
297
298def make_comparison_plots(type, f_base, f_nightly, result_file):
299 """
300
301 :param type: electron or gamma
302 :param f_base: TFile with the baseline plots
303 :param f_nightly: TFile with the nightly plots
304 :param result_file: TFile with the resulting comparison
305 """
306 comparison_list = (
307 photon_comparison_list if type == 'gamma'
308 else electron_comparison_list)
309 for folder in comparison_list:
310 for histo in get_key_names(f_nightly, folder['name']):
311 h_base = f_base.Get(folder['name'] + '/' + histo)
312 h_nightly = f_nightly.Get(folder['name'] + '/' + histo)
313 if not h_base or not h_nightly:
314 print(histo,' is missing in one of the files ',h_base,h_nightly)
315 continue
316 if h_base.GetEntries() == 0 or h_nightly.GetEntries() == 0:
317 continue
318 make_ratio_plot(h_base, h_nightly, folder['title'], result_file)
319
320
321def makeIQEPlots(inHist, name):
322 outHist = inHist.QuantilesX(0.75, "EResolution_IQE_mu")
323 outHist.GetXaxis().SetTitle("<#mu>")
324 outHist.GetYaxis().SetTitle("IQE")
325 outHist25 = inHist.QuantilesX(0.25, "EResolutio_IQE_mu_25")
326 outHist.Add(outHist25, -1)
327 outHist.Scale(1/1.349)
328
329 return outHist.Clone(inHist.GetName() + "_" + name)
330
331
332def make_profile_plots(f_base, f_nightly, result_file, particle_type):
333
334 cluster_list_to_loop = cluster_list
335
336 if particle_type == "gamma":
337 cluster_list_to_loop = cluster_list + cluster_list_photon
338
339 for i, folder in enumerate(cluster_list_to_loop):
340 for histo in get_key_names(f_nightly, folder['name']):
341 if '2D' not in histo and not 'profile' in histo:
342 continue
343 h_base = f_base.Get(folder['name'] + '/' + histo)
344 h_nightly = f_nightly.Get(folder['name'] + '/' + histo)
345 if not h_base or not h_nightly:
346 print(histo,' is missing in one of the files ',h_base,h_nightly)
347 continue
348 if h_base.GetEntries() == 0 or h_nightly.GetEntries() == 0:
349 continue
350 if 'mu' in histo:
351 h_base = makeIQEPlots(h_base, 'IQE')
352 h_nightly = makeIQEPlots(h_nightly, 'IQE')
353 y_axis_label = 'IQE'
354 else:
355 h_base.SetDirectory(0)
356 h_nightly.SetDirectory(0)
357 y_axis_label = "Mean %s" % (h_base.GetTitle())
358 h_base.SetTitle("")
359 make_ratio_plot(h_base, h_nightly,
360 folder['title'], result_file, y_axis_label)
361
362
363def make_conversion_plot(f_base, f_nightly, result_file):
364 """
365 This function creates conversion plots to study reco vs true
366 converion radius for the various conversion categoried
367 """
368 for histo in get_key_names(f_nightly, 'truthConvRecoConv2Si'):
369 variable_name = histo.split("_", 1)[1]
370
371 if variable_name != "convRadiusTrueVsReco":
372 continue
373
374 c1 = TCanvas()
375
376 leg = TLegend(0.1, 0.75, 0.9, 0.9)
377 leg.SetNColumns(2)
378
379 leg2 = TLegend(0.5, 0.7, 0.9, 0.75)
380 leg2.SetNColumns(2)
381
382 for i, folder in enumerate(photon_conversion_list):
383
384 baseline = f_base.Get(
385 folder['name'] + '/' + folder['name'] + "_" + variable_name)
386 baseline.SetDirectory(0)
387 nightly = f_nightly.Get(
388 folder['name'] + '/' + folder['name'] + "_" + variable_name)
389 nightly.SetDirectory(0)
390
391 if baseline.Integral() != 0:
392 baseline.Scale(1/baseline.Integral())
393 if nightly.Integral() != 0:
394 nightly.Scale(1/nightly.Integral())
395
396 baseline.SetMinimum(
397 min(baseline.GetMinimum(), baseline.GetMinimum()) * 0.7)
398 baseline.SetMaximum(
399 max(baseline.GetMaximum(), baseline.GetMaximum()) * 1.4)
400
401 baseline.GetXaxis().SetTitle(
402 "R^{reco}_{conv. vtx} - R^{true}_{conv. vtx} [mm]")
403 baseline.GetYaxis().SetTitle("normalized to unity")
404
405 baseline.SetLineColor(folder['color'])
406 nightly.SetLineColor(folder['color'])
407 baseline.SetMarkerColor(folder['color'])
408 nightly.SetMarkerColor(folder['color'])
409
410 baseline.SetMarkerStyle(1)
411 nightly.SetMarkerStyle(20)
412
413 leg.AddEntry(nightly, folder['title'], "p")
414
415 if i == 0:
416 baseline.Draw("hist ")
417
418 baselineDummy = baseline.Clone()
419 baselineDummy.SetLineColor(kGray+3)
420 baselineDummy.SetMarkerColor(kGray+3)
421 nightlyDummy = nightly.Clone()
422 nightlyDummy.SetLineColor(kGray+3)
423 nightlyDummy.SetMarkerColor(kGray+3)
424 leg2.AddEntry(baselineDummy, "Baseline", "l")
425 leg2.AddEntry(nightlyDummy, "Nightly", "p")
426 else:
427 baseline.Draw("same hist")
428
429 nightly.Draw("p same")
430
431 leg.Draw()
432 leg2.Draw()
433
434 c1.Update()
435
436 result_file.cd()
437
438 c1.SaveAs("ConversionRadiusTrueVsReco.png")
439
440 c1.Write("ConversionRadiusTrueVsReco")
441
442
444 f_base, f_nightly, result_file,
445 example_folder, folder_list, plot_name,
446 axis_title, ymin, ymax, normalize=False):
447 """
448 This functions created a photon validation plot with efficiencies
449 and fractions
450
451 :param f_base TFile with the baseline histograms:
452 :param f_nightly TFile with the nightly histograms:
453 """
454 for histo in get_key_names(f_nightly, example_folder):
455
456 variable_name = histo.split("_", 1)[1]
457
458 c1 = TCanvas()
459
460 leg = TLegend(0.1, 0.75, 0.9, 0.9)
461 leg.SetNColumns(2)
462
463 leg2 = TLegend(0.5, 0.7, 0.9, 0.75)
464 leg2.SetNColumns(2)
465
466 for i, folder in enumerate(folder_list):
467
468 baseline = f_base.Get(
469 folder['name'] + '/' + folder['name'] + "_" + variable_name)
470 baseline.SetDirectory(0)
471 nightly = f_nightly.Get(
472 folder['name'] + '/' + folder['name'] + "_" + variable_name)
473 nightly.SetDirectory(0)
474
475 if normalize and 'vs' not in variable_name:
476 if baseline.Integral() != 0:
477 baseline.Scale(1/baseline.Integral())
478 if nightly.Integral() != 0:
479 nightly.Scale(1/nightly.Integral())
480
481 baseline.SetMinimum(ymin)
482 baseline.SetMaximum(ymax)
483
484 baseline.GetYaxis().SetTitle(axis_title)
485
486 baseline.SetLineColor(folder['color'])
487 nightly.SetLineColor(folder['color'])
488 baseline.SetMarkerColor(folder['color'])
489 nightly.SetMarkerColor(folder['color'])
490
491 baseline.SetMarkerStyle(1)
492 nightly.SetMarkerStyle(20)
493
494 leg.AddEntry(nightly, folder['title'], "p")
495
496 if i == 0:
497 baseline.Draw("hist ")
498
499 baselineDummy = baseline.Clone()
500 baselineDummy.SetLineColor(kGray+3)
501 baselineDummy.SetMarkerColor(kGray+3)
502 nightlyDummy = nightly.Clone()
503 nightlyDummy.SetLineColor(kGray+3)
504 nightlyDummy.SetMarkerColor(kGray+3)
505 leg2.AddEntry(baselineDummy, "Baseline", "l")
506 leg2.AddEntry(nightlyDummy, "Nightly", "p")
507 else:
508 baseline.Draw("same hist")
509
510 nightly.Draw("p same")
511
512 leg.Draw()
513 leg2.Draw()
514
515 c1.Update()
516
517 result_file.cd()
518
519 c1.SaveAs(plot_name + "_" + variable_name + ".png")
520
521 c1.Write(plot_name + "_" + variable_name)
522
523
524def make_ratio_plot(h_base, h_nightly, name, result_file, y_axis_label=None):
525 """
526
527 :param h_base: Baseline histogram
528 :param h_nightly: Nightly histogram
529 :param name: Human-readable name of the histogram
530 :param result_file: TFile where the output is saved
531 :param y_axis_label: Y axis label is case is needed
532 (fraction vs efficiency)
533 """
534 histogram_name = h_nightly.GetName()
535
536 type_name = histogram_name.split("_", 1)[0]
537 variable_name = histogram_name.split("_", 1)[1]
538
539 c1 = TCanvas()
540
541 main_pad = TPad("main_pad", "top", 0.00, 0.25, 1.00, 1.00)
542 main_pad.SetLeftMargin(0.12)
543 main_pad.SetRightMargin(0.04)
544 main_pad.SetTopMargin(0.02)
545 main_pad.SetBottomMargin(0.02)
546 main_pad.SetTicky(0)
547 main_pad.SetTickx(0)
548 main_pad.Draw()
549
550 ratio_pad = TPad("ratio_pad", "bottom", 0.00, 0.00, 1.00, 0.25)
551 ratio_pad.SetLeftMargin(0.12)
552 ratio_pad.SetRightMargin(0.04)
553 ratio_pad.SetTopMargin(0.03)
554 ratio_pad.SetTickx(0)
555 ratio_pad.SetBottomMargin(0.36)
556 ratio_pad.Draw()
557
558 h_base.SetLineColor(4)
559 h_base.SetLineWidth(2)
560
561 h_nightly.SetMarkerStyle(8)
562 h_nightly.SetMarkerSize(0.5)
563
564 main_pad.cd()
565
566 if y_axis_label is not None:
567 h_base.GetYaxis().SetTitle(y_axis_label)
568 h_base.GetYaxis().SetTitle(y_axis_label)
569
570 if '2D' not in variable_name or 'profile' in variable_name:
571 h_base.Draw()
572
573 h_nightly.Draw(
574 "same p" if '2D' not in variable_name or 'profile' in variable_name
575 else 'colz')
576
577 c1.Update()
578
579 h_base.GetXaxis().SetLabelSize(0)
580 h_base.GetXaxis().SetLabelOffset(999)
581
582 h_base.SetMinimum(min(h_base.GetMinimum(), h_nightly.GetMinimum()) * 0.7)
583 h_base.SetMaximum(max(h_base.GetMaximum(), h_nightly.GetMaximum()) * 1.3)
584
585 leg = TLegend(0.4, 0.88, 0.9, 0.95)
586 leg.SetHeader(name, "C")
587 leg.SetNColumns(2)
588 leg.SetFillStyle(0)
589 leg.SetBorderSize(0)
590 leg.AddEntry(h_base, "Baseline", "l")
591 leg.AddEntry(h_nightly, "Nightly", "p")
592 leg.Draw()
593
594 c1.Update()
595
596 ratio_pad.cd()
597
598 h1clone = h_nightly.Clone()
599 h1clone.Sumw2()
600 h1clone.SetStats(0)
601 h1clone.Divide(h_base)
602 h1clone.SetMarkerColor(1)
603 h1clone.SetMarkerStyle(20)
604 h1clone.GetYaxis().SetRangeUser(0.95, 1.05)
605 gStyle.SetOptStat(0)
606 h1clone.GetXaxis().SetLabelSize(0.10)
607 h1clone.GetXaxis().SetTitleSize(0.17)
608 h1clone.GetYaxis().SetLabelSize(0.10)
609 h1clone.GetYaxis().SetTitle("Ratio")
610 h1clone.GetYaxis().CenterTitle(1)
611 h1clone.GetYaxis().SetTitleSize(0.15)
612 h1clone.GetYaxis().SetTitleOffset(0.3)
613 h1clone.GetYaxis().SetNdivisions(505)
614
615 h1clone.Draw("hist")
616
617 c1.Update()
618
619 result_file.cd()
620
621 c1.SaveAs(type_name + '_' + variable_name + ".png")
622
623 c1.Write(type_name + '_' + variable_name)
624
625
626if __name__ == '__main__':
627
628 gROOT.SetBatch(kTRUE)
629 gStyle.SetOptStat(0)
630
631 baseline_file = TFile(sys.argv[1])
632 nightly_file = TFile(sys.argv[2])
633 particle_type = sys.argv[3] # it can be 'electron' or 'gamma'
634
635 output_file = TFile("BN_ComparisonPlots_" +
636 particle_type + ".hist.root", "RECREATE")
637
638 if particle_type == 'gamma':
639
641 baseline_file,
642 nightly_file,
643 output_file, 'truthPhotonConvRecoConvEfficiency',
644 photon_fraction_list, 'ConvertionEff_TrueConv',
645 "Efficiency and fraction", 0., 1.3)
647 baseline_file, nightly_file,
648 output_file, 'truthPhotonUnconvRecoConvEfficiency',
649 photonfake_fraction_list, 'ConvertionEff_TrueUnconv',
650 "Efficiency and fraction", 0., 0.2)
652 baseline_file, nightly_file,
653 output_file, 'truthPhotonRecoPhotonEfficiency',
654 photon_efficiency_list, 'PhotonEff',
655 "Efficiency", 0.8, 1.15)
657 baseline_file, nightly_file, output_file,
658 'InDetTracks', photon_track_list, 'Track',
659 "Tracks", 0., 1.3, True)
661 baseline_file, nightly_file, output_file,
662 'InDetTracksTRT',
663 photon_trackTRT_list, 'TrackTRT',
664 "Tracks", 0., 1.3, True)
666 baseline_file, nightly_file,
667 output_file, 'InDetTrackshighpT',
668 photon_trackhighpT_list, 'TrackhighpT',
669 "Tracks", 0., 1.3, True)
671 baseline_file, nightly_file,
672 output_file, 'InDetTracksTRThighpT',
673 photon_trackTRThighpT_list, 'TrackTRThighpT',
674 "Tracks", 0., 1.3, True)
675 make_conversion_plot(baseline_file, nightly_file, output_file)
676
677 make_comparison_plots(particle_type, baseline_file,
678 nightly_file, output_file)
679
680 make_profile_plots(baseline_file, nightly_file, output_file, particle_type)
void print(char *figname, TCanvas *c1)
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
make_photon_fraction_plot(f_base, f_nightly, result_file, example_folder, folder_list, plot_name, axis_title, ymin, ymax, normalize=False)
make_comparison_plots(type, f_base, f_nightly, result_file)
make_profile_plots(f_base, f_nightly, result_file, particle_type)
make_conversion_plot(f_base, f_nightly, result_file)
make_ratio_plot(h_base, h_nightly, name, result_file, y_axis_label=None)