32 def MakeComparisonPlot( refHist, testHist, plotName, path, doNorm = False, doRatio = True ):
38 print(
'WARNING Ref Histogram not found: '+plotName)
41 print(
'WARNING Test histogram not found: '+plotName)
42 print(
' Creating empty plot')
48 refint = refHist.Integral()
51 testint = testHist.Integral()
55 refHist.Scale( 1./refint )
57 print(
'WARNING empty ref plot ' + plotName )
60 testHist.Scale( 1./testint )
62 print(
'WARNING empty test plot ' + plotName )
64 canvas = ROOT.TCanvas(
"",
"", 860, 900 )
65 canvas.SetLeftMargin( 0 )
66 padMain = ROOT.TPad(
'padMain',
'padMain', 0, 0.3, 1, 1 )
67 padMain.SetBottomMargin( 0 )
71 padRatio = ROOT.TPad(
'padRatio',
'padRatio', 0, 0, 1, 0.3 )
72 padRatio.SetTopMargin( 0 )
73 padRatio.SetBottomMargin( 0.4 )
77 if 'cone' in plotName:
80 leg = ROOT.TLegend( 0.82, 0.77, 0.96, .96 )
81 leg.SetFillColor( ROOT.kWhite )
82 leg.SetTextSizePixels(20)
84 testHist.SetMarkerColor(ROOT.kRed)
85 testHist.SetLineColor(ROOT.kRed)
86 leg.AddEntry(testHist,
"test",
'P')
88 testHist.GetYaxis().SetTitleOffset( 1.4 )
89 testHist.GetYaxis().SetTitleSize( labelsize*0.4 )
90 testHist.SetLabelSize( labelsize*0.4,
'Y' )
92 for i
in testHist.GetListOfFunctions():
93 testHist.GetFunction(i.GetName()).SetBit(ROOT.TF1.kNotDraw)
96 for i
in refHist.GetListOfFunctions():
97 refHist.GetFunction(i.GetName()).SetBit(ROOT.TF1.kNotDraw)
99 refHist.SetMarkerColor(ROOT.kBlack)
100 refHist.SetLineColor(ROOT.kBlack)
101 leg.AddEntry(refHist,
"ref",
'P')
102 if 'cone' not in plotName:
105 refHist.Draw(
"PESAME")
106 testHist.Draw(
"PESAME")
123 if refint == 0
or testint == 0:
124 print(
'WARNING No ratio plot available: '+ plotName )
126 print(
'INFO skipping ratio plot for '+ plotName )
129 ratioHist = testHist.Clone()
130 ratioHist.Divide( refHist )
131 ratioHist.SetMarkerColor( ROOT.kBlack )
132 ratioHist.SetMaximum(1.2)
133 ratioHist.SetMinimum(0.8)
134 ratioHist.SetLineColor( ROOT.kBlack )
135 ratioHist.GetYaxis().SetTitle(
"test / ref" )
136 xtitle = ratioHist.GetXaxis().GetTitle()
137 if 'Transverse Momentum' in xtitle:
138 ratioHist.GetXaxis().SetTitle(xtitle.replace(
'Transverse Momentum',
'pT'))
140 ratioHist.GetXaxis().SetTitleSize( titlesize )
141 ratioHist.GetYaxis().SetTitleSize( labelsize )
142 ratioHist.SetLabelSize( labelsize,
'XY' )
143 ratioHist.GetXaxis().SetTitleOffset( 1.0 )
144 ratioHist.GetYaxis().SetTitleOffset( .4 )
147 lineRatio = ROOT.TLine( ratioHist.GetXaxis().GetXmin(), 1,
148 ratioHist.GetXaxis().GetXmax(), 1 )
149 lineRatio.SetLineColor( ROOT.kRed )
150 lineRatio.SetLineWidth( 2 )
151 lineRatio.Draw(
"same")
154 canvas.SaveAs( path +
'/' + plotName +
'.png' )
155 del canvas, padRatio, padMain