5 fin = ROOT.TFile.Open(fname)
6 if not fin:
return None
8 for key
in fin.GetListOfKeys():
9 if key.GetName().startswith(
'run_'):
10 runname = key.GetName()
12 if runname:
return int(runname[4:])
19 if not run:
return False
20 fin = ROOT.TFile.Open(fname,
'READ')
21 if not fin:
return False
22 dobj = fin.Get(f
'run_{run}/GLOBAL/DQTGlobalWZFinder')
23 if not dobj:
return False
30 fin = ROOT.TFile.Open(infname,
'READ')
32 fout = ROOT.TFile.Open(outfname,
'UPDATE')
34 for objname
in [
'z_lumi',
'z_lumi_ratio']:
35 obj = fin.Get(objname)
37 d = fout.Get(
'run_%d/GLOBAL/DQTGlobalWZFinder' % run)
39 d.WriteTObject(obj, objname)
40 fin.Close(); fout.Close()
43 import DQUtils, DQDefects
47 print(
'Query run information...', end=
'')
48 from DQUtils.db
import fetch_iovs
49 dbinstance =
'CONDBR2'
51 (
max(runs) << 32) | 0xFFFFFFFF,
52 with_channel=
False, what=[], database=
'COOLONL_TDAQ/%s' % dbinstance)
54 eor = DQUtils.IOVSet(iov
for iov
in eor
if iov.since.run
in runs)
56 print(
'Query defects...', end=
'')
57 ddb = DQDefects.DefectsDB(
'COOLOFL_GLOBAL/%s' % dbinstance, tag=tag)
58 ignores = {_
for _
in ddb.defect_names
if 'UNCHECKED' in _}
60 defectiovs = ddb.retrieve(since =
min(runs) << 32 | 1,
61 until =
max(runs) << 32 | 0xffffffff,
63 evaluate_full =
False,
65 except Exception
as e:
68 print(
'Doing exclusions...', end=
'')
69 okiovs = eor.logical_and(eor, defectiovs.logical_not())
72 print(
'Generating GRL...', end=
'')
73 data = DQUtils.grl.make_grl(okiovs,
'',
'2.1')
74 with open(fname,
'w')
as outf:
78 import subprocess, os, shutil
79 if 'DQ_STREAM' in os.environ:
80 if (os.environ.get(
'DQPRODUCTION',
'0') ==
'1'
81 and os.environ[
'DQ_STREAM'] !=
'physics_Main'):
83 if 'DISPLAY' in os.environ: del os.environ[
'DISPLAY']
85 print(
'Seen run', runno)
87 print(
'But DQTGlobalWZFinder directory does not exist: code probably did not run. Exiting')
91 makeGRL(runno,
'PHYS_StandardGRL_All_Good',
'grl.xml')
92 grlcmd = [
'--grl',
'grl.xml']
94 print(
'Run number', runno,
'not 2017 data')
97 subprocess.check_call([
'dqt_zlumi_pandas.py',
'--infile', fname,
'--dblivetime',
'--outdir',
'',
'--campaign',
'mc21'] + grlcmd)
98 subprocess.check_call([
'dqt_csv_luminosity.sh',
'--infile', f
'run_{runno}.csv',
'--outdir',
'',
'--absolute',
'--t0'])
99 if os.path.isfile(f
'run_{runno}.csv'):
100 shutil.move(f
'run_{runno}.csv',
'zlumi.csv')
101 if os.path.isfile(
'zlumi.root'):