2 from PyCool
import cool
7 from AthenaCommon.Logging
import logging
8 msg = logging.getLogger(
'dummyLHCFillDB' )
12 def createSqlite(sqliteName,folderName="/TDAQ/OLC/LHC/FILLPARAMS"):
14 dbSvc = cool.DatabaseSvcFactory.databaseService()
16 if os.access(sqliteName,os.R_OK):
17 msg.debug(
"UPDATING existing sqlite file %s" , sqliteName)
18 db=dbSvc.openDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2",
False)
20 msg.debug(
"Creating new sqlite file %s" , sqliteName)
21 db=dbSvc.createDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2")
24 spec = cool.RecordSpecification()
25 spec.extend(
"Beam1Bunches",cool.StorageType.UInt32)
26 spec.extend(
"Beam2Bunches",cool.StorageType.UInt32)
27 spec.extend(
"LuminousBunches",cool.StorageType.UInt32)
28 spec.extend(
"BCIDmasks",cool.StorageType.Blob64k)
30 descr=
'<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
31 if db.existsFolder(folderName):
32 folder=db.getFolder(folderName)
34 msg.debug(
"Creating COOL folder/tag %s" , (folderName))
35 folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
36 folder = db.createFolder(folderName, folderSpec, descr,
True)
45 dbSvc = cool.DatabaseSvcFactory.databaseService()
47 if os.access(sqliteName,os.R_OK):
48 msg.debug(
"UPDATING existing sqlite file %s" , sqliteName)
49 db=dbSvc.openDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2",
False)
51 msg.debug(
"Creating new sqlite file %s" , sqliteName)
52 db=dbSvc.createDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2")
57 spec = cool.RecordSpecification()
58 spec.extend(
"Beam1Intensity",cool.StorageType.Float)
59 spec.extend(
"Beam2Intensity",cool.StorageType.Float)
61 spec.extend(
"Beam1IntensityAll",cool.StorageType.Float)
62 spec.extend(
"Beam2IntensityAll",cool.StorageType.Float)
63 spec.extend(
"Beam1IntensityStd",cool.StorageType.Float)
64 spec.extend(
"Beam2IntensityStd",cool.StorageType.Float)
65 spec.extend(
"Beam1IntensityAllStd",cool.StorageType.Float)
66 spec.extend(
"Beam2IntensityAllStd",cool.StorageType.Float)
68 spec.extend(
"RunLB",cool.StorageType.UInt63)
69 spec.extend(
"Valid",cool.StorageType.UInt32)
73 descr=
'<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
75 if db.existsFolder(folderName):
76 msg.debug(
"folder exist")
77 folder=db.getFolder(folderName)
79 msg.debug(
"Creating COOL folder/tag %s" , (folderName))
80 folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
81 folder = db.createFolder(folderName, folderSpec, descr,
True)
90 dbSvc = cool.DatabaseSvcFactory.databaseService()
92 if os.access(sqliteName,os.R_OK):
93 msg.debug(
"UPDATING existing sqlite file %s" , sqliteName)
94 db=dbSvc.openDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2",
False)
96 msg.debug(
"Creating new sqlite file %s" , sqliteName)
97 db=dbSvc.createDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2")
102 spec = cool.RecordSpecification()
103 spec.extend(
"RunLB",cool.StorageType.UInt63)
104 spec.extend(
"B1BunchAverage",cool.StorageType.Float)
105 spec.extend(
"B2BunchAverage",cool.StorageType.Float)
107 spec.extend(
"B1BunchIntensities",cool.StorageType.Blob64k)
108 spec.extend(
"B2BunchIntensities",cool.StorageType.Blob64k)
110 spec.extend(
"Valid",cool.StorageType.UInt32)
114 descr=
'<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
116 if db.existsFolder(folderName):
117 msg.debug(
"folder exist")
118 folder=db.getFolder(folderName)
120 msg.debug(
"Creating COOL folder/tag %s" , (folderName))
121 folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
122 folder = db.createFolder(folderName, folderSpec, descr,
True)
128 def fillFolder(folder,data=[],iovMin=cool.ValidityKeyMin,iovMax=cool.ValidityKeyMax):
135 if (bcid & 0x1): nB1+=1
136 if (bcid & 0x2): nB2+=1
137 if (bcid & 0x3 == 0x3): nColl+=1
141 payload=cool.Record(folder.payloadSpecification())
142 payload[
'Beam1Bunches']=nB1
143 payload[
'Beam2Bunches']=nB2
144 payload[
'LuminousBunches']=nColl
145 btype=getattr(ROOT,
"coral::Blob")
150 for i,d
in enumerate(data):
154 payload[
'BCIDmasks']=bcmask
157 msg.debug(
"Storing FILLPARAMS object")
158 folder.storeObject(iovMin, iovMax, payload, cool.ChannelId(0))
164 def fillFolderForAvg(folder,data=[],iovMin=cool.ValidityKeyMin,iovMax=cool.ValidityKeyMax):
171 if (bcid & 0x1): nB1+=1
172 if (bcid & 0x2): nB2+=1
173 if (bcid & 0x3 == 0x3): nColl+=1
176 for chanNum
in range(0,4):
177 payload=cool.Record(folder.payloadSpecification())
179 payload[
'Beam1Intensity']=1.5+1.5*chanNum
180 payload[
'Beam2Intensity']=1.5+1.5*chanNum
181 payload[
'Beam1IntensityAll']=1.5+1.5*chanNum
182 payload[
'Beam2IntensityAll']=1.5+1.5*chanNum
183 payload[
'Beam1IntensityStd']=1.5+1.5*chanNum
184 payload[
'Beam2IntensityStd']=1.5+1.5*chanNum
185 payload[
'Beam1IntensityAllStd']=1.5+1.5*chanNum
186 payload[
'Beam2IntensityAllStd']=1.5+1.5*chanNum
187 payload[
'RunLB']=430897
191 channelId = cool.ChannelId(chanNum)
192 folder.storeObject(iovMin, iovMax, payload, channelId)
193 msg.debug(
"Storing LBDATA3 object")
201 def fillFolderForInt(folder,data=[],iovMin=cool.ValidityKeyMin,iovMax=cool.ValidityKeyMax):
203 for chanNum
in range(0,2):
204 payload=cool.Record(folder.payloadSpecification())
206 payload[
'RunLB']=430897
207 payload[
'B1BunchAverage']=1.5+1.5*chanNum
208 payload[
'B2BunchAverage']=1.5+1.5*chanNum
211 btype=getattr(ROOT,
"coral::Blob")
214 bcmask_1.resize(3564)
217 bcmask_2.resize(3564)
219 for i,d
in enumerate(data):
222 for i,d
in enumerate(data):
225 payload[
'B1BunchIntensities']=bcmask_1
226 payload[
'B2BunchIntensities']=bcmask_2
229 channelId = cool.ChannelId(chanNum)
230 folder.storeObject(iovMin, iovMax, payload, channelId)
232 msg.debug(
"Storing BUNCHDATA object")
241 for i
in range(0,3564):
245 for i
in range (0,25):
248 for i
in range (3550,3564):
252 for i
in range (1000,1030):
261 for i
in range(0,3564):
264 t8b4e=[0x3,0x3,0x3,0x3, 0x3,0x3,0x3,0x3, 0x0,0x0,0x0,0x0]
266 for i
in range(0,20):
268 mask[100+i*12:100+(i+1)*12]=t8b4e
275 if __name__==
"__main__":
283 fillFolder(folder,d1,iovMin=cool.ValidityKey(1e6),iovMax=cool.ValidityKey(2e6))
284 fillFolder(folder,d2,iovMin=cool.ValidityKey(2e6),iovMax=cool.ValidityKey(3e6))