3 from ROOT
import gROOT, TFile
5 defect_val = collections.namedtuple(
'defect_val',
6 'defect, comment, recoverable')
7 defect_iov = collections.namedtuple(
'defect_iov',
8 'defect, comment, recoverable, since, until')
14 for i
in range(0, nlayer):
19 nbin = hhits[i].GetNbinsX()
22 for j
in range(1, nbin-1):
23 val = hhits[i].GetBinContent(j+1)
24 if val >= threshold_hit:
29 for j
in range(1, nbin-1):
31 val = hhits[i].GetBinContent(j+1)
32 if val < threshold_hit:
37 if j > start_lb
and j < end_lb:
38 standby_lb.append([i, start_lb, j-1])
43 standby_lb.append([i, start_lb, lb_max])
46 def find_notready(nlayer, hist, pct_low, pct_high, notready_lb, lb_max=2000):
48 for i
in range(0, nlayer):
52 nbin = hist[i].GetNbinsX()
54 for j
in range(1, nbin-1):
55 val = hist[2].GetBinContent(
56 j+1)*38/90 + hist[3].GetBinContent(j+1)*52/90
57 if val >= pct_low
and val < pct_high:
62 notready_lb.append([i, start_lb, j-1])
66 notready_lb.append([i, start_lb, lb_max])
71 for j
in range(1, nbin-1):
72 val = hist[i].GetBinContent(j+1)
73 if val >= pct_low
and val < pct_high:
78 notready_lb.append([i, start_lb, j-1])
82 notready_lb.append([i, start_lb, lb_max])
89 nbin = hist.GetNbinsX()
90 for i
in range(1, nbin-1):
91 val = hist.GetBinContent(i+1)
92 if val >= pct_low
and val < pct_high:
97 btagdeg_lb.append([start_lb, i-1])
101 btagdeg_lb.append([start_lb, lb_max])
105 for i
in range(0, len(defect_lb)):
106 print(defect_name,
"[", defect_lb[i][0],
"]:", defect_lb[i][1],
"-", defect_lb[i][2])
109 for i
in range(0, len(defect_lb)):
110 print(defect_name,
": ", defect_lb[i][0],
"-", defect_lb[i][1])
114 for i
in range(0, len(defect_lb)):
115 layer = defect_lb[i][0]
129 sdefect =
"PIXEL_" + slayer +
"_" + defect_name
131 lbstart = defect_lb[i][1]
132 lbend = defect_lb[i][2]
134 start = (run << 32) + lbstart
135 until = (run << 32) + lbend + 1
138 comment =
"assign " + sdefect
139 db.append(
defect_iov(sdefect, comment,
False, start, until))
144 sdefect =
"PIXEL_LOWSTAT"
147 start = (run << 32) + lbstart
148 until = (run << 32) + lbend + 1
150 db.append(
defect_iov(sdefect, comment,
False, start, until))
154 for i
in range(0, len(defect_lb)):
155 sdefect =
"PIXEL_" + defect_name
156 lbstart = defect_lb[i][0]
157 lbend = defect_lb[i][1]
159 start = (run << 32) + lbstart
160 until = (run << 32) + lbend + 1
162 comment =
"assign " + sdefect
163 db.append(
defect_iov(sdefect, comment,
False, start, until))
173 shits.append(
"InnerDetector/Pixel/IBL/Hits/AvgOccActivePerLumi_IBL2D")
174 shits.append(
"InnerDetector/Pixel/BLayer/Hits/AvgOccActivePerLumi_BLayer")
175 shits.append(
"InnerDetector/Pixel/Layer1/Hits/AvgOccActivePerLumi_Layer1")
176 shits.append(
"InnerDetector/Pixel/Layer2/Hits/AvgOccActivePerLumi_Layer2")
177 shits.append(
"InnerDetector/Pixel/ECA/Hits/AvgOccActivePerLumi_ECA")
178 shits.append(
"InnerDetector/Pixel/ECC/Hits/AvgOccActivePerLumi_ECC")
180 sbtagdeg =
"InnerDetector/Pixel/PixelExpert/BTagDegEstimation/TotalDegradationPerLumi"
182 sclus =
"Global/Luminosity/AnyTrigger/nClustersAll_vs_LB"
187 for i
in range(0, nlayer):
188 if not file.Get(shits[i]):
192 hhits.append(file.Get(shits[i]))
195 if fexist_hhits
is True:
202 fexist_hbtagdeg =
True
203 hbtagdeg = file.Get(sbtagdeg)
205 fexist_hbtagdeg =
False
206 btagdegestim_tolerable_lb = []
207 btagdegestim_intolerable_lb = []
209 if fexist_hhits
is True and fexist_hbtagdeg
is True:
210 find_btagdeg(hbtagdeg, 0.05, 0.25, btagdegestim_tolerable_lb, lb_max)
211 find_btagdeg(hbtagdeg, 0.25, 1., btagdegestim_intolerable_lb, lb_max)
219 assign_btagdegdef(db,
"PERFORMANCE_INTOLERABLE", run, btagdegestim_intolerable_lb)
222 hclus = file.Get(sclus)
225 if fexist_hclus
is True:
226 nevent = hclus.GetEntries()