ATLAS Offline Software
Functions
python.doZLumi Namespace Reference

Functions

def getRun (fname)
 
def checkDirExists (fname)
 
def copyPlot (infname, outfname)
 
def makeGRL (run, defect, fname)
 
def go (fname)
 

Function Documentation

◆ checkDirExists()

def python.doZLumi.checkDirExists (   fname)

Definition at line 16 of file doZLumi.py.

16 def checkDirExists(fname):
17  # Does DQTGlobalWZFinder directory even exist?
18  import ROOT
19  run = getRun(fname)
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
25  return True
26 

◆ copyPlot()

def python.doZLumi.copyPlot (   infname,
  outfname 
)

Definition at line 27 of file doZLumi.py.

27 def copyPlot(infname, outfname):
28  import ROOT
29  run = getRun(outfname)
30  if not run: return
31  fin = ROOT.TFile.Open(infname, 'READ')
32  if not fin: return
33  fout = ROOT.TFile.Open(outfname, 'UPDATE')
34  if not fout: return
35  for objname in ['z_lumi', 'z_lumi_ratio']:
36  obj = fin.Get(objname)
37  if obj:
38  d = fout.Get('run_%d/GLOBAL/DQTGlobalWZFinder' % run)
39  if d:
40  d.WriteTObject(obj, objname)
41  fin.Close(); fout.Close()
42 

◆ getRun()

def python.doZLumi.getRun (   fname)

Definition at line 4 of file doZLumi.py.

4 def getRun(fname):
5  import ROOT
6  fin = ROOT.TFile.Open(fname)
7  if not fin: return None
8  runname = None
9  for key in fin.GetListOfKeys():
10  if key.GetName().startswith('run_'):
11  runname = key.GetName()
12  break
13  if runname: return int(runname[4:])
14  else: return None
15 

◆ go()

def python.doZLumi.go (   fname)

Definition at line 78 of file doZLumi.py.

78 def go(fname):
79  import subprocess, os, shutil # noqa: F401
80  if 'DQ_STREAM' in os.environ:
81  if (os.environ.get('DQPRODUCTION', '0') == '1'
82  and os.environ['DQ_STREAM'] != 'physics_Main'):
83  return
84  if 'DISPLAY' in os.environ: del os.environ['DISPLAY']
85  runno = getRun(fname)
86  print('Seen run', runno)
87  if not checkDirExists(fname):
88  print('But DQTGlobalWZFinder directory does not exist: code probably did not run. Exiting')
89  return
90  grlcmd = [] # noqa: F841
91  if runno >= 325000:
92  makeGRL(runno, 'PHYS_StandardGRL_All_Good', 'grl.xml')
93  grlcmd = ['--grl', 'grl.xml'] # noqa: F841
94  else:
95  print('Run number', runno, 'not 2017 data')
96 
97  # Temporarily comment. Run 3 version of this code will be inserted soon
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'):
103  copyPlot('zlumi.root', fname)

◆ makeGRL()

def python.doZLumi.makeGRL (   run,
  defect,
  fname 
)

Definition at line 43 of file doZLumi.py.

43 def makeGRL(run, defect, fname):
44  import DQUtils, DQDefects
45 
46  tag = 'HEAD'
47  runs = [run]
48  print('Query run information...', end='')
49  from DQUtils.db import fetch_iovs
50  dbinstance = 'CONDBR2'
51  eor = fetch_iovs('EOR', (min(runs) << 32) | 1,
52  (max(runs) << 32) | 0xFFFFFFFF,
53  with_channel=False, what=[], database='COOLONL_TDAQ/%s' % dbinstance)
54  eor = eor.trim_iovs
55  eor = DQUtils.IOVSet(iov for iov in eor if iov.since.run in runs)
56  print('done')
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 _}
60  try:
61  defectiovs = ddb.retrieve(since = min(runs) << 32 | 1,
62  until = max(runs) << 32 | 0xffffffff,
63  channels = [defect],
64  evaluate_full = False,
65  ignore=ignores)
66  except Exception as e:
67  print(e)
68  raise
69  print('Doing exclusions...', end='')
70  okiovs = eor.logical_and(eor, defectiovs.logical_not())
71  print('done')
72 
73  print('Generating GRL...', end='')
74  data = DQUtils.grl.make_grl(okiovs, '', '2.1')
75  with open(fname, 'w') as outf:
76  outf.write(data)
77 
python.doZLumi.checkDirExists
def checkDirExists(fname)
Definition: doZLumi.py:16
python.db.fetch_iovs
def fetch_iovs(folder_name, since=None, until=None, channels=None, tag="", what="all", max_records=-1, with_channel=True, loud=False, database=None, convert_time=False, named_channels=False, selection=None, runs=None, with_time=False, unicode_strings=False)
Definition: DQUtils/python/db.py:67
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.doZLumi.makeGRL
def makeGRL(run, defect, fname)
Definition: doZLumi.py:43
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
python.doZLumi.copyPlot
def copyPlot(infname, outfname)
Definition: doZLumi.py:27
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.doZLumi.go
def go(fname)
Definition: doZLumi.py:78
python.doZLumi.getRun
def getRun(fname)
Definition: doZLumi.py:4
Trk::open
@ open
Definition: BinningType.h:40