|
def | __init__ (self, db, folder='', tag='', run=None, lumi=0, modmin=0, modmax=275, copyBlob=False) |
|
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 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.__iovList.
append(((MINRUN,MINLBK),(MAXRUN, MAXLBK)))
100 self.__iov = self.__runlumi2iov(self.__iovList[-1])
102 with open(self.__db,
'r')
as the_file:
103 jdata = json.load(the_file)
104 for chan
in range(self.__modmin,self.__modmax):
105 self.__create_drawer(jdata[
str(chan)][0],chan)
106 self.__create_comment(jdata[
'1000'][0])
107 except Exception
as e:
108 self.log().critical( e )
◆ __checkIov()
def python.TileCalibCrest.TileBlobReaderCrest.__checkIov |
( |
|
self, |
|
|
|
runlumi |
|
) |
| |
|
private |
Definition at line 236 of file TileCalibCrest.py.
236 def __checkIov(self,runlumi):
237 point = (runlumi[0]<<32) + runlumi[1]
238 inrange = point>=self.__iov[0]
and point<self.__iov[1]
◆ __create_comment()
def python.TileCalibCrest.TileBlobReaderCrest.__create_comment |
( |
|
self, |
|
|
|
b64string |
|
) |
| |
|
private |
Definition at line 249 of file TileCalibCrest.py.
249 def __create_comment(self,b64string):
250 if b64string
is None or len(b64string)==0:
251 self.__commentBlob =
None
252 self.__comment =
None
254 blob1 = base64.decodebytes(bytes(b64string,
'ascii'))
255 self.__commentBlob = self.__make_blob(blob1)
◆ __create_drawer()
def python.TileCalibCrest.TileBlobReaderCrest.__create_drawer |
( |
|
self, |
|
|
|
b64string, |
|
|
|
chan |
|
) |
| |
|
private |
Definition at line 260 of file TileCalibCrest.py.
260 def __create_drawer(self,b64string,chan):
261 if b64string
is None or len(b64string)==0:
262 self.__drawerBlob[chan] =
None
263 self.__drawer[chan] =
None
265 blob1 = base64.decodebytes(bytes(b64string,
'ascii'))
266 self.__drawerBlob[chan] = self.__make_blob(blob1)
271 if typeName==
'TileCalibDrawerFlt':
273 self.log().
debug(
"typeName = Flt " )
274 elif typeName==
'TileCalibDrawerInt':
276 self.log().
debug(
"typeName = Int " )
277 elif typeName==
'TileCalibDrawerBch':
279 self.log().
debug(
"typeName = Bch " )
280 elif typeName==
'TileCalibDrawerOfc':
282 self.log().
debug(
"typeName = Ofc " )
284 raise Exception(
"Invalid blob type requested: %s" % typeName )
◆ __getIov()
def python.TileCalibCrest.TileBlobReaderCrest.__getIov |
( |
|
self, |
|
|
|
runlumi, |
|
|
|
dbg = False |
|
) |
| |
|
private |
Definition at line 185 of file TileCalibCrest.py.
185 def __getIov(self,runlumi,dbg=False):
186 run_lumi1=
str((runlumi[0]<<32)+runlumi[1]+1)
187 MAXRUNLUMI1=
str(MAXRUNLUMI+1)
188 iovs1=self.__api_instance.select_iovs(self.__tag,
"0",run_lumi1,sort=
'id.since:DESC,id.insertionTime:DESC',size=1,snapshot=0)
189 iovs2=self.__api_instance.select_iovs(self.__tag,run_lumi1,MAXRUNLUMI1,sort=
'id.since:ASC,id.insertionTime:DESC',size=1,snapshot=0)
191 raise Exception(
"IOV for tag %s run,lumi (%s,%s) not found" % (self.__tag,runlumi[0],runlumi[1]) )
193 iov=iovs1[
'resources'][0]
194 since=
int(iov[
'since'])
196 lumiS=since&0xFFFFFFFF
197 until=MAXRUNLUMI
if iovs2[
'size']==0
else iovs2[
'resources'][0][
'since']
199 lumiU=until&0xFFFFFFFF
200 hash=iov[
'payload_hash']
203 self.log().
info(
'IOV [%d,%d] - (%d,%d)' , runS,lumiS,runU,lumiU)
204 self.log().
info(
'Insertion time %s' , iov[
'insertion_time'])
205 self.log().
info(
'Hash %s' , hash)
206 payload = self.__api_instance.get_payload(hash=hash).
decode(
'utf-8')
207 jdata=json.loads(payload)
214 self.__iovList.
append(((runS,lumiS),(runU, lumiU)))
215 self.__iov = self.__runlumi2iov(self.__iovList[-1])
216 for chan
in range(self.__modmin,self.__modmax):
218 blob=jdata[
str(chan)][0]
221 self.__create_drawer(blob,chan)
223 blob=jdata[
'1000'][0]
226 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 230 of file TileCalibCrest.py.
230 def __runlumi2iov(self,runlumi):
231 since = (runlumi[0][0]<<32) + runlumi[0][1]
232 until = (runlumi[1][0]<<32) + runlumi[1][1]
◆ getComment()
def python.TileCalibCrest.TileBlobReaderCrest.getComment |
( |
|
self, |
|
|
|
runlumi = None |
|
) |
| |
Definition at line 317 of file TileCalibCrest.py.
317 def getComment(self,runlumi=None):
319 if self.__remote
and runlumi
is not None and not self.__checkIov(runlumi):
320 self.__getIov(runlumi)
321 if self.__comment
is not None:
322 return self.__comment.getFullComment()
324 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 327 of file TileCalibCrest.py.
327 def getDefault(self, ros, drawer):
329 Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
332 if drawer<=4
or drawer==12
or drawer>=20:
338 elif ros==1
or ros==2:
341 OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2,
342 0, 0, 0, 0, 7, 6, 5, 7,
343 7, 6, 6, 7, 0, 0, 0, 2,
344 3, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 1, 1,
346 1, 1, 2, 3, 0, 0, 0, 0,
347 0, 0, 0, 0, 3, 2, 1, 1,
348 1, 1, 0, 0, 0, 0, 0, 0]
349 drawer1 = 12 + OffsetEBA[drawer]
351 OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2,
352 0, 0, 0, 0, 7, 6, 6, 7,
353 7, 5, 6, 7, 0, 0, 0, 2,
354 3, 0, 0, 3, 4, 0, 3, 4,
355 0, 4, 3, 0, 4, 3, 1, 1,
356 1, 1, 2, 3, 0, 0, 0, 0,
357 0, 0, 0, 0, 3, 2, 1, 1,
358 1, 1, 0, 0, 0, 0, 0, 0]
359 drawer1 = 12 + OffsetEBC[drawer]
◆ getDrawer()
def python.TileCalibCrest.TileBlobReaderCrest.getDrawer |
( |
|
self, |
|
|
|
ros, |
|
|
|
mod, |
|
|
|
runlumi = None , |
|
|
|
dbg = False , |
|
|
|
useDefault = True |
|
) |
| |
Definition at line 288 of file TileCalibCrest.py.
288 def getDrawer(self,ros, mod, runlumi=None, dbg=False, useDefault=True):
290 if self.__remote
and runlumi
is not None and not self.__checkIov(runlumi):
291 self.__getIov(runlumi,dbg)
298 if (chanNum>=0
and chanNum<len(self.__drawer)):
299 drawer=self.__drawer[chanNum]
300 if not useDefault
and drawer
is None:
302 while drawer
is None:
304 if ros==0
and drawer==0:
305 raise Exception(
'No default available')
307 ros,drawer = self.getDefault(ros,drawer)
309 drawer=self.__drawer[chanNum]
311 elif (chanNum == 1000):
312 return self.__comment
314 raise Exception(
"Invalid drawer requested: %s %s" % (ros,mod) )
◆ getFolderTag()
def python.TileCalibCrest.TileBlobReaderCrest.getFolderTag |
( |
|
self, |
|
|
|
folder, |
|
|
|
prefix, |
|
|
|
globalTag |
|
) |
| |
Definition at line 112 of file TileCalibCrest.py.
113 if globalTag==
'CURRENT' or globalTag==
'UPD4' or globalTag==
'':
114 globalTag=TileCalibTools.getAliasFromFile(
'Current')
115 log.info(
"Resolved CURRENT globalTag to \'%s\'", globalTag)
116 elif globalTag==
'CURRENTES' or globalTag==
'UPD1':
117 globalTag=TileCalibTools.getAliasFromFile(
'CurrentES')
118 log.info(
"Resolved CURRENT ES globalTag to \'%s\'", globalTag)
119 elif globalTag==
'NEXT':
120 globalTag=TileCalibTools.getAliasFromFile(
'Next')
121 log.info(
"Resolved NEXT globalTag to \'%s\'", globalTag)
122 elif globalTag==
'NEXTES':
123 globalTag=TileCalibTools.getAliasFromFile(
'NextES')
124 log.info(
"Resolved NEXT ES globalTag to \'%s\'", globalTag)
125 globalTag=globalTag.replace(
'*',
'')
128 for f
in folder.split(
'/'):
129 prefix+=f.capitalize()
131 prefix=prefix.strip(
'-').
split(
'-')[0]
132 if prefix.startswith(
'Calo'):
133 prefix=
'CALO'+prefix[4:]
134 if 'UPD1' in globalTag
or 'UPD4' in globalTag
or 'COND' not in globalTag:
136 tag=prefix+
'-'+globalTag
137 self.log().
info(
"Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
138 elif folder!=
'' and not (globalTag.startswith(
'Tile')
or globalTag.startswith(
'CALO')):
140 if tag.startswith(
'Calo'):
142 self.log().
info(
"Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
145 self.log().
info(
"Use localTag \'%s\' as is", tag)
148 tags=self.__api_instance.find_global_tag_map(globalTag)
150 raise Exception(
"globalTag %s not found" % (globalTag) )
152 for i
in range(tags[
'size']):
153 t=tags[
'resources'][i][
'tag_name']
154 l=tags[
'resources'][i][
'label']
155 if (prefix!=
'' and t.startswith(prefix))
or l==folder:
157 self.log().
info(
"Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
◆ getIovs()
def python.TileCalibCrest.TileBlobReaderCrest.getIovs |
( |
|
self, |
|
|
|
since, |
|
|
|
until |
|
) |
| |
Definition at line 163 of file TileCalibCrest.py.
163 def getIovs(self,since,until):
164 run_lumi1=
str((since[0]<<32)+since[1]+1)
165 run_lumi2=
str((until[0]<<32)+until[1]+1)
166 MAXRUNLUMI1=
str(MAXRUNLUMI+1)
167 iovs1=self.__api_instance.select_iovs(self.__tag,
"0",run_lumi1,sort=
'id.since:DESC,id.insertionTime:DESC',size=1,snapshot=0)
168 iovs2=self.__api_instance.select_iovs(self.__tag,run_lumi2,MAXRUNLUMI1,sort=
'id.since:ASC,id.insertionTime:DESC',size=1,snapshot=0)
169 since1=0
if iovs1[
'size']==0
else iovs1[
'resources'][0][
'since']
170 until1=MAXRUNLUMI
if iovs2[
'size']==0
else iovs2[
'resources'][0][
'since']
171 iovs=self.__api_instance.select_iovs(self.__tag,
str(since1),
str(until1),sort=
'id.since:ASC,id.insertionTime:DESC',size=999999,snapshot=0)
174 raise Exception(
"IOV for tag %s IOV [%s,%s] - (%s,%s) not found" % (self.__tag,since[0],since[1],until[0],until[1]) )
176 for i
in range(iovs[
'size']):
177 iov=iovs[
'resources'][i]
178 since=
int(iov[
'since'])
180 lumiS=since&0xFFFFFFFF
181 iovList.append((runS,lumiS))
◆ __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.