4 from __future__
import print_function
10 print (
"Syntax for UPD4 open-end IoV noise update")
11 print (
" The first parameter is the run number of IoV start, the second parameter is the lumiblock number for IoV start")
12 print (
" The third and fourth parameter are the Run/lb for IoV end (if run is -1, uses open ended IoV)")
18 runSince = sys.argv[1]
19 lbkSince = sys.argv[2]
20 runUntil = sys.argv[3]
21 lbkUntil = sys.argv[4]
24 print (
"runUntil ", runUntil, lbkUntil)
25 print (
"tag ", runTag)
28 from PyCool
import cool
29 from CaloCondBlobAlgs
import CaloCondTools, CaloCondLogger
36 inputFile =
"calopedestal.txt"
38 iovSince = CaloCondTools.iovFromRunLumi(runSince,lbkSince)
39 iovUntil = cool.ValidityKeyMax
40 print (
" iovUntil max ",iovUntil)
42 print (
" use run number to define iobUntil ", runUntil)
43 iovUntil = CaloCondTools.iovFromRunLumi(runUntil,lbkUntil)
45 print (
" iovSince ", iovSince)
46 print (
" iovUntil ", iovUntil)
51 tag =
"CALOOflPedestalCellPedestal-UPD4-00"
52 elif runTag ==
"UPD1":
53 tag =
"CALOOflPedestalCellPedestal-UPD1-00"
55 print(
"expected 'UPD4' or 'BOTH'")
58 comment =
"Updated pedestal shift values"
68 getattr(cppyy.gbl,
'std::vector<float>')
72 log = CaloCondLogger.getLogger(
"CaloNoiseWriter")
75 db = CaloCondTools.openDb(
'SQLITE',
'CONDBR2',
'UPDATE')
79 spec = cool.RecordSpecification()
80 spec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
81 fspec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
84 folderPath = CaloCondTools.getCaloPrefix()+
"Ofl/Pedestal/CellPedestal"
86 log.info(
"Filling COOL folder %s with tag %s", folderPath, folderTag )
87 desc = CaloCondTools.getAthenaFolderDescr()
89 folder = db.getFolder(folderPath)
91 log.warning(
"Folder %s not found, creating it...", folderPath)
92 folder = db.createFolder(folderPath, fspec, desc,
True)
98 gainDefVec = g.std.vector(
'float')()
99 gainDefVec.push_back(0.)
100 gainDefVec.push_back(0.)
102 defVecLAr = g.std.vector(
'std::vector<float>')()
103 defVecLAr.push_back(gainDefVec)
104 defVecLAr.push_back(gainDefVec)
105 defVecLAr.push_back(gainDefVec)
107 defVecTile = g.std.vector(
'std::vector<float>')()
108 defVecTile.push_back(gainDefVec)
109 defVecTile.push_back(gainDefVec)
110 defVecTile.push_back(gainDefVec)
111 defVecTile.push_back(gainDefVec)
114 systemDict = { 0 : (31872, 0, defVecLAr ,
'EMEC, z<0'),
115 1 : (54784, 31872, defVecLAr ,
'EMB , z<0'),
116 2 : (54784, 86656, defVecLAr ,
'EMB , z>0'),
117 3 : (31872, 141440, defVecLAr ,
'EMEC, z>0'),
118 16 : ( 5632, 0, defVecLAr ,
'HEC' ),
119 32 : ( 3524, 0, defVecLAr ,
'FCAL' ),
120 48 : ( 5184, 0, defVecTile,
'TILE' )
123 for systemId, info
in six.iteritems (systemDict):
128 log.info(
"Creating BLOB for %s", sysName)
129 data = cool.Record( spec )
130 blob = data[
'CaloCondBlob16M']
131 flt = g.CaloCondBlobFlt.getInstance(blob)
132 flt.init(defVec,nChannel,2,author,comment)
133 fltDict[systemId] = [data,flt]
135 log.info(
"---> BLOB size is %4.1f kB", mbSize)
138 lines =
open(inputFile,
"r").readlines()
140 fields = line.split()
143 hash =
int(fields[1]) - systemDict[systemId][1]
144 gain = g.CaloCondUtils.getDbCaloGain(
int(fields[2]))
147 flt = fltDict[systemId][1]
149 flt.setData(hash,gain,0,noiseA)
150 flt.setData(hash,gain,1,noiseB)
153 for systemId, dataList
in six.iteritems (fltDict):
155 sysName = systemDict[systemId][3]
156 log.info(
"Committing BLOB for %s", sysName)
157 channelId = cool.ChannelId(systemId)
158 log.info(
"Cool channel ID %s", channelId)
160 folder.storeObject(iovSince, iovUntil, data, channelId, folderTag)
162 except Exception
as e:
163 log.fatal(
"Exception caught:")