13os.environ[
'TERM'] =
'linux'
16 print (
"Usage: ",sys.argv[0],
" [OPTION] ... ")
17 print (
"Dumps the TileCal status bits from various schemas / folders")
19 print (
"-h, --help shows this help")
20 print (
"-f, --folder= specify status folder to use ONL01 or OFL02, don't need to specify full path")
21 print (
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or full suffix like RUN2-HLT-UPD1-00")
22 print (
"-r, --run= specify run number, by default uses latest iov")
23 print (
"-l, --lumi= specify lumi block number, default is 0")
24 print (
"-b, --begin= specify run number of first iov in multi-iov mode, by default uses very first iov")
25 print (
"-e, --end= specify run number of last iov in multi-iov mode, by default uses latest iov")
26 print (
"-m, --module= specify module to use, default is not set")
27 print (
"-N, --chmin= specify minimal channel to use, default is 0")
28 print (
"-X, --chmax= specify maximal channel to use, default is 47")
29 print (
"-c, --chan= specify channel to use , default is all channels from chmin to chmax")
30 print (
"-g, --gain=, -a, --adc= specify adc(gain) to use, default is 2 (i.e. both low and high gains)")
31 print (
"-C, --comment print comment for every IOV")
32 print (
"-i, --iov print IOVs only for every module")
33 print (
"-I, --IOV print IOVs only")
34 print (
"-d, --default print also default values stored in AUX01-AUX20")
35 print (
"-B, --blob print additional blob info")
36 print (
"-H, --hex print frag id instead of module name")
37 print (
"-P, --pmt print pmt number in addition to channel number")
38 print (
"-s, --schema= specify name of input JSON file or CREST_SERVER_PATH")
39 print (
"-w, --warning suppress warning messages about missing drawers in DB")
41letters =
"hr:l:s:t:f:dBHPwm:b:e:a:g:c:N:X:CiI"
42keywords = [
"help",
"run=",
"lumi=",
"schema=",
"tag=",
"folder=",
"default",
"blob",
"hex",
"pmt",
"warning",
"module=",
"begin=",
"end=",
"chmin=",
"chmax=",
"gain=",
"adc=",
"chan=",
"comment",
"iov",
"IOV"]
45 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
46except getopt.GetoptError
as err:
55folderPath =
"/TILE/OFL02/STATUS/ADC"
85 if o
in (
"-f",
"--folder"):
89 folderPath =
"/TILE/%s/STATUS/ADC" % a
90 elif o
in (
"-t",
"--tag"):
92 elif o
in (
"-s",
"--schema"):
94 elif o
in (
"-r",
"--run"):
96 elif o
in (
"-l",
"--lumi"):
98 elif o
in (
"-b",
"--begin"):
102 elif o
in (
"-e",
"--end"):
106 elif o
in (
"-i",
"--iov"):
109 if modulename==
'AUX-1':
111 elif o
in (
"-I",
"--IOV"):
114 if modulename==
'AUX-1':
116 elif o
in (
"-a",
"--adc",
"-g",
"--gain"):
118 elif o
in (
"-m",
"--module"):
121 elif o
in (
"-c",
"--chan"):
123 elif o
in (
"-N",
"--chmin"):
125 elif o
in (
"-X",
"--chmax"):
127 elif o
in (
"-C",
"--comment"):
129 elif o
in (
"-d",
"--default"):
131 elif o
in (
"-B",
"--blob"):
133 elif o
in (
"-H",
"--hex"):
135 elif o
in (
"-P",
"--pmt"):
137 elif o
in (
"-w",
"--warning"):
139 elif o
in (
"-h",
"--help"):
143 raise RuntimeError(
"unhandled option")
146from TileCalibBlobPython
import TileBchCrest
147from TileCalibBlobObjs.Classes
import TileCalibUtils
149from TileCalibBlobPython.TileCalibLogger
import getLogger
150log = getLogger(
"ReadBchFrCrest")
152logLevel=logging.DEBUG
153log.setLevel(logLevel)
154log1 = getLogger(
"TileBchCrest")
155log1.setLevel(logLevel)
156log2 = getLogger(
"TileCalibCrest")
157log2.setLevel(logLevel)
159if tag.upper().endswith(
'HEAD'):
161if len(tag)==0
or tag.endswith(
'HEAD'):
162 folderPath=
'/TILE/ONL01/STATUS/ADC'
163 log.info(
"tag is %s, using %s folder", tag
if tag
else 'empty', folderPath)
168if folderTag.upper().startswith(
"TILE")
or folderTag.upper().startswith(
"CALO") :
170log.info(
"Initializing folder %s with tag %s", folderPath, folderTag)
173mgr = TileBchCrest.TileBchMgr()
174mgr.setLogLvl(logLevel)
175mgr.initialize(schema, folderPath, folderTag, (run,lumi), warn, -2)
176if iov
or comment
or warn<0:
177 blobReader = mgr.getBlobReader()
181if len(list(isBadDef.keys())):
182 log.info(
"isBad Definition: " )
183 for prbCode
in sorted(isBadDef.keys()):
184 prbDesc = isBadDef[prbCode]
185 msg =
"- %2i (%s)" % (prbCode,prbDesc)
189if len(list(isBadTimingDef.keys())):
190 log.info(
"isBadTiming Definition: " )
191 for prbCode
in sorted(isBadTimingDef.keys()):
192 prbDesc = isBadTimingDef[prbCode]
193 msg =
"- %2i (%s)" % (prbCode,prbDesc)
199 partname = modulename[:3]
200 mod = int(modulename[3:]) -1
202part_dict = {
'AUX':0,
'LBA':1,
'LBC':2,
'EBA':3,
'EBC':4}
203if partname
in part_dict:
204 ros = part_dict[partname]
239 if iovonly
or IOVONLY:
243 iovList = blobReader.getIovs((begin,0),(end,0))
248 if begin != be
or end != en:
251 log.info(
"Changing begin run from %d to %d (start of IOV)", begin,be)
255 log.info(
"Changing end run from %d to %d (start of next IOV)", end,en)
257 log.info(
"Changing end run from %d to %d (start of last IOV)", end,en)
259 log.info(
"%d IOVs in total", len(iovList))
262 if iovonly
or IOVONLY:
263 option = 1
if iovonly
else 0
264 option += (2
if IOVONLY
else 0)
265 blobReader.dumpIovs(iovList,rosmin,rosmax,modmin,modmax,option,(rosmin<=0),
True)
268 iovList.append((run,lumi))
277barrel = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
278 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
279 27, 26, 25, 30, 29, 28,-33,-32, 31, 36, 35, 34,
280 39, 38, 37, 42, 41, 40, 45,-44, 43, 48, 47, 46]
281extbar = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
282 13, 14, 15, 16, 17, 18,-19,-20, 21, 22, 23, 24,
283 -27,-26,-25,-31,-32,-28, 33, 29, 30,-36,-35, 34,
284 44, 38, 37, 43, 42, 41,-45,-39,-40,-48,-47,-46]
286ch2pmt = [ dummy, barrel, barrel, extbar, extbar ]
287gname = [
"LG",
"HG" ]
297oneModule = ((rosmax-rosmin==1)
and (modmax-modmin==1)
and iov)
302 pref =
"(%i,%i) " % (iovs[0],iovs[1])
303 mgr.updateFromDb(schema, folderPath, folderTag, iovs, 1, warn)
305 log.info( pref + str(blobReader.getComment(iovs)) )
312 for ros
in range(rosmin,rosmax):
316 modName =
"0x%x" % ((ros<<8)+mod)
320 newBlob = blobReader.getBlob(ros, mod, iovs,
False)
321 if oldBlob == newBlob:
322 log.info( f
'{modName} in IOV {iovs} is identical to previous IOV')
326 log.info( f
'Reading IOV {iovs} for module {modName}')
328 log.info( f
'{modName} was updated in IOV {iovs}')
331 bch = blobReader.getDrawer(ros, mod, iovs,
False,
False)
339 print (
"%s Blob type: %d Version: %d Nchannels: %d Ngains: %d Nval: %d" % (modName, bch.getObjType(), bch.getObjVersion(), bch.getNChans(), bch.getNGains(), bch.getObjSizeUint32()))
341 for chn
in range(chanmin,chanmax):
342 chnName =
" %2i" % chn
343 for adc
in range(gainmin,gainmax):
345 stat = mgr.getAdcStatus(ros,mod,chn,adc)
351 prbs = mgr.getAdcProblems(ros,mod,chn,adc)
356 msg =
"%s pm %02i ch %02i %s " % ( modName, abs(ch2pmt[ros][chn]), chn, gname[adc] )
358 msg =
"%s %2i %1i " % ( modName,chn,adc )
359 for prbCode
in sorted(prbs.keys()):
360 prbDesc = prbs[prbCode]
361 msg +=
" %5i (%s)" % (prbCode,prbDesc)
365 elif stat.isAffected():
366 msg +=
" => Affected"
372 print (
"%s ALL GOOD" % (modName))
379 print (
"%3i drawers are missing in DB" % miss)
380 print (
"%3i drawers are absolutely good" % good)
381 print (
"%3i drawers have good and affected channels" % (aff-miss))
382 print (
"%3i drawers have some bad channels" % (nMod-good-bad-aff))
383 print (
"%3i drawers are completely bad" % bad)
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.