2 from __future__
import print_function
6 fin = ROOT.TFile.Open(fname)
7 if not fin:
return None
9 for key
in fin.GetListOfKeys():
10 if key.GetName().startswith(
'run_'):
11 runname = key.GetName()
13 if runname:
return int(runname[4:])
20 if not run:
return False
21 fin = ROOT.TFile.Open(fname,
'READ')
22 if not fin:
return False
23 dobj = fin.Get(f
'run_{run}/GLOBAL/DQTGlobalWZFinder')
24 if not dobj:
return False
31 fin = ROOT.TFile.Open(infname,
'READ')
33 fout = ROOT.TFile.Open(outfname,
'UPDATE')
35 for objname
in [
'z_lumi',
'z_lumi_ratio']:
36 obj = fin.Get(objname)
38 d = fout.Get(
'run_%d/GLOBAL/DQTGlobalWZFinder' % run)
40 d.WriteTObject(obj, objname)
41 fin.Close(); fout.Close()
44 import DQUtils, DQDefects
48 print(
'Query run information...', end=
'')
49 from DQUtils.db
import fetch_iovs
50 dbinstance =
'CONDBR2'
52 (
max(runs) << 32) | 0xFFFFFFFF,
53 with_channel=
False, what=[], database=
'COOLONL_TDAQ/%s' % dbinstance)
55 eor = DQUtils.IOVSet(iov
for iov
in eor
if iov.since.run
in runs)
57 print(
'Query defects...', end=
'')
58 ddb = DQDefects.DefectsDB(
'COOLOFL_GLOBAL/%s' % dbinstance, tag=tag)
59 ignores = {_
for _
in ddb.defect_names
if 'UNCHECKED' in _}
61 defectiovs = ddb.retrieve(since =
min(runs) << 32 | 1,
62 until =
max(runs) << 32 | 0xffffffff,
64 evaluate_full =
False,
66 except Exception
as e:
69 print(
'Doing exclusions...', end=
'')
70 okiovs = eor.logical_and(eor, defectiovs.logical_not())
73 print(
'Generating GRL...', end=
'')
74 data = DQUtils.grl.make_grl(okiovs,
'',
'2.1')
75 with open(fname,
'w')
as outf:
79 import subprocess, os, shutil
80 if 'DQ_STREAM' in os.environ:
81 if (os.environ.get(
'DQPRODUCTION',
'0') ==
'1'
82 and os.environ[
'DQ_STREAM'] !=
'physics_Main'):
84 if 'DISPLAY' in os.environ: del os.environ[
'DISPLAY']
86 print(
'Seen run', runno)
88 print(
'But DQTGlobalWZFinder directory does not exist: code probably did not run. Exiting')
92 makeGRL(runno,
'PHYS_StandardGRL_All_Good',
'grl.xml')
93 grlcmd = [
'--grl',
'grl.xml']
95 print(
'Run number', runno,
'not 2017 data')
98 subprocess.check_call([
'dqt_zlumi_pandas.py',
'--infile', fname,
'--dblivetime',
'--outdir',
'',
'--campaign',
'mc21'] + grlcmd)
99 subprocess.check_call([
'dqt_csv_luminosity.sh',
'--infile', f
'run_{runno}.csv',
'--outdir',
'',
'--absolute',
'--t0'])
100 if os.path.isfile(f
'run_{runno}.csv'):
101 shutil.move(f
'run_{runno}.csv',
'zlumi.csv')
102 if os.path.isfile(
'zlumi.root'):