25 dfz = pd.read_csv(infilename, delimiter=
",")
27 print(
'No data in file', infilename,
', exiting.')
30 run_number = dfz.RunNum[0]
31 lhc_fill = dfz.FillNum[0]
33 EffTrig = channel +
'EffTrig'
34 EffReco = channel +
'EffReco'
35 ErrTrig = channel +
'ErrTrig'
36 ErrReco = channel +
'ErrReco'
38 dfz = dfz.drop(dfz[(dfz[channel+
'Lumi'] == 0)].index)
39 dfz = dfz.drop(dfz[(dfz[
'LBLive']<pt.lblivetimecut) | (dfz[
'PassGRL']==0)].index)
41 print(
"No valid LBs found. Exiting")
45 channel_string =
"Z #rightarrow ee"
47 leg = R.TLegend(0.7, 0.7, 0.85, 0.9)
50 elif channel ==
"Zmumu":
51 channel_string =
"Z #rightarrow #mu#mu"
55 leg = R.TLegend(0.7, 0.55, 0.85, 0.75)
57 print(
"Wrong channel, exit.")
66 for index, event
in dfz.iterrows():
68 pileup =
int(event.OffMu)
70 pileup = (event.LBNum // 20)*20
72 if event[ErrTrig] == 0.0
or event[ErrReco] == 0.0:
75 weight_trig = 1/
pow(event[ErrTrig], 2)
76 weight_reco = 1/
pow(event[ErrReco], 2)
77 if pileup
not in dict_mu:
78 dict_mu[pileup] = pileup
79 dict_trig[pileup] = weight_trig * event[EffTrig]
80 dict_reco[pileup] = weight_reco * event[EffReco]
81 dict_trig_err[pileup] = weight_trig
82 dict_reco_err[pileup] = weight_reco
84 dict_trig[pileup] += weight_trig * event[EffTrig]
85 dict_reco[pileup] += weight_reco * event[EffReco]
86 dict_trig_err[pileup] += weight_trig
87 dict_reco_err[pileup] += weight_reco
90 vec_trig_err =
array(
'd')
92 vec_reco_err =
array(
'd')
96 print(
"File "+infilename+
" has no filled lumi blocks!")
99 for pileup
in dict_mu:
100 trig_weighted_average = dict_trig[pileup]/dict_trig_err[pileup]
101 trig_error = sqrt(1/dict_trig_err[pileup])
102 vec_trig.append(trig_weighted_average)
103 vec_trig_err.append(trig_error)
105 reco_weighted_average = dict_reco[pileup]/dict_reco_err[pileup]
106 reco_error = sqrt(1/dict_reco_err[pileup])
107 vec_reco.append(reco_weighted_average)
108 vec_reco_err.append(reco_error)
110 vec_mu.append(pileup)
112 trig_graph = R.TGraphErrors(len(vec_trig), vec_mu, vec_trig, R.nullptr, vec_trig_err)
113 trig_graph.GetHistogram().SetYTitle(
"Efficiency")
114 trig_graph.GetHistogram().GetYaxis().SetRangeUser(ymin, 1.0)
115 trig_graph.SetMarkerSize(1)
117 reco_graph = R.TGraphErrors(len(vec_reco), vec_mu, vec_reco, R.nullptr, vec_reco_err)
118 reco_graph.GetHistogram().GetYaxis().SetRangeUser(ymin, 1.0)
119 reco_graph.SetMarkerSize(1)
120 reco_graph.SetMarkerStyle(21)
121 reco_graph.SetMarkerColor(R.kRed)
122 reco_graph.SetLineColor(R.kRed)
125 leg.SetTextSize(0.07)
126 leg.AddEntry(reco_graph,
"#varepsilon_{reco}^{single-"+lep+
"}",
"ep")
127 leg.AddEntry(trig_graph,
"#varepsilon_{trig}^{single-"+lep+
"}",
"ep")
130 trig_graph.Draw(
"ap")
133 pt.drawAtlasLabel(0.2, ylabel,
"Internal")
134 if run_number < 427394:
135 yearsqrtstxt =
"Data 20" + pt.get_year(run_number) +
", #sqrt{s} = 13 TeV"
137 yearsqrtstxt =
"Data 20" + pt.get_year(run_number) +
", #sqrt{s} = 13.6 TeV"
138 pt.drawText(0.2, ylabel-0.05, yearsqrtstxt, size=22)
139 pt.drawText(0.2, ylabel-0.1,
"LHC Fill " +
str(lhc_fill), size=22)
140 pt.drawText(0.2, ylabel-0.15, channel_string +
" counting", size=22)
144 trig_graph.GetHistogram().SetXTitle(
"<#mu>")
145 c1.SaveAs(outdir+
"/"+channel+
"_eff_vs_mu.pdf")
147 trig_graph.GetHistogram().SetXTitle(
"Luminosity Block Number")
148 c1.SaveAs(outdir+
"/"+channel+
"_eff_vs_lb.pdf")