7 from subprocess
import Popen, PIPE
8 from array
import array
14 plotlabel[
"Zee"] =
"Z #rightarrow ee"
15 plotlabel[
"Zmumu"] =
"Z #rightarrow #mu#mu"
16 plotlabel[
"Zll"] =
"Z #rightarrow ll"
19 runlivetimecut = 10*60
25 Get a list of runs for a year from the baseline GRL
27 CVMFS =
"/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists"
29 grl[
"15"] = CVMFS +
"/data15_13TeV/20190708/data15_13TeV.periodAllYear_DetStatus-v105-pro22-13_Unknown_PHYS_StandardGRL_All_Good_25ns.xml"
30 grl[
"16"] = CVMFS +
"/data16_13TeV/20190708/data16_13TeV.periodAllYear_DetStatus-v105-pro22-13_Unknown_PHYS_StandardGRL_All_Good_25ns_WITH_IGNORES.xml"
31 grl[
"17"] = CVMFS +
"/data17_13TeV/20190708/data17_13TeV.periodAllYear_DetStatus-v105-pro22-13_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml"
32 grl[
"18"] = CVMFS +
"/data18_13TeV/20190708/data18_13TeV.periodAllYear_DetStatus-v105-pro22-13_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml"
33 grl[
"22"] = CVMFS +
"/data22_13p6TeV/20230207/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"
34 grl[
"23"] = CVMFS +
"/data23_13p6TeV/20230828/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-06_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"
35 grl[
"24"] = CVMFS +
"/data24_13p6TeV/20241118/data24_13p6TeV.periodsEtoO_DetStatus-v130-pro36-08_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"
36 grl[
"25"] =
"/eos/atlas/atlascerngroupdisk/perf-lumi/Zcounting/Run3/MergedOutputs/data25_13p6TeV/latest_GRL.xml"
39 pipe = Popen([
"grep",
"RunList", grl[year]], stdout=PIPE, stderr=PIPE)
40 runs = re.sub(
"[^0-9,]",
"",
str(pipe.communicate()[0])).
split(
",")
44 runs=subprocess.check_output(
"grep '<Run>' "+grl[year]+
" | tr -dc ' [:digit:] '", shell=
True).
decode(
'ascii').
split()
46 print(
"20"+year+
": list or runs =", runs)
51 R.gROOT.SetStyle(
"Plain")
55 R.gStyle.SetFrameBorderMode(icol)
56 R.gStyle.SetFrameFillColor(icol)
57 R.gStyle.SetCanvasBorderMode(icol)
58 R.gStyle.SetCanvasColor(icol)
59 R.gStyle.SetPadBorderMode(icol)
60 R.gStyle.SetPadColor(icol)
61 R.gStyle.SetStatColor(icol)
63 R.gStyle.SetLineColor(R.kBlack)
66 R.gStyle.SetPaperSize(20,26)
69 R.gStyle.SetPadTopMargin(0.05)
70 R.gStyle.SetPadRightMargin(0.05)
71 R.gStyle.SetPadBottomMargin(0.16)
72 R.gStyle.SetPadLeftMargin(0.16)
75 R.gStyle.SetTitleXOffset(1.4)
76 R.gStyle.SetTitleYOffset(1.4)
81 R.gStyle.SetTextFont(font)
82 R.gStyle.SetTextSize(tsize)
83 R.gStyle.SetLegendFont(font)
84 R.gStyle.SetLabelFont(font,
"xyz")
85 R.gStyle.SetTitleFont(font,
"xyz")
87 R.gStyle.SetLabelSize(tsize,
"xyz")
88 R.gStyle.SetTitleSize(tsize,
"xyz")
91 R.gStyle.SetMarkerStyle(20)
92 R.gStyle.SetMarkerSize(1.2)
93 R.gStyle.SetLineStyleString(2,
"[12 12]")
95 R.gStyle.SetEndErrorSize(0.)
98 R.gStyle.SetOptTitle(0)
99 R.gStyle.SetOptStat(0)
100 R.gStyle.SetOptFit(0)
103 R.gStyle.SetPadTickX(1)
104 R.gStyle.SetPadTickY(1)
111 l.SetTextColor(color)
113 delx = 0.115*696*R.gPad.GetWh()/(472*R.gPad.GetWw())
115 l.DrawLatex(x,y,
"ATLAS")
120 p.SetTextColor(color)
121 p.DrawLatex(x+delx,y,text)
123 def drawText(x, y, text, size=27, color = R.kBlack):
129 l.SetTextColor(color)
130 l.DrawLatex(x,y,text)
133 vec_y =
array(
'd', [yval] * (len(vec_in) + 2))
135 err_y =
array(
'd', [stdev] * (len(vec_in) + 2))
138 vec_x.append(9999999999)
140 line = R.TGraphErrors(len(vec_x), vec_x, vec_y, R.nullptr, err_y)
141 line.SetFillColorAlpha(8, 0.35)
142 line.SetFillStyle(4050)
148 if run >= 472553:
return "24"
149 elif run >= 450227:
return "23"
150 elif run >= 427394:
return "22"
151 elif run >= 348885:
return "18"
152 elif run >= 325713:
return "17"
153 elif run >= 297730:
return "16"
154 elif run >= 276262:
return "15"
156 print(
"ERROR: Cannot classify run", run)
159 def get_dfz(basedir, year, run, channel, standardcuts = True):
161 Standard retrieval of Z counting Panda dataframe from CSV
164 mydir = basedir +
"data"+
get_year(run)+
"_13p6TeV/physics_Main/"
166 mydir = basedir +
"data"+
get_year(run)+
"_13TeV/physics_Main/"
167 elif int(year) >= 22:
168 mydir = basedir +
"data" + year +
"_13p6TeV/physics_Main/"
170 mydir = basedir +
"data" + year +
"_13TeV/physics_Main/"
173 dfz = pd.read_csv(mydir +
"run_" + run +
".csv")
174 except FileNotFoundError:
175 print(
"WARNING: CVS for run", run,
"not found, will skip.")
176 return -1., 0., 0., 0., 0.,
None
180 if channel
is not None:
182 dfz_small[
'ZLumi'] = dfz_small[channel +
'Lumi']
183 dfz_small[
'ZLumiErr'] = dfz_small[channel +
'LumiErr']
185 dfz_small = dfz_small.drop(dfz_small[dfz_small.ZLumi == 0].index)
186 dfz_small = dfz_small.drop(dfz_small[(dfz_small[
'LBLive']<lblivetimecut) | (dfz_small[
'PassGRL']==0)].index)
188 dfz_small[
'ZLumi'] *= dfz_small[
'LBLive']
189 dfz_small[
'ZLumiErr'] *= dfz_small[
'LBLive']
190 zlumi = dfz_small[
'ZLumi'].
sum()
192 dfz_small[
'ZLumiErr'] *= dfz_small[
'ZLumiErr']
193 zerr = math.sqrt(dfz_small[
'ZLumiErr'].
sum())
197 dfz_small = dfz_small.drop(dfz_small[(dfz_small.ZeeLumi == 0) | (dfz_small.ZmumuLumi == 0)].index)
198 dfz_small = dfz_small.drop(dfz_small[(dfz_small[
'LBLive']<lblivetimecut) | (dfz_small[
'PassGRL']==0)].index)
199 dfz_small[
'ZeeLumi'] *= dfz_small[
'LBLive']
200 dfz_small[
'ZeeLumiErr'] *= dfz_small[
'LBLive']
201 dfz_small[
'ZeeLumiErr'] *= dfz_small[
'ZeeLumiErr']
202 dfz_small[
'ZmumuLumi'] *= dfz_small[
'LBLive']
203 dfz_small[
'ZmumuLumiErr'] *= dfz_small[
'LBLive']
204 dfz_small[
'ZmumuLumiErr'] *= dfz_small[
'ZmumuLumiErr']
207 livetime = dfz_small[
'LBLive'].
sum()
210 dfz_small[
'OffLumi'] *= dfz_small[
'LBLive']
211 olumi = dfz_small[
'OffLumi'].
sum()
215 run_start = dfz_small[
'LBStart'].iloc[0]
216 timestamp = time.gmtime(run_start)
217 timestamp = R.TDatime(timestamp[0], timestamp[1], timestamp[2], timestamp[3], timestamp[4], timestamp[5])
218 timestamp = timestamp.Convert()
222 return livetime, zlumi, zerr, olumi, timestamp, dfz_small
227 Fit over a sub-range of the data and print the mean and chi^2/NDF.
228 Useful to test the remaining trends after the global Run-3 normalisation.
231 tg.Fit(
'pol0',
'Rq0',
'0', start, end)
232 mean = tg.GetFunction(
'pol0').GetParameter(0)
233 chi2 = tg.GetFunction(
'pol0').GetChisquare()
234 ndf = tg.GetFunction(
'pol0').GetNDF()