246 def write_new_file(self,new_file_name):
248 print (
" Writing output to file " , new_file_name)
250 dbSvc = cool.DatabaseSvcFactory.databaseService()
251 connectString =
'sqlite://;schema='+new_file_name+
';dbname=L1CALO'
253 print (
'recreating database file',new_file_name)
254 dbSvc.dropDatabase( connectString )
255 db = dbSvc.createDatabase( connectString )
257 spec = cool.RecordSpecification()
258 spec.extend(
'RxMean',cool.StorageType.Float)
260 spec.extend(
'AffectedCells1', cool.StorageType.UChar)
261 spec.extend(
'AffectedCells2', cool.StorageType.UChar)
262 spec.extend(
'AffectedCells3', cool.StorageType.UChar)
263 spec.extend(
'AffectedCells4', cool.StorageType.UChar)
265 spec.extend(
'LayerMean1',cool.StorageType.Float)
266 spec.extend(
'LayerMean2',cool.StorageType.Float)
267 spec.extend(
'LayerMean3',cool.StorageType.Float)
268 spec.extend(
'LayerMean4',cool.StorageType.Float)
270 now =
int(time.time())
272 since = now*self.UNIX2COOL
273 until = cool.ValidityKeyMax
274 db.createFolderSet(
'/TRIGGER')
275 db.createFolderSet(
'/TRIGGER/L1Calo')
276 db.createFolderSet(
'/TRIGGER/L1Calo/V1')
277 db.createFolderSet(
'/TRIGGER/L1Calo/V1/Results')
280 folder_description =
"<timeStamp>time</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\"/></addrHeader><typeName>CondAttrListCollection</typeName>"
281 f = db.createFolder(
"/TRIGGER/L1Calo/V1/Results/HVCorrections" , spec,folder_description)
284 for i
in self.reference_HV.
keys():
286 data = cool.Record( spec )
291 for ilayer
in range(4):
292 if self.NCells[i][ilayer]>0:
293 MeanHV += self.reference_HV[i][ilayer]*self.NCells[i][ilayer]
294 TotalNrCells += self.NCells[i][ilayer]
296 MeanHV /= TotalNrCells
299 data[
'RxMean'] = MeanHV
301 data[
'LayerMean1'] = self.reference_HV[i][0]
302 data[
'LayerMean2'] = self.reference_HV[i][1]
303 data[
'LayerMean3'] = self.reference_HV[i][2]
304 data[
'LayerMean4'] = self.reference_HV[i][3]
306 data[
'AffectedCells1'] = struct.pack(
'B',self.reference_AffectedCells[i][0])
307 data[
'AffectedCells2'] = struct.pack(
'B',self.reference_AffectedCells[i][1])
308 data[
'AffectedCells3'] = struct.pack(
'B',self.reference_AffectedCells[i][2])
309 data[
'AffectedCells4'] = struct.pack(
'B',self.reference_AffectedCells[i][3])
311 f.storeObject(since,until, data,
int(i,16) )