ATLAS Offline Software
Loading...
Searching...
No Matches
python.TileCalibCrest.TileBlobReaderCrest Class Reference
Inheritance diagram for python.TileCalibCrest.TileBlobReaderCrest:
Collaboration diagram for python.TileCalibCrest.TileBlobReaderCrest:

Public Member Functions

 __init__ (self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False)
 getTag (self)
 getFolderTag (self, folder, prefix, globalTag, api=None)
 getIovs (self, since=(MINRUN, MINLBK), until=(MAXRUN, MAXLBK))
 getIov (self, option=0)
 getHashListSize (self)
 getPayloadHash (self)
 getInsertionTime (self)
 getPayloadByHash (self, hash)
 readIov (self, runlumi=None, dbg=False)
 getPayload (self, runlumi=None, dbg=False)
 getBlob (self, ros, mod, runlumi=None, dbg=False)
 getDrawer (self, ros, mod, runlumi=None, dbg=False, useDefault=True)
 getComment (self, runlumi=None, split=False)
 getDefault (self, ros, drawer)
 dumpIovs (self, iovList, rosmin, rosmax, drawermin, drawermax, option=1, comment=False, usenames=True)

Public Attributes

dict payload = {}

Private Member Functions

 __getIov (self, runlumi, dbg=False)
 __runlumi2iov (self, runlumi)
 __checkIov (self, runlumi)
 __make_blob (self, string)
 __create_comment (self, b64string)
 __create_drawer (self, b64string, chan)

Private Attributes

 __db = CREST_HOST
 __folder = folder
str __tag = tag
 __copyBlob = copyBlob
list __iovList = []
tuple __iov = (-1,0)
list __payload_hash = []
list __insertion_time = []
int __commentBlob = None
list __drawerBlob = [None]*276
 __comment = None
list __drawer = [None]*276
 __modmin = modmin
int __modmax = modmax+1
 __remote = not self.__db.endswith(".json")
 __api_instance = chai.Database(f"crest:{self.__db}")
 __tag_instance = self.__api_instance.get_tag(self.__tag)

Detailed Description

TileCalibBlobReader is a helper class, managing the details of CREST interactions for
the user of TileCalibBlobs.

Definition at line 50 of file TileCalibCrest.py.

Constructor & Destructor Documentation

◆ __init__()

python.TileCalibCrest.TileBlobReaderCrest.__init__ ( self,
db,
folder = '',
tag = '',
run = None,
lumi = 0,
modmin = 0,
modmax = 275,
copyBlob = False )
Input:
- db    : server connection string or file name
- folder: full folder path
- tag   : The folder tag, e.g. \"UPD4-24\" or full tag
- run   : Run number (if known)
- lumi  : Lumi block number
- modmin: Minimal module (COOL channel number)
- modmax: Maximal module (COOL channel number)
- copyBlob: save payload from CREST (Default:False, True to copy payload to json file)

Definition at line 57 of file TileCalibCrest.py.

57 def __init__(self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False):
58 """
59 Input:
60 - db : server connection string or file name
61 - folder: full folder path
62 - tag : The folder tag, e.g. \"UPD4-24\" or full tag
63 - run : Run number (if known)
64 - lumi : Lumi block number
65 - modmin: Minimal module (COOL channel number)
66 - modmax: Maximal module (COOL channel number)
67 - copyBlob: save payload from CREST (Default:False, True to copy payload to json file)
68 """
69 #=== initialize base class
70 TileCalibLogger.__init__(self,"TileBlobReader")
71 self.payload = {}
72 if db is None or ('CREST' in db and 'http' not in db):
73 self.__db = CREST_HOST
74 else:
75 self.__db = db
76 self.__folder = folder
77 self.__tag = tag
78 self.__copyBlob = copyBlob
79
80 self.__iovList = []
81 self.__iov = (-1,0)
82 self.__payload_hash = []
83 self.__insertion_time = []
84 self.__commentBlob = None
85 self.__drawerBlob = [None]*276
86 self.__comment = None
87 self.__drawer = [None]*276
88 self.__modmin = modmin
89 self.__modmax = modmax+1
90
91 #=== try to open db
92 self.__remote = not self.__db.endswith(".json")
93 if self.__remote:
94 if 'http' in self.__db:
95 self.log().info('Host %s' , (self.__db))
96 self.__api_instance = chai.Database(f"crest:{self.__db}")
97 else:
98 self.log().info('Local db %s' , (self.__db))
99 self.__api_instance = chai.Database(f"crest_fs:{self.__db}")
100 self.__tag = self.getFolderTag(folder,None,tag)
101 try:
102 self.__tag_instance = self.__api_instance.get_tag(self.__tag)
103 except Exception:
104 self.__tag_instance = None
105 if run is not None and lumi is not None:
106 log.info("Initializing for run %d, lumiblock %d", run,lumi)
107 self.__getIov((run,lumi),True)
108 elif run is None and lumi is not None:
109 log.info("Initializing for hash %s", lumi)
110 self.__getIov(lumi,True)
111 else:
112 self.log().info('File %s' , (self.__db))
113 self.__api_instance = None
114 self.__tag_instance = None
115 self.__tag = 'unknown'
116 self.__iovList.append(((MINRUN,MINLBK),(MAXRUN, MAXLBK)))
117 self.__iov = self.__runlumi2iov(self.__iovList[-1])
118 with open(self.__db, 'r') as the_file:
119 jdata = json.load(the_file)
120 if self.__copyBlob:
121 self.payload = jdata
122 return
123 for chan in range(self.__modmin,self.__modmax):
124 try:
125 blob=jdata[str(chan)][0]
126 except Exception:
127 blob=None
128 self.__create_drawer(blob,chan)
129 try:
130 blob=jdata['1000'][0]
131 except Exception:
132 blob=None
133 self.__create_comment(blob)
134

Member Function Documentation

◆ __checkIov()

python.TileCalibCrest.TileBlobReaderCrest.__checkIov ( self,
runlumi )
private

Definition at line 353 of file TileCalibCrest.py.

353 def __checkIov(self,runlumi):
354 if isinstance(runlumi,list) or isinstance(runlumi,tuple):
355 run = runlumi[0] if isinstance(runlumi[0],int) else 0
356 lumi = runlumi[1] if isinstance(runlumi[1],int) else 0
357 point = (run<<32) + lumi
358 else:
359 point = runlumi if isinstance(runlumi,int) else 0
360 inrange = point>=self.__iov[0] and point<self.__iov[1]
361 return inrange
362

◆ __create_comment()

python.TileCalibCrest.TileBlobReaderCrest.__create_comment ( self,
b64string )
private

Definition at line 371 of file TileCalibCrest.py.

371 def __create_comment(self,b64string):
372 if b64string is None or len(b64string)==0:
373 if b64string is None:
374 self.__commentBlob = None
375 else:
376 self.__commentBlob = 0
377 self.__comment = None
378 else:
379 blob1 = base64.decodebytes(bytes(b64string,'ascii'))
380 self.__commentBlob = self.__make_blob(blob1)
381 self.__comment = TileCalibDrawerCmt.getInstance(self.__commentBlob)
382 return
383
static const TileCalibDrawerCmt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerCmt.

◆ __create_drawer()

python.TileCalibCrest.TileBlobReaderCrest.__create_drawer ( self,
b64string,
chan )
private

Definition at line 385 of file TileCalibCrest.py.

385 def __create_drawer(self,b64string,chan):
386 if b64string is None or isinstance(b64string, (int, float)) or len(b64string)==0:
387 if b64string is None:
388 self.__drawerBlob[chan] = None
389 else:
390 self.__drawerBlob[chan] = 0
391 self.__drawer[chan] = None
392 return
393 blob1 = base64.decodebytes(bytes(b64string,'ascii'))
394 self.__drawerBlob[chan] = self.__make_blob(blob1)
395 cmt = TileCalibDrawerCmt.getInstance(self.__drawerBlob[chan])
396 typeName = TileCalibType.getClassName(cmt.getObjType())
397 del cmt
398 #=== create calibDrawer depending on type
399 if typeName=='TileCalibDrawerFlt':
400 self.__drawer[chan] = TileCalibDrawerFlt.getInstance(self.__drawerBlob[chan])
401 self.log().debug( "typeName = Flt " )
402 elif typeName=='TileCalibDrawerInt':
403 self.__drawer[chan] = TileCalibDrawerInt.getInstance(self.__drawerBlob[chan])
404 self.log().debug( "typeName = Int " )
405 elif typeName=='TileCalibDrawerBch':
406 self.__drawer[chan] = TileCalibDrawerBch.getInstance(self.__drawerBlob[chan])
407 self.log().debug( "typeName = Bch " )
408 elif typeName=='TileCalibDrawerOfc':
409 self.__drawer[chan] = TileCalibDrawerOfc.getInstance(self.__drawerBlob[chan])
410 self.log().debug( "typeName = Ofc " )
411 elif typeName=='TileCalibDrawerCmt':
412 self.__drawer[chan] = cppyy.gbl.CaloCondBlobFlt.getInstance(self.__drawerBlob[chan])
413 self.log().debug( "typeName = CaloFlt " )
414 else:
415 self.__drawer[chan] = None
416 self.log().warn("Unknown blob type for chan %d - ignoring", chan)
417 return
418
const bool debug
static const TileCalibDrawerBch * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
static const TileCalibDrawerFlt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerFlt.
static const TileCalibDrawerInt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
static TileCalibDrawerOfc * getInstance(coral::Blob &blob, uint16_t objVersion, uint32_t nSamples, int32_t nPhases, uint16_t nChans, uint16_t nGains, std::string_view author="", std::string_view comment="", uint64_t timeStamp=0)
Returns a pointer to a non-const TileCalibDrawerOfc.
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.

◆ __getIov()

python.TileCalibCrest.TileBlobReaderCrest.__getIov ( self,
runlumi,
dbg = False )
private

Definition at line 279 of file TileCalibCrest.py.

279 def __getIov(self,runlumi,dbg=False):
280 if self.__tag_instance is None:
281 pass
282 else:
283 usehash = not (isinstance(runlumi,list) or isinstance(runlumi,tuple))
284 if usehash:
285 res=self.__tag_instance.get_payload(runlumi)
286 else:
287 res=self.__tag_instance.get_payload_at((runlumi[0]<<32)+runlumi[1])
288 if not res:
289 if usehash:
290 raise Exception( "IOV for tag %s run,lumi (%s,%s) not found" % (self.__tag,runlumi[0],runlumi[1]) )
291 else:
292 raise Exception( "IOV for tag %s hash %s not found" % (self.__tag,runlumi) )
293 else:
294 if usehash:
295 (runS,lumiS,runU,lumiU) = (0,0,MAXRUN,MAXLBK)
296 self.__insertion_time.append(0)
297 self.__payload_hash.append(runlumi)
298 jdata = json.loads(res.to_json())
299 if dbg:
300 self.log().info('hash %s' , runlumi)
301 else:
302 runS=res.since>>32
303 lumiS=res.since&0xFFFFFFFF
304 if res.until is None:
305 runU=MAXRUN
306 lumiU=MAXLBK
307 else:
308 runU=res.until>>32
309 lumiU=res.until&0xFFFFFFFF
310 if dbg:
311 #self.log().info('Run,Lumi (%d,%d)' , runlumi)
312 self.log().info('IOV [%d,%d] - (%d,%d)' , runS,lumiS,runU,lumiU)
313 iovs=self.__tag_instance.get_iovs(res.since,res.since+1)
314 self.__payload_hash = []
315 self.__insertion_time = []
316 for iov in iovs:
317 if iov.since == res.since:
318 self.__insertion_time.append(iov.insertion_time)
319 self.__payload_hash.append(iov.payload_hash)
320 if dbg:
321 self.log().info('Insertion time %s Hash %s' , iov.insertion_time, iov.payload_hash)
322 self.__insertion_time.reverse()
323 self.__payload_hash.reverse()
324 jdata = json.loads(res.payload.to_json())
325 #with open("payload.json", 'w') as the_file:
326 # the_file.write(payload)
327 # the_file.write('\n')
328 self.__iovList.append(((runS,lumiS),(runU, lumiU)))
329 self.__iov = self.__runlumi2iov(self.__iovList[-1])
330 if self.__copyBlob:
331 self.payload = jdata
332 return
333 for chan in range(self.__modmin,self.__modmax):
334 try:
335 blob=jdata[str(chan)][0]
336 except Exception:
337 blob=None
338 self.__create_drawer(blob,chan)
339 try:
340 blob=jdata['1000'][0]
341 except Exception:
342 blob=None
343 self.__create_comment(blob)
344 return
345

◆ __make_blob()

python.TileCalibCrest.TileBlobReaderCrest.__make_blob ( self,
string )
private

Definition at line 364 of file TileCalibCrest.py.

364 def __make_blob(self,string):
365 b = Blob()
366 b.write(string)
367 b.seek(0)
368 return b
369

◆ __runlumi2iov()

python.TileCalibCrest.TileBlobReaderCrest.__runlumi2iov ( self,
runlumi )
private

Definition at line 347 of file TileCalibCrest.py.

347 def __runlumi2iov(self,runlumi):
348 since = (runlumi[0][0]<<32) + runlumi[0][1]
349 until = (runlumi[1][0]<<32) + runlumi[1][1]
350 return (since,until)
351

◆ dumpIovs()

python.TileCalibCrest.TileBlobReaderCrest.dumpIovs ( self,
iovList,
rosmin,
rosmax,
drawermin,
drawermax,
option = 1,
comment = False,
usenames = True )
Dumps statistics - how many non-empty modules exists in different IOVs

Definition at line 522 of file TileCalibCrest.py.

522 def dumpIovs(self, iovList, rosmin, rosmax, drawermin, drawermax, option=1, comment=False, usenames=True):
523 """
524 Dumps statistics - how many non-empty modules exists in different IOVs
525 """
526
527 if len(iovList)>0:
528 alliovs={}
529 allmods={}
530 zeroiovs={}
531 nmod=0
532 rosrange=list(range(rosmin,rosmax))
533 if comment:
534 rosrange+=[9999]
535 for since in iovList:
536 iov="(%s,%s)" % since
537 allmod=""
538 missmod=""
539 zeromod=""
540 zero=0
541 miss=0
542 for ros in rosrange:
543 if ros<0:
544 (dmin,dmax) = (drawermin,drawermax)
545 elif ros>4:
547 else:
548 (dmin,dmax) = (drawermin,min(drawermax,TileCalibUtils.getMaxDrawer(ros)))
549 for drawer in range(dmin,dmax):
550 flt = self.getDrawer(ros, drawer, since, False, False)
551 if ros<0 or ros>4:
553 mod = "Comment"
554 else:
555 mod = "CH_"+str(getDrawerIdx(ros,drawer))
556 elif usenames:
557 mod = TileCalibUtils.getDrawerString(ros,drawer)
558 else:
559 mod = str(getDrawerIdx(ros,drawer))
560 if mod not in allmods:
561 allmods[mod] = ""
562 nmod += 1
563 if flt is not None:
564 if flt==0:
565 zero += 1
566 zeromod += " " + mod
567 allmod += " " + mod + "_zero"
568 allmods[mod] += " " + iov + "_zero"
569 else:
570 allmod += " " + mod
571 allmods[mod] += " " + iov
572 else:
573 miss+=1
574 missmod += " " + mod
575 word = 'module' if usenames else 'COOL channel'
576 if miss==0 and nmod>1:
577 alliovs[iov] = " All %s" % plural(nmod,word)
578 elif miss>0 and miss<10:
579 alliovs[iov] = " %s present, %s missing:%s" % (plural(nmod-miss,word),plural(miss,word),missmod)
580 else:
581 alliovs[iov] = "%s ; %s present, %s missing" % (allmod,plural(nmod-miss,word),plural(miss,word))
582 zeroiovs[iov] = (zero,zeromod)
583
584 if (option&1)==1:
585 print("")
586 for key,value in allmods.items():
587 if value=="":
588 value=" None"
589 print("%s\t%s" % (key,value))
590 if (option&2)==2:
591 print("")
592 for key,value in alliovs.items():
593 if value=="":
594 value=" None"
595 if zeroiovs[key] and zeroiovs[key][0]>0:
596 if "_zero" not in value:
597 print("%s\t%s ; zero-sized blobs for %d modules:%s" % (key,value,zeroiovs[key][0],zeroiovs[key][1]))
598 else:
599 print("%s\t%s ; zero-sized blobs for %d modules" % (key,value,zeroiovs[key][0]))
600 else:
601 print("%s\t%s" % (key,value))
602 else:
603 print("\nNo IOVs found")
604
605
void print(char *figname, TCanvas *c1)
#define min(a, b)
Definition cfImp.cxx:40
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
static unsigned int getMaxDrawer(unsigned int ros)
Returns the maximal channel number for a given drawer.
static unsigned int getCommentChannel()
Returns the COOL channel number for the comment channel.

◆ getBlob()

python.TileCalibCrest.TileBlobReaderCrest.getBlob ( self,
ros,
mod,
runlumi = None,
dbg = False )

Definition at line 428 of file TileCalibCrest.py.

428 def getBlob(self,ros, mod, runlumi=None, dbg=False):
429
430 if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
431 self.__getIov(runlumi,dbg)
432
433 chanNum = getDrawerIdx(ros,mod)
434
435 if (chanNum>=0 and chanNum<len(self.__drawer)):
436 return self.__drawerBlob[chanNum]
437 else:
438 raise Exception( "Invalid drawer requested: %s %s" % (ros,mod) )
439

◆ getComment()

python.TileCalibCrest.TileBlobReaderCrest.getComment ( self,
runlumi = None,
split = False )

Definition at line 470 of file TileCalibCrest.py.

470 def getComment(self,runlumi=None,split=False):
471
472 if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
473 self.__getIov(runlumi)
474 if self.__comment is not None:
475 if split:
476 return (self.__comment.getAuthor(),self.__comment.getComment(),self.__comment.getDate())
477 else:
478 return self.__comment.getFullComment()
479 else:
480 return "<no comment found>"
481

◆ getDefault()

python.TileCalibCrest.TileBlobReaderCrest.getDefault ( self,
ros,
drawer )
Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition

Definition at line 483 of file TileCalibCrest.py.

483 def getDefault(self, ros, drawer):
484 """
485 Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
486 """
487 if ros==0:
488 if drawer<=4 or drawer==12 or drawer>=20:
489 drawer1=0
490 elif drawer<12:
491 drawer1=4
492 else:
493 drawer1=12
494 elif ros==1 or ros==2:
495 drawer1=4
496 elif ros==3:
497 OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E+1: EBA07; Outer MBTS: EBA08
498 0, 0, 0, 0, 7, 6, 5, 7, #// D+4: EBA13, EBA16; Special D+4: EBA14; Special D+40: EBA15
499 7, 6, 6, 7, 0, 0, 0, 2, #// D+4: EBA17, EBA20; Special D+4: EBA18, EBA19; Outer MBTS: EBA24
500 3, 0, 0, 0, 0, 0, 0, 0, #// Merged E+1: EBA25
501 0, 0, 0, 0, 0, 0, 1, 1, #// Inner MBTS + special C+10: EBA39, EBA40
502 1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C+10: EBA41, EBA42; Outer MBTS: EBA43; Merged E+1: EBA44
503 0, 0, 0, 0, 3, 2, 1, 1, #// Merged E+1: EBA53; Outer MBTS: EBA54; Inner MBTS + special C+10: EBA55, EBA56
504 1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C+10: EBA57, EBA58
505 drawer1 = 12 + OffsetEBA[drawer]
506 elif ros==4:
507 OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E-1: EBC07; Outer MBTS: EBC08
508 0, 0, 0, 0, 7, 6, 6, 7, # // D-4: EBC13, EBC16; Special D-4: EBC14, EBC15;
509 7, 5, 6, 7, 0, 0, 0, 2, #// D-4: EBC17, EBC20; Special D-40 EBC18; Special D-4: EBC19; Outer MBTS: EBC24
510 3, 0, 0, 3, 4, 0, 3, 4, #// Merged E-1: EBC25, EBC28, EBC31; E-4': EBC29, EBC32
511 0, 4, 3, 0, 4, 3, 1, 1, #// E-4': EBC34, EBC37; Merged E-1: EBC35, EBC38; Inner MBTS + special C-10: EBC39, EBC40
512 1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C-10: EBC41, EBC42; Outer MBTS: EBC43; Merged E-1: EBC44
513 0, 0, 0, 0, 3, 2, 1, 1, #// Merged E-1: EBC53; Outer MBTS: EBC54; Inner MBTS + special C-10: EBC55, EBC56
514 1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C-10: EBC57, EBC58
515 drawer1 = 12 + OffsetEBC[drawer]
516 else:
517 drawer1=0
518
519 return (0,drawer1)
520

◆ getDrawer()

python.TileCalibCrest.TileBlobReaderCrest.getDrawer ( self,
ros,
mod,
runlumi = None,
dbg = False,
useDefault = True )

Definition at line 441 of file TileCalibCrest.py.

441 def getDrawer(self,ros, mod, runlumi=None, dbg=False, useDefault=True):
442
443 if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
444 self.__getIov(runlumi,dbg)
445
446 chanNum = getDrawerIdx(ros,mod)
447
448 if (chanNum>=0 and chanNum<len(self.__drawer)):
449 drawer=self.__drawer[chanNum]
450 if not useDefault and drawer is None:
451 if self.__drawerBlob[chanNum] is None:
452 return None
453 else:
454 return 0
455 while drawer is None:
456 #=== no default at all?
457 if ros==0 and drawer==0:
458 raise Exception('No default available')
459 #=== follow default policy
460 ros,mod = self.getDefault(ros,mod)
461 chanNum = getDrawerIdx(ros,mod)
462 drawer=self.__drawer[chanNum]
463 return drawer
464 elif (chanNum == 1000):
465 return self.__comment
466 else:
467 raise Exception( "Invalid drawer requested: %s %s" % (ros,mod) )
468

◆ getFolderTag()

python.TileCalibCrest.TileBlobReaderCrest.getFolderTag ( self,
folder,
prefix,
globalTag,
api = None )

Definition at line 140 of file TileCalibCrest.py.

140 def getFolderTag(self, folder, prefix, globalTag, api=None):
141 if globalTag=='CURRENT' or globalTag=='UPD4' or globalTag=='' or globalTag=='HEAD':
142 globalTag=TileCalibTools.getAliasFromFile('Current')
143 log.info("Resolved CURRENT globalTag to \'%s\'", globalTag)
144 elif globalTag=='CURRENTES' or globalTag=='UPD1':
145 globalTag=TileCalibTools.getAliasFromFile('CurrentES')
146 log.info("Resolved CURRENT ES globalTag to \'%s\'", globalTag)
147 elif globalTag=='NEXT':
148 globalTag=TileCalibTools.getAliasFromFile('Next')
149 log.info("Resolved NEXT globalTag to \'%s\'", globalTag)
150 elif globalTag=='NEXTES':
151 globalTag=TileCalibTools.getAliasFromFile('NextES')
152 log.info("Resolved NEXT ES globalTag to \'%s\'", globalTag)
153 globalTag=globalTag.replace('*','')
154 if prefix is None:
155 prefix = ''
156 for f in folder.split('/'):
157 if re.findall('[a-z]+',f) != [] and f!='CellNoise':
158 prefix+=f
159 else:
160 prefix+=f.capitalize()
161 else:
162 prefix=prefix.strip('-').split('-')[0]
163 if prefix.startswith('Calo') and 'NoiseCell' not in prefix:
164 prefix='CALO'+prefix[4:]
165 prefix=prefix.replace('Pileupnoiselumi','PileUpNoiseLumi')
166 if 'UPD1' in globalTag or 'UPD4' in globalTag or ('COND' not in globalTag and 'CREST' not in globalTag):
167 if prefix != '':
168 if prefix in globalTag or prefix.upper() in globalTag:
169 tag=globalTag
170 else:
171 tag=prefix+'-'+globalTag
172 self.log().info("Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
173 elif folder!='' and not (globalTag.upper().startswith('TILE') or globalTag.upper().startswith('CALO')):
174 tag = TileCalibUtils.getFullTag(folder, globalTag)
175 if tag.startswith('Calo') and 'NoiseCell' not in tag:
176 tag='CALO'+tag[4:]
177 tag=tag.replace('Pileupnoiselumi','PileUpNoiseLumi')
178 self.log().info("Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
179 else:
180 tag=globalTag
181 self.log().info("Use localTag \'%s\' as is", tag)
182 else:
183 tag=None
184 try:
185 if api:
186 gtag = api.get_global_tag(globalTag)
187 elif self.__api_instance and 'http' in self.__db:
188 gtag = self.__api_instance.get_global_tag(globalTag)
189 else:
190 api = chai.Database(f"crest:{CREST_HOST}")
191 gtag = api.get_global_tag(globalTag)
192 tags = gtag.mapping
193 except Exception:
194 tags = {}
195 if len(tags)==0:
196 raise Exception( "globalTag %s not found" % (globalTag) )
197 else:
198 for l in tags:
199 t=tags[l][1]
200 if (prefix!='' and t.startswith(prefix)) or l==folder:
201 tag=t
202 self.log().info("Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
203 #taginfo = self.__api_instance.get_tag(tag)
204 #print(taginfo.to_json())
205 return tag
206
static std::string getFullTag(const std::string &folder, const std::string &tag)
Returns the full tag string, composed of camelized folder name and tag part.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

◆ getHashListSize()

python.TileCalibCrest.TileBlobReaderCrest.getHashListSize ( self)

Definition at line 234 of file TileCalibCrest.py.

234 def getHashListSize(self):
235 return len(self.__payload_hash)
236

◆ getInsertionTime()

python.TileCalibCrest.TileBlobReaderCrest.getInsertionTime ( self)

Definition at line 242 of file TileCalibCrest.py.

242 def getInsertionTime(self):
243 return self.__insertion_time
244

◆ getIov()

python.TileCalibCrest.TileBlobReaderCrest.getIov ( self,
option = 0 )

Definition at line 227 of file TileCalibCrest.py.

227 def getIov(self, option=0):
228 if option!=0:
229 return self.__iov
230 else:
231 return self.__iovList[-1]
232

◆ getIovs()

python.TileCalibCrest.TileBlobReaderCrest.getIovs ( self,
since = (MINRUN,MINLBK),
until = (MAXRUN,MAXLBK) )

Definition at line 208 of file TileCalibCrest.py.

208 def getIovs(self,since=(MINRUN,MINLBK),until=(MAXRUN,MAXLBK)):
209 if self.__tag_instance is None:
210 return [self.__iovList[0][0]]
211 else:
212 run_lumi1=(since[0]<<32)+since[1]
213 run_lumi2=(until[0]<<32)+until[1]
214 run_lumi0=self.__tag_instance.get_payload_at(run_lumi1).since
215 iovs=self.__tag_instance.get_iovs(run_lumi0,run_lumi2)
216 iovList=[]
217 for iov in iovs:
218 runS=iov.since>>32
219 lumiS=iov.since&0xFFFFFFFF
220 if (runS,lumiS) not in iovList:
221 iovList.append((runS,lumiS))
222 if len(iovList)==0:
223 raise Exception( "IOV for tag %s IOV [%s,%s] - (%s,%s) not found" % (self.__tag,since[0],since[1],until[0],until[1]) )
224 return iovList
225

◆ getPayload()

python.TileCalibCrest.TileBlobReaderCrest.getPayload ( self,
runlumi = None,
dbg = False )

Definition at line 420 of file TileCalibCrest.py.

420 def getPayload(self, runlumi=None, dbg=False):
421
422 if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
423 self.__getIov(runlumi,dbg)
424
425 return self.payload
426

◆ getPayloadByHash()

python.TileCalibCrest.TileBlobReaderCrest.getPayloadByHash ( self,
hash )

Definition at line 246 of file TileCalibCrest.py.

246 def getPayloadByHash(self,hash):
247 if self.__tag_instance is None:
248 pass
249 else:
250 if isinstance(hash,int) and hash>=0 and hash<len(self.__payload_hash):
251 hash = self.__payload_hash[hash]
252 try:
253 payload = self.__tag_instance.get_payload(hash)
254 except Exception:
255 raise Exception( "Payload for hash %s not found" % hash )
256 jdata = json.loads(payload.to_json())
257 if self.__copyBlob:
258 self.payload = jdata
259 return
260 for chan in range(self.__modmin,self.__modmax):
261 try:
262 blob=jdata[str(chan)][0]
263 except Exception:
264 blob=None
265 self.__create_drawer(blob,chan)
266 try:
267 blob=jdata['1000'][0]
268 except Exception:
269 blob=None
270 self.__create_comment(blob)
271 return
272

◆ getPayloadHash()

python.TileCalibCrest.TileBlobReaderCrest.getPayloadHash ( self)

Definition at line 238 of file TileCalibCrest.py.

238 def getPayloadHash(self):
239 return self.__payload_hash
240

◆ getTag()

python.TileCalibCrest.TileBlobReaderCrest.getTag ( self)

Definition at line 136 of file TileCalibCrest.py.

136 def getTag(self):
137 return self.__tag
138

◆ readIov()

python.TileCalibCrest.TileBlobReaderCrest.readIov ( self,
runlumi = None,
dbg = False )

Definition at line 274 of file TileCalibCrest.py.

274 def readIov(self,runlumi=None,dbg=False):
275 if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
276 self.__getIov(runlumi,dbg)
277

Member Data Documentation

◆ __api_instance

python.TileCalibCrest.TileBlobReaderCrest.__api_instance = chai.Database(f"crest:{self.__db}")
private

Definition at line 96 of file TileCalibCrest.py.

◆ __comment

python.TileCalibCrest.TileBlobReaderCrest.__comment = None
private

Definition at line 86 of file TileCalibCrest.py.

◆ __commentBlob

int python.TileCalibCrest.TileBlobReaderCrest.__commentBlob = None
private

Definition at line 84 of file TileCalibCrest.py.

◆ __copyBlob

python.TileCalibCrest.TileBlobReaderCrest.__copyBlob = copyBlob
private

Definition at line 78 of file TileCalibCrest.py.

◆ __db

python.TileCalibCrest.TileBlobReaderCrest.__db = CREST_HOST
private

Definition at line 73 of file TileCalibCrest.py.

◆ __drawer

list python.TileCalibCrest.TileBlobReaderCrest.__drawer = [None]*276
private

Definition at line 87 of file TileCalibCrest.py.

◆ __drawerBlob

list python.TileCalibCrest.TileBlobReaderCrest.__drawerBlob = [None]*276
private

Definition at line 85 of file TileCalibCrest.py.

◆ __folder

python.TileCalibCrest.TileBlobReaderCrest.__folder = folder
private

Definition at line 76 of file TileCalibCrest.py.

◆ __insertion_time

list python.TileCalibCrest.TileBlobReaderCrest.__insertion_time = []
private

Definition at line 83 of file TileCalibCrest.py.

◆ __iov

tuple python.TileCalibCrest.TileBlobReaderCrest.__iov = (-1,0)
private

Definition at line 81 of file TileCalibCrest.py.

◆ __iovList

list python.TileCalibCrest.TileBlobReaderCrest.__iovList = []
private

Definition at line 80 of file TileCalibCrest.py.

◆ __modmax

python.TileCalibCrest.TileBlobReaderCrest.__modmax = modmax+1
private

Definition at line 89 of file TileCalibCrest.py.

◆ __modmin

python.TileCalibCrest.TileBlobReaderCrest.__modmin = modmin
private

Definition at line 88 of file TileCalibCrest.py.

◆ __payload_hash

python.TileCalibCrest.TileBlobReaderCrest.__payload_hash = []
private

Definition at line 82 of file TileCalibCrest.py.

◆ __remote

python.TileCalibCrest.TileBlobReaderCrest.__remote = not self.__db.endswith(".json")
private

Definition at line 92 of file TileCalibCrest.py.

◆ __tag

python.TileCalibCrest.TileBlobReaderCrest.__tag = tag
private

Definition at line 77 of file TileCalibCrest.py.

◆ __tag_instance

python.TileCalibCrest.TileBlobReaderCrest.__tag_instance = self.__api_instance.get_tag(self.__tag)
private

Definition at line 102 of file TileCalibCrest.py.

◆ payload

dict python.TileCalibCrest.TileBlobReaderCrest.payload = {}

Definition at line 71 of file TileCalibCrest.py.


The documentation for this class was generated from the following file: