 |
ATLAS Offline Software
|
|
| def | getLastRunNumber () |
| |
| def | getPromptCalibRunNumber () |
| |
| def | getAliasFromFile (aliastype='Current') |
| |
| def | getTilePrefix (ofl=True, splitOnlInOflSchema=True) |
| |
| def | getTilePrefixes () |
| |
| def | getAthenaFolderDescr (type="run-lumi") |
| |
| def | getAthenaFolderType (folderDescr) |
| |
| def | openDb (db, instance, mode="READONLY", schema="COOLOFL_TILE", sqlfn="tileSqlite.db") |
| |
| def | openDbOracle (db, schema, folder) |
| |
| def | openDbConn (connStr, mode="READONLY") |
| |
| def | coolTimeFromRunLumi (runNum, lbkNum) |
| |
| def | decodeTimeString (timeString) |
| |
| def | getCoolValidityKey (pointInTime, isSince=True) |
| |
| def | getFolderTag (db, folderPath, globalTag) |
| |
| def | findTag (folder, tag) |
| |
| def | runLumiFromCoolTime (iov) |
| |
| def | copyFolder (dbr, dbw, folder, tagr, tagw, chanNum, pointInTime1, pointInTime2) |
| |
◆ coolTimeFromRunLumi()
| def python.TileCalibTools.coolTimeFromRunLumi |
( |
|
runNum, |
|
|
|
lbkNum |
|
) |
| |
Returns COOL timeStamp build from run and lumi block numbers
Definition at line 344 of file TileCalibTools.py.
346 Returns COOL timeStamp build from run and lumi block numbers
348 return (
int(runNum)<<32) +
int(lbkNum)
◆ copyFolder()
| def python.TileCalibTools.copyFolder |
( |
|
dbr, |
|
|
|
dbw, |
|
|
|
folder, |
|
|
|
tagr, |
|
|
|
tagw, |
|
|
|
chanNum, |
|
|
|
pointInTime1, |
|
|
|
pointInTime2 |
|
) |
| |
Definition at line 494 of file TileCalibTools.py.
494 def copyFolder(dbr, dbw, folder, tagr, tagw, chanNum, pointInTime1, pointInTime2):
496 log.info(
"Copy channel %i", chanNum)
498 folderR = dbr.getFolder(folder)
499 folderW = dbw.getFolder(folder)
501 chansel = cool.ChannelSelection(chanNum)
508 objs = folderR.browseObjects(iov1,iov2,chansel)
511 objs = folderR.browseObjects(iov1,iov2,chansel,tagr)
512 while objs.goToNext():
513 obj=objs.currentRef()
514 sinceCool=obj.since()
517 untilCool=obj.until()
521 log.debug(
"Copy entry: [%i,%i] - [%i,%i]: %s", sinceTup[0],sinceTup[1],untilTup[0],untilTup[1], data)
522 folderW.storeObject(sinceCool, untilCool, data, chanNum, tagw, multiVersion)
◆ decodeTimeString()
| def python.TileCalibTools.decodeTimeString |
( |
|
timeString | ) |
|
Retruns UNIX time stamp given an input time string
Definition at line 352 of file TileCalibTools.py.
354 Retruns UNIX time stamp given an input time string
356 return int(time.mktime(time.strptime(timeString,
"%Y-%m-%d %H:%M:%S")))
◆ findTag()
| def python.TileCalibTools.findTag |
( |
|
folder, |
|
|
|
tag |
|
) |
| |
Definition at line 477 of file TileCalibTools.py.
478 taglist=folder.listTags()
485 return 'tag-not-found'
◆ getAliasFromFile()
| def python.TileCalibTools.getAliasFromFile |
( |
|
aliastype = 'Current' | ) |
|
Return name of top-level tag for 'Current' or 'CurrentES' or 'Next' or 'NextES' aliases
Definition at line 126 of file TileCalibTools.py.
128 Return name of top-level tag for 'Current' or 'CurrentES' or 'Next' or 'NextES' aliases
131 aliasfolder =
'/afs/cern.ch/atlas/conditions/poolcond/buffer/BestKnowledge'
133 falias =
open(
'%s/%s' % (aliasfolder, aliastype))
134 alias = falias.readline()
136 return alias.replace(
'\n',
'').
replace(
'*',
'')
139 aliasfolder = os.getcwd()+
'/BestKnowledge'
140 print(
"Looking for %s in %s" % (aliastype,aliasfolder))
142 falias =
open(
'%s/%s' % (aliasfolder, aliastype))
143 alias = falias.readline()
145 return alias.replace(
'\n',
'').
replace(
'*',
'')
147 return aliastype.upper()
◆ getAthenaFolderDescr()
| def 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 179 of file TileCalibTools.py.
181 Returns the run-lumi type folder description needed to read back the folder content
182 as a CondAttrListCollection in Athena.
184 desc =
'<timeStamp>'+type+
'</timeStamp>'
185 desc+=
'<addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader>'
186 desc+=
'<typeName>CondAttrListCollection</typeName>'
◆ getAthenaFolderType()
| def python.TileCalibTools.getAthenaFolderType |
( |
|
folderDescr | ) |
|
Definition at line 191 of file TileCalibTools.py.
192 type = re.compile(
".*<timeStamp>(.*)</timeStamp>.*").
search(folderDescr)
194 raise Exception(
"No folder type info found in \'%s\'" % folderDescr)
195 return type.groups()[0]
◆ getCoolValidityKey()
| def 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 360 of file TileCalibTools.py.
362 The interpretation of pointInTime depends on their type:
363 - tuple(int,int) : run and lbk number
364 - integer : Values are interpreted as unix time stamps
365 - string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
371 if isinstance(pointInTime, str):
375 if isinstance(pointInTime, int):
377 validityKey = pointInTime * UNIX2COOL
380 validityKey =
int(time.time()) * UNIX2COOL
382 validityKey = cool.ValidityKeyMax
384 elif isinstance(pointInTime, tuple):
388 raise Exception(
"Unrecognized pointInTime type=%s" %
type(pointInTime))
389 return cool.ValidityKey(validityKey)
◆ getFolderTag()
| def python.TileCalibTools.getFolderTag |
( |
|
db, |
|
|
|
folderPath, |
|
|
|
globalTag |
|
) |
| |
Definition at line 394 of file TileCalibTools.py.
397 gTAG = globalTag.upper()
398 findTAG = (gTAG ==
"ANY" or gTAG ==
"FIRST" or gTAG ==
"LAST")
399 if globalTag.startswith(
"/")
or globalTag.startswith(
"TileO")
or globalTag.upper().startswith(
"CALO"):
401 log.warning(
"Using tag as-is for folder %s", folderPath)
402 elif '/TILE/ONL01' in folderPath:
403 log.info(
"Using empty tag for single-version folder %s", folderPath)
404 elif globalTag.startswith(
" "):
405 log.warning(
"Using empty tag for folder %s", folderPath)
408 log.warning(
"Using tag with empty suffix for folder %s", folderPath)
410 if folderPath.startswith(
'/CALO'):
411 dbname =
'COOLOFL_CALO' if folderPath.startswith(
'/CALO/Ofl')
else 'COOLONL_CALO'
413 dbname =
'COOLOFL_TILE'
414 schema=dbname+
'/CONDBR2'
415 if isinstance(db, str):
416 if 'OFLP200' in db
or 'MC' in db:
417 schema=dbname+
'/OFLP200'
418 if not globalTag.startswith(
"OFLCOND"):
419 if globalTag.startswith(
"RUN"):
420 globalTag=
'OFLCOND-'+globalTag
421 log.info(
"Using Simulation global tag \'%s\'", globalTag)
422 elif 'COMP200' in db
or 'RUN1' in db:
423 schema=dbname+
'/COMP200'
424 if globalTag!=
'UPD1' and globalTag!=
'UPD4' and (
'UPD1' in globalTag
or 'UPD4' in globalTag
or 'COND' not in globalTag):
426 log.info(
"Using suffix \'%s\' as it is", globalTag)
429 globalTag=
'COMCOND-BLKPA-RUN1-06'
430 log.info(
"Using RUN1 global tag \'%s\'", globalTag)
431 if schema == dbname+
'/CONDBR2':
432 if globalTag==
'CURRENT' or globalTag==
'UPD4' or globalTag==
'':
434 log.info(
"Resolved CURRENT globalTag to \'%s\'", globalTag)
435 elif globalTag==
'CURRENTES' or globalTag==
'UPD1':
437 log.info(
"Resolved CURRENT ES globalTag to \'%s\'", globalTag)
438 elif globalTag==
'NEXT':
440 log.info(
"Resolved NEXT globalTag to \'%s\'", globalTag)
441 elif globalTag==
'NEXTES':
443 log.info(
"Resolved NEXT ES globalTag to \'%s\'", globalTag)
444 globalTag=globalTag.replace(
'*',
'')
445 if not findTAG
and (
'UPD1' in globalTag
or 'UPD4' in globalTag
or 'COND' not in globalTag):
447 if tag.startswith(
'Calo')
and 'NoiseCell' not in tag:
449 log.info(
"Resolved localTag \'%s\' to folderTag \'%s\'", globalTag,tag)
451 if not isinstance(db, str):
453 folder = db.getFolder(folderPath)
457 tag = folder.resolveTag(globalTag)
458 log.info(
"Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
460 except Exception
as e:
462 log.warning(
"Using %s to resolve globalTag",schema)
465 folder = dbr.getFolder(folderPath)
469 tag = folder.resolveTag(globalTag)
471 log.info(
"Resolved globalTag \'%s\' to folderTag \'%s\'", globalTag,tag)
◆ getLastRunNumber()
| def python.TileCalibTools.getLastRunNumber |
( |
| ) |
|
Return the run number of next run to be taken in the pit
Definition at line 55 of file TileCalibTools.py.
57 Return the run number of next run to be taken in the pit
60 urls = [
"http://atlas-service-db-runlist.web.cern.ch/atlas-service-db-runlist/cgi-bin/latestRun.py",
61 "http://pcata007.cern.ch/cgi-bin/getLastRunNumber.py",
62 "http://pcata007.cern.ch/latestRun"]
67 for line
in urlopen(url).readlines():
77 return max(run+1,222222)
◆ getPromptCalibRunNumber()
| def python.TileCalibTools.getPromptCalibRunNumber |
( |
| ) |
|
Return the minimal run number of runs in prompt calibration loop
Definition at line 81 of file TileCalibTools.py.
83 Return the minimal run number of runs in prompt calibration loop
89 fin =
open(
"/afs/cern.ch/user/a/atlcond/scratch0/nemo/prod/web/calibruns.txt",
"r").
read().
split()
93 promptCalibRuns.append(
int(line) )
99 if len(promptCalibRuns)==0:
101 urls = [
"http://pcata007.cern.ch/cgi-bin/getBulkRunNumber.py",
102 "http://pcata007.cern.ch/latestRun"]
107 for line
in urlopen(url).readlines():
113 promptCalibRuns=[run]
118 if len(promptCalibRuns) >= 1:
119 promptCalibRuns.sort()
120 return promptCalibRuns[0]
◆ getTilePrefix()
| def 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 151 of file TileCalibTools.py.
153 Returns the common Tile prefix used for all COOL folders.
154 ofl = False ... single version folders
155 ofl = True ... multiversion folders
156 splitOnlInOflSchema = False ... offline only folders or
157 splitOnline folders in Online schema
158 splitOnlInOflSchema = True ... splitOnlineFolders in
162 if splitOnlInOflSchema:
163 return "/TILE/OFL02/"
165 return "/TILE/OFL01/"
167 return "/TILE/ONL01/"
◆ getTilePrefixes()
| def python.TileCalibTools.getTilePrefixes |
( |
| ) |
|
Returns a list of all TILE folder prefixes
Definition at line 171 of file TileCalibTools.py.
173 Returns a list of all TILE folder prefixes
175 return [
"/TILE/ONL01/",
"/TILE/OFL01/",
"/TILE/OFL02/"]
◆ openDb()
| def 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 199 of file TileCalibTools.py.
199 def openDb(db, instance, mode="READONLY", schema="COOLOFL_TILE", sqlfn="tileSqlite.db"):
201 Opens a COOL db connection.
202 - db: The DB type. The following names are recognized:
203 * SQLITE: Opens file mentioned in sqlfn parameter
204 * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
205 - instance: One of valid instances - CONDBR2 OFLP200 COMP200 CMCP200
206 - mode: Can be READONLY (default), RECREATE or UPDATE
207 - schema: One of valid schemas - COOLONL_CALO COOLOFL_CALO COOLONL_LAR COOLOFL_LAR COOLONL_TILE COOLOFL_TILE
208 - sqlfn: Name of sqlite file if db is SQLITE
212 validDb = [
"SQLITE",
"ORACLE",
"FRONTIER"]
213 if db
not in validDb:
214 raise Exception(
"DB not valid: %s, valid DBs are: %s" % (db,validDb) )
215 elif db ==
"ORACLE" or db ==
"FRONTIER":
219 validInstance = [
"COMP200",
"CONDBR2",
"CMCP200",
"OFLP200"]
220 if instance
not in validInstance:
221 raise Exception(
"Instance not valid: %s, valid instance are: %s" % (instance,validInstance) )
224 validSchema = [
"COOLONL_TILE",
"COOLOFL_TILE"]
225 if schema
not in validSchema:
226 raise Exception(
"Schema not valid: %s, valid schemas are: %s" % (schema,validSchema) )
231 if mode==
"READONLY" and not os.path.exists(sqlfn):
232 raise Exception(
"Sqlite file %s does not exist" % (sqlfn) )
233 if (mode==
"RECREATE" or mode==
"UPDATE")
and not os.path.exists(os.path.dirname(sqlfn)):
234 dirn=os.path.dirname(sqlfn)
237 connStr=
"sqlite://X;schema=%s;dbname=%s" % (sqlfn,instance)
239 connStr=
'frontier://ATLF/()/;schema=ATLAS_%s;dbname=%s' % (schema,instance)
241 connStr=
'oracle://%s;schema=ATLAS_%s;dbname=%s' % (
'ATLAS_COOLPROD',schema,instance)
243 connStr=schema+
'/'+instance
◆ openDbConn()
| def 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 275 of file TileCalibTools.py.
277 Opens a COOL db connection.
278 - connStr: The DB connection string
279 - mode: Can be READONLY (default), RECREATE or UPDATE
280 or ORACLE or FRONTIER if connStr is only short name of the database
284 splitname=connStr.split(
'/')
285 if (len(splitname)!=2):
289 instance=splitname[1]
291 connStr_new=
'oracle://%s;schema=ATLAS_%s;dbname=%s' % (
'ATLAS_COOLPROD',schema,instance)
293 connStr_new=
'frontier://ATLF/()/;schema=ATLAS_%s;dbname=%s' % (schema,instance)
296 dbSvc = cool.DatabaseSvcFactory.databaseService()
297 log.info(
"---------------------------------------------------------------------------------" )
298 log.info(
"-------------------------- TileCalibTools.openDbConn ----------------------------" )
299 log.info(
"- using COOL version %s", dbSvc.serviceVersion() )
300 log.info(
"- opening TileDb: %s",connStr_new )
301 log.info(
"- mode: %s", mode )
302 log.info(
"---------------------------------------------------------------------------------" )
305 if mode
in [
"READONLY",
"ORACLE",
"FRONTIER",
"",
None]:
308 db=dbSvc.openDatabase(connStr_new,
True)
309 except Exception
as e:
311 log.critical(
"Could not connect to %s" % connStr_new )
314 elif mode==
"RECREATE":
316 dbSvc.dropDatabase(connStr_new)
318 db = dbSvc.createDatabase(connStr_new)
319 except Exception
as e:
321 log.critical(
"Could not create database, giving up..." )
327 db=dbSvc.openDatabase(connStr_new,
False)
328 except Exception
as e:
330 log.warning(
"Could not connect to \'%s\', trying to create it....", connStr_new )
332 db=dbSvc.createDatabase(connStr_new)
333 except Exception
as e:
335 log.critical(
"Could not create database, giving up..." )
339 log.error(
"Mode \"%s\" not recognized", mode )
◆ openDbOracle()
| def 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 249 of file TileCalibTools.py.
251 Opens a COOL db connection.
252 - db: The DB type. The following names are recognized:
253 * ORACLE or FRONTIER: Opens ORACLE DB, forces READONLY
254 - schema: Full schema string for sqlite file, dbname will be extracted from this string
255 - folder: Fill folder path, schema string will be construced using folder name
259 if '/OFL' in folder.upper():
263 connStr += folder.strip(
'/').
split(
'/')[0].
upper()
264 dbn=schema.split(
'dbname=')
266 dbname=dbn[1].
split(
';')[0]
269 connStr +=
'/' + dbname
◆ runLumiFromCoolTime()
| def python.TileCalibTools.runLumiFromCoolTime |
( |
|
iov | ) |
|
◆ LASPARTCHAN
| python.TileCalibTools.LASPARTCHAN |
◆ log
| python.TileCalibTools.log |
◆ MAXLBK
| python.TileCalibTools.MAXLBK |
◆ MAXRUN
| python.TileCalibTools.MAXRUN |
◆ MINLBK
| python.TileCalibTools.MINLBK |
◆ MINRUN
| python.TileCalibTools.MINRUN |
◆ UNIX2COOL
| python.TileCalibTools.UNIX2COOL |
◆ UNIXTMAX
| python.TileCalibTools.UNIXTMAX |
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
void print(char *figname, TCanvas *c1)
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.