10os.environ[
'TERM'] =
'linux'
13 print (
"Usage: ",sys.argv[0],
" [OPTION] ... ")
14 print (
"Dumps the TileCal status bits from various schemas / folders")
16 print (
"-h, --help shows this help")
17 print (
"-f, --folder= specify status folder to use ONL01 or OFL02, don't need to specify full path")
18 print (
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or full suffix like RUN2-HLT-UPD1-00")
19 print (
"-r, --run= specify run number, by default uses latest iov")
20 print (
"-l, --lumi= specify lumi block number, default is 0")
21 print (
"-b, --begin= specify run number of first iov in multi-iov mode, by default uses very first iov")
22 print (
"-e, --end= specify run number of last iov in multi-iov mode, by default uses latest iov")
23 print (
"-m, --module= specify module to use, default is not set")
24 print (
"-N, --chmin= specify minimal channel to use, default is 0")
25 print (
"-X, --chmax= specify maximal channel to use, default is 47")
26 print (
"-c, --chan= specify channel to use , default is all channels from chmin to chmax")
27 print (
"-g, --gain=, -a, --adc= specify adc(gain) to use, default is 2 (i.e. both low and high gains)")
28 print (
"-C, --comment print comment for every IOV")
29 print (
"-i, --iov print IOVs only for every module")
30 print (
"-I, --IOV print IOVs only")
31 print (
"-d, --default print also default values stored in AUX01-AUX20")
32 print (
"-B, --blob print additional blob info")
33 print (
"-H, --hex print frag id instead of module name")
34 print (
"-P, --pmt print pmt number in addition to channel number")
35 print (
"-s, --schema= specify schema to use, like 'COOLOFL_TILE/CONDBR2' or 'sqlite://;schema=tileSqlite.db;dbname=CONDBR2' or tileSqlite.db")
36 print (
"-D, --dbname= specify dbname part of schema if schema only contains file name, default is CONDBR2")
37 print (
"-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER")
38 print (
"-w, --warning suppress warning messages about missing drawers in DB")
40letters =
"hr:l:s:t:f:D:S:dBHPwm:b:e:a:g:c:N:X:CiI"
41keywords = [
"help",
"run=",
"lumi=",
"schema=",
"tag=",
"folder=",
"dbname=",
"server=",
"default",
"blob",
"hex",
"pmt",
"warning",
"module=",
"begin=",
"end=",
"chmin=",
"chmax=",
"gain=",
"adc=",
"chan=",
"comment",
"iov",
"IOV"]
44 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
45except getopt.GetoptError
as err:
53schema =
'COOLOFL_TILE/CONDBR2'
56folderPath =
"/TILE/OFL02/STATUS/ADC"
86 if o
in (
"-f",
"--folder"):
90 folderPath =
"/TILE/%s/STATUS/ADC" % a
91 elif o
in (
"-t",
"--tag"):
93 elif o
in (
"-s",
"--schema"):
95 elif o
in (
"-D",
"--dbname"):
97 elif o
in (
"-S",
"--server"):
99 elif o
in (
"-r",
"--run"):
101 elif o
in (
"-l",
"--lumi"):
103 elif o
in (
"-b",
"--begin"):
107 elif o
in (
"-e",
"--end"):
111 elif o
in (
"-i",
"--iov"):
114 if modulename==
'AUX-1':
116 elif o
in (
"-I",
"--IOV"):
119 if modulename==
'AUX-1':
121 elif o
in (
"-a",
"--adc",
"-g",
"--gain"):
123 elif o
in (
"-m",
"--module"):
126 elif o
in (
"-c",
"--chan"):
128 elif o
in (
"-N",
"--chmin"):
130 elif o
in (
"-X",
"--chmax"):
132 elif o
in (
"-C",
"--comment"):
134 elif o
in (
"-d",
"--default"):
136 elif o
in (
"-B",
"--blob"):
138 elif o
in (
"-H",
"--hex"):
140 elif o
in (
"-P",
"--pmt"):
142 elif o
in (
"-w",
"--warning"):
144 elif o
in (
"-h",
"--help"):
148 raise RuntimeError(
"unhandled option")
151from TileCalibBlobPython
import TileCalibTools
152from TileCalibBlobPython
import TileBchTools
153from TileCalibBlobPython.TileCalibTools
import MAXRUN, MAXLBK
154from TileCalibBlobObjs.Classes
import TileCalibUtils
156from TileCalibBlobPython.TileCalibLogger
import getLogger
157log = getLogger(
"ReadBch")
159logLevel=logging.DEBUG
160log.setLevel(logLevel)
161log1 = getLogger(
"TileCalibTools")
162log1.setLevel(logLevel)
166if len(dbname)<7
and run!=2147483647:
167 dbname =
'COMP200' if run<232000
else 'CONDBR2'
169if 'COOLO' not in schema
and ':' not in schema
and ';' not in schema:
170 schema=
'sqlite://;schema='+schema+
';dbname='+(dbname
if len(dbname)
else 'CONDBR2')
172if 'sqlite:' not in schema
and len(dbname):
173 schema=schema.replace(
'CONDBR2',dbname)
174 schema=schema.replace(
'COMP200',dbname)
177 folderPath=
'/TILE/ONL01/STATUS/ADC'
178 if 'COOLOFL' in schema:
179 if 'COMP200' in schema:
180 schema=
'COOLONL_TILE/COMP200'
181 if 'CONDBR2' in schema:
182 schema=
'COOLONL_TILE/CONDBR2'
183 log.warning(
"tag is empty, using %s folder and schema %s", folderPath,schema)
185if schema==
'COOLONL_TILE/COMP200':
186 if folderPath!=
"/TILE/ONL01/STATUS/ADC" and folderPath!=
"/TILE/OFL01/STATUS/ADC":
187 log.warning(
"Folder %s doesn't exist in schema %s", folderPath,schema)
188 folderPath=
"/TILE/ONL01/STATUS/ADC"
189 log.warning(
"Changing folder to %s", folderPath)
191if schema==
'COOLONL_TILE/CONDBR2':
192 if folderPath!=
"/TILE/ONL01/STATUS/ADC":
193 log.warning(
"Folder %s doesn't exist in schema %s ", folderPath,schema)
194 folderPath=
"/TILE/ONL01/STATUS/ADC"
195 log.warning(
"Changing folder to %s", folderPath)
197if schema==
'COOLOFL_TILE/COMP200' or schema==
'COOLOFL_TILE/CONDBR2':
198 if folderPath!=
"/TILE/OFL02/STATUS/ADC":
199 log.warning(
"Folder %s doesn't exist in schema %s ", folderPath,schema)
200 folderPath=
"/TILE/OFL02/STATUS/ADC"
201 log.warning(
"Changing folder to %s", folderPath)
205db = TileCalibTools.openDbConn(schema,server)
206folderTag = TileCalibTools.getFolderTag(db
if 'CONDBR2' in schema
else schema, folderPath, tag)
207log.info(
"Initializing folder %s with tag %s", folderPath, folderTag)
210mgr = TileBchTools.TileBchMgr()
211mgr.setLogLvl(logLevel)
212mgr.initialize(db, folderPath, folderTag, (run,lumi), warn, -2)
213if iov
or comment
or warn<0:
214 blobReader = TileCalibTools.TileBlobReader(db,folderPath,folderTag)
218if len(list(isBadDef.keys())):
219 log.info(
"isBad Definition: " )
220 for prbCode
in sorted(isBadDef.keys()):
221 prbDesc = isBadDef[prbCode]
222 msg =
"- %2i (%s)" % (prbCode,prbDesc)
226if len(list(isBadTimingDef.keys())):
227 log.info(
"isBadTiming Definition: " )
228 for prbCode
in sorted(isBadTimingDef.keys()):
229 prbDesc = isBadTimingDef[prbCode]
230 msg =
"- %2i (%s)" % (prbCode,prbDesc)
236 partname = modulename[:3]
237 mod = int(modulename[3:]) -1
239part_dict = {
'AUX':0,
'LBA':1,
'LBC':2,
'EBA':3,
'EBC':4}
240if partname
in part_dict:
241 ros = part_dict[partname]
273if iovonly
or IOVONLY:
280 roslist = list(range(rosmin,rosmax))
292 modName =
"0x%x" % ((ros<<8)+mod)
296 dbobjs = blobReader.getDBobjsWithinRange(ros,mod)
297 while dbobjs.goToNext():
298 obj = dbobjs.currentRef()
299 objsince = obj.since()
300 sinceRun = objsince >> 32
301 sinceLum = objsince & 0xFFFFFFFF
302 since =
"(%d,%d)" % (sinceRun, sinceLum)
310 if since
in allsince:
311 allsince[since] += [modName]
313 allsince[since] = [modName]
317 print(
"%s %s" % (modName,
" ".join(iovs)) )
321 for since
in allsince:
322 if comment
and allsince[since][-1]!=
"Comment":
323 allsince[since] += [
"NO_COMMENT"]
324 all+=[
"%s %s" % (since,
" ".join(allsince[since]))]
330 print(
"No new IOVs after run",lastRun)
347 dbobjs = blobReader.getDBobjsWithinRange(COOL_part,COOL_chan)
349 raise Exception(
"No DB objects retrieved when building IOV list!")
350 while dbobjs.goToNext():
351 obj = dbobjs.currentRef()
352 objsince = obj.since()
353 sinceRun = objsince >> 32
354 sinceLum = objsince & 0xFFFFFFFF
355 since = (sinceRun, sinceLum)
356 objuntil = obj.until()
357 untilRun = objuntil >> 32
358 untilLum = objuntil & 0xFFFFFFFF
359 until = (untilRun, untilLum)
360 iovList.append((since, until))
362 log.warning(
"Warning: can not read IOVs from input DB file" )
368 if begin != be
or end != en:
371 for i,iovs
in enumerate(iovList):
374 if (run<begin
and run>be)
or run==begin :
377 if run>=end
and run<en:
382 log.info(
"Changing begin run from %d to %d (start of IOV)", begin,be)
386 log.info(
"Changing end run from %d to %d (start of next IOV)", end,en)
388 log.info(
"Changing end run from %d to %d (start of last IOV)", end,en)
390 iovList=iovList[ib:ie]
391 if COOL_chan == 1000:
392 log.info(
"%d IOVs in total for comment field", len(iovList) )
394 log.info(
"%d IOVs in total for %s", len(iovList),modulename)
396 iovList.append(((run,lumi),(MAXRUN, MAXLBK)))
405barrel = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
406 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
407 27, 26, 25, 30, 29, 28,-33,-32, 31, 36, 35, 34,
408 39, 38, 37, 42, 41, 40, 45,-44, 43, 48, 47, 46]
409extbar = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
410 13, 14, 15, 16, 17, 18,-19,-20, 21, 22, 23, 24,
411 -27,-26,-25,-31,-32,-28, 33, 29, 30,-36,-35, 34,
412 44, 38, 37, 43, 42, 41,-45,-39,-40,-48,-47,-46]
414ch2pmt = [ dummy, barrel, barrel, extbar, extbar ]
415gname = [
"LG",
"HG" ]
428 pref =
"(%i,%i) " % (iovs[0][0],iovs[0][1])
430 log.info( pref + blobReader.getComment(iovs[0]) )
437 for ros
in range(rosmin,rosmax):
440 mgr.updateFromDb(db, folderPath, folderTag, iovs[0], 1, warn, ros, mod)
442 modName =
"0x%x" % ((ros<<8)+mod)
446 bch = blobReader.getDrawer(ros, mod, iovs[0],
False,
False)
454 print (
"%s Blob type: %d Version: %d Nchannels: %d Ngains: %d Nval: %d" % (modName, bch.getObjType(), bch.getObjVersion(), bch.getNChans(), bch.getNGains(), bch.getObjSizeUint32()))
456 for chn
in range(chanmin,chanmax):
457 chnName =
" %2i" % chn
458 for adc
in range(gainmin,gainmax):
460 stat = mgr.getAdcStatus(ros,mod,chn,adc)
466 prbs = mgr.getAdcProblems(ros,mod,chn,adc)
471 msg =
"%s pm %02i ch %02i %s " % ( modName, abs(ch2pmt[ros][chn]), chn, gname[adc] )
473 msg =
"%s %2i %1i " % ( modName,chn,adc )
474 for prbCode
in sorted(prbs.keys()):
475 prbDesc = prbs[prbCode]
476 msg +=
" %5i (%s)" % (prbCode,prbDesc)
480 elif stat.isAffected():
481 msg +=
" => Affected"
487 print (
"%s ALL GOOD" % (modName))
494 print (
"%3i drawers are missing in DB" % miss)
495 print (
"%3i drawers are absolutely good" % good)
496 print (
"%3i drawers have good and affected channels" % (aff-miss))
497 print (
"%3i drawers have some bad channels" % (nMod-good-bad-aff))
498 print (
"%3i drawers are completely bad" % bad)
void print(char *figname, TCanvas *c1)
static unsigned int max_gain()
Python compatibility function.
static unsigned int badtiming_definition_chan()
Python compatibility function.
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
static unsigned int max_chan()
Python compatibility function.
static unsigned int getMaxDrawer(unsigned int ros)
Returns the maximal channel number for a given drawer.
static unsigned int definitions_draweridx()
Python compatibility function.
static unsigned int bad_definition_chan()
Python compatibility function.