ATLAS Offline Software
Functions | Variables
python.utils.AtlRunQueryDQUtils Namespace Reference

Functions

def _intersect (lbr1, lbr2)
 
def lumi (run, lbr)
 
def GetDQEfficiency (rundict)
 
def MakeDQeffHtml (dic, dicsum, datapath)
 

Variables

 dbSvc = cool.DatabaseSvcFactory.databaseService()
 
 THIRTYTWOMASK = int(2**32-1)
 
string SERVER = 'http://atlasdqm.cern.ch:8080'
 
list FLAGS_WE_CARE_ABOUT
 
dictionary FLAGGROUPS
 
dictionary lumicache = {}
 
 p = et.parse(sys.argv[1])
 
dictionary rundict = {}
 
 runnum = int(lbc.find('Run').text)
 

Function Documentation

◆ _intersect()

def python.utils.AtlRunQueryDQUtils._intersect (   lbr1,
  lbr2 
)
private

Definition at line 70 of file AtlRunQueryDQUtils.py.

70 def _intersect(lbr1, lbr2):
71  def normalize(lbr):
72  return (max(1, lbr[0]), lbr[1] if lbr[1] != -1 else THIRTYTWOMASK)
73  tlbr1 = normalize(lbr1)
74  tlbr2 = normalize(lbr2)
75  rv = (max(tlbr1[0],tlbr2[0]), min(tlbr1[1],tlbr2[1]))
76  if rv[1] <= rv[0]:
77  return None
78  else:
79  return rv
80 

◆ GetDQEfficiency()

def python.utils.AtlRunQueryDQUtils.GetDQEfficiency (   rundict)

Definition at line 119 of file AtlRunQueryDQUtils.py.

119 def GetDQEfficiency( rundict ):
120 
121  runset = set()
122  for runnum in rundict.keys():
123  runset.add(runnum)
124 
125  s = xmlrpc.client.ServerProxy(SERVER)
126  flaginfo = s.get_dqmf_summary_flags_lb({'run_list': list(runset)}, FLAGS_WE_CARE_ABOUT, 'SHIFTOFL')
127  #print (flaginfo)
128  record = {}
129  for flag in FLAGS_WE_CARE_ABOUT:
130  record[flag] = []
131  for run in runset:
132  if str(run) not in flaginfo:
133  print ('%s not in flaginfo' % run)
134  del rundict[run]
135  continue
136  for sublb in rundict[run]:
137  for flag, periods in flaginfo[str(run)].items():
138  for period in periods:
139  ip = _intersect(period, sublb)
140  if ip is not None:
141  #print (run, flag, ip, period[2])
142  #print (lumi(run, ip))
143  record[flag].append((ip[1]-ip[0], period[2], lumi(run, ip)))
144 
145 
146  totallum = 0
147  for run in rundict:
148  for pair in rundict[run]:
149  totallum += lumi(run, pair)
150  print ('Total lumi:', totallum)
151 
152  flagsum = {}
153 
154  for flag in FLAGS_WE_CARE_ABOUT:
155  flagsum[flag] = {}
156  lr = record[flag]
157  cols = set([x[1] for x in lr])
158  accounted = 0
159  for col in cols:
160  llum = sum([x[2] for x in lr if x[1] == col])
161  accounted += llum
162  print (flag, col, llum, '%.2f%%' % (llum/totallum*100))
163  flagsum[flag][col] = (llum/totallum*100)
164  if abs(accounted-totallum) > 1e-8:
165  print (flag, 'n.a.', totallum-accounted, '%.2f%%' % ((1-accounted/totallum)*100))
166  flagsum[flag]['n.a.'] = ((1-accounted/totallum)*100)
167 
168  def _sum(d1, d2):
169  rv = {}
170  for key in set(d1.keys() + d2.keys()):
171  rv[key] = d1.get(key, 0) + d2.get(key, 0)
172  #print (rv)
173  return rv
174 
175  for flagtop, flaggroup in FLAGGROUPS.items():
176  vals = reduce(_sum, [flagsum[f] for f in flaggroup], {})
177  print (flagtop)
178  for typ in vals:
179  print (' %s: %.2f%%' % (typ, vals[typ]/len(flaggroup)))
180 

◆ lumi()

def python.utils.AtlRunQueryDQUtils.lumi (   run,
  lbr 
)

Definition at line 83 of file AtlRunQueryDQUtils.py.

83 def lumi(run, lbr):
84  if tuple(lbr) in lumicache:
85  return lumicache[tuple(lbr)]
86 
87  lblbdb = dbSvc.openDatabase('COOLONL_TRIGGER/CONDBR2', True)
88  lblb = lblbdb.getFolder('/TRIGGER/LUMI/LBLB')
89  lblestonl = lblbdb.getFolder('/TRIGGER/LUMI/LBLESTONL')
90 
91  lbs = lblb.browseObjects((run<<32)+lbr[0],
92  (run<<32)+lbr[1]-1,
93  cool.ChannelSelection(0))
94  inf = {}
95  for obj in lbs:
96  lbpy = obj.payload()
97  #print ((lbpy['EndTime']-lbpy['StartTime'])/1e9)
98  inf[(run, obj.since() & 0xFFFFFFFF)] = (lbpy['EndTime']-lbpy['StartTime'])/1e9
99  if obj.since() & 0xFFFFFFFF == lbr[1]:
100  print ('Oops: this should not happen, appears to be off-by-one error')
101  lbls = lblestonl = lblestonl.browseObjects((run<<32)+lbr[0],
102  (run<<32)+lbr[1]-1,
103  cool.ChannelSelection(0))
104  infl = {}
105  for obj in lbls:
106  lblpy = obj.payload()
107  infl[(run, obj.since() & 0xFFFFFFFF)] = lblpy['LBAvInstLumi']
108 
109  #print (sorted(infl.keys()))
110  totlum = 0
111  for lb in inf:
112  if lb in infl:
113  totlum += inf[lb]*infl[lb]
114  else:
115  print ('Missing run %d, LB %d' % lb)
116  lumicache[tuple(lbr)] = totlum
117  return totlum
118 

◆ MakeDQeffHtml()

def python.utils.AtlRunQueryDQUtils.MakeDQeffHtml (   dic,
  dicsum,
  datapath 
)

Definition at line 181 of file AtlRunQueryDQUtils.py.

181 def MakeDQeffHtml( dic, dicsum, datapath ):
182  s = ''
183 
184 
185  # run and time ranges
186  runs = dic[DataKey('Run')]
187  times = dic[DataKey('Start and endtime')]
188 
189  starttime = float(times[-1].partition(',')[0])
190  endtime = float(times[0].partition(',')[2])
191 
192  s = '<table style="color: #777777; font-size: 85%; margin-left: 14px" cellpadding="0" cellspacing="3">\n'
193  # runs in reverse order
194  s += '<tr><td><i>Number of runs selected:</i></td><td>&nbsp;&nbsp;%g</td><td></td></tr>\n' % (len(runs))
195  s += '<tr><td><i>First run selected:</i></td><td>&nbsp;&nbsp;%s</td><td>&nbsp;&nbsp;(%s)</td></tr>\n' % (runs[-1], time.strftime("%a %b %d, %Y, %X",time.gmtime(starttime)))
196  s += '<tr><td><i>Last run selected:</i></td><td>&nbsp;&nbsp;%s</td><td>&nbsp;&nbsp;(%s)</td></tr>\n' % (runs[0], time.strftime("%a %b %d, %Y, %X",time.gmtime(endtime)))
197  s += '</table>\n'
198 
199  # --------------------------------------------------------------------------------------
200  # run summary table
201  s += '<p></p>\n'
202  s += '<table style="margin-left: 14px">\n'
203  s += '<tr><td><b>Run / Event Summary</b></td></tr>\n'
204  s += '</table>\n'
205 
206  return s
207 

Variable Documentation

◆ dbSvc

python.utils.AtlRunQueryDQUtils.dbSvc = cool.DatabaseSvcFactory.databaseService()

Definition at line 20 of file AtlRunQueryDQUtils.py.

◆ FLAGGROUPS

dictionary python.utils.AtlRunQueryDQUtils.FLAGGROUPS
Initial value:
1 = {
2  'PIX': ['PIXB', 'PIX0', 'PIXEA', 'PIXEC'],
3  'SCT': ['SCTB', 'SCTEA', 'SCTEC'],
4  'TRT': ['TRTB', 'TRTEA', 'TRTEC', 'TRTTR'],
5  'LAR': ['EMBA', 'EMBC', 'EMECA', 'EMECC',
6  'HECA', 'HECC', 'FCALA', 'FCALC'],
7  'EM': ['EMBA', 'EMBC', 'EMECA', 'EMECC'],
8  'HEC': ['HECA', 'HECC'],
9  'FCAL': ['FCALA', 'FCALC'],
10  'TILE': ['TILBA', 'TILBC', 'TIEBA', 'TIEBC'],
11  'MDT': ['MDTBA', 'MDTBC', 'MDTEA', 'MDTEC'],
12  'RPC': ['RPCBA', 'RPCBC'],
13  'TGC': ['TGCEA', 'TGCEC'],
14  'CSC': ['CSCEA', 'CSCEC'],
15  'MBTS': ['MBTSA', 'MBTSC'],
16  'LUCID': ['LCD']
17  }

Definition at line 52 of file AtlRunQueryDQUtils.py.

◆ FLAGS_WE_CARE_ABOUT

list python.utils.AtlRunQueryDQUtils.FLAGS_WE_CARE_ABOUT
Initial value:
1 = ['PIXB', 'PIX0', 'PIXEA', 'PIXEC',
2  'SCTB', 'SCTEA', 'SCTEC',
3  'TRTB', 'TRTEA', 'TRTEC','TRTTR'
4  'IDGL', 'IDAL',
5  'EMBA', 'EMBC', 'EMECA', 'EMECC', 'HECA', 'HECC',
6  'FCALA', 'FCALC',
7  'TILBA', 'TILBC', 'TIEBA', 'TIEBC',
8  'MBTSA', 'MBTSC',
9  'MDTBA', 'MDTBC', 'MDTEA', 'MDTEC',
10  'RPCBA', 'RPCBC',
11  'TGCEA', 'TGCEC',
12  'CSCEA', 'CSCEC',
13  'LCD',
14  #'L1CAL',
15  #'L1MUB', 'L1MUE',
16  #'L1CTP',
17  #'TRCAL', 'TRBJT', 'TRBPH', 'TRCOS',
18  #'TRELE', 'TRGAM', 'TRJET', 'TRMET',
19  #'TRMBI', 'TRMUO', 'TRTAU', 'TRIDT',
20 # 'EIDB', 'EIDCR', 'EIDE', 'PIDB', 'PIDCR', 'PIDE',
21 # 'JETB', 'JETEA', 'JETEC',
22 # 'MET', 'METCALO', 'METMUON',
23 # 'TAUB', 'TAUCR', 'TAUE',
24  ]

Definition at line 27 of file AtlRunQueryDQUtils.py.

◆ lumicache

dictionary python.utils.AtlRunQueryDQUtils.lumicache = {}

Definition at line 81 of file AtlRunQueryDQUtils.py.

◆ p

python.utils.AtlRunQueryDQUtils.p = et.parse(sys.argv[1])

Definition at line 210 of file AtlRunQueryDQUtils.py.

◆ rundict

dictionary python.utils.AtlRunQueryDQUtils.rundict = {}

Definition at line 212 of file AtlRunQueryDQUtils.py.

◆ runnum

python.utils.AtlRunQueryDQUtils.runnum = int(lbc.find('Run').text)

Definition at line 214 of file AtlRunQueryDQUtils.py.

◆ SERVER

string python.utils.AtlRunQueryDQUtils.SERVER = 'http://atlasdqm.cern.ch:8080'

Definition at line 25 of file AtlRunQueryDQUtils.py.

◆ THIRTYTWOMASK

python.utils.AtlRunQueryDQUtils.THIRTYTWOMASK = int(2**32-1)

Definition at line 24 of file AtlRunQueryDQUtils.py.

max
#define max(a, b)
Definition: cfImp.cxx:41
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
reduce
void reduce(HepMC::GenEvent *ge, std::vector< HepMC::GenParticlePtr > toremove)
Remove unwanted particles from the event, collapsing the graph structure consistently.
Definition: FixHepMC.cxx:81
normalize
Double_t normalize(TF1 *func, Double_t *rampl=NULL, Double_t from=0., Double_t to=0., Double_t step=1.)
Definition: LArPhysWaveHECTool.cxx:825
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
python.utils.AtlRunQueryDQUtils.MakeDQeffHtml
def MakeDQeffHtml(dic, dicsum, datapath)
Definition: AtlRunQueryDQUtils.py:181
python.utils.AtlRunQueryDQUtils.lumi
def lumi(run, lbr)
Definition: AtlRunQueryDQUtils.py:83
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
min
#define min(a, b)
Definition: cfImp.cxx:40
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.utils.AtlRunQueryDQUtils.GetDQEfficiency
def GetDQEfficiency(rundict)
Definition: AtlRunQueryDQUtils.py:119
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
python.utils.AtlRunQueryDQUtils._intersect
def _intersect(lbr1, lbr2)
Definition: AtlRunQueryDQUtils.py:70
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83