4 from PyCool
import cool
7 desc=
'<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
8 spec = cool.RecordSpecification()
9 spec.extend(
'LBAvInstLumi',cool.StorageType.Float)
10 spec.extend(
'Valid',cool.StorageType.UInt32)
11 folderSpec=cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
13 return db.createFolder(name,folderSpec,desc,
True)
22 if db.existsFolder(folderName):
23 folder = db.getFolder(folderName)
26 print(
"Folder", folderName,
"does not exit yet. Creating it now.")
29 since=cool.ValidityKeyMin
30 until=cool.ValidityKeyMax
32 payload = cool.Record(folder.payloadSpecification())
33 payload[
"LBAvInstLumi"]=data
35 folder.storeObject(since,until,payload,cool.ChannelId(0),tag)
36 folder.storeObject(since,until,payload,cool.ChannelId(1),tag)
41 if __name__==
'__main__':
44 if len(sys.argv)<2
or sys.argv[1]==
"-h" or sys.argv[1]==
"--help":
47 print(
"fillPileUpNoiseLumi.py lumi")
51 from LArConditionsCommon.getCurrentFolderTag
import getCurrentFolderTag
54 print(
"Failed to get CURRENT folder level tag!")
60 print(
"Argument is not a float")
64 sqlitename=
"PileUpNoiseLumi.db"
65 if os.access(sqlitename,os.F_OK):
66 print(
"ERROR: File",sqlitename,
"exists already. Please delete!")
69 print(
"Using folder-level tag:",current)
70 connect=
"sqlite://;schema="+sqlitename+
";dbname=CONDBR2"
71 dbSvc = cool.DatabaseSvcFactory.databaseService()
73 db = dbSvc.openDatabase(connect,
False)
75 print(
"Database does not exist, try to create it ...")
77 db=dbSvc.createDatabase(connect)
78 except Exception
as e:
80 print(
"Could not create database")