ATLAS Offline Software
Loading...
Searching...
No Matches
python.TileCalibTools Namespace Reference

Classes

class  TileASCIIParser
class  TileASCIIParser2
class  TileASCIIParser3
class  TileBlobReader
class  TileBlobWriter

Functions

 getLastRunNumber ()
 getNextRunNumber ()
 getPromptCalibRunNumber ()
 getAliasFromFile (aliastype='Current')
 getTilePrefix (ofl=True, splitOnlInOflSchema=True)
 getTilePrefixes ()
 getAthenaFolderDescr (type="run-lumi")
 getAthenaFolderType (folderDescr)
 openDb (db, instance, mode="READONLY", schema="COOLOFL_TILE", sqlfn="tileSqlite.db")
 openDbOracle (db, schema, folder)
 openDbConn (connStr, mode="READONLY")
 coolTimeFromRunLumi (runNum, lbkNum)
 decodeTimeString (timeString)
 getCoolValidityKey (pointInTime, isSince=True)
 getFolderTag (db, folderPath, globalTag)
 findTag (folder, tag)
 runLumiFromCoolTime (iov)
 copyFolder (dbr, dbw, folder, tagr, tagw, chanNum, pointInTime1, pointInTime2)
 moduleListToString (modules, checkAUX=True, checkMOD=True, checkComment=True, shortLength=15, exceptLength=15)

Variables

 log = getLogger("TileCalibTools")
int MINRUN = 0
int MINLBK = 0
 MAXRUN = cool.Int32Max
 MAXLBK = cool.UInt32Max
int UNIX2COOL = 1000000000
 UNIXTMAX = cool.Int32Max
int LASPARTCHAN = 43

Function Documentation

◆ coolTimeFromRunLumi()

python.TileCalibTools.coolTimeFromRunLumi ( runNum,
lbkNum )
Returns COOL timeStamp build from run and lumi block numbers

Definition at line 352 of file TileCalibTools.py.

352def coolTimeFromRunLumi(runNum, lbkNum):
353 """
354 Returns COOL timeStamp build from run and lumi block numbers
355 """
356 return (int(runNum)<<32) + int(lbkNum)
357
358#
359#______________________________________________________________________

◆ copyFolder()

python.TileCalibTools.copyFolder ( dbr,
dbw,
folder,
tagr,
tagw,
chanNum,
pointInTime1,
pointInTime2 )

Definition at line 503 of file TileCalibTools.py.

503def copyFolder(dbr, dbw, folder, tagr, tagw, chanNum, pointInTime1, pointInTime2):
504
505 log.info("Copy channel %i", chanNum)
506
507 folderR = dbr.getFolder(folder)
508 folderW = dbw.getFolder(folder)
509
510 chansel = cool.ChannelSelection(chanNum)
511
512 iov1 = getCoolValidityKey(pointInTime1,False)
513 iov2 = getCoolValidityKey(pointInTime2,False)
514
515 if tagr=='':
516 multiVersion = False
517 objs = folderR.browseObjects(iov1,iov2,chansel)
518 else:
519 multiVersion = True
520 objs = folderR.browseObjects(iov1,iov2,chansel,tagr)
521 while objs.goToNext():
522 obj=objs.currentRef()
523 sinceCool=obj.since()
524 if sinceCool < iov1:
525 sinceCool = iov1
526 untilCool=obj.until()
527 data=obj.payload()
528 sinceTup = runLumiFromCoolTime(sinceCool)
529 untilTup = runLumiFromCoolTime(untilCool)
530 log.debug("Copy entry: [%i,%i] - [%i,%i]: %s", sinceTup[0],sinceTup[1],untilTup[0],untilTup[1], data)
531 folderW.storeObject(sinceCool, untilCool, data, chanNum, tagw, multiVersion)
532
533#
534#____________________________________________________________________

◆ decodeTimeString()

python.TileCalibTools.decodeTimeString ( timeString)
Retruns UNIX time stamp given an input time string

Definition at line 360 of file TileCalibTools.py.

360def decodeTimeString(timeString):
361 """
362 Retruns UNIX time stamp given an input time string
363 """
364 return int(time.mktime(time.strptime(timeString,"%Y-%m-%d %H:%M:%S")))
365
366#
367#______________________________________________________________________

◆ findTag()

python.TileCalibTools.findTag ( folder,
tag )

Definition at line 486 of file TileCalibTools.py.

486def findTag(folder,tag):
487 taglist=folder.listTags()
488 if len(taglist):
489 if tag=='FIRST':
490 return taglist[0]
491 else:
492 return taglist[-1]
493 else:
494 return 'tag-not-found'
495
496#
497#____________________________________________________________________

◆ getAliasFromFile()

python.TileCalibTools.getAliasFromFile ( aliastype = 'Current')
Return name of top-level tag for 'Current' or 'CurrentES' or 'Next' or 'NextES' aliases

Definition at line 134 of file TileCalibTools.py.

134def getAliasFromFile(aliastype='Current'):
135 """
136 Return name of top-level tag for 'Current' or 'CurrentES' or 'Next' or 'NextES' aliases
137 """
138
139 aliasfolder = '/afs/cern.ch/atlas/conditions/poolcond/buffer/BestKnowledge'
140 try:
141 falias = open('%s/%s' % (aliasfolder, aliastype))
142 alias = falias.readline()
143 falias.close()
144 return alias.replace('\n','').replace('*','')
145 except Exception:
146 import os
147 aliasfolder = os.getcwd()+'/BestKnowledge'
148 print("Looking for %s in %s" % (aliastype,aliasfolder))
149 try:
150 falias = open('%s/%s' % (aliasfolder, aliastype))
151 alias = falias.readline()
152 falias.close()
153 return alias.replace('\n','').replace('*','')
154 except Exception:
155 return aliastype.upper()
156
157#
158#______________________________________________________________________
void print(char *figname, TCanvas *c1)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ getAthenaFolderDescr()

python.TileCalibTools.getAthenaFolderDescr ( type = "run-lumi")
Returns the run-lumi type folder description needed to read back the folder content
as a CondAttrListCollection in Athena.

Definition at line 187 of file TileCalibTools.py.

187def getAthenaFolderDescr(type="run-lumi"):
188 """
189 Returns the run-lumi type folder description needed to read back the folder content
190 as a CondAttrListCollection in Athena.
191 """
192 desc ='<timeStamp>'+type+'</timeStamp>'
193 desc+='<addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader>'
194 desc+='<typeName>CondAttrListCollection</typeName>'
195 return desc
196
197#
198#______________________________________________________________________

◆ getAthenaFolderType()

python.TileCalibTools.getAthenaFolderType ( folderDescr)

Definition at line 199 of file TileCalibTools.py.

199def getAthenaFolderType(folderDescr):
200 type = re.compile(".*<timeStamp>(.*)</timeStamp>.*").search(folderDescr)
201 if not type:
202 raise Exception("No folder type info found in \'%s\'" % folderDescr)
203 return type.groups()[0]
204
205#
206#______________________________________________________________________
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
Definition hcg.cxx:739

◆ getCoolValidityKey()

python.TileCalibTools.getCoolValidityKey ( pointInTime,
isSince = True )
The interpretation of pointInTime depends on their type:
- tuple(int,int) : run and lbk number
- integer        : Values are interpreted as unix time stamps
- string         : time stamp of format 'yyyy-mm-dd hh:mm:ss'

Definition at line 368 of file TileCalibTools.py.

368def getCoolValidityKey(pointInTime, isSince=True):
369 """
370 The interpretation of pointInTime depends on their type:
371 - tuple(int,int) : run and lbk number
372 - integer : Values are interpreted as unix time stamps
373 - string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
374 """
375
376 validityKey = None
377
378 #=== string: convert to unix time and treat as latter
379 if isinstance(pointInTime, str):
380 pointInTime = decodeTimeString(pointInTime)
381
382 #=== integer: unix time stamp
383 if isinstance(pointInTime, int):
384 if pointInTime >=0:
385 validityKey = pointInTime * UNIX2COOL
386 else:
387 if isSince:
388 validityKey = int(time.time()) * UNIX2COOL
389 else :
390 validityKey = cool.ValidityKeyMax
391 #=== run-lumi tuple
392 elif isinstance(pointInTime, tuple):
393 validityKey = coolTimeFromRunLumi(pointInTime[0],pointInTime[1])
394 #=== catch other types
395 else:
396 raise Exception("Unrecognized pointInTime type=%s" % type(pointInTime))
397 return cool.ValidityKey(validityKey)
398
399
400#
401#____________________________________________________________________

◆ getFolderTag()

python.TileCalibTools.getFolderTag ( db,
folderPath,
globalTag )

Definition at line 402 of file TileCalibTools.py.

402def getFolderTag(db, folderPath, globalTag):
403
404 tag=""
405 gTAG = globalTag.upper()
406 findTAG = (gTAG == "ANY" or gTAG == "FIRST" or gTAG == "LAST")
407 if globalTag.startswith("/") or globalTag.startswith("TileO") or globalTag.upper().startswith("CALO"):
408 tag = globalTag
409 log.warning("Using tag as-is for folder %s", folderPath)
410 elif '/TILE/ONL01' in folderPath:
411 log.info("Using empty tag for single-version folder %s", folderPath)
412 elif globalTag.startswith(" "):
413 log.warning("Using empty tag for folder %s", folderPath)
414 elif globalTag=="":
415 tag = TileCalibUtils.getFullTag(folderPath, globalTag)
416 log.warning("Using tag with empty suffix for folder %s", folderPath)
417 else:
418 if folderPath.startswith('/CALO'):
419 dbname = 'COOLOFL_CALO' if folderPath.startswith('/CALO/Ofl') else 'COOLONL_CALO'
420 else:
421 dbname ='COOLOFL_TILE'
422 schema=dbname+'/CONDBR2'
423 if isinstance(db, str):
424 if 'OFLP200' in db or 'MC' in db:
425 schema=dbname+'/OFLP200'
426 if not globalTag.startswith("OFLCOND"):
427 if globalTag.startswith("RUN"):
428 globalTag='OFLCOND-'+globalTag
429 log.info("Using Simulation global tag \'%s\'", globalTag)
430 elif 'COMP200' in db or 'RUN1' in db:
431 schema=dbname+'/COMP200'
432 if globalTag!='UPD1' and globalTag!='UPD4' and ('UPD1' in globalTag or 'UPD4' in globalTag or 'COND' not in globalTag):
433 if not findTAG:
434 log.info("Using suffix \'%s\' as it is", globalTag)
435 else:
436 findTAG = False
437 globalTag='COMCOND-BLKPA-RUN1-06'
438 log.info("Using RUN1 global tag \'%s\'", globalTag)
439 if schema == dbname+'/CONDBR2':
440 if globalTag=='CURRENT' or globalTag=='UPD4' or globalTag=='':
441 globalTag=getAliasFromFile('Current')
442 log.info("Resolved CURRENT globalTag to \'%s\'", globalTag)
443 elif globalTag=='CURRENTES' or globalTag=='UPD1':
444 globalTag=getAliasFromFile('CurrentES')
445 log.info("Resolved CURRENT ES globalTag to \'%s\'", globalTag)
446 elif globalTag=='NEXT':
447 globalTag=getAliasFromFile('Next')
448 log.info("Resolved NEXT globalTag to \'%s\'", globalTag)
449 elif globalTag=='NEXTES':
450 globalTag=getAliasFromFile('NextES')
451 log.info("Resolved NEXT ES globalTag to \'%s\'", globalTag)
452 globalTag=globalTag.replace('*','')
453 if not findTAG and ('UPD1' in globalTag or 'UPD4' in globalTag or 'COND' not in globalTag):
454 tag = TileCalibUtils.getFullTag(folderPath, globalTag)
455 if tag.startswith('Calo') and 'NoiseCell' not in tag:
456 tag='CALO'+tag[4:]
457 tag=tag.replace('Pileupnoiselumi','PileUpNoiseLumi')
458 log.info("Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
459 else:
460 if not isinstance(db, str):
461 try:
462 folder = db.getFolder(folderPath)
463 if findTAG:
464 tag = findTag(folder,gTAG)
465 else:
466 tag = folder.resolveTag(globalTag)
467 log.info("Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
468 schema=""
469 except Exception as e:
470 log.warning(e)
471 log.warning("Using %s to resolve globalTag",schema)
472 if len(schema):
473 dbr = openDbConn(schema,'READONLY')
474 folder = dbr.getFolder(folderPath)
475 if findTAG:
476 tag = findTag(folder,gTAG)
477 else:
478 tag = folder.resolveTag(globalTag)
479 dbr.closeDatabase()
480 log.info("Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
481
482 return tag
483
484#
485#____________________________________________________________________
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.

◆ getLastRunNumber()

python.TileCalibTools.getLastRunNumber ( )
Return the run number of next run to be taken in the pit
Keep this function temporary for backward compatibility

Definition at line 50 of file TileCalibTools.py.

50def getLastRunNumber():
51 """
52 Return the run number of next run to be taken in the pit
53 Keep this function temporary for backward compatibility
54 """
55 return getNextRunNumber()
56
57#
58#______________________________________________________________________

◆ getNextRunNumber()

python.TileCalibTools.getNextRunNumber ( )
Return the run number of next run to be taken in the pit

Definition at line 59 of file TileCalibTools.py.

59def getNextRunNumber():
60 """
61 Return the run number of next run to be taken in the pit
62 """
63
64 urls = ["http://atlas-run-info-api.web.cern.ch/api/runs?sort=runnumber:DESC&size=1",
65 "http://pcata007.cern.ch/cgi-bin/getLastRunNumber.py",
66 "http://pcata007.cern.ch/latestRun"]
67
68 run=0
69 for url in urls:
70 try:
71 for line in urlopen(url).readlines():
72 r=line.strip()
73 if r.isdigit():
74 run=int(r)
75 break
76 else:
77 jdata=json.loads(r)
78 run=int(jdata['resources'][0]['runnumber'])
79 break
80 if run>0:
81 break
82 except Exception:
83 continue
84
85 return max(run+1,222222)
86
87#
88#______________________________________________________________________
#define max(a, b)
Definition cfImp.cxx:41

◆ getPromptCalibRunNumber()

python.TileCalibTools.getPromptCalibRunNumber ( )
Return the minimal run number of runs in prompt calibration loop

Definition at line 89 of file TileCalibTools.py.

89def getPromptCalibRunNumber():
90 """
91 Return the minimal run number of runs in prompt calibration loop
92 """
93
94 promptCalibRuns = []
95
96 try:
97 fin = open("/afs/cern.ch/user/a/atlcond/scratch0/nemo/prod/web/calibruns.txt","r").read().split()
98 for line in fin:
99 try:
100 if line:
101 promptCalibRuns.append( int(line) )
102 except ValueError:
103 pass
104 except Exception:
105 promptCalibRuns=[]
106
107 if len(promptCalibRuns)==0:
108
109 urls = ["http://pcata007.cern.ch/cgi-bin/getBulkRunNumber.py",
110 "http://pcata007.cern.ch/latestRun"]
111
112 run=0
113 for url in urls:
114 try:
115 for line in urlopen(url).readlines():
116 r=line.strip()
117 if r.isdigit():
118 run=int(r)
119 break
120 if run>0:
121 promptCalibRuns=[run]
122 break
123 except Exception:
124 continue
125
126 if len(promptCalibRuns) >= 1:
127 promptCalibRuns.sort()
128 return promptCalibRuns[0]
129 else:
130 return getNextRunNumber()
131
132#
133#______________________________________________________________________
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)

◆ getTilePrefix()

python.TileCalibTools.getTilePrefix ( ofl = True,
splitOnlInOflSchema = True )
Returns the common Tile prefix used for all COOL folders.
ofl = False ... single version folders
ofl = True  ... multiversion folders
splitOnlInOflSchema = False ... offline only folders or
                splitOnline folders in Online schema
splitOnlInOflSchema = True ... splitOnlineFolders in
                offline schema

Definition at line 159 of file TileCalibTools.py.

159def getTilePrefix(ofl=True,splitOnlInOflSchema=True):
160 """
161 Returns the common Tile prefix used for all COOL folders.
162 ofl = False ... single version folders
163 ofl = True ... multiversion folders
164 splitOnlInOflSchema = False ... offline only folders or
165 splitOnline folders in Online schema
166 splitOnlInOflSchema = True ... splitOnlineFolders in
167 offline schema
168 """
169 if ofl:
170 if splitOnlInOflSchema:
171 return "/TILE/OFL02/"
172 else:
173 return "/TILE/OFL01/"
174 else:
175 return "/TILE/ONL01/"
176
177#
178#______________________________________________________________________

◆ getTilePrefixes()

python.TileCalibTools.getTilePrefixes ( )
Returns a list of all TILE folder prefixes

Definition at line 179 of file TileCalibTools.py.

179def getTilePrefixes():
180 """
181 Returns a list of all TILE folder prefixes
182 """
183 return ["/TILE/ONL01/","/TILE/OFL01/","/TILE/OFL02/"]
184
185#
186#______________________________________________________________________

◆ moduleListToString()

python.TileCalibTools.moduleListToString ( modules,
checkAUX = True,
checkMOD = True,
checkComment = True,
shortLength = 15,
exceptLength = 15 )

Definition at line 535 of file TileCalibTools.py.

535def moduleListToString(modules, checkAUX=True, checkMOD=True, checkComment=True, shortLength=15, exceptLength=15):
536
537 fulllist = "@".join(modules)
538 mlist = []
539
540 if checkAUX:
541 list1=re.findall("AUX..",fulllist)
542 if len(list1)==20:
543 mlist += ["ALL 20 AUX modules"]
544 elif list1:
545 mlist += [" ".join(list1)]
546 else:
547 mlist += ["NO AUX modules"]
548
549 if checkMOD:
550 list2=re.findall("[LE]B[AC]..",fulllist)
551 if len(list2)==256:
552 mlist += ["ALL 256 modules"]
553 elif 256-len(list2)<=exceptLength:
554 list3 = []
555 for p in ["LBA","LBC","EBA","EBC"]:
556 for n in range(1,65):
557 m = "%s%02d" % (p,n)
558 if m not in list2:
559 list3 += [m]
560 mlist += ["%d modules: all except %s" % (len(list2)," ".join(list3))]
561 elif list2:
562 if len(list2)<=shortLength:
563 mlist += [" ".join(list2)]
564 else:
565 for p in ["LBA","LBC","EBA","EBC"]:
566 list2=re.findall(p+"..",fulllist)
567 if len(list2)==64:
568 mlist += ["64 %s modules" % p]
569 elif 64-len(list2)<=exceptLength:
570 list3 = []
571 for n in range(1,65):
572 m = "%s%02d" % (p,n)
573 if m not in list2:
574 list3 += [m]
575 mlist += ["%d %s modules: all except %s" % (len(list2),p," ".join(list3))]
576 elif list2:
577 mlist += [" ".join(list2)]
578 else:
579 mlist += ["NO %s modules" % p]
580 else:
581 mlist += ["NO modules"]
582
583 if checkComment:
584 list4=re.findall("Comment[^@]*",fulllist)
585 if list4:
586 mlist += [" ".join(list4)]
587 else:
588 mlist += ["NO COMMENT"]
589
590 all = ", ".join(mlist)
591 return all
592
593
594
595#======================================================================
596#===
597#=== TileBlobWriter
598#===
599#======================================================================
600
601#
602#______________________________________________________________________

◆ openDb()

python.TileCalibTools.openDb ( db,
instance,
mode = "READONLY",
schema = "COOLOFL_TILE",
sqlfn = "tileSqlite.db" )
Opens a COOL db connection.
- db:       The DB type. The following names are recognized:
                * SQLITE: Opens file mentioned in sqlfn parameter
                * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
- instance: One of valid instances - CONDBR2 OFLP200 COMP200 CMCP200
- mode:     Can be READONLY (default), RECREATE or UPDATE
- schema:   One of valid schemas - COOLONL_CALO COOLOFL_CALO COOLONL_LAR COOLOFL_LAR COOLONL_TILE COOLOFL_TILE
- sqlfn:    Name of sqlite file if db is SQLITE

Definition at line 207 of file TileCalibTools.py.

207def openDb(db, instance, mode="READONLY", schema="COOLOFL_TILE", sqlfn="tileSqlite.db"):
208 """
209 Opens a COOL db connection.
210 - db: The DB type. The following names are recognized:
211 * SQLITE: Opens file mentioned in sqlfn parameter
212 * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
213 - instance: One of valid instances - CONDBR2 OFLP200 COMP200 CMCP200
214 - mode: Can be READONLY (default), RECREATE or UPDATE
215 - schema: One of valid schemas - COOLONL_CALO COOLOFL_CALO COOLONL_LAR COOLOFL_LAR COOLONL_TILE COOLOFL_TILE
216 - sqlfn: Name of sqlite file if db is SQLITE
217 """
218 #=== check for valid db names
219 if db is not None:
220 validDb = ["SQLITE", "ORACLE", "FRONTIER"]
221 if db not in validDb:
222 raise Exception( "DB not valid: %s, valid DBs are: %s" % (db,validDb) )
223 elif db == "ORACLE" or db == "FRONTIER":
224 mode = "READONLY"
225
226 #=== check for valid instance names
227 validInstance = ["COMP200", "CONDBR2", "CMCP200", "OFLP200"]
228 if instance not in validInstance:
229 raise Exception( "Instance not valid: %s, valid instance are: %s" % (instance,validInstance) )
230
231 #=== check for valid schema names
232 validSchema = ["COOLONL_TILE","COOLOFL_TILE"]
233 if schema not in validSchema:
234 raise Exception( "Schema not valid: %s, valid schemas are: %s" % (schema,validSchema) )
235
236 #=== construct connection string
237 connStr = ""
238 if db=='SQLITE':
239 if mode=="READONLY" and not os.path.exists(sqlfn):
240 raise Exception( "Sqlite file %s does not exist" % (sqlfn) )
241 if (mode=="RECREATE" or mode=="UPDATE") and not os.path.exists(os.path.dirname(sqlfn)):
242 dirn=os.path.dirname(sqlfn)
243 if dirn:
244 os.makedirs(dirn)
245 connStr="sqlite://X;schema=%s;dbname=%s" % (sqlfn,instance)
246 elif db=='FRONTIER':
247 connStr='frontier://ATLF/()/;schema=ATLAS_%s;dbname=%s' % (schema,instance)
248 elif db=='ORACLE':
249 connStr='oracle://%s;schema=ATLAS_%s;dbname=%s' % ('ATLAS_COOLPROD',schema,instance)
250 else:
251 connStr=schema+'/'+instance
252
253 return openDbConn(connStr, mode)
254
255#
256#______________________________________________________________________

◆ openDbConn()

python.TileCalibTools.openDbConn ( connStr,
mode = "READONLY" )
Opens a COOL db connection.
- connStr: The DB connection string
- mode:    Can be READONLY (default), RECREATE or UPDATE
           or ORACLE or FRONTIER if connStr is only short name of the database

Definition at line 283 of file TileCalibTools.py.

283def openDbConn(connStr, mode="READONLY"):
284 """
285 Opens a COOL db connection.
286 - connStr: The DB connection string
287 - mode: Can be READONLY (default), RECREATE or UPDATE
288 or ORACLE or FRONTIER if connStr is only short name of the database
289 """
290
291 #=== split the name into schema and dbinstance
292 splitname=connStr.split('/')
293 if (len(splitname)!=2): # string connection ready to be used as it is
294 connStr_new=connStr
295 else: # construct connection string
296 schema=splitname[0]
297 instance=splitname[1]
298 if mode=="ORACLE":
299 connStr_new='oracle://%s;schema=ATLAS_%s;dbname=%s' % ('ATLAS_COOLPROD',schema,instance)
300 else:
301 connStr_new='frontier://ATLF/()/;schema=ATLAS_%s;dbname=%s' % (schema,instance)
302
303 #=== get dbSvc and print header info
304 dbSvc = cool.DatabaseSvcFactory.databaseService()
305 log.info( "---------------------------------------------------------------------------------" )
306 log.info( "-------------------------- TileCalibTools.openDbConn ----------------------------" )
307 log.info( "- using COOL version %s", dbSvc.serviceVersion() )
308 log.info( "- opening TileDb: %s",connStr_new )
309 log.info( "- mode: %s", mode )
310 log.info( "---------------------------------------------------------------------------------" )
311
312 #=== action depends on mode
313 if mode in ["READONLY","ORACLE","FRONTIER","",None]:
314 #=== open read only
315 try:
316 db=dbSvc.openDatabase(connStr_new,True)
317 except Exception as e:
318 log.debug( e )
319 log.critical("Could not connect to %s" % connStr_new )
320 return None
321 return db
322 elif mode=="RECREATE":
323 #=== recreating database
324 dbSvc.dropDatabase(connStr_new)
325 try:
326 db = dbSvc.createDatabase(connStr_new)
327 except Exception as e:
328 log.debug( e )
329 log.critical( "Could not create database, giving up..." )
330 return None
331 return db
332 elif mode=="UPDATE":
333 #=== update database
334 try:
335 db=dbSvc.openDatabase(connStr_new,False)
336 except Exception as e:
337 log.debug( e )
338 log.warning( "Could not connect to \'%s\', trying to create it....", connStr_new )
339 try:
340 db=dbSvc.createDatabase(connStr_new)
341 except Exception as e:
342 log.debug( e )
343 log.critical( "Could not create database, giving up..." )
344 return None
345 return db
346 else:
347 log.error("Mode \"%s\" not recognized", mode )
348 return None
349
350#
351#______________________________________________________________________

◆ openDbOracle()

python.TileCalibTools.openDbOracle ( db,
schema,
folder )
Opens a COOL db connection.
- db:       The DB type. The following names are recognized:
                * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
- schema:   Full schema string for sqlite file, dbname will be extracted from this string
- folder:   Fill folder path, schema string will be construced using folder name

Definition at line 257 of file TileCalibTools.py.

257def openDbOracle(db, schema, folder):
258 """
259 Opens a COOL db connection.
260 - db: The DB type. The following names are recognized:
261 * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
262 - schema: Full schema string for sqlite file, dbname will be extracted from this string
263 - folder: Fill folder path, schema string will be construced using folder name
264 """
265
266 connStr = 'COOL'
267 if '/OFL' in folder.upper():
268 connStr += 'OFL_'
269 else:
270 connStr += 'ONL_'
271 connStr += folder.strip('/').split('/')[0].upper()
272 dbn=schema.split('dbname=')
273 if len(dbn)==2:
274 dbname=dbn[1].split(';')[0]
275 else:
276 dbname='CONDBR2'
277 connStr += '/' + dbname
278
279 return openDbConn(connStr,db)
280
281#
282#______________________________________________________________________
int upper(int c)

◆ runLumiFromCoolTime()

python.TileCalibTools.runLumiFromCoolTime ( iov)

Definition at line 498 of file TileCalibTools.py.

498def runLumiFromCoolTime(iov):
499 return (int(iov >> 32), int(iov & 0xFFFFFFFF))
500
501#
502#____________________________________________________________________

Variable Documentation

◆ LASPARTCHAN

int python.TileCalibTools.LASPARTCHAN = 43

Definition at line 46 of file TileCalibTools.py.

◆ log

python.TileCalibTools.log = getLogger("TileCalibTools")

Definition at line 27 of file TileCalibTools.py.

◆ MAXLBK

python.TileCalibTools.MAXLBK = cool.UInt32Max

Definition at line 42 of file TileCalibTools.py.

◆ MAXRUN

python.TileCalibTools.MAXRUN = cool.Int32Max

Definition at line 41 of file TileCalibTools.py.

◆ MINLBK

int python.TileCalibTools.MINLBK = 0

Definition at line 40 of file TileCalibTools.py.

◆ MINRUN

int python.TileCalibTools.MINRUN = 0

Definition at line 39 of file TileCalibTools.py.

◆ UNIX2COOL

int python.TileCalibTools.UNIX2COOL = 1000000000

Definition at line 43 of file TileCalibTools.py.

◆ UNIXTMAX

python.TileCalibTools.UNIXTMAX = cool.Int32Max

Definition at line 44 of file TileCalibTools.py.