ATLAS Offline Software
Functions | Variables
plotting.yearwise_luminosity_vs_mu Namespace Reference

Functions

def main ()
 

Variables

 parser = argparse.ArgumentParser()
 
 type
 
 str
 
 help
 
 action
 
 args = parser.parse_args()
 
 year = args.year
 
 channel = args.channel
 
 comp = args.comp
 
 indir = args.indir
 
 outdir = args.outdir
 
float xmin = 0.2
 
 bins = np.concatenate((np.array([0, 10]), np.linspace(11, 17, 7), np.array([18, 22])))
 
string date_string = "Run 2, #sqrt{s} = 13 TeV"
 
 grl = pt.get_grl("15")
 
string out_tag = "run2"
 
string outfile = "ZeeZmm_ratio_vs_mu_"+out_tag+".pdf"
 
 ymin
 
 ymax
 

Function Documentation

◆ main()

def plotting.yearwise_luminosity_vs_mu.main ( )

Definition at line 73 of file yearwise_luminosity_vs_mu.py.

73 def main():
74  dflist = []
75  for run in grl:
76  livetime, zlumi, zerr, olumi, timestamp, dfz_small = pt.get_dfz(args.indir, year, run, channel)
77 
78  # Cut out short runs
79  if livetime < pt.runlivetimecut:
80  if livetime >= 0.: print(f"Skip Run {run} because of live time {livetime/60:.1f} min")
81  continue
82 
83  # Cut out early 2016 runs with "strange" bunch structure
84  if (year == "16" and dfz_small['LBStart'].iloc[0] < 1463184000) or run == "310247":
85  continue
86 
87  dflist.append(dfz_small)
88 
89  df = pd.concat(dflist)
90  df['OffMu'] = df['OffMu'].round(0)
91  df = df.groupby(pd.cut(df.OffMu, bins, right=False)).sum()
92  df.reset_index(drop=True, inplace=True)
93  if comp:
94  df['ZeeLumiErr'] = np.sqrt(df['ZeeLumiErr'])
95  df['ZmumuLumiErr'] = np.sqrt(df['ZmumuLumiErr'])
96  df['Ratio'] = df['ZeeLumi'] / df['ZmumuLumi']
97  df['RatioErr'] = df['Ratio'] * np.sqrt(pow(df['ZeeLumiErr'] / df['ZeeLumi'], 2) + pow(df['ZmumuLumiErr'] / df['ZmumuLumi'], 2))
98  else:
99  df['ZLumiErr'] = np.sqrt(df['ZLumiErr'])
100  df['Bin'] = pd.Series(bins)
101 
102  norm = df['ZLumi'].sum() / df['OffLumi'].sum()
103  df['Ratio'] = df['ZLumi'] / df['OffLumi'] / norm
104  df['RatioErr'] = df['ZLumiErr'] / df['OffLumi'] / norm
105 
106  h_total = R.TH1F("h_total", "", len(bins)-1, bins)
107 
108  nan_list = df[df['Ratio'].isnull()].index.tolist()
109 
110  arr_ratio = []
111 
112  for xbin in range(0, h_total.GetNbinsX()):
113 
114  if xbin in nan_list:
115  continue
116 
117  try:
118  h_total.SetBinContent(xbin+1, df['Ratio'][xbin])
119  h_total.SetBinError(xbin+1, df['RatioErr'][xbin])
120  arr_ratio.append(df['Ratio'][xbin])
121 
122  except KeyError:
123  print("Cannot do ratio for", xbin)
124 
125  arr_ratio = np.array(arr_ratio)
126 
127  median = np.median(arr_ratio)
128  stdev = np.percentile(abs(arr_ratio - median), 68)
129 
130  c1 = R.TCanvas()
131  h_total.GetXaxis().SetTitle("<#mu>")
132  h_total.Draw("E0")
133  R.gStyle.SetErrorX()
134  line = R.TLine(h_total.GetXaxis().GetXmin(), median, h_total.GetXaxis().GetXmax(), median)
135  line.SetLineColor(R.kRed)
136  line.Draw()
137 
138  if comp:
139  h_total.GetYaxis().SetRangeUser(ymin, ymax)
140  leg = R.TLegend(0.54, 0.72, 0.805, 0.92)
141  leg.SetTextSize(18)
142  leg.AddEntry(h_total, "L_{Z #rightarrow ee}/L_{Z #rightarrow #mu#mu}", "ep")
143  leg.AddEntry(line, f"Median = {median:.3f} #pm {stdev:.3f}", "l")
144  else:
145  h_total.GetYaxis().SetRangeUser(0.95, 1.05)
146  leg = R.TLegend(0.20, 0.18, 0.45, 0.35)
147 
148  print(f"Year = {year} channel = {channel}: median +- 68% percentile = {median:.3f} +- {stdev:.3f}")
149 
150  line1 = pt.make_bands(bins, stdev, median)
151  line1.Draw("same 3")
152  if comp: line.Draw()
153  h_total.Draw('same E0')
154 
155  leg.SetBorderSize(0)
156  leg.SetTextSize(0.05)
157  if comp:
158  h_total.GetYaxis().SetTitle("L_{Z #rightarrow ee} / L_{Z #rightarrow #mu#mu}")
159  zstring = ""
160  else:
161  h_total.GetYaxis().SetTitle("L_{"+pt.plotlabel[channel]+"} / L_{ATLAS}")
162  leg.AddEntry(h_total, "L_{"+pt.plotlabel[channel]+"}^{year-normalised}/L_{ATLAS}", "ep")
163  zstring = pt.plotlabel[channel]+" counting"
164 
165  if comp:
166  pt.drawAtlasLabel(0.2, 0.88, "Internal")
167  pt.drawText(0.2, 0.83, date_string, size=22)
168  pt.drawText(0.2, 0.78, zstring, size=22)
169  else:
170  pt.drawAtlasLabel(xmin, 0.88, "Internal")
171  pt.drawText(xmin, 0.83, date_string, size=22)
172  pt.drawText(xmin, 0.78, zstring, size=22)
173  pt.drawText(xmin, 0.71, "OflLumi-Run3-005", size=22)
174 
175  leg.AddEntry(line1, "68% band", "f")
176  leg.Draw()
177 
178  if comp:
179  c1.SaveAs(outdir + outfile)
180  else:
181  c1.SaveAs(outdir + channel + "ATLAS_ratio_vs_mu_"+out_tag+".pdf")
182 

Variable Documentation

◆ action

plotting.yearwise_luminosity_vs_mu.action

Definition at line 15 of file yearwise_luminosity_vs_mu.py.

◆ args

plotting.yearwise_luminosity_vs_mu.args = parser.parse_args()

Definition at line 19 of file yearwise_luminosity_vs_mu.py.

◆ bins

plotting.yearwise_luminosity_vs_mu.bins = np.concatenate((np.array([0, 10]), np.linspace(11, 17, 7), np.array([18, 22])))

Definition at line 30 of file yearwise_luminosity_vs_mu.py.

◆ channel

plotting.yearwise_luminosity_vs_mu.channel = args.channel

Definition at line 21 of file yearwise_luminosity_vs_mu.py.

◆ comp

plotting.yearwise_luminosity_vs_mu.comp = args.comp

Definition at line 23 of file yearwise_luminosity_vs_mu.py.

◆ date_string

string plotting.yearwise_luminosity_vs_mu.date_string = "Run 2, #sqrt{s} = 13 TeV"

Definition at line 51 of file yearwise_luminosity_vs_mu.py.

◆ grl

plotting.yearwise_luminosity_vs_mu.grl = pt.get_grl("15")

Definition at line 52 of file yearwise_luminosity_vs_mu.py.

◆ help

plotting.yearwise_luminosity_vs_mu.help

Definition at line 13 of file yearwise_luminosity_vs_mu.py.

◆ indir

plotting.yearwise_luminosity_vs_mu.indir = args.indir

Definition at line 24 of file yearwise_luminosity_vs_mu.py.

◆ out_tag

string plotting.yearwise_luminosity_vs_mu.out_tag = "run2"

Definition at line 56 of file yearwise_luminosity_vs_mu.py.

◆ outdir

plotting.yearwise_luminosity_vs_mu.outdir = args.outdir

Definition at line 25 of file yearwise_luminosity_vs_mu.py.

◆ outfile

string plotting.yearwise_luminosity_vs_mu.outfile = "ZeeZmm_ratio_vs_mu_"+out_tag+".pdf"

Definition at line 69 of file yearwise_luminosity_vs_mu.py.

◆ parser

plotting.yearwise_luminosity_vs_mu.parser = argparse.ArgumentParser()

Definition at line 12 of file yearwise_luminosity_vs_mu.py.

◆ str

plotting.yearwise_luminosity_vs_mu.str

Definition at line 13 of file yearwise_luminosity_vs_mu.py.

◆ type

plotting.yearwise_luminosity_vs_mu.type

Definition at line 13 of file yearwise_luminosity_vs_mu.py.

◆ xmin

float plotting.yearwise_luminosity_vs_mu.xmin = 0.2

Definition at line 29 of file yearwise_luminosity_vs_mu.py.

◆ year

plotting.yearwise_luminosity_vs_mu.year = args.year

Definition at line 20 of file yearwise_luminosity_vs_mu.py.

◆ ymax

plotting.yearwise_luminosity_vs_mu.ymax

Definition at line 71 of file yearwise_luminosity_vs_mu.py.

◆ ymin

plotting.yearwise_luminosity_vs_mu.ymin

Definition at line 71 of file yearwise_luminosity_vs_mu.py.

MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
plotting.yearwise_luminosity_vs_mu.main
def main()
Definition: yearwise_luminosity_vs_mu.py:73
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15