ATLAS Offline Software
Functions | Variables
plotting.yearwise_efficiency_vs_mu Namespace Reference

Functions

def main ()
 
def plot_efficiency_comb (channel, years)
 

Variables

 parser = argparse.ArgumentParser()
 
 type
 
 str
 
 help
 
 args = parser.parse_args()
 
 year = args.year
 
 channel = args.channel
 
 indir = args.indir
 
 outdir = args.outdir
 
list years = ["22", "23", "24"]
 
string out_tag = "run3"
 
string time_format = "%m/%y"
 
 ymin
 
 ymax
 
string xtitle = 'Month / Year'
 
string date_tag = "Run 3, #sqrt{s} = 13.6 TeV"
 
float xval = 0.30
 
float yval = 0.33
 
int set_size = 1
 

Function Documentation

◆ main()

def plotting.yearwise_efficiency_vs_mu.main ( )

Definition at line 52 of file yearwise_efficiency_vs_mu.py.

52 def main():
53  plot_efficiency_comb(channel, years)
54 

◆ plot_efficiency_comb()

def plotting.yearwise_efficiency_vs_mu.plot_efficiency_comb (   channel,
  years 
)

Definition at line 55 of file yearwise_efficiency_vs_mu.py.

55 def plot_efficiency_comb(channel, years):
56 
57  all_graphs = []
58 
59  for year in years:
60  dict_comb = {}
61  dict_comb_err = {}
62  dict_mu = {}
63 
64  vec_comb = array('d')
65  vec_comb_err = array('d')
66  vec_mu = array('d')
67 
68  grl = pt.get_grl(year)
69 
70  for run in grl:
71  livetime, zlumi, zerr, olumi, timestamp, dfz_small = pt.get_dfz(args.indir, year, run, channel)
72 
73  # Cut out short runs
74  if livetime < pt.runlivetimecut:
75  if livetime >= 0.: print(f"Skip Run {run} because of live time {livetime/60:.1f} min")
76  continue
77 
78  dfz_small['CombEff'] = dfz_small[channel + 'EffComb']
79  dfz_small['CombErr'] = dfz_small[channel + 'ErrComb']
80 
81  # Scale event-level efficiency with FMC
82  campaign = "mc23a"
83  dfz_small['CombEff'] *= dq_cf.correction(dfz_small['OffMu'], channel, campaign, int(run))
84  dfz_small['CombErr'] *= dq_cf.correction(dfz_small['OffMu'], channel, campaign, int(run))
85 
86  for index, event in dfz_small.iterrows():
87  pileup = int(event.OffMu)
88 
89  weight_comb = 1/pow(event.CombErr, 2)
90  if pileup not in dict_mu:
91  dict_mu[pileup] = pileup
92  dict_comb[pileup] = weight_comb * event.CombEff
93  dict_comb_err[pileup] = weight_comb
94  else:
95  dict_comb[pileup] += weight_comb * event.CombEff
96  dict_comb_err[pileup] += weight_comb
97 
98  if not dict_mu:
99  print("File has no filled lumi blocks!")
100  return
101 
102  for pileup in dict_mu:
103  comb_weighted_average = dict_comb[pileup]/dict_comb_err[pileup]
104  comb_error = sqrt(1/dict_comb_err[pileup])
105  vec_comb.append(comb_weighted_average)
106  vec_comb_err.append(comb_error)
107 
108  vec_mu.append(pileup)
109 
110  all_graphs.append((year, R.TGraphErrors(len(vec_comb), vec_mu, vec_comb, R.nullptr, vec_comb_err)))
111 
112  # now draw all
113  c1 = R.TCanvas()
114  leg = R.TLegend(0.645, 0.7, 0.805, 0.9)
115  if channel == "Zee":
116  ymin, ymax = 0.52, 0.74
117  elif channel == "Zmumu":
118  ymin, ymax = 0.74, 0.84
119  xmin, xmax = 0, 80
120 
121  for igraph in range(len(all_graphs)):
122  comb_graph = all_graphs[igraph][1]
123  comb_graph.SetMarkerSize(1)
124  comb_graph.SetMarkerColor(R.kBlack+igraph)
125  comb_graph.SetMarkerStyle(R.kFullCircle+igraph)
126  if igraph == 0:
127  comb_graph.Draw("ap")
128  comb_graph.GetHistogram().SetYTitle("#varepsilon_{event}^{"+pt.plotlabel[channel]+"}#times F^{MC}")
129  comb_graph.GetHistogram().GetYaxis().SetRangeUser(ymin, ymax)
130  comb_graph.GetHistogram().GetXaxis().SetLimits(xmin, xmax)
131  comb_graph.GetHistogram().SetXTitle("Pileup (#mu)")
132  else:
133  comb_graph.Draw("p same")
134  leg.SetBorderSize(0)
135  leg.SetTextSize(0.07)
136  leg.AddEntry(comb_graph, "Data 20"+all_graphs[igraph][0], "ep")
137  leg.Draw()
138 
139  if channel == "Zee":
140  pt.drawAtlasLabel(0.6, ymax-0.46, "Internal")
141  pt.drawText(0.2, ymax-0.46, date_tag)
142  pt.drawText(0.2, ymax-0.52, pt.plotlabel[channel] + " counting")
143  elif channel == "Zmumu":
144  pt.drawAtlasLabel(0.6, ymax-0.56, "Internal")
145  pt.drawText(0.2, ymax-0.62, pt.plotlabel[channel] + " counting")
146 
147  c1.SaveAs(outdir + channel + "_eventeff_vs_mu_"+out_tag+".pdf")
148 

Variable Documentation

◆ args

plotting.yearwise_efficiency_vs_mu.args = parser.parse_args()

Definition at line 21 of file yearwise_efficiency_vs_mu.py.

◆ channel

plotting.yearwise_efficiency_vs_mu.channel = args.channel

Definition at line 23 of file yearwise_efficiency_vs_mu.py.

◆ date_tag

string plotting.yearwise_efficiency_vs_mu.date_tag = "Run 3, #sqrt{s} = 13.6 TeV"

Definition at line 33 of file yearwise_efficiency_vs_mu.py.

◆ help

plotting.yearwise_efficiency_vs_mu.help

Definition at line 16 of file yearwise_efficiency_vs_mu.py.

◆ indir

plotting.yearwise_efficiency_vs_mu.indir = args.indir

Definition at line 24 of file yearwise_efficiency_vs_mu.py.

◆ out_tag

string plotting.yearwise_efficiency_vs_mu.out_tag = "run3"

Definition at line 29 of file yearwise_efficiency_vs_mu.py.

◆ outdir

plotting.yearwise_efficiency_vs_mu.outdir = args.outdir

Definition at line 25 of file yearwise_efficiency_vs_mu.py.

◆ parser

plotting.yearwise_efficiency_vs_mu.parser = argparse.ArgumentParser()

Definition at line 15 of file yearwise_efficiency_vs_mu.py.

◆ set_size

int plotting.yearwise_efficiency_vs_mu.set_size = 1

Definition at line 40 of file yearwise_efficiency_vs_mu.py.

◆ str

plotting.yearwise_efficiency_vs_mu.str

Definition at line 16 of file yearwise_efficiency_vs_mu.py.

◆ time_format

string plotting.yearwise_efficiency_vs_mu.time_format = "%m/%y"

Definition at line 30 of file yearwise_efficiency_vs_mu.py.

◆ type

plotting.yearwise_efficiency_vs_mu.type

Definition at line 16 of file yearwise_efficiency_vs_mu.py.

◆ xtitle

string plotting.yearwise_efficiency_vs_mu.xtitle = 'Month / Year'

Definition at line 32 of file yearwise_efficiency_vs_mu.py.

◆ xval

float plotting.yearwise_efficiency_vs_mu.xval = 0.30

Definition at line 35 of file yearwise_efficiency_vs_mu.py.

◆ year

plotting.yearwise_efficiency_vs_mu.year = args.year

Definition at line 22 of file yearwise_efficiency_vs_mu.py.

◆ years

list plotting.yearwise_efficiency_vs_mu.years = ["22", "23", "24"]

Definition at line 28 of file yearwise_efficiency_vs_mu.py.

◆ ymax

plotting.yearwise_efficiency_vs_mu.ymax

Definition at line 31 of file yearwise_efficiency_vs_mu.py.

◆ ymin

plotting.yearwise_efficiency_vs_mu.ymin

Definition at line 31 of file yearwise_efficiency_vs_mu.py.

◆ yval

float plotting.yearwise_efficiency_vs_mu.yval = 0.33

Definition at line 36 of file yearwise_efficiency_vs_mu.py.

CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
plotting.yearwise_efficiency_vs_mu.plot_efficiency_comb
def plot_efficiency_comb(channel, years)
Definition: yearwise_efficiency_vs_mu.py:55
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
array
plotting.yearwise_efficiency_vs_mu.main
def main()
Definition: yearwise_efficiency_vs_mu.py:52
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70