8 print (
"Syntax for open-end IoV time constant update")
9 print (
" The first parameter is the run number of IoV start, the second parameter is the lumiblock number for IoV start")
10 print (
" The third and fourth parameters are the Run/lb for IoV end (if run is -1, uses open ended IoV)")
11 print (
" the fifth and sixth parameters are the inputfile for allconstants and runconstants")
17 runSince = sys.argv[1]
18 lbkSince = sys.argv[2]
19 runUntil = sys.argv[3]
20 lbkUntil = sys.argv[4]
22 print (
"runSince ", runSince, lbkSince)
23 print (
"runUntil ", runUntil, lbkUntil)
26 from PyCool
import cool
27 from CaloCondBlobAlgs
import CaloCondTools, CaloCondLogger
34 inputFile_con = sys.argv[5]
35 inputFile_run = sys.argv[6]
38 iovSince_con = CaloCondTools.iovFromRunLumi(runSince,lbkSince)
39 iovUntil_con = CaloCondTools.iovFromRunLumi(runUntil,lbkUntil)
41 iovMin = cool.ValidityKeyMin
42 iovMax = cool.ValidityKeyMax
44 print (
" iovSince_con ", iovSince_con)
45 print (
" iovUntil_con ", iovUntil_con)
47 print (
" iovMin ", iovMin)
48 print (
" iovMax ", iovMax)
54 tagCon =
"LARTimeCorrectionOflNonRunCon-00"
55 tagRun =
"LARTimeCorrectionOflRunCon-00"
58 comment =
"Updated time constant values"
67 cppyy.makeClass(
'std::vector<float>')
70 log = CaloCondLogger.getLogger(
"CaloTimeConsWriter")
73 db = CaloCondTools.openDb(
'SQLITE',
'COMP200',
'UPDATE')
77 spec = cool.RecordSpecification()
78 spec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
81 folderPath = CaloCondTools.getCaloPrefix()+
"LAR/TimeCorrectionOfl/NonRunCon"
83 print (
"Filling COOL folder ", folderPath,
" with tag ", folderTag )
84 desc = CaloCondTools.getAthenaFolderDescr()
86 folder = db.getFolder(folderPath)
88 log.warning(
"Folder %s not found, creating it...", folderPath)
89 print (
"Folder ", folderPath,
" not found, creating it... " )
90 folderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION, spec)
91 folder = db.createFolder(folderPath, folderSpec, desc,
True)
97 gainDefVec_1 = g.std.vector(
'float')()
98 gainDefVec_1.push_back(0.)
99 gainDefVec_1.push_back(0.)
100 gainDefVec_1.push_back(0.)
101 gainDefVec_1.push_back(0.)
102 gainDefVec_1.push_back(0.)
103 gainDefVec_1.push_back(0.)
104 gainDefVec_1.push_back(0.)
105 gainDefVec_1.push_back(0.)
106 gainDefVec_1.push_back(0.)
107 gainDefVec_1.push_back(0.)
108 gainDefVec_1.push_back(0.)
109 gainDefVec_1.push_back(0.)
110 gainDefVec_1.push_back(0.)
111 gainDefVec_1.push_back(0.)
112 gainDefVec_1.push_back(0.)
113 gainDefVec_1.push_back(0.)
114 gainDefVec_1.push_back(0.)
115 gainDefVec_1.push_back(0.)
117 defVecLAr_1 = g.std.vector(
'std::vector<float>')()
118 defVecLAr_1.push_back(gainDefVec_1)
119 defVecLAr_1.push_back(gainDefVec_1)
120 defVecLAr_1.push_back(gainDefVec_1)
124 systemDict = { 0 : (31872, 0, defVecLAr_1 ,
'EMEC, z<0'),
125 1 : (54784, 31872, defVecLAr_1 ,
'EMB , z<0'),
126 2 : (54784, 86656, defVecLAr_1 ,
'EMB , z>0'),
127 3 : (31872, 141440, defVecLAr_1 ,
'EMEC, z>0'),
130 print (
"before fill virtual database")
131 for systemId, info
in systemDict.items():
132 print (
"before fill virtual database for sysId=", systemId)
134 print (
"Creating BLOB for Calo sysId=", systemId)
138 log.info(
"Creating BLOB for %s", sysName)
139 data_vir = cool.Record( spec )
140 blob_vir = data_vir[
'CaloCondBlob16M']
141 flt_vir = g.CaloCondBlobFlt.getInstance(blob_vir)
142 flt_vir.init(defVec,nChannel,1,author,comment)
144 log.info(
"Committing BLOB for %s", sysName)
145 channelId = cool.ChannelId(systemId)
146 log.info(
"Cool channel ID %s", channelId)
147 folder.storeObject(iovMin, iovMax, data_vir, channelId, folderTag)
149 print (
"after fill virtual database")
152 print (
"Prepare BLOB for Calo")
153 for systemId, info
in systemDict.items():
154 print (
"before check sysId=", systemId )
156 print (
"Creating BLOB for Calo sysId=", systemId )
160 log.info(
"Creating BLOB for %s", sysName)
161 data = cool.Record( spec )
162 blob = data[
'CaloCondBlob16M']
163 flt = g.CaloCondBlobFlt.getInstance(blob)
164 flt.init(defVec,nChannel,1,author,comment)
165 fltDict_1[systemId] = [data,flt]
167 print (
"BLOB size is ", kbSize,
" KB")
169 print (
"BLOB size is ", mbSize,
" MB")
173 print (
"before read time values from file")
174 lines =
open(inputFile_con,
"r").readlines()
175 print (
"before enter file line loop")
177 fields = line.split()
180 hash_offset =
int(systemDict[systemId][1])
182 hash = hash_raw - hash_offset
183 hash_check =
int(fields[7])
184 gain = g.CaloCondUtils.getDbCaloGain(
int(fields[8]))
204 if not hash==hash_check:
205 print (
"hash!=hash_check:", hash , hash_check)
210 print (
"hash>=31872 for hash ", hash ,
", sys ", systemId)
215 print (
"hash>=54784 for hash ", hash ,
", sys ", systemId)
220 print (
"hash>=54784 for hash ", hash ,
", sys ", systemId)
225 print (
"hash>=31872 for hash ", hash ,
", sys ", systemId)
228 print (systemId, hash, hash_check, gain, febchanOffset, errPar1, errPar2, enePar1, enePar2, enePar3, enePar4, enePar5, enePar6, enePar7, enePar8, enePar9, enePar10, enePar11, enePar12, enePar13, enePar14, enePar15)
230 print (
"before get flt")
231 flt = fltDict_1[systemId][1]
232 flt.setData(hash,gain,0,febchanOffset)
233 flt.setData(hash,gain,1,errPar1)
234 flt.setData(hash,gain,2,errPar2)
235 flt.setData(hash,gain,3,enePar1)
236 flt.setData(hash,gain,4,enePar2)
237 flt.setData(hash,gain,5,enePar3)
238 flt.setData(hash,gain,6,enePar4)
239 flt.setData(hash,gain,7,enePar5)
240 flt.setData(hash,gain,8,enePar6)
241 flt.setData(hash,gain,9,enePar7)
242 flt.setData(hash,gain,10,enePar8)
243 flt.setData(hash,gain,11,enePar9)
244 flt.setData(hash,gain,12,enePar10)
245 flt.setData(hash,gain,13,enePar11)
246 flt.setData(hash,gain,14,enePar12)
247 flt.setData(hash,gain,15,enePar13)
248 flt.setData(hash,gain,16,enePar14)
249 flt.setData(hash,gain,17,enePar15)
251 print (
"outside file line loop")
254 print (
"Committing BLOB for Calo")
255 for systemId, dataList
in fltDict_1.items():
257 sysName = systemDict[systemId][3]
258 log.info(
"Committing BLOB for %s", sysName)
259 channelId = cool.ChannelId(systemId)
260 log.info(
"Cool channel ID %s", channelId)
262 folder.storeObject(iovSince_con, iovUntil_con, data, channelId, folderTag)
264 except Exception
as e:
265 log.fatal(
"Exception caught: fill LAR/TimeCorrectionOfl/NonRunCon")
266 print (
"Exception caught: fill LAR/TimeCorrectionOfl/NonRunCon")
271 spec = cool.RecordSpecification()
272 spec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
275 folderPath = CaloCondTools.getCaloPrefix()+
"LAR/TimeCorrectionOfl/RunCon"
277 print (
"Filling COOL folder ", folderPath,
"with tag ", folderTag)
278 desc = CaloCondTools.getAthenaFolderDescr()
280 folder = db.getFolder(folderPath)
282 log.warning(
"Folder %s not found, creating it...", folderPath)
283 print (
"Folder ", folderPath,
" not found, creating it... " )
285 folder = db.createFolder(folderPath, spec, desc, cool.FolderVersioning.MULTI_VERSION,
True)
291 gainDefVec_2 = g.std.vector(
'float')()
292 gainDefVec_2.push_back(0.)
293 gainDefVec_2.push_back(0.)
295 defVecLAr_2 = g.std.vector(
'std::vector<float>')()
296 defVecLAr_2.push_back(gainDefVec_2)
297 defVecLAr_2.push_back(gainDefVec_2)
298 defVecLAr_2.push_back(gainDefVec_2)
301 print (
"before fill virtual database")
303 channelId = cool.ChannelId(1)
304 data_vir = cool.Record( spec )
305 blob_vir = data_vir[
'CaloCondBlob16M']
306 flt_vir = g.CaloCondBlobFlt.getInstance(blob_vir)
307 flt_vir.init(defVecLAr_2,nChannel,1,author,comment)
308 folder.storeObject(iovMin, iovMax, data_vir, channelId, folderTag)
309 print (
"after fill virtual database")
312 lines =
open(inputFile_run,
"r").readlines()
314 print (
"before fill run_list")
316 fields = line.split()
318 if run_list.count(run)==0:
321 print (
"after fill run_list")
323 print (
"number of runs: ", len(run_list))
324 print (
"run_list: ", run_list)
327 for runId
in run_list:
328 print (
"Creating BLOB for run ", runId )
330 data = cool.Record( spec )
331 blob = data[
'CaloCondBlob16M']
332 flt = g.CaloCondBlobFlt.getInstance(blob)
333 flt.init(defVecLAr_2,nChannel,1,author,comment)
334 fltDict_2[runId] = [data,flt]
335 kbSize =
float(blob.size()) / 1024.
336 print (
"BLOB size is ", kbSize,
" kB")
337 mbSize =
float(kbSize) / 1024
338 print (
"BLOB size is ", mbSize,
" MB")
341 print (
"before enter file line loop")
343 fields = line.split()
353 gain0 = g.CaloCondUtils.getDbCaloGain(0)
354 gain1 = g.CaloCondUtils.getDbCaloGain(1)
355 gain2 = g.CaloCondUtils.getDbCaloGain(2)
357 flt = fltDict_2[runId][1]
358 flt.setData(ftID,gain0,0,runOffsetHigh)
359 flt.setData(ftID,gain0,1,runEntryHigh)
360 flt.setData(ftID,gain1,0,runOffsetMed)
361 flt.setData(ftID,gain1,1,runEntryMed)
362 flt.setData(ftID,gain2,0,runOffsetLow)
363 flt.setData(ftID,gain2,1,runEntryLow)
365 print (runId, ftID, runOffsetHigh, runEntryHigh, runOffsetMed, runEntryMed, runOffsetLow, runEntryLow)
367 print (
"after enter file line loop")
369 for runId, dataList
in fltDict_2.items():
370 print (
"Committing BLOB for run ", runId)
371 iovSince_run = CaloCondTools.iovFromRunLumi(runId,lbkdown)
372 iovUntil_run = CaloCondTools.iovFromRunLumi(runId,lbkup)
373 channelId = cool.ChannelId(1)
374 print (
"Cool channel ID ", channelId )
376 folder.storeObject(iovSince_run, iovUntil_run, data, channelId, folderTag)
378 except Exception
as e:
379 log.fatal(
"Exception caught: LAR/TimeCorrectionOfl/RunCon")
380 print (
"Exception caught: LAR/TimeCorrectionOfl/RunCon")