ATLAS Offline Software
Loading...
Searching...
No Matches
python.utils.AtlRunQueryDQUtils Namespace Reference

Functions

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

Variables

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

Function Documentation

◆ _intersect()

python.utils.AtlRunQueryDQUtils._intersect ( lbr1,
lbr2 )
protected

Definition at line 69 of file AtlRunQueryDQUtils.py.

69def _intersect(lbr1, lbr2):
70 def normalize(lbr):
71 return (max(1, lbr[0]), lbr[1] if lbr[1] != -1 else THIRTYTWOMASK)
72 tlbr1 = normalize(lbr1)
73 tlbr2 = normalize(lbr2)
74 rv = (max(tlbr1[0],tlbr2[0]), min(tlbr1[1],tlbr2[1]))
75 if rv[1] <= rv[0]:
76 return None
77 else:
78 return rv
79
Double_t normalize(TF1 *func, Double_t *rampl=NULL, Double_t from=0., Double_t to=0., Double_t step=1.)
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41

◆ GetDQEfficiency()

python.utils.AtlRunQueryDQUtils.GetDQEfficiency ( rundict)

Definition at line 118 of file AtlRunQueryDQUtils.py.

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

◆ lumi()

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

Definition at line 82 of file AtlRunQueryDQUtils.py.

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

◆ MakeDQeffHtml()

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

Definition at line 180 of file AtlRunQueryDQUtils.py.

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

Variable Documentation

◆ dbSvc

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

Definition at line 19 of file AtlRunQueryDQUtils.py.

◆ FLAGGROUPS

dict 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 51 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 26 of file AtlRunQueryDQUtils.py.

◆ lumicache

dict python.utils.AtlRunQueryDQUtils.lumicache = {}

Definition at line 80 of file AtlRunQueryDQUtils.py.

◆ p

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

Definition at line 209 of file AtlRunQueryDQUtils.py.

◆ rundict

dict python.utils.AtlRunQueryDQUtils.rundict = {}

Definition at line 211 of file AtlRunQueryDQUtils.py.

◆ runnum

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

Definition at line 213 of file AtlRunQueryDQUtils.py.

◆ SERVER

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

Definition at line 24 of file AtlRunQueryDQUtils.py.

◆ THIRTYTWOMASK

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

Definition at line 23 of file AtlRunQueryDQUtils.py.