315 def hancool_defects(runNumber, filePath="./", dbConnection="", isESn=True):
316 from .
import pix_defect
320 analyzers += [ctp_defects]
322 analyzers += [sct_eff_defect,
328 if (len(filePath) == 0
or filePath[-1] !=
'/'):
330 if (len(dbConnection) < 1):
331 dbConnection =
"/afs/cern.ch/user/a/atlasdqm/dqmdisk1/cherrypy-devel/defectstest.db/COMP200"
335 defects_by_function = {}
339 fnames = ([[filePath+
"run_"+
str(runNumber)+
"_han.root"], []]
340 + [glob.glob(os.path.join(filePath,
'run_%s%s*_han.root' % (runNumber, intervalType[i])))
for i
in [2, 3]])
342 for i, itype
in enumerate(fnames):
343 ldefects_by_function = {}
344 for globname
in itype:
345 filename = os.path.basename(globname)
349 default_iov = default_iov._replace(since=since, until=until)
351 fobj = ROOT.TFile.Open(globname)
352 for func
in analyzers:
353 rv = func(fobj, i, runNumber)
355 rvt = [default_iov._replace(**(i._asdict()))
for i
in rv]
356 if func
not in ldefects_by_function:
357 ldefects_by_function[func] = rvt
359 ldefects_by_function[func] += rvt
360 defects_by_function.update(ldefects_by_function)
361 defects =
sum(defects_by_function.values(), [])
364 globname = fnames[0][0]
365 filename = os.path.basename(globname)
368 defects += pix_defect.execute(runNumber, globname, until-1)
369 except Exception
as e:
370 logging.warning(
'Unable to execute pixel hancool code')
371 logging.warning(
'--> %s: %s',
type(e).__name__, e)
373 from DQDefects
import DefectsDB, DEFECT_IOV
374 from DQUtils.sugar
import RunLumi
376 ddb = DefectsDB(dbConnection, read_only=
False)
378 logging.info(
'Running detmask_defects')
382 for defect
in dm_defects +
iovs_merge(defects):
383 logger.debug(
'Working with %s', defect)
385 RunLumi(runNumber, defect.until),
386 channel=defect.defect,
387 comment=defect.comment,
389 recoverable=defect.recoverable,
391 secret_path=os.environ.get(
'COOLFLASK_SECRET',
'/afs/cern.ch/user/a/atlasdqm/private/coolflask_secret/coolflask_secret.json')
392 auth = json.loads(
open(secret_path).
read())
393 logger.debug(
'Flask upload')
394 ddb.insert_multiple(defectlist, use_flask=(
'sqlite' not in dbConnection),