ATLAS Offline Software
Loading...
Searching...
No Matches
PlotEFTrk Namespace Reference

Functions

 GetParserArgs ()
 isTEfficiency (obj)
 isTProfile (obj)
 getHistoName (category, args)
 getHistoPath (cfg, args)
 getConfig (input, chain, pipeline, trkana, args, color, markstyle, linestyle, isRef=False)
 getLegend (xmin, ymin, xmax, ymax)
 getATLASLabel (args)
 getPadSizes (args, NRef)
 getCanvas (args, cfg, NRef)
 getURDRequirementLine (h, type, canv, scale, logx=False)
 setStyle (h, cfg)
 setRatioStyle (ratio, cfg, color, linestyle, markstyle, ref='C000', multigraph=False, labelsizescale=65./35., lastpad=False, splittitle=False)
 getTEfficiencyRatio (histos)
 drawTEfficiencyOutliers (r, configs, multigraphs, markers, NRef)
 drawTHOutliers (r, configs, ratios, markers, NRef)
 drawRefLine (r, ratios, reflines)
 draw (args, configs, tails=False, pu_comparison=False)
 main ()

Variables

dict category_dict
 Dictionaries.
dict resolution_dict

Function Documentation

◆ draw()

PlotEFTrk.draw ( args,
configs,
tails = False,
pu_comparison = False )

Definition at line 453 of file PlotEFTrk.py.

453def draw(args, configs, tails=False, pu_comparison=False):
454
455 NRef = len(args.ref) if not pu_comparison else 1
456 canv = getCanvas(args,configs[0], NRef)
457 ATLASLabel = getATLASLabel(args)
458 legend = getLegend(args.legend_coord[0],args.legend_coord[1],args.legend_coord[2],args.legend_coord[3])
459 doComparison = len(configs) > 1
460 isTEfficiencyObj = False
461 histos = []
462 canv.cd(1)
463
464 for i,cfg in enumerate(configs): # loop over the trkAnalysis to be compared (if single plot, there will be only 1 trkAnalysis)
465 h = getHistoPath(cfg,args)
466 isTEfficiencyObj = isTEfficiency(h)
467 histos.append(h)
468
469 if not tails: h.Draw('same' if i!=0 else '')
470
471 else: h.Draw('sameHISTE' if i%2!=0 else 'samePE')
472
473 setStyle(h, cfg)
474
475 if doComparison and cfg['dimension'] == '1D':
476 draw_option = 'lp'
477
478 if tails:
479 draw_option = 'l' if i%2!=0 else 'lp'
480 jet = 'b-Jet' if i%2==0 else 'LF-Jet'
481 legend.AddEntry(h, f"{cfg['legend']} {jet}",draw_option)
482
483 else: legend.AddEntry(h, cfg['legend'],draw_option)
484
485 legend.Draw()
486
487 ATLASLabel.Draw()
488
489 multigraphs = []
490 reflines = []
491 markers = []
492 urd_lines = []
493 urd_text = []
494
495 if 'rate' in args.type and 'C000' in args.ref[0] and args.param != 'truthMu':
496 requirement_line, requirement_text = getURDRequirementLine(histos[0].GetPaintedGraph(), 'rate', canv, 1)
497 requirement_line.Draw('same')
498 requirement_text.Draw('same')
499
500 # Loop over reference histograms to create one ratio per reference
501 for r in range(NRef):
502
503 labelsizescales = [canv.GetPad(1).GetHNDC()/canv.GetPad(i+2).GetHNDC() for i in range(NRef)]
504 canv.cd(r+2)
505 ratios = []
506 multigraphs.append(ROOT.TMultiGraph())
507 markers.append([])
508
509 if not tails and not pu_comparison:
510
511 for i in range(NRef, len(configs)):
512 ratio_histos = [histos[r] if not isTProfile(histos[r]) else histos[r].ProjectionX(), histos[i] if not isTProfile(histos[i]) else histos[i].ProjectionX()]
513
514 if isTEfficiencyObj: ratios.append(getTEfficiencyRatio(ratio_histos))
515
516 else:
517 ratio = ratio_histos[1].Clone()
518 ratio.Divide(ratio_histos[0])
519 ratios.append(ratio)
520
521 for i, ratio in enumerate(ratios):
522 color = configs[i+NRef]['linecolor'] #if len(configs)>2 else ROOT.kBlack
523 linestyle = configs[i+1]['linestyle']# if len(configs)>2 else 1
524 markstyle = configs[i+1]['markstyle']# if len(configs)>2 else 20
525 setRatioStyle(ratio, configs[i], color, linestyle, markstyle, ref=configs[r]['pipeline'], labelsizescale = labelsizescales[r], lastpad = (r==NRef-1), splittitle = (NRef>1))
526
527 if isTEfficiencyObj:
528 multigraphs[r].Add(ratio,'p')
529 multigraphs[r].GetXaxis().SetTitle(ratio.GetXaxis().GetTitle())
530
531 else:
532 ratio.Draw('same')
533
534 if isTEfficiencyObj:
535 xmin, xmax = ratios[0].GetXaxis().GetXmin(), ratios[0].GetXaxis().GetXmax()
536 setRatioStyle(multigraphs[r], configs[i], color, linestyle, markstyle, ref=configs[r]['pipeline'], multigraph=True, labelsizescale = labelsizescales[r], lastpad = (r==NRef-1), splittitle = (NRef>1))
537 multigraphs[r].Draw('a')
538 drawTEfficiencyOutliers(r, configs, multigraphs, markers, NRef)
539 multigraphs[r].GetXaxis().SetLimits(xmin, xmax)
540
541 else:
542 drawTHOutliers(r, configs, ratios, markers, NRef)
543
544 drawRefLine(r, ratios, reflines)
545
546 if args.type == 'resolution' and not pu_comparison and 'C000' in args.ref[0]:
547 requirement_line, requirement_text = getURDRequirementLine(ratios[0], 'resolution', canv, labelsizescales[r], logx = ('x' in args.log))
548 urd_lines.append(requirement_line)
549 urd_text.append(requirement_text)
550 urd_lines[r].Draw('same')
551 urd_text[r].Draw('same')
552
553 else:
554 for i in [0,2]:
555 ratio_histos = [histos[i],histos[i+1]]
556 ratio = ratio_histos[0].Clone()
557 ratio.Divide(ratio_histos[1])
558 ratios.append(ratio)
559
560 for i, ratio in enumerate(ratios):
561 color = configs[i*2]['linecolor']
562 linestyle = configs[i*2]['linestyle']
563 markstyle = configs[i*2]['markstyle']
564 setRatioStyle(ratio, configs[i], color, linestyle, markstyle, ref=configs[r]['pipeline'],labelsizescale = labelsizescales[r], lastpad = (r==NRef-1))
565 ratio.GetYaxis().SetTitle('b-Jet / LF-Jet' if tails else '<#mu> = 140/<#mu> = 200')
566 ratio.Draw('same')
567
568 drawRefLine(r, ratios, reflines)
569
570 var = cfg['histo'] if not cfg['category'] == 'Efficiencies/Technical' else cfg['histo'].replace('eff','tech_eff')
571 canv.SaveAs(f"{args.output}/{args.tag+'_' if args.tag != '' else ''}{var}.png")
572
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312

◆ drawRefLine()

PlotEFTrk.drawRefLine ( r,
ratios,
reflines )

Definition at line 445 of file PlotEFTrk.py.

445def drawRefLine(r, ratios, reflines):
446
447 reflines.append(ROOT.TLine(ratios[0].GetXaxis().GetXmin(),1,ratios[0].GetXaxis().GetXmax(),1))
448 reflines[r].SetLineStyle(2)
449 reflines[r].SetLineColor(ROOT.kBlack)
450 reflines[r].SetLineWidth(1)
451 reflines[r].Draw('same')
452

◆ drawTEfficiencyOutliers()

PlotEFTrk.drawTEfficiencyOutliers ( r,
configs,
multigraphs,
markers,
NRef )

Definition at line 394 of file PlotEFTrk.py.

394def drawTEfficiencyOutliers(r, configs, multigraphs, markers, NRef):
395
396 outliers_index = 0
397
398 for j,g in enumerate(multigraphs[r].GetListOfGraphs()):
399 markers.append([])
400 ROOT.gPad.Update()
401 ymin = ROOT.gPad.GetFrame().GetY1()
402 ymax = ROOT.gPad.GetFrame().GetY2()
403
404 for i in range(g.GetN()):
405
406 if g.GetPointY(i) > ymax:
407 markers[r].append(ROOT.TMarker(g.GetPointX(i), ymax-(ymax-ymin)*0.05, 26))
408 markers[r][outliers_index].SetMarkerColor(configs[j+NRef]['linecolor'])
409 markers[r][outliers_index].SetMarkerSize(1.2)
410 markers[r][outliers_index].Draw('same')
411 outliers_index += 1
412
413 if g.GetPointY(i) < ymin and g.GetPointY(i) > 0:
414 markers[r].append(ROOT.TMarker(g.GetPointX(i), ymin+(ymax-ymin)*0.05, 32))
415 markers[r][outliers_index].SetMarkerColor(configs[j+NRef]['linecolor'])
416 markers[r][outliers_index].SetMarkerSize(1.2)
417 markers[r][outliers_index].Draw('same')
418 outliers_index += 1
419

◆ drawTHOutliers()

PlotEFTrk.drawTHOutliers ( r,
configs,
ratios,
markers,
NRef )

Definition at line 420 of file PlotEFTrk.py.

420def drawTHOutliers(r, configs, ratios, markers, NRef):
421
422 outliers_index = 0
423
424 for j,ratio in enumerate(ratios):
425 ROOT.gPad.Update()
426 ymin = ROOT.gPad.GetFrame().GetY1()
427 ymax = ROOT.gPad.GetFrame().GetY2()
428
429 for i in range(ratio.GetNbinsX()):
430
431 if ratio.GetBinContent(i) > ymax:
432 markers[r].append(ROOT.TMarker(ratio.GetXaxis().GetBinCenter(i), ymax-(ymax-ymin)*0.05, 26))
433 markers[r][outliers_index].SetMarkerColor(configs[j+NRef]['linecolor'])
434 markers[r][outliers_index].SetMarkerSize(1.2)
435 markers[r][outliers_index].Draw('same')
436 outliers_index += 1
437
438 if ratio.GetBinContent(i) < ymin and ratio.GetBinContent(i) > 0:
439 markers[r].append(ROOT.TMarker(ratio.GetXaxis().GetBinCenter(i), ymin+(ymax-ymin)*0.05, 32))
440 markers[r][outliers_index].SetMarkerColor(configs[j+NRef]['linecolor'])
441 markers[r][outliers_index].SetMarkerSize(1.2)
442 markers[r][outliers_index].Draw('same')
443 outliers_index += 1
444

◆ getATLASLabel()

PlotEFTrk.getATLASLabel ( args)

Definition at line 156 of file PlotEFTrk.py.

156def getATLASLabel(args):
157
158 sample = ''
159 if args.sample == '':
160 if 'ttbar' in args.ref[0]: sample = 't#bar{t}'
161 if 'SingleMu' in args.ref[0]: sample = 'single #mu'
162 if 'SinglePi' in args.ref[0]: sample = 'single #pi'
163 if 'SingleEl' in args.ref[0]: sample = 'single e'
164 if 'pT10_' in args.ref[0]: sample += ', p_{T} = 10 GeV'
165 if 'pT100' in args.ref[0]: sample += ', p_{T} = 100 GeV'
166 if 'pT1_' in args.ref[0]: sample += ', p_{T} = 1 GeV'
167 else: sample = args.sample
168 if args.particle != '': sample += f', {args.particle}'
169
170 diffItkLayout = args.layoutTest != args.layoutRef
171 itklayout = f"{args.layoutTest} vs {args.layoutRef}" if diffItkLayout else f"ITk Layout: {args.layout}"
172 subatlas = ROOT.TLatex(.2, .84, "#splitline{#bf{#it{ATLAS}} Simulation Internal}{#splitline{#sqrt{s} = 14 TeV, HL-LHC}{#splitline{%s}{<#mu> = %s, %s}}}" %(itklayout, args.mu, sample))
173 if args.pu_comparison:
174 subatlas = ROOT.TLatex(.2, .84, "#splitline{#bf{#it{ATLAS}} Simulation Internal}{#splitline{#sqrt{s} = 14 TeV, HL-LHC}{#splitline{%s}{%s}}}" %(itklayout,sample))
175
176 subatlas.SetNDC(1)
177 subatlas.SetTextFont(42)
178 subatlas.SetTextSize(0.05)
179
180 return subatlas
181

◆ getCanvas()

PlotEFTrk.getCanvas ( args,
cfg,
NRef )

Definition at line 191 of file PlotEFTrk.py.

191def getCanvas(args,cfg, NRef):
192
193 pad_heights = getPadSizes(args, NRef)
194 canv_heigh = sum(pad_heights)
195 pad_bottom = [(1-sum([pad_heights[j] for j in range(i+1)])/canv_heigh) for i in range(len(pad_heights))]
196 canv = ROOT.TCanvas("c","c",600,int(canv_heigh))
197
198 canv.cd()
199 pad1 = ROOT.TPad("pad1","pad1",0,pad_bottom[0],1,1)
200 pad1.SetNumber(1)
201 pad1.SetBottomMargin(0.05)
202
203 ratio_pads = []
204
205 for r in range(NRef):
206 ratio_pads.append(ROOT.TPad(f"pad{r+2}",f"pad{r+2}",0,pad_bottom[r+1],1,pad_bottom[r]))
207 ratio_pads[r].SetTopMargin(0.05)
208 ratio_pads[r].SetBottomMargin(0.05 if r!=(NRef-1) else 1./3.)
209 ratio_pads[r].SetNumber(r+2)
210
211 if cfg['log'] == 'x':
212 pad1.SetLogx()
213 for r in range(NRef): ratio_pads[r].SetLogx()
214
215 if cfg['log'] == 'y':
216 pad1.SetLogy()
217
218 if cfg['log'] == 'xy':
219 pad1.SetLogx()
220 pad1.SetLogy()
221 for r in range(NRef): ratio_pads[r].SetLogx()
222
223 pad1.Draw()
224
225 for r in range(NRef): ratio_pads[r].Draw()
226
227 return canv
228

◆ getConfig()

PlotEFTrk.getConfig ( input,
chain,
pipeline,
trkana,
args,
color,
markstyle,
linestyle,
isRef = False )

Definition at line 115 of file PlotEFTrk.py.

115def getConfig (input, chain, pipeline, trkana, args, color, markstyle, linestyle, isRef=False):
116
117 category = category_dict[args.type.split('_vs_')[0]] #Efficiencies, Resolutions, FakeRates, ...
118 histo = getHistoName(category, args)
119
120 config_dict = {
121 'pipeline' : pipeline,
122 'chain' : chain,
123 'isReference' : isRef,
124 'input' : input,
125 'trkAnalysis' : trkana,
126 'category' : category,
127 'histo' : histo,
128 'legend' : pipeline,
129 'linestyle' : linestyle,
130 'linecolor' : color,
131 'markstyle' : markstyle,
132 'markcolor' : color,
133 'log' : args.log,
134 'ymax' : float(args.ymax),
135 'ymin' : float(args.ymin),
136 'ratioyrange' : args.ratioyrange,
137 'dimension' : args.dim,
138 'norm' : args.norm,
139 }
140
141 return config_dict
142
143

◆ getHistoName()

PlotEFTrk.getHistoName ( category,
args )

Definition at line 81 of file PlotEFTrk.py.

81def getHistoName(category, args):
82
83 par = args.param
84 if args.vertex:
85 match category:
86 case 'Parameters': return f"offl_vtx_{par}" if args.chain == 'Offline' else f"vtx_{par}"
87 case _: return 'None'
88 else:
89 match category:
90 case 'Parameters': return par
91 case 'Resolutions': return f"{resolution_dict[args.resplot]}_{par}"
92 case 'Efficiencies': return f"eff_vs_truth_{par}" if par!="truthMu" else "eff_vs_truthMu"
93 case 'Efficiencies/Technical': return f"eff_vs_truth_{par}" if par!="truthMu" else "eff_vs_truthMu"
94 case 'Efficiencies/Purities': return f"eff_vs_offl_{par}" if par!="truthMu" else "eff_vs_truthMu"
95 case 'FakeRates': return f"fakerate_vs_offl_{par}" if par!="truthMu" else "fakerate_vs_truthMu"
96 case 'Duplicates': return f"duplrate_vs_truth_{par}" if par!="truthMu" else "duplrate_vs_truthMu"
97 case 'Multiplicities': return par
98 case 'HitsOnTracks': return par
99 case 'PixelClusters': return par
100 case 'StripClusters': return par
101 case _: return 'None'
102

◆ getHistoPath()

PlotEFTrk.getHistoPath ( cfg,
args )

Definition at line 103 of file PlotEFTrk.py.

103def getHistoPath(cfg, args):
104 if args.vertex:
105 histopath = f"InDetTrackPerfMonPlots/{cfg['trkAnalysis']}/{cfg['chain']}/Vertices/{args.vertexcategory}/{cfg['category']}/{cfg['histo']}"
106 else:
107 histopath = f"InDetTrackPerfMonPlots/{cfg['trkAnalysis']}/{cfg['chain']}/Tracks/{cfg['category']}/{cfg['histo']}" if 'Clusters' not in cfg['category'] else f"InDetTrackPerfMonPlots/{cfg['trkAnalysis']}/Offline/{cfg['category']}/{cfg['histo']}"
108 h = cfg['input'].Get(histopath)
109 print(histopath)
110 if cfg['norm']: h.Scale(1./h.Integral())
111 print(cfg['input'])
112
113 return h
114
void print(char *figname, TCanvas *c1)
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...

◆ getLegend()

PlotEFTrk.getLegend ( xmin,
ymin,
xmax,
ymax )

Definition at line 144 of file PlotEFTrk.py.

144def getLegend(xmin,ymin,xmax,ymax):
145
146 leg = ROOT.TLegend(xmin,ymin,xmax,ymax)
147 leg.SetFillColor(0)
148 leg.SetLineColor(0)
149 leg.SetBorderSize(0)
150 leg.SetTextSize(0.05)
151 leg.SetTextFont(42)
152 leg.SetLineWidth(2)
153
154 return leg
155

◆ getPadSizes()

PlotEFTrk.getPadSizes ( args,
NRef )

Definition at line 182 of file PlotEFTrk.py.

182def getPadSizes(args, NRef):
183
184 pad_heights = [600*0.65]
185
186 for nref in range(NRef-1): pad_heights.append(600*0.35 * (1-0.05-1/3))
187 pad_heights.append(600*0.35)
188
189 return pad_heights
190

◆ GetParserArgs()

PlotEFTrk.GetParserArgs ( )

Definition at line 40 of file PlotEFTrk.py.

40def GetParserArgs() :
41
42 from argparse import ArgumentParser
43 parser = ArgumentParser( description='Parser for IDTPM plotting' )
44 parser.add_argument( '--test', help="Input test ROOT files", nargs = '+')
45 parser.add_argument( '--ref', help="Input reference ROOT files", nargs = '+')
46 parser.add_argument( '-o', '--output', help="Output directory")
47 parser.add_argument( '--vertex','--pv','--vtx', help="Include this tag if plotting vertex parameters.", action='store_true', default = False)
48 parser.add_argument( '--vertexcategory', help="Type for vertex parameters if plotting vertex. Default is AllPrimary", default = "AllPrimary")
49 parser.add_argument( '--trkAnalysisTest', help='IDTPM TrackAnalysis for test (e.g. TrkAnaEF)', nargs = '+')
50 parser.add_argument( '--trkAnalysisRef', help='IDTPM TrackAnalysis for reference (e.g. TrkAnaEF)', nargs = '+')
51 parser.add_argument( '--chain', help="Trigger chain (or Offline)", default = 'Offline')
52 parser.add_argument( '-t','--type', help="type of plot (eff, tech_eff, purity, resolution, fakerate, duplrate, num, summary)")
53 parser.add_argument( '-p','--param', help="parameter (e.g pt/eta for efficiencies, d0_vs_truth_eta for resolutions, ...)")
54 parser.add_argument( '--resplot', help="which resolution plot ('resHelp','pullHelp','pullwidth','pullmean','res','resmean','corr')", default=None)
55 parser.add_argument( '--log', help="log scale on x axis, y axis or bot (x, y, xy)", default = '')
56 parser.add_argument( '--ymax', help="maximum value for y-axis ", default = 0)
57 parser.add_argument( '--ymin', help="minimum value for y-axis ", default = 0)
58 parser.add_argument( '--ratioyrange', help="range of ratio y-axis", default = None, nargs = '+', type = float)
59 parser.add_argument( '--dim', help="specify 1D or 2D ", default='1D')
60 parser.add_argument( '--pipelineTest', help="Tested pipeline", nargs = '+')
61 parser.add_argument( '--pipelineRef', help="Reference pipeline", nargs = '+')
62 parser.add_argument( '--norm', help="normalize to unit area", action='store_true')
63 parser.add_argument( '--pu-comparison', help="compare different PU samples", action='store_true')
64 parser.add_argument( '--mu', help="<mu> value (will be printed in ATLAS legend)", default = 200)
65 parser.add_argument( '--sample', help="Sample (e.g. 't#bar{t}' / 'single e, p_{T}>10 GeV', ...). Will be printed in ATLAS legend", default = '')
66 parser.add_argument( '--particle', help="Truth particle (e.g. B-hadrons / #tau, p_{T}>15 GeV). Will be printed in ATLAS legend", default = '')
67 parser.add_argument( '--legend-coord', help="xmin, ymin, xmax, ymax TLegend coordinates", default = [0.65,0.65,0.9,0.87], type = float, nargs = '+')
68 parser.add_argument( '--layout', '--l', help="ITk layout of samples (default 03-00-01)", default="03-00-01")
69 parser.add_argument( '--layoutTest', help = "ITk layout of test if different ITk layout", default = None)
70 parser.add_argument( '--layoutRef', help = "ITk layout of ref if different ITk layout", default = None)
71 parser.add_argument( '--tag', help="output file tag", default = '')
72 parser.print_help()
73 return parser.parse_args()
74

◆ getTEfficiencyRatio()

PlotEFTrk.getTEfficiencyRatio ( histos)

Definition at line 338 of file PlotEFTrk.py.

338def getTEfficiencyRatio(histos):
339
340 xmin, xmax = histos[0].GetPaintedGraph().GetXaxis().GetXmin(), histos[0].GetPaintedGraph().GetXaxis().GetXmax()
341 g1 = ROOT.TGraphAsymmErrors(histos[0].GetPaintedGraph())
342 g2 = ROOT.TGraphAsymmErrors(histos[1].GetPaintedGraph())
343 title = g1.GetXaxis().GetTitle()
344 ratio = ROOT.TGraphAsymmErrors()
345 n, n_ref, n_test = max(g1.GetN(),g2.GetN()), g1.GetN(), g2.GetN()
346 x_ref_arr, y_ref_arr = g1.GetX(), g1.GetY()
347 x_test_arr, y_test_arr = g2.GetX(), g2.GetY()
348 i_test, i_ref = 0, 0
349 err_r_low = []
350 err_r_high = []
351
352 for i in range(n):
353
354 if i_test < n_test and i_ref < n_ref:
355
356 x_ref, y_ref = x_ref_arr[i_ref], y_ref_arr[i_ref]
357 x_test, y_test = x_test_arr[i_test], y_test_arr[i_test]
358 err_ref_low, err_ref_high = g1.GetErrorYlow(i_ref), g1.GetErrorYhigh(i_ref)
359 err_test_low, err_test_high = g2.GetErrorYlow(i_test), g2.GetErrorYhigh(i_test)
360
361 # Check points matching between test and reference
362 if x_test==x_ref:
363 y_ref, y_test = y_ref_arr[i_ref], y_test_arr[i_test]
364 i_test += 1
365 i_ref += 1
366
367 if x_ref>x_test:
368 x_ref = x_test
369 y_ref, y_test = 0, y_test_arr[i_test]
370 i_test+= 1
371
372 if x_test>x_ref:
373 x_test = x_ref
374 y_test, y_ref = 0, y_ref_arr[i_ref]
375 i_ref += 1
376
377 r = y_test / y_ref if y_ref != 0 else 1000
378 if y_test == 0 and y_ref == 0: r = 1
379 err_r_low.append(r * math.sqrt((err_ref_low / y_ref)**2 + (err_test_low / y_test)**2) if y_ref > 0 and y_test > 0 else 0)
380 err_r_high.append(r * math.sqrt((err_ref_high / y_ref)**2 + (err_test_high / y_test)**2) if y_ref > 0 and y_test > 0 else 0)
381 ratio.SetPoint(i, x_ref, r)
382 ratio.GetXaxis().SetTitle(title)
383
384 # Set errors and final x axis range
385 for i in range(ratio.GetN()):
386
387 width = ratio.GetPointX(i+1)-ratio.GetPointX(i) if i < ratio.GetN()-1 else ratio.GetPointX(i)-ratio.GetPointX(i-1)
388 ratio.SetPointError(i, width/2.,width/2., err_r_low[i], err_r_high[i])
389
390 ratio.GetXaxis().SetLimits(xmin, xmax)
391
392 return ratio
393
#define max(a, b)
Definition cfImp.cxx:41

◆ getURDRequirementLine()

PlotEFTrk.getURDRequirementLine ( h,
type,
canv,
scale,
logx = False )

Definition at line 229 of file PlotEFTrk.py.

229def getURDRequirementLine(h, type, canv, scale, logx = False):
230
231 scaleshift = canv.GetPad(1).GetHNDC()/canv.GetPad(2).GetHNDC()
232
233 level = 0.01 if 'rate' in type else 2
234 xmin, xmax = h.GetXaxis().GetXmin(), h.GetXaxis().GetXmax()
235 ymax,ymin = h.GetMaximum(), h.GetMinimum()
236
237 requirement_line = (ROOT.TLine(xmin,level,xmax,level))
238 requirement_line.SetLineStyle(2)
239 requirement_line.SetLineColor(ROOT.kRed)
240 requirement_line.SetLineWidth(1)
241
242 shiftup = 0.01*scaleshift if 'rate' not in type else 0.01
243 shiftdn = 0.07*scaleshift if 'rate' not in type else 0.07
244 y = level + shiftup*(ymax-ymin) if level < ymax else ymax - shiftdn *(ymax-ymin)
245 x = (.63*(xmax-xmin)+xmin) if not logx else math.exp( math.log(xmin) + 0.63*(math.log(xmax) - math.log(xmin)) )
246
247 requirement_text = ROOT.TLatex(x,y, f"#uparrow URD requirement = {level}" if level > ymax else f"URD requirement = {level}")
248 requirement_text.SetTextFont(42)
249 requirement_text.SetTextSize(0.04*scale if 'rate' not in type else 0.04)
250 requirement_text.SetTextColor(ROOT.kRed)
251 return requirement_line, requirement_text
252

◆ isTEfficiency()

PlotEFTrk.isTEfficiency ( obj)

Definition at line 75 of file PlotEFTrk.py.

75def isTEfficiency(obj):
76 return obj.InheritsFrom("TEfficiency")
77

◆ isTProfile()

PlotEFTrk.isTProfile ( obj)

Definition at line 78 of file PlotEFTrk.py.

78def isTProfile(obj):
79 return obj.InheritsFrom("TProfile")
80

◆ main()

PlotEFTrk.main ( )

Definition at line 573 of file PlotEFTrk.py.

573def main():
574
575 args = GetParserArgs()
576 chain = args.chain
577 inputTest = args.test
578 inputRef = args.ref
579 pipelinesRef = args.pipelineRef
580 pipelinesTest = args.pipelineTest
581 trkanalysesRef = args.trkAnalysisRef
582 trkanalysesTest = args.trkAnalysisTest
583 doTails = (args.type == 'tails')
584 doPUComparison = args.pu_comparison
585
586
587 if not doTails and not doPUComparison:
588 colors = [ ROOT.kRed, ROOT.kBlue, ROOT.kGreen+2, ROOT.kOrange+7, ROOT.kMagenta, ROOT.kCyan+1, ROOT.kViolet, ROOT.kTeal+2, ROOT.kPink+6, ROOT.kAzure+1]
589 linestyles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
590 markstyles = [ 20, 21, 22, 23, 24, 25, 26, 27, 28, 30 ]
591 inputFiles = inputRef+inputTest
592 pipelines = pipelinesRef+pipelinesTest
593 trkanalyses = trkanalysesRef+trkanalysesTest
594 inputFiles = inputRef+inputTest
595
596 print(pipelines)
597 print(trkanalyses)
598 print(inputFiles)
599
600 configs = []
601
602 for i,pipeline in enumerate(pipelines):
603 isReference = (i<len(pipelinesRef))
604 f = ROOT.TFile.Open(inputFiles[i], 'READ')
605 configs.append(getConfig(f, chain, pipeline, trkanalyses[i], args, colors[i], markstyles[i], linestyles[i], isReference))
606
607 draw(args, configs)
608
609 else:
610
611 colors = [ROOT.kRed, ROOT.kRed, ROOT.kBlue, ROOT.kBlue]
612 linestyles = [2,1,2,1]
613 markstyles = [20,0,24,0] if doTails else [20, 24, 20, 24]
614 pipelines = args.pipelineRef+args.pipelineRef+args.pipelineTest+args.pipelineTest if doTails else args.pipelineRef+args.pipelineTest
615 trkanalyses = args.trkAnalysisRef
616 trkanalyses.extend(args.trkAnalysisTest)
617 inputFiles = inputRef+inputRef+inputTest+inputTest if doTails else inputRef+inputTest
618 configs = []
619
620 for i,trkana in enumerate(trkanalyses):
621 f = ROOT.TFile.Open(inputFiles[i], 'READ')
622 configs.append(getConfig(f, chain, pipelines[i], trkanalyses[i], args, colors[i], markstyles[i], linestyles[i]))
623
624 draw(args, configs, tails=doTails,pu_comparison=doPUComparison)
625
int main()
Definition hello.cxx:18

◆ setRatioStyle()

PlotEFTrk.setRatioStyle ( ratio,
cfg,
color,
linestyle,
markstyle,
ref = 'C000',
multigraph = False,
labelsizescale = 65./35.,
lastpad = False,
splittitle = False )

Definition at line 307 of file PlotEFTrk.py.

307def setRatioStyle(ratio, cfg, color, linestyle, markstyle, ref='C000', multigraph=False, labelsizescale = 65./35., lastpad = False, splittitle = False):
308 if 'vs_truthMu' in cfg['histo']: ratio.GetXaxis().SetTitle('Truth <#mu>')
309 ratio.GetXaxis().SetTitleOffset(1.5)
310 ratio.GetYaxis().SetTitle('#splitline{Ratio wrt}{%s}' %ref if splittitle else 'Ratio wrt %s' %ref)
311 ratio.GetYaxis().SetTitleSize(0.05*labelsizescale)
312 ratio.GetYaxis().SetNdivisions(505)
313 ratio.GetYaxis().SetTitleOffset(1.3*1/labelsizescale)
314
315 if cfg['ratioyrange'] is None:
316
317 if not multigraph:
318 ratio.SetMaximum()
319 ratio.SetMinimum()
320 ratio.GetYaxis().SetRangeUser(max(0.,min(ratio.GetMinimum()-0.1,abs(1.9-ratio.GetMaximum()))),max(ratio.GetMaximum()+0.1,abs(2-ratio.GetMinimum())))
321
322 else:
323 ratio.GetYaxis().SetRangeUser(cfg['ratioyrange'][0],cfg['ratioyrange'][1])
324
325 ratio.GetXaxis().SetLabelSize(0.05*labelsizescale if lastpad else 0)
326 ratio.GetXaxis().SetTitleSize(0.05*labelsizescale if lastpad else 0)
327 ratio.GetYaxis().SetLabelSize(0.05*labelsizescale)
328 ratio.GetYaxis().SetTitleSize(0.05*labelsizescale)
329
330 if not multigraph:
331
332 ratio.SetLineColor(color)
333 ratio.SetLineStyle(linestyle)
334 ratio.SetMarkerStyle(markstyle)
335 ratio.SetMarkerColor(color)
336 ratio.SetMarkerSize(0.8)
337
#define min(a, b)
Definition cfImp.cxx:40

◆ setStyle()

PlotEFTrk.setStyle ( h,
cfg )

Definition at line 253 of file PlotEFTrk.py.

253def setStyle(h, cfg):
254
255 h.SetLineColor(cfg['linecolor'])
256 h.SetLineStyle(cfg['linestyle'])
257 h.SetMarkerStyle(cfg['markstyle'])
258 h.SetMarkerColor(cfg['markcolor'])
259 h.SetMarkerSize(0.8)
260 h.SetLineWidth(2)
261
262 if isTEfficiency(h):
263
264 ROOT.gPad.Update()
265
266 if 'Efficiencies' in cfg['category']:
267 h.GetPaintedGraph().SetMaximum(1.2 if cfg['ymax']==0 else cfg['ymax'])
268 h.GetPaintedGraph().SetMinimum(0.7 if cfg['ymin']==0 else cfg['ymin'])
269
270 else:
271
272 if 'y' in str(cfg['log']):
273 h.GetPaintedGraph().SetMaximum(10*max(1,abs(math.log10(max(h.GetPaintedGraph().GetY()))))*max(h.GetPaintedGraph().GetY()) if cfg['ymax']==0 else cfg['ymax'])
274 h.GetPaintedGraph().SetMinimum(max(1e-10, min(h.GetPaintedGraph().GetY())*(0.9)) if cfg['ymin']==0 else cfg['ymin'])
275
276 else:
277 h.GetPaintedGraph().SetMaximum(1.5*float(max(h.GetPaintedGraph().GetY())) if cfg['ymax']==0 else cfg['ymax'])
278 h.GetPaintedGraph().SetMinimum(0 if cfg['ymin']==0 else cfg['ymin'])
279
280 h.GetPaintedGraph().GetXaxis().SetTitleSize(0)
281 h.GetPaintedGraph().GetXaxis().SetLabelSize(0)
282 h.GetPaintedGraph().GetYaxis().SetLabelSize(0.05)
283 h.GetPaintedGraph().GetXaxis().SetTitleSize(0.05)
284
285 else:
286
287 if cfg['norm']:
288 h.SetMaximum(1.5 if cfg['ymax']==0 else cfg['ymax'])
289 h.SetMinimum(0 if cfg['ymin']==0 else cfg['ymin'])
290
291 else:
292
293 if 'y' in str(cfg['log']):
294 h.SetMaximum(1.5*max(1,max(1,abs(math.log10(h.GetMaximum()))))*h.GetMaximum() if cfg['ymax']==0 else cfg['ymax'])
295 h.SetMinimum(max(1e-10, h.GetMinimum()*(0.9)) if cfg['ymin']==0 else cfg['ymin'])
296 if 'avgNum' in cfg['histo']: h.SetMinimum(100 if cfg['ymin']==0 else cfg['ymin'])
297
298 else:
299 h.SetMaximum(1.4*h.GetMaximum() if cfg['ymax']==0 else cfg['ymax'])
300 h.SetMinimum(0 if cfg['ymin']==0 else cfg['ymin'])
301
302 h.GetXaxis().SetTitleSize(0)
303 h.GetXaxis().SetLabelSize(0)
304 h.GetYaxis().SetLabelSize(0.05)
305 h.GetYaxis().SetTitleSize(0.05)
306

Variable Documentation

◆ category_dict

dict PlotEFTrk.category_dict
Initial value:
1= {
2
3 'eff' : 'Efficiencies',
4 'tech_eff' : 'Efficiencies/Technical',
5 'purity' : 'Efficiencies/Purities',
6 'resolution' : 'Resolutions',
7 'parameter' : 'Parameters',
8 'fakerate' : 'FakeRates',
9 'duplrate' : 'Duplicates',
10 'num' : 'Multiplicities',
11 'summary' : 'Multiplicities',
12 'hits' : 'HitsOnTracks',
13 'pixels' : 'PixelClusters',
14 'strips' : 'StripClusters',
15 'tails' : 'Parameters',
16}

Dictionaries.

Definition at line 13 of file PlotEFTrk.py.

◆ resolution_dict

dict PlotEFTrk.resolution_dict
Initial value:
1= {
2 'resHelp' : 'resHelper',
3 'pullHelp' : 'pullHelper',
4 'pullwidth' : 'pullwidth',
5 'pullmean' : 'pullmean',
6 'res' : 'resolution',
7 'resmean' : 'resmean',
8 'corr' : 'corr'
9}

Definition at line 30 of file PlotEFTrk.py.