|
| def | __init__ (self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False) |
| |
| def | getTag (self) |
| |
| def | getFolderTag (self, folder, prefix, globalTag, api=None) |
| |
| def | getIovs (self, since=(MINRUN, MINLBK), until=(MAXRUN, MAXLBK)) |
| |
| def | getIov (self, option=0) |
| |
| def | getBlob (self, ros, mod, runlumi=None, dbg=False) |
| |
| def | getDrawer (self, ros, mod, runlumi=None, dbg=False, useDefault=True) |
| |
| def | getComment (self, runlumi=None, split=False) |
| |
| def | getDefault (self, ros, drawer) |
| |
TileCalibBlobReader is a helper class, managing the details of CREST interactions for
the user of TileCalibBlobs.
Definition at line 48 of file TileCalibCrest.py.
◆ __init__()
| def 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 55 of file TileCalibCrest.py.
55 def __init__(self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False):
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)
68 TileCalibLogger.__init__(self,
"TileBlobReader")
71 self.__folder = folder
73 self.__copyBlob = copyBlob
77 self.__commentBlob =
None
78 self.__drawerBlob = [
None]*276
80 self.__drawer = [
None]*276
81 self.__modmin = modmin
82 self.__modmax = modmax+1
85 self.__remote = ((
"http://" in db)
or (
"https://" in db)
or (
"CREST" in db))
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)
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):
107 blob=jdata[
str(chan)][0]
110 self.__create_drawer(blob,chan)
112 blob=jdata[
'1000'][0]
115 self.__create_comment(blob)
◆ __checkIov()
| def python.TileCalibCrest.TileBlobReaderCrest.__checkIov |
( |
|
self, |
|
|
|
runlumi |
|
) |
| |
|
private |
Definition at line 268 of file TileCalibCrest.py.
268 def __checkIov(self,runlumi):
269 point = (runlumi[0]<<32) + runlumi[1]
270 inrange = point>=self.__iov[0]
and point<self.__iov[1]
◆ __create_comment()
| def python.TileCalibCrest.TileBlobReaderCrest.__create_comment |
( |
|
self, |
|
|
|
b64string |
|
) |
| |
|
private |
Definition at line 281 of file TileCalibCrest.py.
281 def __create_comment(self,b64string):
282 if b64string
is None or len(b64string)==0:
283 if b64string
is None:
284 self.__commentBlob =
None
286 self.__commentBlob = 0
287 self.__comment =
None
289 blob1 = base64.decodebytes(bytes(b64string,
'ascii'))
290 self.__commentBlob = self.__make_blob(blob1)
◆ __create_drawer()
| def python.TileCalibCrest.TileBlobReaderCrest.__create_drawer |
( |
|
self, |
|
|
|
b64string, |
|
|
|
chan |
|
) |
| |
|
private |
Definition at line 295 of file TileCalibCrest.py.
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
300 self.__drawerBlob[chan] = 0
301 self.__drawer[chan] =
None
303 blob1 = base64.decodebytes(bytes(b64string,
'ascii'))
304 self.__drawerBlob[chan] = self.__make_blob(blob1)
309 if typeName==
'TileCalibDrawerFlt':
311 self.log().
debug(
"typeName = Flt " )
312 elif typeName==
'TileCalibDrawerInt':
314 self.log().
debug(
"typeName = Int " )
315 elif typeName==
'TileCalibDrawerBch':
317 self.log().
debug(
"typeName = Bch " )
318 elif typeName==
'TileCalibDrawerOfc':
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 " )
325 self.__drawer[chan] =
None
326 self.log().
warn(
"Unknown blob type for chan %d - ignoring", chan)
◆ __getIov()
| def python.TileCalibCrest.TileBlobReaderCrest.__getIov |
( |
|
self, |
|
|
|
runlumi, |
|
|
|
dbg = False |
|
) |
| |
|
private |
Definition at line 214 of file TileCalibCrest.py.
214 def __getIov(self,runlumi,dbg=False):
215 if self.__api_instance
is None:
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)
223 raise Exception(
"IOV for tag %s run,lumi (%s,%s) not found" % (self.__tag,runlumi[0],runlumi[1]) )
225 iov=iovs1.resources[0]
228 lumiS=since&0xFFFFFFFF
229 until=MAXRUNLUMI
if iovs2.size==0
else iovs2.resources[0].since
231 lumiU=until&0xFFFFFFFF
232 hash=iov.payload_hash
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)
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):
250 blob=jdata[
str(chan)][0]
253 self.__create_drawer(blob,chan)
255 blob=jdata[
'1000'][0]
258 self.__create_comment(blob)
◆ __make_blob()
| def python.TileCalibCrest.TileBlobReaderCrest.__make_blob |
( |
|
self, |
|
|
|
string |
|
) |
| |
|
private |
◆ __runlumi2iov()
| def python.TileCalibCrest.TileBlobReaderCrest.__runlumi2iov |
( |
|
self, |
|
|
|
runlumi |
|
) |
| |
|
private |
Definition at line 262 of file TileCalibCrest.py.
262 def __runlumi2iov(self,runlumi):
263 since = (runlumi[0][0]<<32) + runlumi[0][1]
264 until = (runlumi[1][0]<<32) + runlumi[1][1]
◆ getBlob()
| def python.TileCalibCrest.TileBlobReaderCrest.getBlob |
( |
|
self, |
|
|
|
ros, |
|
|
|
mod, |
|
|
|
runlumi = None, |
|
|
|
dbg = False |
|
) |
| |
Definition at line 330 of file TileCalibCrest.py.
330 def getBlob(self,ros, mod, runlumi=None, dbg=False):
332 if self.__remote
and runlumi
is not None and not self.__checkIov(runlumi):
333 self.__getIov(runlumi,dbg)
340 if (chanNum>=0
and chanNum<len(self.__drawer)):
341 return self.__drawerBlob[chanNum]
343 raise Exception(
"Invalid drawer requested: %s %s" % (ros,mod) )
◆ getComment()
| def python.TileCalibCrest.TileBlobReaderCrest.getComment |
( |
|
self, |
|
|
|
runlumi = None, |
|
|
|
split = False |
|
) |
| |
Definition at line 378 of file TileCalibCrest.py.
378 def getComment(self,runlumi=None,split=False):
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:
384 return (self.__comment.
getAuthor(),self.__comment.getComment(),self.__comment.getDate())
386 return self.__comment.getFullComment()
388 return "<no comment found>"
◆ getDefault()
| def 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 391 of file TileCalibCrest.py.
391 def getDefault(self, ros, drawer):
393 Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
396 if drawer<=4
or drawer==12
or drawer>=20:
402 elif ros==1
or ros==2:
405 OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2,
406 0, 0, 0, 0, 7, 6, 5, 7,
407 7, 6, 6, 7, 0, 0, 0, 2,
408 3, 0, 0, 0, 0, 0, 0, 0,
409 0, 0, 0, 0, 0, 0, 1, 1,
410 1, 1, 2, 3, 0, 0, 0, 0,
411 0, 0, 0, 0, 3, 2, 1, 1,
412 1, 1, 0, 0, 0, 0, 0, 0]
413 drawer1 = 12 + OffsetEBA[drawer]
415 OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2,
416 0, 0, 0, 0, 7, 6, 6, 7,
417 7, 5, 6, 7, 0, 0, 0, 2,
418 3, 0, 0, 3, 4, 0, 3, 4,
419 0, 4, 3, 0, 4, 3, 1, 1,
420 1, 1, 2, 3, 0, 0, 0, 0,
421 0, 0, 0, 0, 3, 2, 1, 1,
422 1, 1, 0, 0, 0, 0, 0, 0]
423 drawer1 = 12 + OffsetEBC[drawer]
◆ getDrawer()
| def python.TileCalibCrest.TileBlobReaderCrest.getDrawer |
( |
|
self, |
|
|
|
ros, |
|
|
|
mod, |
|
|
|
runlumi = None, |
|
|
|
dbg = False, |
|
|
|
useDefault = True |
|
) |
| |
Definition at line 346 of file TileCalibCrest.py.
346 def getDrawer(self,ros, mod, runlumi=None, dbg=False, useDefault=True):
348 if self.__remote
and runlumi
is not None and not self.__checkIov(runlumi):
349 self.__getIov(runlumi,dbg)
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:
363 while drawer
is None:
365 if ros==0
and drawer==0:
366 raise Exception(
'No default available')
368 ros,mod = self.getDefault(ros,mod)
370 drawer=self.__drawer[chanNum]
372 elif (chanNum == 1000):
373 return self.__comment
375 raise Exception(
"Invalid drawer requested: %s %s" % (ros,mod) )
◆ getFolderTag()
| def python.TileCalibCrest.TileBlobReaderCrest.getFolderTag |
( |
|
self, |
|
|
|
folder, |
|
|
|
prefix, |
|
|
|
globalTag, |
|
|
|
api = None |
|
) |
| |
Definition at line 122 of file TileCalibCrest.py.
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(
'*',
'')
138 for f
in folder.split(
'/'):
139 if re.findall(
'[a-z]+',f) != []
and f!=
'CellNoise':
142 prefix+=f.capitalize()
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:
149 if globalTag.startswith(prefix)
or globalTag.startswith(prefix.upper()):
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')):
156 if tag.startswith(
'Calo')
and 'NoiseCell' not in tag:
158 self.log().
info(
"Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
161 self.log().
info(
"Use localTag \'%s\' as is", tag)
165 tags=api.find_global_tag_map(globalTag)
167 tags=self.__api_instance.find_global_tag_map(globalTag)
169 raise Exception(
"globalTag %s not found" % (globalTag) )
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:
176 self.log().
info(
"Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
◆ getIov()
| def python.TileCalibCrest.TileBlobReaderCrest.getIov |
( |
|
self, |
|
|
|
option = 0 |
|
) |
| |
Definition at line 207 of file TileCalibCrest.py.
207 def getIov(self, option=0):
211 return self.__iovList[-1]
◆ getIovs()
Definition at line 182 of file TileCalibCrest.py.
182 def getIovs(self,since=(MINRUN,MINLBK),until=(MAXRUN,MAXLBK)):
183 if self.__api_instance
is None:
184 return [self.__iovList[0][0]]
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)
196 raise Exception(
"IOV for tag %s IOV [%s,%s] - (%s,%s) not found" % (self.__tag,since[0],since[1],until[0],until[1]) )
198 for i
in range(iovs.size):
199 iov=iovs.resources[i]
202 lumiS=since&0xFFFFFFFF
203 iovList.append((runS,lumiS))
◆ getTag()
| def python.TileCalibCrest.TileBlobReaderCrest.getTag |
( |
|
self | ) |
|
◆ __api_instance
| python.TileCalibCrest.TileBlobReaderCrest.__api_instance |
|
private |
◆ __comment
| python.TileCalibCrest.TileBlobReaderCrest.__comment |
|
private |
◆ __commentBlob
| python.TileCalibCrest.TileBlobReaderCrest.__commentBlob |
|
private |
◆ __copyBlob
| python.TileCalibCrest.TileBlobReaderCrest.__copyBlob |
|
private |
◆ __db
| python.TileCalibCrest.TileBlobReaderCrest.__db |
|
private |
◆ __drawer
| python.TileCalibCrest.TileBlobReaderCrest.__drawer |
|
private |
◆ __drawerBlob
| python.TileCalibCrest.TileBlobReaderCrest.__drawerBlob |
|
private |
◆ __folder
| python.TileCalibCrest.TileBlobReaderCrest.__folder |
|
private |
◆ __iov
| python.TileCalibCrest.TileBlobReaderCrest.__iov |
|
private |
◆ __iovList
| python.TileCalibCrest.TileBlobReaderCrest.__iovList |
|
private |
◆ __modmax
| python.TileCalibCrest.TileBlobReaderCrest.__modmax |
|
private |
◆ __modmin
| python.TileCalibCrest.TileBlobReaderCrest.__modmin |
|
private |
◆ __remote
| python.TileCalibCrest.TileBlobReaderCrest.__remote |
|
private |
◆ __tag
| python.TileCalibCrest.TileBlobReaderCrest.__tag |
|
private |
◆ payload
| python.TileCalibCrest.TileBlobReaderCrest.payload |
The documentation for this class was generated from the following file:
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.