141 print(
"Efficiency Plots vs Time for years: ", years)
150 trigeff_vs_runlength = R.TH2D(
"trigeff_vs_runlength",\
151 "Trigger efficiency vs. Run Length;Run Length [h]; Trigger Efficiency;N_{run}",\
152 48, 0., 24., 80, .6, 1.0)
153 recoeff_vs_runlength = R.TH2D(
"recoeff_vs_runlength",\
154 "Reconstruction efficiency vs. Run Length;Run Length [h]; Reconstruction Efficiency;N_{run}",\
155 48, 0., 24., 60, .8, 1.0)
158 grl = pt.get_grl(year)
161 livetime, zlumi, zerr, olumi, timestamp, dfz_small = pt.get_dfz(args.indir, year, run, channel)
163 if livetime < pt.lblivetimecut:
164 if livetime >= 0.:
print(f
"Skip Run {run} because of live time {livetime/60:.1f} min")
167 dfz_small[
'TrigEff'] = dfz_small[channel +
'EffTrig']
168 dfz_small[
'TrigErr'] = dfz_small[channel +
'ErrTrig']
169 dfz_small[
'RecoEff'] = dfz_small[channel +
'EffReco']
170 dfz_small[
'RecoErr'] = dfz_small[channel +
'ErrReco']
173 dfz_small[
'TrigEff'] *= dfz_small[
'LBLive']
174 trig_eff_avg = dfz_small[
'TrigEff'].
sum()/livetime
177 dfz_small[
'RecoEff'] *= dfz_small[
'LBLive']
178 reco_eff_avg = dfz_small[
'RecoEff'].
sum()/livetime
181 dfz_small[
'TrigErr'] *= dfz_small[
'LBLive']
182 dfz_small[
'TrigErr'] *= dfz_small[
'TrigErr']
183 trig_err_avg = math.sqrt(dfz_small[
'TrigErr'].
sum())/livetime
186 dfz_small[
'RecoErr'] *= dfz_small[
'LBLive']
187 dfz_small[
'RecoErr'] *= dfz_small[
'RecoErr']
188 reco_err_avg = math.sqrt(dfz_small[
'RecoErr'].
sum())/livetime
190 arr_date.append(timestamp)
191 arr_trigeff.append(trig_eff_avg)
192 arr_trigerr.append(trig_err_avg)
193 arr_recoeff.append(reco_eff_avg)
194 arr_recoerr.append(reco_err_avg)
197 trigeff_vs_runlength.Fill(
min(livetime/3600, 23.99), trig_eff_avg)
198 recoeff_vs_runlength.Fill(
min(livetime/3600, 23.99), reco_eff_avg)
200 arr_date =
array(
'd', arr_date)
202 arr_trigeff = np.array(arr_trigeff)
203 arr_trigerr = np.array(arr_trigerr)
204 arr_recoeff = np.array(arr_recoeff)
205 arr_recoerr = np.array(arr_recoerr)
209 elif channel ==
"Zmumu":
211 ymin, ymax = 0.64, 0.96
213 trig_graph = R.TGraphErrors(len(arr_date), arr_date, arr_trigeff, R.nullptr,arr_trigerr)
214 trig_graph.GetHistogram().SetYTitle(
"Efficiency")
215 trig_graph.GetHistogram().GetYaxis().SetRangeUser(ymin, ymax)
216 trig_graph.GetXaxis().SetTimeDisplay(2)
217 trig_graph.GetXaxis().SetNdivisions(9,R.kFALSE)
218 trig_graph.GetXaxis().SetTimeFormat(time_format)
219 trig_graph.GetXaxis().SetTimeOffset(0,
"gmt")
220 trig_graph.SetMarkerSize(1)
222 reco_graph = R.TGraphErrors(len(arr_date), arr_date, arr_recoeff, R.nullptr,arr_recoerr)
223 reco_graph.GetHistogram().GetYaxis().SetRangeUser(ymin, ymax)
224 reco_graph.GetXaxis().SetTimeDisplay(2)
225 reco_graph.GetXaxis().SetNdivisions(9,R.kFALSE)
226 reco_graph.GetXaxis().SetTimeFormat(time_format)
227 reco_graph.GetXaxis().SetTimeOffset(0,
"gmt")
228 reco_graph.SetMarkerSize(1)
229 reco_graph.SetMarkerStyle(21)
230 reco_graph.SetMarkerColor(R.kRed)
231 reco_graph.SetLineColor(R.kRed)
233 if out_tag ==
"run3":
234 c1 = R.TCanvas(
"c1",
"c1", 2000, 1200)
238 trig_graph.Draw(
"ap")
242 leg = R.TLegend(0.645, 0.2, 0.805, 0.4)
243 pt.drawAtlasLabel(0.2, ymax-0.64,
"Internal")
244 pt.drawText(0.2, ymax-0.70, date_tag, size=labelsize)
245 pt.drawText(0.2, ymax-0.76, pt.plotlabel[channel] +
" counting", size=labelsize)
246 elif channel ==
"Zmumu":
247 leg = R.TLegend(0.645, 0.45, 0.805, 0.65)
248 pt.drawAtlasLabel(0.2, ymax-0.36,
"Internal")
249 pt.drawText(0.2, ymax-0.42, date_tag, size=labelsize)
250 pt.drawText(0.2, ymax-0.48, pt.plotlabel[channel] +
" counting", size=labelsize)
253 leg.SetTextSize(0.07)
254 leg.AddEntry(reco_graph,
"#varepsilon_{reco}^{single-"+lep+
"}",
"ep")
255 leg.AddEntry(trig_graph,
"#varepsilon_{trig}^{single-"+lep+
"}",
"ep")
260 new_trig_line = R.TLine(1683743066.0, ymin, 1683743066.0, ymax)
261 new_trig_line.SetLineColor(R.kBlue)
262 new_trig_line.SetLineWidth(3)
263 new_trig_line.SetLineStyle(2)
264 new_trig_line.Draw(
"same")
267 trig_graph.GetHistogram().SetXTitle(
"Date")
268 c1.SaveAs(outdir + channel +
"_eff_vs_time_"+out_tag+
".pdf")
270 c1.SetRightMargin(0.15)
271 trigeff_vs_runlength.Draw(
"colz")
273 ymin, ymax = 0.73, 0.95
274 elif channel ==
"Zmumu":
275 ymin, ymax = 0.6, 0.85
276 trigeff_vs_runlength.GetYaxis().SetRangeUser(ymin, ymax)
277 pt.drawAtlasLabel(0.2, 0.89,
"Internal")
278 pt.drawText(0.2, 0.83, date_tag, size=labelsize)
279 pt.drawText(0.2, 0.77, pt.plotlabel[channel] +
" counting", size=labelsize)
280 c1.SaveAs(outdir + channel +
"_trigeff_vs_runlength_"+out_tag+
".pdf")
282 recoeff_vs_runlength.Draw(
"colz")
284 ymin, ymax = 0.8, 0.95
285 elif channel ==
"Zmumu":
286 ymin, ymax = 0.92, 1.0
287 recoeff_vs_runlength.GetYaxis().SetRangeUser(ymin, ymax)
288 pt.drawAtlasLabel(0.2, 0.89,
"Internal")
289 pt.drawText(0.2, 0.83, date_tag, size=labelsize)
290 pt.drawText(0.2, 0.77, pt.plotlabel[channel] +
" counting", size=labelsize)
291 c1.SaveAs(outdir + channel +
"_recoeff_vs_runlength_"+out_tag+
".pdf")