7 ROOT.gStyle.SetOptStat(0)
8 ROOT.gStyle.SetTitleFont(42,
"xy")
9 ROOT.gStyle.SetTitleFont(42,
"t")
11 ScalarColor = ROOT.kPink+4
12 DarkPhotonColor = ROOT.kAzure-3
13 ElectronColor = ROOT.kRed-3
14 MuonColor = ROOT.kBlue-3
15 PionColor = ROOT.kGreen-3
20 canvas = ROOT.TCanvas(
'whoCares'+name ,
'name', 1600,1600)
26 canvas.SaveAs(prefix+name+
'.pdf')
31 if prefix !=
'' and prefix[-1] !=
'_':
35 if isinstance(hists, list):
39 hist.Scale( 1./
float(hist.GetEntries()) )
40 hist.SetYTitle(
'Normalized to Unity')
41 if hist.GetMaximum() > maxY
and (
'Electron' in hist.GetName()
or 'Pion' in hist.GetName()
or 'Muon' in hist.GetName()):
42 maxY = hist.GetMaximum()
43 maxEntries = hist.GetEntries()
48 legend = ROOT.TLegend(.6, .65, .85, .89)
49 legend.SetFillColor(0)
50 legend.SetBorderSize(0)
51 legend.SetTextFont(102)
52 legend.SetTextSize(0.04)
54 canvas = ROOT.TCanvas(
'whoCares'+name ,
'name', 1600,1200)
58 for index,hist
in enumerate(hists):
65 if 'Electron' in hist.GetName():
66 legend.AddEntry(hist,
'#splitline{Electrons}{'+
str(
int(hist.GetEntries()))+
' events}',
'f')
67 hist.SetLineColor(ElectronColor)
68 hist.SetMaximum(1.2*maxY )
70 elif 'Muon' in hist.GetName():
71 legend.AddEntry(hist,
'#splitline{Muons}{'+
str(
int(hist.GetEntries()))+
' events}',
'f')
72 hist.SetLineColor(MuonColor)
73 hist.SetMaximum(1.2*maxY )
75 elif 'Pion' in hist.GetName():
76 legend.AddEntry(hist,
'#splitline{Pions}{'+
str(
int(hist.GetEntries()))+
' events}',
'f')
77 hist.SetLineColor(PionColor)
78 hist.SetMaximum(1.2*maxY )
80 elif 'DarkPhoton' in hist.GetName()
or 'darkPhoton' in hist.GetName():
81 hist.SetLineColor(DarkPhotonColor)
85 elif 'Scalar' in hist.GetName()
or 'scalar' in hist.GetName():
86 hist.SetLineColor(ScalarColor)
90 hist.Draw(drawOptions)
95 canvas.SaveAs(prefix+name+
'.pdf')
97 if not 'darkPhoton' in name:
98 name =
'darkPhoton'+name
100 makePdf(name, darkphotonhist, prefix)
103 if not 'scalar' in name:
106 makePdf(name, scalarhist, prefix)
109 canvas = ROOT.TCanvas(
'whoCares2'+name ,
'name', 1600,1200)
112 canvas.SaveAs(prefix+name+
'.pdf')
115 if __name__==
'__main__':
116 ROOT.gROOT.SetBatch(1)
117 parser = optparse.OptionParser()
118 parser.add_option(
'-f',
'--file', dest=
'hist_file_in', help=
'path to ROOT file with histograms' )
119 parser.add_option(
'-p',
'--prefix', dest=
'prefix', default=
'', help=
'prefix to all output pdfs' )
122 (options, args) = parser.parse_args()
124 if not options.hist_file_in:
125 print 'ERROR: input file (./plotmaker.py -f <path to ROOT file>) needed'
129 hist_file = ROOT.TFile.Open(options.hist_file_in,
'r')
131 print 'Path provided to ROOT file is incorrect. Or something is wrong with the file.'
135 hist1DDict = {
'darkPhotonPt': [],
'darkPhotonEta':[],
'darkPhotonPhi': [],
'Polarization': [],
136 'scalarPt': [],
'scalarEta':[],
'scalarPhi': [],
137 'decayR1D': [],
'decayZ1D':[],
138 'OpeningR':[],
'OpeningPhi':[],
'OpeningEta':[],
139 'ptBalance':[],
'subLeadingPt':[],
'leadingPt':[]}
141 hist2DDict = {
'decayZR2D':
None,
'decayEtaR2D':
None }
143 keys = hist_file.GetListOfKeys()
145 keyName = key.GetName()
146 for histName
in hist1DDict.keys():
147 if histName
in keyName:
149 hist_file.GetObject(keyName, hist)
150 if hist.GetEntries() == 0:
152 hist1DDict[histName].
append(hist)
158 keyName = key.GetName()
159 for histName
in hist2DDict.keys():
160 if histName
in keyName:
162 hist_file.GetObject(keyName, hist)
163 if hist.GetEntries() == 0:
165 hist2DDict[histName] = hist
170 for name,hist
in hist1DDict.iteritems():
171 makePdf(name, hist, options.prefix)
174 for name,hist
in hist2DDict.iteritems():