|
def | __init__ (self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275) |
|
def | getFolderTag (self, folder, prefix, globalTag) |
|
def | getIovs (self, since, until) |
|
def | getDrawer (self, ros, mod, runlumi=None, dbg=False, useDefault=True) |
|
def | getComment (self, runlumi=None) |
|
def | getDefault (self, ros, drawer) |
|
TileCalibBlobReader is a helper class, managing the details of CREST interactions for
the user of TileCalibBlobs.
Definition at line 47 of file TileCalibCrest.py.
◆ __init__()
def python.TileCalibCrest.TileBlobReaderCrest.__init__ |
( |
|
self, |
|
|
|
db, |
|
|
|
folder = '' , |
|
|
|
tag = '' , |
|
|
|
run = None , |
|
|
|
lumi = 0 , |
|
|
|
modmin = 0 , |
|
|
|
modmax = 275 |
|
) |
| |
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)
Definition at line 54 of file TileCalibCrest.py.
54 def __init__(self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275):
57 - db : server connection string or file name
58 - folder: full folder path
59 - tag : The folder tag, e.g. \"UPD4-24\" or full tag
60 - run : Run number (if known)
61 - lumi : Lumi block number
62 - modmin: Minimal module (COOL channel number)
63 - modmax: Maximal module (COOL channel number)
66 TileCalibLogger.__init__(self,
"TileBlobReader")
69 self.__folder = folder
74 self.__commentBlob =
None
75 self.__drawerBlob = [
None]*276
77 self.__drawer = [
None]*276
78 self.__modmin = modmin
79 self.__modmax = modmax+1
82 self.__remote = ((
"http://" in db)
or (
"https://" in db)
or (
"CREST" in db))
84 if 'http' not in self.__db:
85 self.__db = os.getenv(db,os.getenv(
'CREST_HOST',os.getenv(
'CREST_SERVER_PATH',
'http://crest-j23.cern.ch:8080/api-v5.0')))
86 self.log().
info(
'Host %s' , (self.__db))
87 self.__api_instance = CrestApi(host=self.__db)
88 socks = os.getenv(
'CREST_SOCKS',
'False')
89 if socks ==
'True': self.__api_instance.socks()
90 self.__tag = self.getFolderTag(folder,
None,tag)
91 if run
is not None and lumi
is not None:
92 log.info(
"Initializing for run %d, lumiblock %d", run,lumi)
93 self.__getIov((run,lumi),
True)
95 self.log().
info(
'File %s' , (self.__db))
96 self.__iovList.
append(((MINRUN,MINLBK),(MAXRUN, MAXLBK)))
97 self.__iov = self.__runlumi2iov(self.__iovList[-1])
99 with open(self.__db,
'r')
as the_file:
100 jdata = json.load(the_file)
101 for chan
in range(self.__modmin,self.__modmax):
102 self.__create_drawer(jdata[
str(chan)][0],chan)
103 self.__create_comment(jdata[
'1000'][0])
104 except Exception
as e:
105 self.log().critical( e )
◆ __checkIov()
def python.TileCalibCrest.TileBlobReaderCrest.__checkIov |
( |
|
self, |
|
|
|
runlumi |
|
) |
| |
|
private |
Definition at line 232 of file TileCalibCrest.py.
232 def __checkIov(self,runlumi):
233 point = (runlumi[0]<<32) + runlumi[1]
234 inrange = point>=self.__iov[0]
and point<self.__iov[1]
◆ __create_comment()
def python.TileCalibCrest.TileBlobReaderCrest.__create_comment |
( |
|
self, |
|
|
|
b64string |
|
) |
| |
|
private |
Definition at line 245 of file TileCalibCrest.py.
245 def __create_comment(self,b64string):
246 if b64string
is None or len(b64string)==0:
247 self.__commentBlob =
None
248 self.__comment =
None
250 blob1 = base64.decodebytes(bytes(b64string,
'ascii'))
251 self.__commentBlob = self.__make_blob(blob1)
◆ __create_drawer()
def python.TileCalibCrest.TileBlobReaderCrest.__create_drawer |
( |
|
self, |
|
|
|
b64string, |
|
|
|
chan |
|
) |
| |
|
private |
Definition at line 256 of file TileCalibCrest.py.
256 def __create_drawer(self,b64string,chan):
257 if b64string
is None or len(b64string)==0:
258 self.__drawerBlob[chan] =
None
259 self.__drawer[chan] =
None
261 blob1 = base64.decodebytes(bytes(b64string,
'ascii'))
262 self.__drawerBlob[chan] = self.__make_blob(blob1)
267 if typeName==
'TileCalibDrawerFlt':
269 self.log().
debug(
"typeName = Flt " )
270 elif typeName==
'TileCalibDrawerInt':
272 self.log().
debug(
"typeName = Int " )
273 elif typeName==
'TileCalibDrawerBch':
275 self.log().
debug(
"typeName = Bch " )
276 elif typeName==
'TileCalibDrawerOfc':
278 self.log().
debug(
"typeName = Ofc " )
280 raise Exception(
"Invalid blob type requested: %s" % typeName )
◆ __getIov()
def python.TileCalibCrest.TileBlobReaderCrest.__getIov |
( |
|
self, |
|
|
|
runlumi, |
|
|
|
dbg = False |
|
) |
| |
|
private |
Definition at line 181 of file TileCalibCrest.py.
181 def __getIov(self,runlumi,dbg=False):
182 run_lumi1=
str((runlumi[0]<<32)+runlumi[1]+1)
183 MAXRUNLUMI1=
str(MAXRUNLUMI+1)
184 iovs1=self.__api_instance.select_iovs(self.__tag,
"0",run_lumi1,sort=
'id.since:DESC,id.insertionTime:DESC',size=1,snapshot=0)
185 iovs2=self.__api_instance.select_iovs(self.__tag,run_lumi1,MAXRUNLUMI1,sort=
'id.since:ASC,id.insertionTime:DESC',size=1,snapshot=0)
187 raise Exception(
"IOV for tag %s run,lumi (%s,%s) not found" % (self.__tag,runlumi[0],runlumi[1]) )
189 iov=iovs1[
'resources'][0]
192 lumiS=since&0xFFFFFFFF
193 until=MAXRUNLUMI
if iovs2[
'size']==0
else iovs2[
'resources'][0][
'since']
195 lumiU=until&0xFFFFFFFF
196 hash=iov[
'payload_hash']
199 self.log().
info(
'IOV [%d,%d] - (%d,%d)' , runS,lumiS,runU,lumiU)
200 self.log().
info(
'Insertion time %s' , iov[
'insertion_time'])
201 self.log().
info(
'Hash %s' , hash)
202 payload = self.__api_instance.get_payload(hash=hash).
decode(
'utf-8')
203 jdata=json.loads(payload)
210 self.__iovList.
append(((runS,lumiS),(runU, lumiU)))
211 self.__iov = self.__runlumi2iov(self.__iovList[-1])
212 for chan
in range(self.__modmin,self.__modmax):
214 blob=jdata[
str(chan)][0]
217 self.__create_drawer(blob,chan)
219 blob=jdata[
'1000'][0]
222 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 226 of file TileCalibCrest.py.
226 def __runlumi2iov(self,runlumi):
227 since = (runlumi[0][0]<<32) + runlumi[0][1]
228 until = (runlumi[1][0]<<32) + runlumi[1][1]
◆ getComment()
def python.TileCalibCrest.TileBlobReaderCrest.getComment |
( |
|
self, |
|
|
|
runlumi = None |
|
) |
| |
Definition at line 313 of file TileCalibCrest.py.
313 def getComment(self,runlumi=None):
315 if self.__remote
and runlumi
is not None and not self.__checkIov(runlumi):
316 self.__getIov(runlumi)
317 if self.__comment
is not None:
318 return self.__comment.getFullComment()
320 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 323 of file TileCalibCrest.py.
323 def getDefault(self, ros, drawer):
325 Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
328 if drawer<=4
or drawer==12
or drawer>=20:
334 elif ros==1
or ros==2:
337 OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2,
338 0, 0, 0, 0, 7, 6, 5, 7,
339 7, 6, 6, 7, 0, 0, 0, 2,
340 3, 0, 0, 0, 0, 0, 0, 0,
341 0, 0, 0, 0, 0, 0, 1, 1,
342 1, 1, 2, 3, 0, 0, 0, 0,
343 0, 0, 0, 0, 3, 2, 1, 1,
344 1, 1, 0, 0, 0, 0, 0, 0]
345 drawer1 = 12 + OffsetEBA[drawer]
347 OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2,
348 0, 0, 0, 0, 7, 6, 6, 7,
349 7, 5, 6, 7, 0, 0, 0, 2,
350 3, 0, 0, 3, 4, 0, 3, 4,
351 0, 4, 3, 0, 4, 3, 1, 1,
352 1, 1, 2, 3, 0, 0, 0, 0,
353 0, 0, 0, 0, 3, 2, 1, 1,
354 1, 1, 0, 0, 0, 0, 0, 0]
355 drawer1 = 12 + OffsetEBC[drawer]
◆ getDrawer()
def python.TileCalibCrest.TileBlobReaderCrest.getDrawer |
( |
|
self, |
|
|
|
ros, |
|
|
|
mod, |
|
|
|
runlumi = None , |
|
|
|
dbg = False , |
|
|
|
useDefault = True |
|
) |
| |
Definition at line 284 of file TileCalibCrest.py.
284 def getDrawer(self,ros, mod, runlumi=None, dbg=False, useDefault=True):
286 if self.__remote
and runlumi
is not None and not self.__checkIov(runlumi):
287 self.__getIov(runlumi,dbg)
294 if (chanNum>=0
and chanNum<len(self.__drawer)):
295 drawer=self.__drawer[chanNum]
296 if not useDefault
and drawer
is None:
298 while drawer
is None:
300 if ros==0
and drawer==0:
301 raise Exception(
'No default available')
303 ros,drawer = self.getDefault(ros,drawer)
305 drawer=self.__drawer[chanNum]
307 elif (chanNum == 1000):
308 return self.__comment
310 raise Exception(
"Invalid drawer requested: %s %s" % (ros,mod) )
◆ getFolderTag()
def python.TileCalibCrest.TileBlobReaderCrest.getFolderTag |
( |
|
self, |
|
|
|
folder, |
|
|
|
prefix, |
|
|
|
globalTag |
|
) |
| |
Definition at line 109 of file TileCalibCrest.py.
110 if globalTag==
'CURRENT' or globalTag==
'UPD4' or globalTag==
'':
111 globalTag=TileCalibTools.getAliasFromFile(
'Current')
112 log.info(
"Resolved CURRENT globalTag to \'%s\'", globalTag)
113 elif globalTag==
'CURRENTES' or globalTag==
'UPD1':
114 globalTag=TileCalibTools.getAliasFromFile(
'CurrentES')
115 log.info(
"Resolved CURRENT ES globalTag to \'%s\'", globalTag)
116 elif globalTag==
'NEXT':
117 globalTag=TileCalibTools.getAliasFromFile(
'Next')
118 log.info(
"Resolved NEXT globalTag to \'%s\'", globalTag)
119 elif globalTag==
'NEXTES':
120 globalTag=TileCalibTools.getAliasFromFile(
'NextES')
121 log.info(
"Resolved NEXT ES globalTag to \'%s\'", globalTag)
122 globalTag=globalTag.replace(
'*',
'')
125 for f
in folder.split(
'/'):
126 prefix+=f.capitalize()
128 prefix=prefix.strip(
'-').
split(
'-')[0]
129 if prefix.startswith(
'Calo'):
130 prefix=
'CALO'+prefix[4:]
131 if 'UPD1' in globalTag
or 'UPD4' in globalTag
or 'COND' not in globalTag:
133 tag=prefix+
'-'+globalTag
134 self.log().
info(
"Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
135 elif folder!=
'' and not (globalTag.startswith(
'Tile')
or globalTag.startswith(
'CALO')):
137 if tag.startswith(
'Calo'):
139 self.log().
info(
"Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
142 self.log().
info(
"Use localTag \'%s\' as is", tag)
145 tags=self.__api_instance.find_global_tag_map(globalTag)
147 raise Exception(
"globalTag %s not found" % (globalTag) )
149 for i
in range(tags[
'size']):
150 t=tags[
'resources'][i][
'tag_name']
151 l=tags[
'resources'][i][
'label']
152 if (prefix!=
'' and t.startswith(prefix))
or l==folder:
154 self.log().
info(
"Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
◆ getIovs()
def python.TileCalibCrest.TileBlobReaderCrest.getIovs |
( |
|
self, |
|
|
|
since, |
|
|
|
until |
|
) |
| |
Definition at line 160 of file TileCalibCrest.py.
160 def getIovs(self,since,until):
161 run_lumi1=
str((since[0]<<32)+since[1]+1)
162 run_lumi2=
str((until[0]<<32)+until[1]+1)
163 MAXRUNLUMI1=
str(MAXRUNLUMI+1)
164 iovs1=self.__api_instance.select_iovs(self.__tag,
"0",run_lumi1,sort=
'id.since:DESC,id.insertionTime:DESC',size=1,snapshot=0)
165 iovs2=self.__api_instance.select_iovs(self.__tag,run_lumi2,MAXRUNLUMI1,sort=
'id.since:ASC,id.insertionTime:DESC',size=1,snapshot=0)
166 since1=0
if iovs1[
'size']==0
else iovs1[
'resources'][0][
'since']
167 until1=MAXRUNLUMI
if iovs2[
'size']==0
else iovs2[
'resources'][0][
'since']
168 iovs=self.__api_instance.select_iovs(self.__tag,
str(since1),
str(until1),sort=
'id.since:ASC,id.insertionTime:DESC',size=999999,snapshot=0)
171 raise Exception(
"IOV for tag %s IOV [%s,%s] - (%s,%s) not found" % (self.__tag,since[0],since[1],until[0],until[1]) )
173 for i
in range(iovs[
'size']):
174 iov=iovs[
'resources'][i]
175 runS=iov[
'since']>>32
176 lumiS=iov[
'since']&0xFFFFFFFF
177 iovList.append((runS,lumiS))
◆ __api_instance
python.TileCalibCrest.TileBlobReaderCrest.__api_instance |
|
private |
◆ __comment
python.TileCalibCrest.TileBlobReaderCrest.__comment |
|
private |
◆ __commentBlob
python.TileCalibCrest.TileBlobReaderCrest.__commentBlob |
|
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 |
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.