5 from array
import array
7 from PlotUtils
import PlotUtils, DiagnosticHisto
8 from CheckAppliedSFs
import KnownWPs, getArgParser, getCalibReleasesAndWP
14 var_name = "", axis_title ="",
15 bins = -1, bmin = 0., bmax = 0.,
24 self.
__muon_var = test_tree.GetLeaf(
"Muon_%s"%(var_name))
25 self.
__norm = 1.
if var_name.find(
"pt") == -1
else 1./1.e3
27 self.
__var_name =
"%s%s_%s_%s"%(
"" if len(calib) == 0
else calib+
"_", wp,var_name, sys)
31 self.
__nom_sf = test_tree.GetLeaf(
"%s%s_SF"%(
"" if len(calib) == 0
else "c%s_"%(calib), wp))
32 self.
__1up_sf = test_tree.GetLeaf(
"%s%s_SF__MUON_EFF_%s_%s__1up"%(
"" if len(calib) == 0
else "c%s_"%(calib), wp,KnownWPs[wp],sys))
33 self.
__1dn_sf = test_tree.GetLeaf(
"%s%s_SF__MUON_EFF_%s_%s__1down"%(
"" if len(calib) == 0
else "c%s_"%(calib), wp,KnownWPs[wp],sys))
36 axis_title = axis_title,
37 bins = bins, bmin = bmin, bmax = bmax,
39 log_binning = log_binning)
42 axis_title = axis_title,
43 bins = bins, bmin = bmin, bmax = bmax,
45 log_binning = log_binning )
48 axis_title = axis_title,
49 bins = bins, bmin = bmin, bmax = bmax,
51 log_binning = log_binning )
75 if __name__ ==
"__main__":
78 if not os.path.exists(Options.InputFile):
79 print 'ERROR: File %s does not exist!'%Options.InputFile
81 infile = ROOT.TFile(Options.InputFile)
83 tree = infile.Get(
"MuonEfficiencyTest")
87 WPs = [wp
for wp
in Options.WP
if wp
in WPs]
88 print 'INFO: WPs given by user, only plot: %s'%(
",".
join(WPs))
91 ROOT.gROOT.Macro(
"rootlogon.C")
92 ROOT.gROOT.SetStyle(
"ATLAS")
93 ROOT.gROOT.SetBatch(1)
96 if os.path.isdir(Options.outDir) ==
False:
97 os.system(
"mkdir -p %s"%(Options.outDir))
99 bonusname=Options.bonusname
103 for calib
in calibReleases:
105 for sys
in [
"SYS",
"STAT"]:
109 axis_title =
"p_{T} #mu(%s) [GeV]"%(wp),
110 calib = calib, log_binning =
True,
111 bins = 25, bmin = 15, bmax = 1000,
112 wp =wp, sys = sys, test_tree = tree),
115 axis_title =
"#eta #mu(%s)"%(wp),
117 bins =54 , bmin = -2.7, bmax = 2.7,
118 wp =wp, sys = sys, test_tree = tree),
121 axis_title =
"#phi (%s)"%(wp),
123 bins =20 , bmin = -3.15, bmax = 3.15,
124 wp =wp, sys = sys, test_tree = tree) ]
126 for i
in range(tree.GetEntries()):
128 if i > 0
and i % 5000 == 0:
129 print "INFO: %d/%d events processed"%(i, tree.GetEntries())
132 if tree.Muon_isHighPt ==
True or H.name().
find(
"HighPt") == -1: H.fill()
134 print "INFO: Histograms filled"
135 dummy = ROOT.TCanvas(
"dummy",
"dummy", 800, 600)
136 dummy.SaveAs(
"%s/AllSystDep%s.pdf[" % (Options.outDir, bonusname))
139 pu.Prepare1PadCanvas(H.name())
141 nom = H.get_nom_H1().TH1()
142 dn = H.get_1dn_H1().TH1()
143 up = H.get_1up_H1().TH1()
145 up.SetLineColor(ROOT.kRed)
146 dn.SetLineColor(ROOT.kBlue)
152 up.SetTitle(
"+1#sigma %s"%(
"systematic" if H.get_sys() ==
"SYS" else "statistics"))
153 dn.SetTitle(
"-1#sigma %s"%(
"systematic" if H.get_sys() ==
"SYS" else "statistics"))
155 nom.GetYaxis().SetTitle(
"Ratio to nominal")
156 pu.drawStyling(nom, 0.95,
157 1.05, TopPad =
False)
162 pu.CreateLegend(0.7, 0.8, 0.9, 0.9)
163 pu.AddToLegend([up, dn])
165 pu.DrawAtlas(0.2, 0.9)
166 pu.DrawSqrtS(0.2, 0.85)
167 pu.DrawTLatex(0.2,0.8,
"%s, %s"%(H.get_wp(), H.get_calib()))
171 pu.saveHisto(
"%s/SysCheck%s%s"%(Options.outDir, H.name(),bonusname) ,[
"pdf"])
172 pu.saveHisto(
"%s/AllSystDep%s" % (Options.outDir, bonusname),[
"pdf"])
174 dummy.SaveAs(
"%s/AllSystDep%s.pdf]" % (Options.outDir, bonusname))