50 from .
import detmaskmod
51 runNumber = re.match(
r'run_(\d+)_.*han.root', name).group(1)
52 max_hi_limit = detmaskmod.getNumLumiBlocks(int(runNumber))+1
53 if (name.find(
'minutes10_') > -1):
54 t = name.split(
'minutes10_')
55 digit = float(((t[len(t)-1]).
split(
'_'))[0])
56 low_limit = int((digit-1.0)*10.0/LBlength+1)-1
57 hi_limit = int(digit*10.0/LBlength)
58 elif (name.find(
'minutes30_') > -1):
59 t = name.split(
'minutes30_')
60 digit = float(((t[len(t)-1]).
split(
'_'))[0])
61 low_limit = int((digit-1.0)*30.0/LBlength+1)-1
62 hi_limit = int(digit*30.0/LBlength)
63 elif 'lowStat_' in name:
64 t = name.split(
'lowStat_LB')[-1]
65 t = t.split(
'_han.root')[0]
67 low_limit = int(digits[0])
68 hi_limit =
min(int(digits[1])+1, max_hi_limit)
69 elif 'medStat_' in name:
70 t = name.split(
'medStat_LB')[-1]
71 t = t.split(
'_han.root')[0]
73 low_limit = int(digits[0])
74 hi_limit =
min(int(digits[1])+1, max_hi_limit)
77 hi_limit = max_hi_limit
78 except Exception
as e:
79 logging.warning(
'Could not determine limits because: %s', e)
83 return (low_limit, hi_limit)
104 filePath="/afs/cern.ch/user/a/atlasdqm/dqmdisk/han_results/tier0/FDR2/NoStream/",
105 dbConnection="sqlite://;schema=MyCOOL.db;dbname=CONDBR2
", isESn=True):
107 logger.info('====> Running hancool_defects')
109 logger.info(
'<==== Done with hancool_defects')
129 mapping = {1:
'TRIG_L1_CTP_CTP_ROD_bcid',
130 2:
'TRIG_L1_CTP_bcid',
131 3:
'TRIG_L1_CTP_CTP_MuCTPI_bcid',
132 4:
'TRIG_L1_CTP_candnumber',
133 5:
'TRIG_L1_CTP_multpt',
134 6:
'TRIG_L1_CTP_roiNum',
135 7:
'TRIG_L1_CTP_roiCand',
136 8:
'TRIG_L1_CTP_bcidrange',
137 9:
'TRIG_L1_CTP_lumiblockrange',
138 10:
'TRIG_L1_CTP_lumiblocktime',
139 11:
'TRIG_L1_CTP_nanosectime',
140 12:
'TRIG_L1_CTP_TAPnoTBP',
141 13:
'TRIG_L1_CTP_TAVnoTAP',
142 14:
'TRIG_L1_CTP_CTPsim',
143 15:
'TRIG_L1_CTP_incompletefragment',
148 when = d.Get(
'CentralTrigger/ErrorSummary/errorSummaryPerLumiBlock')
152 overflow_bad_lbs = {}
157 for errorBin
in mapping:
158 bad_lbs[errorBin] = [bin
for bin
in range(1, when.GetNbinsX(
159 )+1)
if when.GetBinContent(bin, errorBin) > 0]
160 overflow_bad_lbs[errorBin] = (
161 when.GetBinContent(when.GetNbinsX()+1, errorBin) > 0)
163 message =
'Automatically set'
165 for defect
in mapping:
166 for lb
in bad_lbs[defect]:
167 rv.append(
defect_iov(mapping[defect], message,
False, lb, lb+1))
168 if overflow_bad_lbs[defect]:
169 message +=
'; defect occurred past end of monitoring histogram, marking end of run as bad'
170 from .
import detmaskmod
171 nlbs = detmaskmod.getNumLumiBlocks(runNumber)
173 False, when.GetNbinsX(), nlbs+1))
190 def sct_conf_defects_core(d, i, runNumber, histname, mapping):
192 histogram = d.Get(histname)
197 if mapping[bin] ==
'SCT_MOD_OUT_GT40':
199 if histogram.GetBinContent(bin) > threshold:
201 mapping[bin],
'%.1d modules affected' % histogram.GetBinContent(bin),
False))
204 rv1 = sct_conf_defects_core(d, i, runNumber,
'InnerDetector/SCT/Summary/SCTConfOutM',
205 {1:
'SCT_MOD_OUT_GT40'})
206 rv2 = sct_conf_defects_core(d, i, runNumber,
'InnerDetector/SCT/Summary/SCTConfNew',
207 {3:
'SCT_MOD_ERR_GT40',
208 5:
'SCT_MOD_NOISE_GT40'})
209 if rv1
is None and rv2
is None:
212 return (rv1
if rv1
is not None else [])+(rv2
if rv2
is not None else [])
216 pairs = [(
'InnerDetector/SCT/Summary/SCT_LinksWithLinkLevelErrorsVsLbs',
217 'SCT_PERIOD_ERR_GT40',
lambda _: _ > 80)]
221 overflow_bad_lbs = {}
222 message =
'Automatically set'
225 for hname, dname, policy
in pairs:
232 bad_lbs[dname] = [bin
for bin
in range(
233 1, when.GetNbinsX()+1)
if policy(when.GetBinContent(bin))]
234 overflow_bad_lbs[dname] = policy(
235 when.GetBinContent(when.GetNbinsX()+1))
237 for lb
in bad_lbs[dname]:
238 rv.append(
defect_iov(dname, message,
False, lb, lb+1))
239 if overflow_bad_lbs[dname]:
240 message +=
'; defect occurred past end of monitoring histogram, marking end of run as bad'
241 from .
import detmaskmod
242 nlbs = detmaskmod.getNumLumiBlocks(runNumber)
244 False, when.GetNbinsX(), nlbs+1))
297 badstatuses =
set(badstatuses)
299 def dqmf_node_defect_core(d, i, runNumber):
300 filenode = d.Get(node +
'_/Results/Status')
303 status =
set(x.GetName()
for x
in filenode.GetListOfKeys())
304 if len(badstatuses & status) > 0:
306 status) == 1,
'Status must be length one or the file is corrupt'
307 return [
defect_val(defect, node +
' DQMF color ' + status.pop(),
False)]
310 return dqmf_node_defect_core
314 from .
import pix_defect
318 analyzers += [ctp_defects]
320 analyzers += [sct_eff_defect,
326 if (len(filePath) == 0
or filePath[-1] !=
'/'):
328 if (len(dbConnection) < 1):
329 dbConnection =
"/afs/cern.ch/user/a/atlasdqm/dqmdisk1/cherrypy-devel/defectstest.db/COMP200"
333 defects_by_function = {}
337 fnames = ([[filePath+
"run_"+
str(runNumber)+
"_han.root"], []]
338 + [glob.glob(os.path.join(filePath,
'run_%s%s*_han.root' % (runNumber, intervalType[i])))
for i
in [2, 3]])
340 for i, itype
in enumerate(fnames):
341 ldefects_by_function = {}
342 for globname
in itype:
343 filename = os.path.basename(globname)
347 default_iov = default_iov._replace(since=since, until=until)
349 fobj = ROOT.TFile.Open(globname)
350 for func
in analyzers:
351 rv = func(fobj, i, runNumber)
353 rvt = [default_iov._replace(**(i._asdict()))
for i
in rv]
354 if func
not in ldefects_by_function:
355 ldefects_by_function[func] = rvt
357 ldefects_by_function[func] += rvt
358 defects_by_function.update(ldefects_by_function)
359 defects = sum(defects_by_function.values(), [])
362 globname = fnames[0][0]
363 filename = os.path.basename(globname)
366 defects += pix_defect.execute(runNumber, globname, until-1)
367 except Exception
as e:
368 logging.warning(
'Unable to execute pixel hancool code')
369 logging.warning(
'--> %s: %s',
type(e).__name__, e)
371 from DQDefects
import DefectsDB, DEFECT_IOV
372 from DQUtils.sugar
import RunLumi
374 ddb =
DefectsDB(dbConnection, read_only=
False)
376 logging.info(
'Running detmask_defects')
380 for defect
in dm_defects +
iovs_merge(defects):
381 logger.debug(
'Working with %s', defect)
382 defectlist.append(DEFECT_IOV(RunLumi(runNumber, defect.since),
383 RunLumi(runNumber, defect.until),
384 channel=defect.defect,
385 comment=defect.comment,
387 recoverable=defect.recoverable,
389 secret_path=os.environ.get(
'COOLFLASK_SECRET',
'/afs/cern.ch/user/a/atlasdqm/private/coolflask_secret/coolflask_secret.json')
390 auth = json.loads(open(secret_path).
read())
391 logger.debug(
'Flask upload')
392 ddb.insert_multiple(defectlist, use_flask=(
'sqlite' not in dbConnection),