ATLAS Offline Software
TileCalibCrest.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 # TileCalibCrest.py
5 # Sanya Solodkov <Sanya.Solodkov@cern.ch>, 2025-02-04
6 # Laura Sargsyan <Laura.Sargsyan@cern.ch>, 2025-09-16
7 # Siarhei Harkusha <Siarhei.Harkusha@cern.ch>, 2025-05-19
8 
9 """
10 Python helper module for managing CREST DB connections and TileCalibBlobs.
11 """
12 
13 import os, re, cppyy, base64, json, time, datetime
14 
15 from PyCool import cool # noqa: F401
16 Blob = cppyy.gbl.coral.Blob
17 
18 from pycrest.api.crest_api import CrestApi
19 
20 from TileCalibBlobObjs.Classes import TileCalibUtils, TileCalibDrawerCmt, \
21  TileCalibDrawerInt, TileCalibDrawerOfc, TileCalibDrawerBch, \
22  TileCalibDrawerFlt, TileCalibType
23 from TileCalibBlobPython import TileCalibTools
24 
25 #=== get a logger
26 from TileCalibBlobPython.TileCalibLogger import TileCalibLogger, getLogger
27 log = getLogger("TileCalibCrest")
28 
29 
30 #======================================================================
31 #===
32 #=== Global helper functions
33 #===
34 #======================================================================
35 
36 #
37 #______________________________________________________________________
38 #=== useful constants
39 MINRUN = 0
40 MINLBK = 0
41 MAXRUN = (1<<31)-1
42 MAXLBK = (1<<32)-1
43 MAXRUNLUMI = (MAXRUN<<32)+MAXLBK
44 # empty Tile channel for storing laser partition variation. DO NOT CHANGE.
45 LASPARTCHAN = 43
46 
47 
48 class TileBlobReaderCrest(TileCalibLogger):
49  """
50  TileCalibBlobReader is a helper class, managing the details of CREST interactions for
51  the user of TileCalibBlobs.
52  """
53 
54  #____________________________________________________________________
55  def __init__(self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False):
56  """
57  Input:
58  - db : server connection string or file name
59  - folder: full folder path
60  - tag : The folder tag, e.g. \"UPD4-24\" or full tag
61  - run : Run number (if known)
62  - lumi : Lumi block number
63  - modmin: Minimal module (COOL channel number)
64  - modmax: Maximal module (COOL channel number)
65  - copyBlob: save payload from CREST (Default:False, True to copy payload to json file)
66  """
67  #=== initialize base class
68  TileCalibLogger.__init__(self,"TileBlobReader")
69  self.payload = {}
70  self.__db = db
71  self.__folder = folder
72  self.__tag = tag
73  self.__copyBlob = copyBlob
74 
75  self.__iovList = []
76  self.__iov = (-1,0)
77  self.__commentBlob = None
78  self.__drawerBlob = [None]*276
79  self.__comment = None
80  self.__drawer = [None]*276
81  self.__modmin = modmin
82  self.__modmax = modmax+1
83 
84  #=== try to open db
85  self.__remote = (("http://" in db) or ("https://" in db) or ("CREST" in db))
86  if self.__remote:
87  if 'http' not in self.__db:
88  self.__db = os.getenv(db,os.getenv('CREST_HOST',os.getenv('CREST_SERVER_PATH','http://crest-j23.cern.ch:8080/api-v5.0')))
89  self.log().info('Host %s' , (self.__db))
90  self.__api_instance = CrestApi(host=self.__db)
91  socks = os.getenv('CREST_SOCKS', 'False')
92  if socks == 'True': self.__api_instance.socks()
93  self.__tag = self.getFolderTag(folder,None,tag)
94  if run is not None and lumi is not None:
95  log.info("Initializing for run %d, lumiblock %d", run,lumi)
96  self.__getIov((run,lumi),True)
97  else:
98  self.log().info('File %s' , (self.__db))
99  self.__api_instance = None
100  self.__tag = 'unknown'
101  self.__iovList.append(((MINRUN,MINLBK),(MAXRUN, MAXLBK)))
102  self.__iov = self.__runlumi2iov(self.__iovList[-1])
103  with open(self.__db, 'r') as the_file:
104  jdata = json.load(the_file)
105  for chan in range(self.__modmin,self.__modmax):
106  try:
107  blob=jdata[str(chan)][0]
108  except Exception:
109  blob=None
110  self.__create_drawer(blob,chan)
111  try:
112  blob=jdata['1000'][0]
113  except Exception:
114  blob=None
115  self.__create_comment(blob)
116 
117  #____________________________________________________________________
118  def getTag(self):
119  return self.__tag
120 
121  #____________________________________________________________________
122  def getFolderTag(self, folder, prefix, globalTag, api=None):
123  if globalTag=='CURRENT' or globalTag=='UPD4' or globalTag=='' or globalTag=='HEAD':
124  globalTag=TileCalibTools.getAliasFromFile('Current')
125  log.info("Resolved CURRENT globalTag to \'%s\'", globalTag)
126  elif globalTag=='CURRENTES' or globalTag=='UPD1':
127  globalTag=TileCalibTools.getAliasFromFile('CurrentES')
128  log.info("Resolved CURRENT ES globalTag to \'%s\'", globalTag)
129  elif globalTag=='NEXT':
130  globalTag=TileCalibTools.getAliasFromFile('Next')
131  log.info("Resolved NEXT globalTag to \'%s\'", globalTag)
132  elif globalTag=='NEXTES':
133  globalTag=TileCalibTools.getAliasFromFile('NextES')
134  log.info("Resolved NEXT ES globalTag to \'%s\'", globalTag)
135  globalTag=globalTag.replace('*','')
136  if prefix is None:
137  prefix = ''
138  for f in folder.split('/'):
139  if re.findall('[a-z]+',f) != [] and f!='CellNoise':
140  prefix+=f
141  else:
142  prefix+=f.capitalize()
143  else:
144  prefix=prefix.strip('-').split('-')[0]
145  if prefix.startswith('Calo') and 'NoiseCell' not in prefix:
146  prefix='CALO'+prefix[4:]
147  if 'UPD1' in globalTag or 'UPD4' in globalTag or 'COND' not in globalTag:
148  if prefix != '':
149  if globalTag.startswith(prefix) or globalTag.startswith(prefix.upper()):
150  tag=globalTag
151  else:
152  tag=prefix+'-'+globalTag
153  self.log().info("Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
154  elif folder!='' and not (globalTag.upper().startswith('TILE') or globalTag.upper().startswith('CALO')):
155  tag = TileCalibUtils.getFullTag(folder, globalTag)
156  if tag.startswith('Calo') and 'NoiseCell' not in tag:
157  tag='CALO'+tag[4:]
158  self.log().info("Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
159  else:
160  tag=globalTag
161  self.log().info("Use localTag \'%s\' as is", tag)
162  else:
163  tag=None
164  if api:
165  tags=api.find_global_tag_map(globalTag)
166  else:
167  tags=self.__api_instance.find_global_tag_map(globalTag)
168  if tags.size==0:
169  raise Exception( "globalTag %s not found" % (globalTag) )
170  else:
171  for i in range(tags.size):
172  t=tags.resources[i].tag_name
173  l=tags.resources[i].label
174  if (prefix!='' and t.startswith(prefix)) or l==folder:
175  tag=t
176  self.log().info("Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
177  #taginfo = self.__api_instance.find_tag(name=tag)
178  #print(taginfo)
179  return tag
180 
181  #____________________________________________________________________
182  def getIovs(self,since=(MINRUN,MINLBK),until=(MAXRUN,MAXLBK)):
183  if self.__api_instance is None:
184  return [self.__iovList[0][0]]
185  else:
186  run_lumi1=str((since[0]<<32)+since[1]+1)
187  run_lumi2=str((until[0]<<32)+until[1]+1)
188  MAXRUNLUMI1=str(MAXRUNLUMI+1)
189  iovs1=self.__api_instance.select_iovs(self.__tag,"0",run_lumi1,sort='id.since:DESC,id.insertionTime:DESC',size=1,snapshot=0)
190  iovs2=self.__api_instance.select_iovs(self.__tag,run_lumi2,MAXRUNLUMI1,sort='id.since:ASC,id.insertionTime:DESC',size=1,snapshot=0)
191  since1=0 if iovs1.size==0 else iovs1.resources[0].since
192  until1=MAXRUNLUMI if iovs2.size==0 else iovs2.resources[0].since
193  iovs=self.__api_instance.select_iovs(self.__tag,str(since1),str(until1),sort='id.since:ASC,id.insertionTime:DESC',size=999999,snapshot=0)
194  iovList=[]
195  if iovs.size==0:
196  raise Exception( "IOV for tag %s IOV [%s,%s] - (%s,%s) not found" % (self.__tag,since[0],since[1],until[0],until[1]) )
197  else:
198  for i in range(iovs.size):
199  iov=iovs.resources[i]
200  since=int(iov.since)
201  runS=since>>32
202  lumiS=since&0xFFFFFFFF
203  iovList.append((runS,lumiS))
204  return iovList
205 
206  #____________________________________________________________________
207  def getIov(self, option=0):
208  if option!=0:
209  return self.__iov
210  else:
211  return self.__iovList[-1]
212 
213  #____________________________________________________________________
214  def __getIov(self,runlumi,dbg=False):
215  if self.__api_instance is None:
216  pass
217  else:
218  run_lumi1=str((runlumi[0]<<32)+runlumi[1]+1)
219  MAXRUNLUMI1=str(MAXRUNLUMI+1)
220  iovs1=self.__api_instance.select_iovs(self.__tag,"0",run_lumi1,sort='id.since:DESC,id.insertionTime:DESC',size=1,snapshot=0)
221  iovs2=self.__api_instance.select_iovs(self.__tag,run_lumi1,MAXRUNLUMI1,sort='id.since:ASC,id.insertionTime:DESC',size=1,snapshot=0)
222  if iovs1.size==0:
223  raise Exception( "IOV for tag %s run,lumi (%s,%s) not found" % (self.__tag,runlumi[0],runlumi[1]) )
224  else:
225  iov=iovs1.resources[0]
226  since=int(iov.since)
227  runS=since>>32
228  lumiS=since&0xFFFFFFFF
229  until=MAXRUNLUMI if iovs2.size==0 else iovs2.resources[0].since
230  runU=until>>32
231  lumiU=until&0xFFFFFFFF
232  hash=iov.payload_hash
233  if dbg:
234  #self.log().info('Run,Lumi (%d,%d)' , runlumi)
235  self.log().info('IOV [%d,%d] - (%d,%d)' , runS,lumiS,runU,lumiU)
236  self.log().info('Insertion time %s' , iov.insertion_time)
237  self.log().info('Hash %s' , hash)
238  payload = self.__api_instance.get_payload(hash=hash).decode('utf-8')
239  jdata=json.loads(payload)
240  #with open("payload.json", 'w') as the_file:
241  # the_file.write(payload)
242  # the_file.write('\n')
243  if self.__copyBlob:
244  self.payload = jdata
245  return
246  self.__iovList.append(((runS,lumiS),(runU, lumiU)))
247  self.__iov = self.__runlumi2iov(self.__iovList[-1])
248  for chan in range(self.__modmin,self.__modmax):
249  try:
250  blob=jdata[str(chan)][0]
251  except Exception:
252  blob=None
253  self.__create_drawer(blob,chan)
254  try:
255  blob=jdata['1000'][0]
256  except Exception:
257  blob=None
258  self.__create_comment(blob)
259  return
260 
261  #____________________________________________________________________
262  def __runlumi2iov(self,runlumi):
263  since = (runlumi[0][0]<<32) + runlumi[0][1]
264  until = (runlumi[1][0]<<32) + runlumi[1][1]
265  return (since,until)
266 
267  #____________________________________________________________________
268  def __checkIov(self,runlumi):
269  point = (runlumi[0]<<32) + runlumi[1]
270  inrange = point>=self.__iov[0] and point<self.__iov[1]
271  return inrange
272 
273  #____________________________________________________________________
274  def __make_blob(self,string):
275  b = Blob()
276  b.write(string)
277  b.seek(0)
278  return b
279 
280  #____________________________________________________________________
281  def __create_comment(self,b64string):
282  if b64string is None or len(b64string)==0:
283  if b64string is None:
284  self.__commentBlob = None
285  else:
286  self.__commentBlob = 0
287  self.__comment = None
288  else:
289  blob1 = base64.decodebytes(bytes(b64string,'ascii'))
290  self.__commentBlob = self.__make_blob(blob1)
292  return
293 
294  #____________________________________________________________________
295  def __create_drawer(self,b64string,chan):
296  if b64string is None or isinstance(b64string, (int, float)) or len(b64string)==0:
297  if b64string is None:
298  self.__drawerBlob[chan] = None
299  else:
300  self.__drawerBlob[chan] = 0
301  self.__drawer[chan] = None
302  return
303  blob1 = base64.decodebytes(bytes(b64string,'ascii'))
304  self.__drawerBlob[chan] = self.__make_blob(blob1)
306  typeName = TileCalibType.getClassName(cmt.getObjType())
307  del cmt
308  #=== create calibDrawer depending on type
309  if typeName=='TileCalibDrawerFlt':
310  self.__drawer[chan] = TileCalibDrawerFlt.getInstance(self.__drawerBlob[chan])
311  self.log().debug( "typeName = Flt " )
312  elif typeName=='TileCalibDrawerInt':
313  self.__drawer[chan] = TileCalibDrawerInt.getInstance(self.__drawerBlob[chan])
314  self.log().debug( "typeName = Int " )
315  elif typeName=='TileCalibDrawerBch':
316  self.__drawer[chan] = TileCalibDrawerBch.getInstance(self.__drawerBlob[chan])
317  self.log().debug( "typeName = Bch " )
318  elif typeName=='TileCalibDrawerOfc':
319  self.__drawer[chan] = TileCalibDrawerOfc.getInstance(self.__drawerBlob[chan])
320  self.log().debug( "typeName = Ofc " )
321  elif typeName=='TileCalibDrawerCmt':
322  self.__drawer[chan] = cppyy.gbl.CaloCondBlobFlt.getInstance(self.__drawerBlob[chan])
323  self.log().debug( "typeName = CaloFlt " )
324  else:
325  self.__drawer[chan] = None
326  self.log().warn("Unknown blob type for chan %d - ignoring", chan)
327  return
328 
329  #____________________________________________________________________
330  def getBlob(self,ros, mod, runlumi=None, dbg=False):
331 
332  if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
333  self.__getIov(runlumi,dbg)
334 
335  if ros<0:
336  chanNum = mod
337  else:
338  chanNum = TileCalibUtils.getDrawerIdx(ros,mod)
339 
340  if (chanNum>=0 and chanNum<len(self.__drawer)):
341  return self.__drawerBlob[chanNum]
342  else:
343  raise Exception( "Invalid drawer requested: %s %s" % (ros,mod) )
344 
345  #____________________________________________________________________
346  def getDrawer(self,ros, mod, runlumi=None, dbg=False, useDefault=True):
347 
348  if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
349  self.__getIov(runlumi,dbg)
350 
351  if ros<0:
352  chanNum = mod
353  else:
354  chanNum = TileCalibUtils.getDrawerIdx(ros,mod)
355 
356  if (chanNum>=0 and chanNum<len(self.__drawer)):
357  drawer=self.__drawer[chanNum]
358  if not useDefault and drawer is None:
359  if self.__drawerBlob[chanNum] is None:
360  return None
361  else:
362  return 0
363  while drawer is None:
364  #=== no default at all?
365  if ros==0 and drawer==0:
366  raise Exception('No default available')
367  #=== follow default policy
368  ros,mod = self.getDefault(ros,mod)
369  chanNum = TileCalibUtils.getDrawerIdx(ros,mod)
370  drawer=self.__drawer[chanNum]
371  return drawer
372  elif (chanNum == 1000):
373  return self.__comment
374  else:
375  raise Exception( "Invalid drawer requested: %s %s" % (ros,mod) )
376 
377  #____________________________________________________________________
378  def getComment(self,runlumi=None,split=False):
379 
380  if self.__remote and runlumi is not None and not self.__checkIov(runlumi):
381  self.__getIov(runlumi)
382  if self.__comment is not None:
383  if split:
384  return (self.__comment.getAuthor(),self.__comment.getComment(),self.__comment.getDate())
385  else:
386  return self.__comment.getFullComment()
387  else:
388  return "<no comment found>"
389 
390  #____________________________________________________________________
391  def getDefault(self, ros, drawer):
392  """
393  Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
394  """
395  if ros==0:
396  if drawer<=4 or drawer==12 or drawer>=20:
397  drawer1=0
398  elif drawer<12:
399  drawer1=4
400  else:
401  drawer1=12
402  elif ros==1 or ros==2:
403  drawer1=4
404  elif ros==3:
405  OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E+1: EBA07; Outer MBTS: EBA08
406  0, 0, 0, 0, 7, 6, 5, 7, #// D+4: EBA13, EBA16; Special D+4: EBA14; Special D+40: EBA15
407  7, 6, 6, 7, 0, 0, 0, 2, #// D+4: EBA17, EBA20; Special D+4: EBA18, EBA19; Outer MBTS: EBA24
408  3, 0, 0, 0, 0, 0, 0, 0, #// Merged E+1: EBA25
409  0, 0, 0, 0, 0, 0, 1, 1, #// Inner MBTS + special C+10: EBA39, EBA40
410  1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C+10: EBA41, EBA42; Outer MBTS: EBA43; Merged E+1: EBA44
411  0, 0, 0, 0, 3, 2, 1, 1, #// Merged E+1: EBA53; Outer MBTS: EBA54; Inner MBTS + special C+10: EBA55, EBA56
412  1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C+10: EBA57, EBA58
413  drawer1 = 12 + OffsetEBA[drawer]
414  elif ros==4:
415  OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E-1: EBC07; Outer MBTS: EBC08
416  0, 0, 0, 0, 7, 6, 6, 7, # // D-4: EBC13, EBC16; Special D-4: EBC14, EBC15;
417  7, 5, 6, 7, 0, 0, 0, 2, #// D-4: EBC17, EBC20; Special D-40 EBC18; Special D-4: EBC19; Outer MBTS: EBC24
418  3, 0, 0, 3, 4, 0, 3, 4, #// Merged E-1: EBC25, EBC28, EBC31; E-4': EBC29, EBC32
419  0, 4, 3, 0, 4, 3, 1, 1, #// E-4': EBC34, EBC37; Merged E-1: EBC35, EBC38; Inner MBTS + special C-10: EBC39, EBC40
420  1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C-10: EBC41, EBC42; Outer MBTS: EBC43; Merged E-1: EBC44
421  0, 0, 0, 0, 3, 2, 1, 1, #// Merged E-1: EBC53; Outer MBTS: EBC54; Inner MBTS + special C-10: EBC55, EBC56
422  1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C-10: EBC57, EBC58
423  drawer1 = 12 + OffsetEBC[drawer]
424  else:
425  drawer1=0
426 
427  return (0,drawer1)
428 
429 class TileBlobWriterCrest(TileCalibLogger):
430  """
431  TileBlobWriterCrest is a helper class, managing the details of
432  CREST interactions for the user of TileCalibBlobs.
433  """
434 
435  #____________________________________________________________________
436  def __init__(self, db, folderPath, calibDrawerType, isMultiVersionFolder=True):
437  """
438  Input:
439  - db : db should be a database connection
440  - folderPath: full folder path to create or update
441  """
442 
443  #=== initialize base class
444  TileCalibLogger.__init__(self, "TileBlobWriter")
445 
446  #=== store db
447  self.__db = db
448  self.__folderPath = folderPath
449 
450  #=== create default vectors based on calibDrawerType
451  self.__calibDrawerType = calibDrawerType
452  if calibDrawerType in ['TileCalibDrawerFlt', 'Flt']:
453  self.__TileCalibDrawer = TileCalibDrawerFlt
454  self.__defVec = cppyy.gbl.std.vector('std::vector<float>')()
455  elif calibDrawerType in ['TileCalibDrawerBch', 'Bch']:
456  self.__TileCalibDrawer = TileCalibDrawerBch
457  self.__defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
458  elif calibDrawerType in ['TileCalibDrawerInt', 'Int']:
459  self.__TileCalibDrawer = TileCalibDrawerInt
460  self.__defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
461  else:
462  raise Exception("Unknown calibDrawerType: %s" % calibDrawerType)
463 
464  # Always all drawers should be written
465  self.__drawerBlob = {drawerIdx:Blob() for drawerIdx in range(0, TileCalibUtils.max_draweridx())}
466  self.__drawer = {}
467  #____________________________________________________________________
468  def register(self, since=(MINRUN,MINLBK), tag=""):
469  """
470  Registers the folder in the database.
471  - since: lower limit of IOV
472  - tag : The tag to write to
473 
474  The interpretation of the 'since' inputs depends on their type:
475  - tuple(int,int) : run and lbk number
476  """
477 
478  jdata = {}
479  for drawerIdx,blob in self.__drawerBlob.items():
480  if blob is None or blob==0:
481  b64string = ''
482  else:
483  b64string = str(base64.b64encode(blob.read()), 'ascii')
484  jdata[drawerIdx] = [b64string]
485 
486  (sinceRun, sinceLumi) = since
487 
488  if not self.__db or (self.__db and self.__db.endswith('.json')):
489  # Writting into the json file
490  fullTag = tag
491  if self.__folderPath and not (tag.upper().startswith('TILE') or tag.upper().startswith('CALO')):
492  fullTag = TileCalibUtils.getFullTag(self.__folderPath, tag)
493  fileName = f"{fullTag}.{sinceRun}.{sinceLumi}.json"
494  if self.__db:
495  fileName = f'{self.__db[:-5]}.{fileName}'
496 
497  with open(fileName, 'w') as the_file:
498  json.dump(jdata, the_file)
499  the_file.write('\n')
500 
501  #=== print info
502  self.log().info( 'Writting tag "%s"', fullTag)
503  self.log().info( '... since : [%s,%s]' , sinceRun, sinceLumi)
504  self.log().info( '... with comment field: "%s"', self.getComment())
505  self.log().info( '... into file : %s' , fileName)
506 
507  #____________________________________________________________________
508  def setComment(self, author, comment=None):
509  """
510  Sets a general comment in the comment channel.
511  """
513  commentBlob = self.__drawer.get(drawerIdx, None)
514  if not commentBlob:
515  commentBlob = Blob()
516  self.__drawerBlob[drawerIdx] = commentBlob
517 
518  if isinstance(author, tuple) and len(author) == 3:
519  tm = time.mktime(datetime.datetime.strptime(author[2], "%a %b %d %H:%M:%S %Y").timetuple())
520  self.__drawer[drawerIdx] = TileCalibDrawerCmt.getInstance(commentBlob, author[0], author[1], int(tm))
521  else:
522  self.__drawer[drawerIdx] = TileCalibDrawerCmt.getInstance(commentBlob, author, comment)
523 
524  #____________________________________________________________________
525  def getComment(self, split=False):
526  """
527  Returns the general comment (default if none is set)
528  """
530  comment = self.__drawer.get(drawerIdx, None)
531  if comment:
532  if split:
533  return (comment.getAuthor(), self.__comment.getComment(), self.__comment.getDate())
534  else:
535  return comment.getFullComment()
536  else:
537  return "<No general comment!>"
538 
539  #____________________________________________________________________
540  def getDrawer(self, ros, drawer, calibDrawerTemplate=None):
541  """
542  Returns a TileCalibDrawer object of requested type
543  for the given ROS and drawer.
544  """
545 
546  try:
547  drawerIdx = TileCalibUtils.getDrawerIdx(ros, drawer)
548  calibDrawer = self.__drawer.get(drawerIdx, None)
549 
550  if not calibDrawer:
551  calibDrawer = self.__TileCalibDrawer.getInstance(self.__drawerBlob[drawerIdx], self.__defVec,0,0)
552  self.__drawer[drawerIdx] = calibDrawer
553 
554  #=== clone if requested
555  if calibDrawerTemplate:
556  calibDrawer.clone(calibDrawerTemplate)
557 
558  return calibDrawer
559 
560  except Exception as e:
561  self.log().critical( e )
562  return None
563 
564  #____________________________________________________________________
565  def zeroBlob(self, ros, drawer):
566  """
567  Resets blob size to zero
568  """
569  try:
570  drawerIdx = TileCalibUtils.getDrawerIdx(ros, drawer)
571  blob = self.__drawerBlob[drawerIdx]
572  blob.resize(0)
573  except Exception as e:
574  self.log().critical( e )
575  return None
python.TileCalibCrest.TileBlobReaderCrest.getIovs
def getIovs(self, since=(MINRUN, MINLBK), until=(MAXRUN, MAXLBK))
Definition: TileCalibCrest.py:182
AtlasMcWeight::decode
double decode(number_type binnedWeight)
Convert weight from unsigned to double.
Definition: AtlasMcWeight.cxx:32
python.TileCalibCrest.TileBlobReaderCrest.__checkIov
def __checkIov(self, runlumi)
Definition: TileCalibCrest.py:268
python.TileCalibCrest.TileBlobWriterCrest.register
def register(self, since=(MINRUN, MINLBK), tag="")
Definition: TileCalibCrest.py:468
IDTPM::getAuthor
std::vector< unsigned int > getAuthor(const xAOD::TrackParticle &p)
Accessor utility function for getting the track author.
Definition: TrackParametersHelper.h:137
ReadBchFromCrest.warn
warn
Definition: ReadBchFromCrest.py:66
TileCalibDrawerBch::getInstance
static const TileCalibDrawerBch * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
Definition: TileCalibDrawerBch.cxx:28
python.TileCalibCrest.TileBlobWriterCrest.setComment
def setComment(self, author, comment=None)
Definition: TileCalibCrest.py:508
python.TileCalibCrest.TileBlobWriterCrest.__defVec
__defVec
Definition: TileCalibCrest.py:454
python.TileCalibCrest.TileBlobReaderCrest.getFolderTag
def getFolderTag(self, folder, prefix, globalTag, api=None)
Definition: TileCalibCrest.py:122
python.TileCalibCrest.TileBlobReaderCrest.getDefault
def getDefault(self, ros, drawer)
Definition: TileCalibCrest.py:391
python.TileCalibCrest.TileBlobWriterCrest.__TileCalibDrawer
__TileCalibDrawer
Definition: TileCalibCrest.py:453
TileCalibType::getClassName
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.
Definition: TileCalibType.cxx:10
python.TileCalibCrest.TileBlobReaderCrest.getIov
def getIov(self, option=0)
Definition: TileCalibCrest.py:207
python.TileCalibCrest.TileBlobWriterCrest.__drawerBlob
__drawerBlob
Definition: TileCalibCrest.py:465
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.TileCalibCrest.TileBlobWriterCrest.getDrawer
def getDrawer(self, ros, drawer, calibDrawerTemplate=None)
Definition: TileCalibCrest.py:540
python.TileCalibCrest.TileBlobWriterCrest.__init__
def __init__(self, db, folderPath, calibDrawerType, isMultiVersionFolder=True)
Definition: TileCalibCrest.py:436
python.TileCalibCrest.TileBlobReaderCrest.payload
payload
Definition: TileCalibCrest.py:69
python.TileCalibCrest.TileBlobReaderCrest.__iovList
__iovList
Definition: TileCalibCrest.py:75
python.TileCalibCrest.TileBlobReaderCrest.__db
__db
Definition: TileCalibCrest.py:70
python.TileCalibCrest.TileBlobReaderCrest.__tag
__tag
Definition: TileCalibCrest.py:72
python.TileCalibCrest.TileBlobReaderCrest.__copyBlob
__copyBlob
Definition: TileCalibCrest.py:73
python.TileCalibCrest.TileBlobWriterCrest.__drawer
__drawer
Definition: TileCalibCrest.py:466
python.TileCalibCrest.TileBlobWriterCrest.getComment
def getComment(self, split=False)
Definition: TileCalibCrest.py:525
TileCalibDrawerInt::getInstance
static const TileCalibDrawerInt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
Definition: TileCalibDrawerInt.cxx:27
TileCalibDrawerFlt::getInstance
static const TileCalibDrawerFlt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerFlt.
Definition: TileCalibDrawerFlt.cxx:13
python.TileCalibCrest.TileBlobReaderCrest.getBlob
def getBlob(self, ros, mod, runlumi=None, dbg=False)
Definition: TileCalibCrest.py:330
python.TileCalibCrest.TileBlobReaderCrest.__comment
__comment
Definition: TileCalibCrest.py:79
python.TileCalibCrest.TileBlobReaderCrest.__drawerBlob
__drawerBlob
Definition: TileCalibCrest.py:78
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.TileCalibCrest.TileBlobReaderCrest.__modmin
__modmin
Definition: TileCalibCrest.py:81
python.TileCalibCrest.TileBlobReaderCrest.__create_comment
def __create_comment(self, b64string)
Definition: TileCalibCrest.py:281
python.TileCalibCrest.TileBlobReaderCrest.__drawer
__drawer
Definition: TileCalibCrest.py:80
python.TileCalibCrest.TileBlobWriterCrest.__calibDrawerType
__calibDrawerType
Definition: TileCalibCrest.py:451
python.TileCalibCrest.TileBlobWriterCrest.zeroBlob
def zeroBlob(self, ros, drawer)
Definition: TileCalibCrest.py:565
python.TileCalibCrest.TileBlobReaderCrest.__init__
def __init__(self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False)
Definition: TileCalibCrest.py:55
python.TileCalibCrest.TileBlobReaderCrest.__modmax
__modmax
Definition: TileCalibCrest.py:82
python.TileCalibCrest.TileBlobReaderCrest.__getIov
def __getIov(self, runlumi, dbg=False)
Definition: TileCalibCrest.py:214
TileCalibUtils::getCommentChannel
static unsigned int getCommentChannel()
Returns the COOL channel number for the comment channel.
Definition: TileCalibUtils.h:82
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
TileCalibUtils::max_draweridx
static unsigned int max_draweridx()
Python compatibility function.
Definition: TileCalibUtils.h:116
python.TileCalibCrest.TileBlobReaderCrest.__iov
__iov
Definition: TileCalibCrest.py:76
python.TileCalibCrest.TileBlobReaderCrest.getTag
def getTag(self)
Definition: TileCalibCrest.py:118
python.TileCalibCrest.TileBlobReaderCrest.__commentBlob
__commentBlob
Definition: TileCalibCrest.py:77
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.TileCalibCrest.TileBlobReaderCrest.__api_instance
__api_instance
Definition: TileCalibCrest.py:90
python.TileCalibCrest.TileBlobReaderCrest.__runlumi2iov
def __runlumi2iov(self, runlumi)
Definition: TileCalibCrest.py:262
Trk::open
@ open
Definition: BinningType.h:40
python.TileCalibCrest.TileBlobReaderCrest.__remote
__remote
Definition: TileCalibCrest.py:85
python.TileCalibCrest.TileBlobWriterCrest.__folderPath
__folderPath
Definition: TileCalibCrest.py:448
python.TileCalibCrest.TileBlobReaderCrest.__make_blob
def __make_blob(self, string)
Definition: TileCalibCrest.py:274
TileCalibDrawerOfc::getInstance
static TileCalibDrawerOfc * getInstance(coral::Blob &blob, uint16_t objVersion, uint32_t nSamples, int32_t nPhases, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
Returns a pointer to a non-const TileCalibDrawerOfc.
Definition: TileCalibDrawerOfc.cxx:14
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.TileCalibCrest.TileBlobWriterCrest.__db
__db
Definition: TileCalibCrest.py:447
python.TileCalibCrest.TileBlobReaderCrest.getDrawer
def getDrawer(self, ros, mod, runlumi=None, dbg=False, useDefault=True)
Definition: TileCalibCrest.py:346
python.TileCalibCrest.TileBlobWriterCrest
Definition: TileCalibCrest.py:429
TileCalibDrawerCmt::getInstance
static const TileCalibDrawerCmt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerCmt.
Definition: TileCalibDrawerCmt.cxx:24
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:130
python.TileCalibCrest.TileBlobReaderCrest.__folder
__folder
Definition: TileCalibCrest.py:71
python.TileCalibCrest.Blob
Blob
Definition: TileCalibCrest.py:16
str
Definition: BTagTrackIpAccessor.cxx:11
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
python.TileCalibCrest.TileBlobReaderCrest.__create_drawer
def __create_drawer(self, b64string, chan)
Definition: TileCalibCrest.py:295
python.TileCalibCrest.TileBlobReaderCrest
Definition: TileCalibCrest.py:48
python.TileCalibCrest.TileBlobReaderCrest.getComment
def getComment(self, runlumi=None, split=False)
Definition: TileCalibCrest.py:378
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.CaloCondLogger.getLogger
def getLogger(name="CaloCond")
Definition: CaloCondLogger.py:16
TileCalibUtils::getFullTag
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.
Definition: TileCalibUtils.cxx:33