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

Classes

class  TileBlobWriter
class  TileBlobReader
class  TileASCIIParser
class  TileASCIIParser2
class  TileASCIIParser3

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 364 of file TileCalibTools.py.

364def coolTimeFromRunLumi(runNum, lbkNum):
365 """
366 Returns COOL timeStamp build from run and lumi block numbers
367 """
368 return (int(runNum)<<32) + int(lbkNum)
369
370#
371#______________________________________________________________________

◆ copyFolder()

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

Definition at line 515 of file TileCalibTools.py.

515def copyFolder(dbr, dbw, folder, tagr, tagw, chanNum, pointInTime1, pointInTime2):
516
517 log.info("Copy channel %i", chanNum)
518
519 folderR = dbr.getFolder(folder)
520 folderW = dbw.getFolder(folder)
521
522 chansel = cool.ChannelSelection(chanNum)
523
524 iov1 = getCoolValidityKey(pointInTime1,False)
525 iov2 = getCoolValidityKey(pointInTime2,False)
526
527 if tagr=='':
528 multiVersion = False
529 objs = folderR.browseObjects(iov1,iov2,chansel)
530 else:
531 multiVersion = True
532 objs = folderR.browseObjects(iov1,iov2,chansel,tagr)
533 while objs.goToNext():
534 obj=objs.currentRef()
535 sinceCool=obj.since()
536 if sinceCool < iov1:
537 sinceCool = iov1
538 untilCool=obj.until()
539 data=obj.payload()
540 sinceTup = runLumiFromCoolTime(sinceCool)
541 untilTup = runLumiFromCoolTime(untilCool)
542 log.debug("Copy entry: [%i,%i] - [%i,%i]: %s", sinceTup[0],sinceTup[1],untilTup[0],untilTup[1], data)
543 folderW.storeObject(sinceCool, untilCool, data, chanNum, tagw, multiVersion)
544
545#
546#____________________________________________________________________

◆ decodeTimeString()

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

Definition at line 372 of file TileCalibTools.py.

372def decodeTimeString(timeString):
373 """
374 Retruns UNIX time stamp given an input time string
375 """
376 return int(time.mktime(time.strptime(timeString,"%Y-%m-%d %H:%M:%S")))
377
378#
379#______________________________________________________________________

◆ findTag()

python.TileCalibTools.findTag ( folder,
tag )

Definition at line 498 of file TileCalibTools.py.

498def findTag(folder,tag):
499 taglist=folder.listTags()
500 if len(taglist):
501 if tag=='FIRST':
502 return taglist[0]
503 else:
504 return taglist[-1]
505 else:
506 return 'tag-not-found'
507
508#
509#____________________________________________________________________

◆ getAliasFromFile()

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

Definition at line 141 of file TileCalibTools.py.

141def getAliasFromFile(aliastype='Current'):
142 """
143 Return name of top-level tag for 'Current' or 'CurrentES' or 'Next' or 'NextES' aliases
144 """
145
146 try:
147 aliasfolder = os.getenv(
148 'TILE_ALIAS_FOLDER',
149 '/afs/cern.ch/atlas/conditions/poolcond/buffer/BestKnowledge'
150 )
151 if not aliasfolder or not os.path.isdir(aliasfolder):
152 log.warning("Alias folder not found: %s", aliasfolder)
153 raise FileNotFoundError(aliasfolder)
154 falias = open('%s/%s' % (aliasfolder, aliastype))
155 alias = falias.readline()
156 falias.close()
157 return alias.replace('\n','').replace('*','')
158 except Exception:
159 aliasfolder = os.getcwd()+'/BestKnowledge'
160 print("Looking for %s in %s" % (aliastype,aliasfolder))
161 try:
162 falias = open('%s/%s' % (aliasfolder, aliastype))
163 alias = falias.readline()
164 falias.close()
165 return alias.replace('\n','').replace('*','')
166 except Exception:
167 return aliastype.upper()
168
169#
170#______________________________________________________________________
void print(char *figname, TCanvas *c1)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312

◆ 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 199 of file TileCalibTools.py.

199def getAthenaFolderDescr(type="run-lumi"):
200 """
201 Returns the run-lumi type folder description needed to read back the folder content
202 as a CondAttrListCollection in Athena.
203 """
204 desc ='<timeStamp>'+type+'</timeStamp>'
205 desc+='<addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader>'
206 desc+='<typeName>CondAttrListCollection</typeName>'
207 return desc
208
209#
210#______________________________________________________________________

◆ getAthenaFolderType()

python.TileCalibTools.getAthenaFolderType ( folderDescr)

Definition at line 211 of file TileCalibTools.py.

211def getAthenaFolderType(folderDescr):
212 type = re.compile(".*<timeStamp>(.*)</timeStamp>.*").search(folderDescr)
213 if not type:
214 raise Exception("No folder type info found in \'%s\'" % folderDescr)
215 return type.groups()[0]
216
217#
218#______________________________________________________________________
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:743

◆ 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 380 of file TileCalibTools.py.

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

◆ getFolderTag()

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

Definition at line 414 of file TileCalibTools.py.

414def getFolderTag(db, folderPath, globalTag):
415
416 tag=""
417 gTAG = globalTag.upper()
418 findTAG = (gTAG == "ANY" or gTAG == "FIRST" or gTAG == "LAST")
419 if globalTag.startswith("/") or globalTag.startswith("TileO") or globalTag.upper().startswith("CALO"):
420 tag = globalTag
421 log.warning("Using tag as-is for folder %s", folderPath)
422 elif '/TILE/ONL01' in folderPath:
423 log.info("Using empty tag for single-version folder %s", folderPath)
424 elif globalTag.startswith(" "):
425 log.warning("Using empty tag for folder %s", folderPath)
426 elif globalTag=="":
427 tag = TileCalibUtils.getFullTag(folderPath, globalTag)
428 log.warning("Using tag with empty suffix for folder %s", folderPath)
429 else:
430 if folderPath.startswith('/CALO'):
431 dbname = 'COOLOFL_CALO' if folderPath.startswith('/CALO/Ofl') else 'COOLONL_CALO'
432 else:
433 dbname ='COOLOFL_TILE'
434 schema=dbname+'/CONDBR2'
435 if isinstance(db, str):
436 if 'OFLP200' in db or 'MC' in db:
437 schema=dbname+'/OFLP200'
438 if not globalTag.startswith("OFLCOND"):
439 if globalTag.startswith("RUN"):
440 globalTag='OFLCOND-'+globalTag
441 log.info("Using Simulation global tag \'%s\'", globalTag)
442 elif 'COMP200' in db or 'RUN1' in db:
443 schema=dbname+'/COMP200'
444 if globalTag!='UPD1' and globalTag!='UPD4' and ('UPD1' in globalTag or 'UPD4' in globalTag or 'COND' not in globalTag):
445 if not findTAG:
446 log.info("Using suffix \'%s\' as it is", globalTag)
447 else:
448 findTAG = False
449 globalTag='COMCOND-BLKPA-RUN1-06'
450 log.info("Using RUN1 global tag \'%s\'", globalTag)
451 if schema == dbname+'/CONDBR2':
452 if globalTag=='CURRENT' or globalTag=='UPD4' or globalTag=='':
453 globalTag=getAliasFromFile('Current')
454 log.info("Resolved CURRENT globalTag to \'%s\'", globalTag)
455 elif globalTag=='CURRENTES' or globalTag=='UPD1':
456 globalTag=getAliasFromFile('CurrentES')
457 log.info("Resolved CURRENT ES globalTag to \'%s\'", globalTag)
458 elif globalTag=='NEXT':
459 globalTag=getAliasFromFile('Next')
460 log.info("Resolved NEXT globalTag to \'%s\'", globalTag)
461 elif globalTag=='NEXTES':
462 globalTag=getAliasFromFile('NextES')
463 log.info("Resolved NEXT ES globalTag to \'%s\'", globalTag)
464 globalTag=globalTag.replace('*','')
465 if not findTAG and ('UPD1' in globalTag or 'UPD4' in globalTag or 'COND' not in globalTag):
466 tag = TileCalibUtils.getFullTag(folderPath, globalTag)
467 if tag.startswith('Calo') and 'NoiseCell' not in tag:
468 tag='CALO'+tag[4:]
469 tag=tag.replace('Pileupnoiselumi','PileUpNoiseLumi')
470 log.info("Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
471 else:
472 if not isinstance(db, str):
473 try:
474 folder = db.getFolder(folderPath)
475 if findTAG:
476 tag = findTag(folder,gTAG)
477 else:
478 tag = folder.resolveTag(globalTag)
479 log.info("Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
480 schema=""
481 except Exception as e:
482 log.warning(e)
483 log.warning("Using %s to resolve globalTag",schema)
484 if len(schema):
485 dbr = openDbConn(schema,'READONLY')
486 folder = dbr.getFolder(folderPath)
487 if findTAG:
488 tag = findTag(folder,gTAG)
489 else:
490 tag = folder.resolveTag(globalTag)
491 dbr.closeDatabase()
492 log.info("Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
493
494 return tag
495
496#
497#____________________________________________________________________
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 aliascalibrun = os.getenv(
98 'TILE_ALIAS_CALIBRUN',
99 '/afs/cern.ch/user/a/atlcond/scratch0/nemo/prod/web/calibruns.txt'
100 )
101 if not aliascalibrun or not os.path.exists(aliascalibrun):
102 log.warning("Prompt calib run file not found: %s", aliascalibrun)
103 raise FileNotFoundError(aliascalibrun)
104 fin = open(aliascalibrun, 'r').read().split()
105 for line in fin:
106 try:
107 if line:
108 promptCalibRuns.append( int(line) )
109 except ValueError:
110 pass
111 except Exception:
112 promptCalibRuns=[]
113
114 if len(promptCalibRuns)==0:
115
116 urls = ["http://pcata007.cern.ch/cgi-bin/getBulkRunNumber.py",
117 "http://pcata007.cern.ch/latestRun"]
118
119 run=0
120 for url in urls:
121 try:
122 for line in urlopen(url).readlines():
123 r=line.strip()
124 if r.isdigit():
125 run=int(r)
126 break
127 if run>0:
128 promptCalibRuns=[run]
129 break
130 except Exception:
131 continue
132
133 if len(promptCalibRuns) >= 1:
134 promptCalibRuns.sort()
135 return promptCalibRuns[0]
136 else:
137 return getNextRunNumber()
138
139#
140#______________________________________________________________________
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179
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 171 of file TileCalibTools.py.

171def getTilePrefix(ofl=True,splitOnlInOflSchema=True):
172 """
173 Returns the common Tile prefix used for all COOL folders.
174 ofl = False ... single version folders
175 ofl = True ... multiversion folders
176 splitOnlInOflSchema = False ... offline only folders or
177 splitOnline folders in Online schema
178 splitOnlInOflSchema = True ... splitOnlineFolders in
179 offline schema
180 """
181 if ofl:
182 if splitOnlInOflSchema:
183 return "/TILE/OFL02/"
184 else:
185 return "/TILE/OFL01/"
186 else:
187 return "/TILE/ONL01/"
188
189#
190#______________________________________________________________________

◆ getTilePrefixes()

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

Definition at line 191 of file TileCalibTools.py.

191def getTilePrefixes():
192 """
193 Returns a list of all TILE folder prefixes
194 """
195 return ["/TILE/ONL01/","/TILE/OFL01/","/TILE/OFL02/"]
196
197#
198#______________________________________________________________________

◆ moduleListToString()

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

Definition at line 547 of file TileCalibTools.py.

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

◆ 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 219 of file TileCalibTools.py.

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

◆ 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 295 of file TileCalibTools.py.

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

◆ 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 269 of file TileCalibTools.py.

269def openDbOracle(db, schema, folder):
270 """
271 Opens a COOL db connection.
272 - db: The DB type. The following names are recognized:
273 * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
274 - schema: Full schema string for sqlite file, dbname will be extracted from this string
275 - folder: Fill folder path, schema string will be construced using folder name
276 """
277
278 connStr = 'COOL'
279 if '/OFL' in folder.upper():
280 connStr += 'OFL_'
281 else:
282 connStr += 'ONL_'
283 connStr += folder.strip('/').split('/')[0].upper()
284 dbn=schema.split('dbname=')
285 if len(dbn)==2:
286 dbname=dbn[1].split(';')[0]
287 else:
288 dbname='CONDBR2'
289 connStr += '/' + dbname
290
291 return openDbConn(connStr,db)
292
293#
294#______________________________________________________________________
int upper(int c)

◆ runLumiFromCoolTime()

python.TileCalibTools.runLumiFromCoolTime ( iov)

Definition at line 510 of file TileCalibTools.py.

510def runLumiFromCoolTime(iov):
511 return (int(iov >> 32), int(iov & 0xFFFFFFFF))
512
513#
514#____________________________________________________________________

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.