7 from PyCool
import cool
8 from CaloCondBlobAlgs
import CaloCondTools, CaloCondLogger
17 inputFile =
"pedestal.txt"
21 iovSince = CaloCondTools.iovFromRunLumi(runSince,lbkSince)
22 iovUntil = cool.ValidityKeyMax
27 comment =
"to fill pedestal shifts"
37 cppyy.makeClass(
'std::vector<float>')
40 log = CaloCondLogger.getLogger(
"CaloNoiseWriter")
43 db = CaloCondTools.openDb(
'SQLITE',
'COMP200',
'UPDATE')
47 spec = cool.RecordSpecification()
48 spec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
51 folderPath = CaloCondTools.getCaloPrefix()+
"Pedestal/CellPedestal"
52 folderTag = g.CaloCondUtils.getFullTag(folderPath,tag)
53 log.info(
"Filling COOL folder %s with tag %s", folderPath, folderTag )
54 desc = CaloCondTools.getAthenaFolderDescr()
56 folder = db.getFolder(folderPath)
58 log.warning(
"Folder %s not found, creating it...", folderPath)
59 folder = db.createFolder(folderPath, spec, desc, cool.FolderVersioning.MULTI_VERSION,
True)
65 gainDefVec = g.std.vector(
'float')()
66 gainDefVec.push_back(0.)
67 gainDefVec.push_back(0.)
69 defVecLAr = g.std.vector(
'std::vector<float>')()
70 defVecLAr.push_back(gainDefVec)
71 defVecLAr.push_back(gainDefVec)
72 defVecLAr.push_back(gainDefVec)
74 defVecTile = g.std.vector(
'std::vector<float>')()
75 defVecTile.push_back(gainDefVec)
76 defVecTile.push_back(gainDefVec)
77 defVecTile.push_back(gainDefVec)
78 defVecTile.push_back(gainDefVec)
81 systemDict = { 0 : (31872, 0, defVecLAr ,
'EMEC, z<0'),
82 1 : (54784, 31872, defVecLAr ,
'EMB , z<0'),
83 2 : (54784, 86656, defVecLAr ,
'EMB , z>0'),
84 3 : (31872, 141440, defVecLAr ,
'EMEC, z>0'),
85 16 : ( 5632, 0, defVecLAr ,
'HEC' ),
86 32 : ( 3524, 0, defVecLAr ,
'FCAL' ),
87 48 : ( 5184, 0, defVecTile,
'TILE' )
90 for systemId, info
in six.iteritems (systemDict):
94 log.info(
"Creating BLOB for %s", sysName)
95 data = cool.Record( spec )
96 blob = data[
'CaloCondBlob16M']
97 flt = g.CaloCondBlobFlt.getInstance(blob)
98 flt.init(defVec,nChannel,2,author,comment)
99 fltDict[systemId] = [data,flt]
101 log.info(
"---> BLOB size is %4.1f kB", mbSize)
104 lines =
open(inputFile,
"r").readlines()
106 fields = line.split()
109 hash =
int(fields[1]) - systemDict[systemId][1]
110 gain = g.CaloCondUtils.getDbCaloGain(
int(fields[2]))
113 flt = fltDict[systemId][1]
115 flt.setData(hash,gain,0,noiseA)
116 flt.setData(hash,gain,1,noiseB)
119 for systemId, dataList
in six.iteritems (fltDict):
120 sysName = systemDict[systemId][3]
121 log.info(
"Committing BLOB for %s", sysName)
122 channelId = cool.ChannelId(systemId)
124 folder.storeObject(iovSince, iovUntil, data, channelId, folderTag)
128 log.fatal(
"Exception caught:")
129 log.fatal (traceback.format_exc())