2 from __future__
import print_function
4 from ROOT
import gROOT, TFile
6 defect_val = collections.namedtuple(
'defect_val',
7 'defect, comment, recoverable')
8 defect_iov = collections.namedtuple(
'defect_iov',
9 'defect, comment, recoverable, since, until')
15 for i
in range(0, nlayer):
20 nbin = hhits[i].GetNbinsX()
23 for j
in range(1, nbin-1):
24 val = hhits[i].GetBinContent(j+1)
25 if val >= threshold_hit:
30 for j
in range(1, nbin-1):
32 val = hhits[i].GetBinContent(j+1)
33 if val < threshold_hit:
38 if j > start_lb
and j < end_lb:
39 standby_lb.append([i, start_lb, j-1])
44 standby_lb.append([i, start_lb, lb_max])
47 def find_notready(nlayer, hist, pct_low, pct_high, notready_lb, lb_max=2000):
49 for i
in range(0, nlayer):
53 nbin = hist[i].GetNbinsX()
55 for j
in range(1, nbin-1):
56 val = hist[2].GetBinContent(
57 j+1)*38/90 + hist[3].GetBinContent(j+1)*52/90
58 if val >= pct_low
and val < pct_high:
63 notready_lb.append([i, start_lb, j-1])
67 notready_lb.append([i, start_lb, lb_max])
72 for j
in range(1, nbin-1):
73 val = hist[i].GetBinContent(j+1)
74 if val >= pct_low
and val < pct_high:
79 notready_lb.append([i, start_lb, j-1])
83 notready_lb.append([i, start_lb, lb_max])
90 nbin = hist.GetNbinsX()
91 for i
in range(1, nbin-1):
92 val = hist.GetBinContent(i+1)
93 if val >= pct_low
and val < pct_high:
98 btagdeg_lb.append([start_lb, i-1])
102 btagdeg_lb.append([start_lb, lb_max])
106 for i
in range(0, len(defect_lb)):
107 print(defect_name,
"[", defect_lb[i][0],
"]:", defect_lb[i][1],
"-", defect_lb[i][2])
110 for i
in range(0, len(defect_lb)):
111 print(defect_name,
": ", defect_lb[i][0],
"-", defect_lb[i][1])
115 for i
in range(0, len(defect_lb)):
116 layer = defect_lb[i][0]
130 sdefect =
"PIXEL_" + slayer +
"_" + defect_name
132 lbstart = defect_lb[i][1]
133 lbend = defect_lb[i][2]
135 start = (run << 32) + lbstart
136 until = (run << 32) + lbend + 1
139 comment =
"assign " + sdefect
140 db.append(
defect_iov(sdefect, comment,
False, start, until))
145 sdefect =
"PIXEL_LOWSTAT"
148 start = (run << 32) + lbstart
149 until = (run << 32) + lbend + 1
151 db.append(
defect_iov(sdefect, comment,
False, start, until))
155 for i
in range(0, len(defect_lb)):
156 sdefect =
"PIXEL_" + defect_name
157 lbstart = defect_lb[i][0]
158 lbend = defect_lb[i][1]
160 start = (run << 32) + lbstart
161 until = (run << 32) + lbend + 1
163 comment =
"assign " + sdefect
164 db.append(
defect_iov(sdefect, comment,
False, start, until))
174 shits.append(
"InnerDetector/Pixel/IBL/Hits/AvgOccActivePerLumi_IBL2D")
175 shits.append(
"InnerDetector/Pixel/BLayer/Hits/AvgOccActivePerLumi_BLayer")
176 shits.append(
"InnerDetector/Pixel/Layer1/Hits/AvgOccActivePerLumi_Layer1")
177 shits.append(
"InnerDetector/Pixel/Layer2/Hits/AvgOccActivePerLumi_Layer2")
178 shits.append(
"InnerDetector/Pixel/ECA/Hits/AvgOccActivePerLumi_ECA")
179 shits.append(
"InnerDetector/Pixel/ECC/Hits/AvgOccActivePerLumi_ECC")
181 sbtagdeg =
"InnerDetector/Pixel/PixelExpert/BTagDegEstimation/TotalDegradationPerLumi"
183 sclus =
"Global/Luminosity/AnyTrigger/nClustersAll_vs_LB"
188 for i
in range(0, nlayer):
189 if not file.Get(shits[i]):
193 hhits.append(file.Get(shits[i]))
196 if fexist_hhits
is True:
203 fexist_hbtagdeg =
True
204 hbtagdeg = file.Get(sbtagdeg)
206 fexist_hbtagdeg =
False
207 btagdegestim_tolerable_lb = []
208 btagdegestim_intolerable_lb = []
210 if fexist_hhits
is True and fexist_hbtagdeg
is True:
211 find_btagdeg(hbtagdeg, 0.05, 0.25, btagdegestim_tolerable_lb, lb_max)
212 find_btagdeg(hbtagdeg, 0.25, 1., btagdegestim_intolerable_lb, lb_max)
220 assign_btagdegdef(db,
"PERFORMANCE_INTOLERABLE", run, btagdegestim_intolerable_lb)
223 hclus = file.Get(sclus)
226 if fexist_hclus
is True:
227 nevent = hclus.GetEntries()