ATLAS Offline Software
Loading...
Searching...
No Matches
plotting.yearwise_luminosity_vs_mu Namespace Reference

Functions

 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])))
str date_string = "Run 2,#kern[-0.5]{ }#sqrt{s} = 13 TeV"
 grl = pt.get_grl("15")
str out_tag = "run2"
str outfile = "ZeeZmm_ratio_vs_mu_"+out_tag+".pdf"
 ymin
 ymax

Function Documentation

◆ main()

plotting.yearwise_luminosity_vs_mu.main ( )

Definition at line 80 of file yearwise_luminosity_vs_mu.py.

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

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

str plotting.yearwise_luminosity_vs_mu.date_string = "Run 2,#kern[-0.5]{ }#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

str 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

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

Definition at line 76 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 78 of file yearwise_luminosity_vs_mu.py.

◆ ymin

plotting.yearwise_luminosity_vs_mu.ymin

Definition at line 78 of file yearwise_luminosity_vs_mu.py.