28def makePdf(name, hists, prefix):
29 if len(hists) == 0:
30 return
31 if prefix != '' and prefix[-1] != '_':
32 prefix += '_'
33 pass
34
35 if isinstance(hists, list):
36 maxY = -999
37 maxEntries = -999
38 for hist in hists:
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()
44 pass
45 hist.SetLineWidth(2)
46 pass
47
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)
53
54 canvas = ROOT.TCanvas('whoCares'+name , 'name', 1600,1200)
55 canvas.cd(0)
56 scalarhist = None
57 darkphotonhist = None
58 for index,hist in enumerate(hists):
59
60 drawOptions = 'HIST'
61 if index!=0:
62 drawOptions += 'SAME'
63 pass
64
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 )
69 pass
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 )
74 pass
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 )
79 pass
80 elif 'DarkPhoton' in hist.GetName() or 'darkPhoton' in hist.GetName():
81 hist.SetLineColor(DarkPhotonColor)
82 darkphotonhist = hist
83 continue
84 pass
85 elif 'Scalar' in hist.GetName() or 'scalar' in hist.GetName():
86 hist.SetLineColor(ScalarColor)
87 scalarhist = hist
88 continue
89 pass
90 hist.Draw(drawOptions)
91 pass
92 if legend.GetNRows():
93 legend.Draw()
94 pass
95 canvas.SaveAs(prefix+name+'.pdf')
96 if darkphotonhist:
97 if not 'darkPhoton' in name:
98 name = 'darkPhoton'+name
99 pass
100 makePdf(name, darkphotonhist, prefix)
101 pass
102 if scalarhist:
103 if not 'scalar' in name:
104 name = 'scalar'+name
105 pass
106 makePdf(name, scalarhist, prefix)
107 pass
108 else:
109 canvas = ROOT.TCanvas('whoCares2'+name , 'name', 1600,1200)
110 canvas.cd(0)
111 hists.Draw('HIST')
112 canvas.SaveAs(prefix+name+'.pdf')
113
114