15 os.environ[
'TERM'] =
'linux'
18 print (
"Usage: ",sys.argv[0],
" [OPTION] ... ")
19 print (
"Dumps noise constants from online or offline folders / tags")
21 print (
"-h, --help shows this help")
22 print (
"-s, --schema= specify schema to use, ONL or OFL for RUN1 or ONL2 or OFL2 for RUN2 or MC")
23 print (
"-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER")
24 print (
"-f, --folder= specify status folder to use f.i. /TILE/OFL02/NOISE/CELL or /CALO/Noise/CellNoise ")
25 print (
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or tag suffix like 14TeV-N200_dT50-01")
26 print (
"-r, --run= specify run number, by default uses latest iov")
27 print (
"-l, --lumi= specify lumi block number, default is 0")
28 print (
"-n, --channel= specify cool channel to read (48 by defalt)")
29 print (
"-c, --cell= specify cell hash (0-5183), default is -1, means all cells")
30 print (
"-g, --gain= specify gain to print (0-3), default is -1, means all gains")
31 print (
"-i, --index= specify parameter index (0-4), default is -1, means all parameters")
32 print (
"-b, --brief print only numbers without character names")
33 print (
"-d, --double print values with double precision")
35 letters =
"hS:s:t:f:r:l:n:c:g:i:bd"
36 keywords = [
"help",
"server=",
"schema=",
"tag=",
"folder=",
"run=",
"lumi=",
"channel=",
"cell=",
"gain=",
"index=",
"brief",
"double"]
39 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
40 except getopt.GetoptError
as err:
50 folderPath =
'/TILE/OFL02/NOISE/CELL'
61 if o
in (
"-s",
"--schema"):
63 elif o
in (
"-S",
"--server"):
65 elif o
in (
"-f",
"--folder"):
67 elif o
in (
"-t",
"--tag"):
69 elif o
in (
"-n",
"--channel"):
71 elif o
in (
"-c",
"--cell"):
73 elif o
in (
"-g",
"--gain"):
75 elif o
in (
"-i",
"--index"):
77 elif o
in (
"-r",
"--run"):
79 elif o
in (
"-l",
"--lumi"):
81 elif o
in (
"-b",
"--brief"):
83 elif o
in (
"-d",
"--double"):
85 elif o
in (
"-h",
"--help"):
96 from CaloCondBlobAlgs
import CaloCondTools, CaloCondLogger
97 from TileCalibBlobPython
import TileCalibTools
98 from TileCalibBlobPython
import TileCellTools
101 log = CaloCondLogger.getLogger(
"ReadCellNoise")
106 schema=
'COOLONL_CALO/COMP200'
107 folderPath=
'/CALO/Noise/CellNoise'
111 schema=
'COOLONL_CALO/CONDBR2'
112 folderPath=
'/CALO/Noise/CellNoise'
117 schema=
'COOLOFL_LAR/COMP200'
118 folderPath=
'/LAR/NoiseOfl/CellNoise'
122 schema=
'COOLOFL_TILE/COMP200'
123 folderPath=
'/TILE/OFL02/NOISE/CELL'
128 schema=
'COOLOFL_LAR/CONDBR2'
129 folderPath=
'/LAR/NoiseOfl/CellNoise'
131 schema=
'COOLOFL_TILE/CONDBR2'
132 folderPath=
'/TILE/OFL02/NOISE/CELL'
133 elif schema==
'ONLMC':
134 schema=
'COOLONL_CALO/OFLP200'
135 folderPath=
'/CALO/Noise/CellNoise'
138 elif schema==
'OFLMC':
139 schema=
'COOLOFL_CALO/OFLP200'
140 folderPath=
'/CALO/Ofl/Noise/CellNoise'
145 schema=
'COOLOFL_LAR/OFLP200'
146 folderPath=
'/LAR/NoiseOfl/CellNoise'
148 schema=
'COOLOFL_TILE/OFLP200'
149 folderPath=
'/TILE/OFL02/NOISE/CELL'
151 tag=
'OFLCOND-MC23-SDR-RUN3-02'
153 if run<222222
or 'COMP200' in schema:
156 if (
'OFLP200' in schema
and run>=330000)
or run>=400000:
158 elif (
'OFLP200' in schema
and run>=310000)
or run>=342550:
163 hashMgrDef=TileCellTools.TileCellHashMgr(cabling=cabling)
164 hashMgrA=TileCellTools.TileCellHashMgr(
"UpgradeA")
165 hashMgrBC=TileCellTools.TileCellHashMgr(
"UpgradeBC")
166 hashMgrABC=TileCellTools.TileCellHashMgr(
"UpgradeABC")
168 db = CaloCondTools.openDbConn(schema, server)
170 if folderPath.startswith(
'/TILE')
or tag==
'UPD1' or tag==
'UPD4' or 'COND'in tag:
171 folderTag = TileCalibTools.getFolderTag(db, folderPath, tag )
172 elif folderPath.startswith(
'/CALO/Ofl'):
173 folderTag =
'CaloOflNoiseCellnoise-'+tag
174 elif folderPath.startswith(
'/CALO'):
175 folderTag =
'CaloNoiseCellnoise-'+tag
176 elif folderPath.startswith(
'/LAR'):
177 folderTag =
'LARNoiseOflCellNoise-'+tag
179 log.info(
"Initializing folder %s with tag %s", folderPath, folderTag)
181 folder = db.getFolder(folderPath)
184 iov = CaloCondTools.iovFromRunLumi( run, lumi )
186 obj = folder.findObject( iov, chan, folderTag )
187 blob = obj.payload()[0]
190 blobFlt = cppyy.gbl.CaloCondBlobFlt.getInstance(blob)
197 ncell=blobFlt.getNChans()
198 ngain=blobFlt.getNGains()
199 nval=blobFlt.getObjSizeUint32()
201 if ncell>hashMgrA.getHashMax():
203 elif ncell>hashMgrBC.getHashMax():
205 elif ncell>hashMgrDef.getHashMax():
209 log.info(
"Using %s CellMgr with hashMax %d", hashMgr.getGeometry(),hashMgr.getHashMax())
211 if cell<0
or cell>=ncell:
218 if gain<0
or gain>=ngain:
225 if index<0
or index>=nval:
233 name1 = [
"",
"",
"0.0 "]
236 for i
in range(indexmax):
239 name1 = [
"Noise cell ",
"gain ",
"0.00 "]
240 names = [
"RMS ",
"pileup ",
"RMS1 ",
"RMS2 ",
"Ratio "]
241 for i
in range(len(names),indexmax):
242 names += [
"c"+
str(i)+
" "]
244 for cell
in range(cellmin,cellmax):
245 if tile
and len(name1[0]):
246 name1[0] =
"%s %6s hash " % hashMgr.getNames(cell)
247 for gain
in range(gainmin,gainmax):
248 msg=
"%s%4d %s%d\t" % ( name1[0], cell, name1[1], gain)
249 for index
in range(indexmin,indexmax):
250 v=blobFlt.getData(cell, gain, index)
252 msg +=
"%s%s%s" % (names[index],
"{0:<15.10g}".
format(v).ljust(15),dm)
254 msg +=
"%s%s%s" % (names[index],name1[2],dm)
256 msg +=
"%s%8.6f%s" % (names[index],v,dm)
258 msg +=
"%s%s%s" % (names[index],
"{0:<8.7g}".
format(v).ljust(8),dm)