11 os.environ[
'TERM'] =
'linux'
14 print (
"Usage: ",sys.argv[0],
" [OPTION] ... ")
15 print (
"Dumps noise constants from online or offline folders / tags")
17 print (
"-h, --help shows this help")
18 print (
"-s, --schema= specify schema to use, ONL or OFL for RUN1 or ONL2 or OFL2 for RUN2 or MC")
19 print (
"-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER")
20 print (
"-f, --folder= specify status folder to use f.i. /TILE/OFL02/NOISE/CELL or /CALO/Noise/CellNoise ")
21 print (
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or tag suffix like 14TeV-N200_dT50-01")
22 print (
"-r, --run= specify run number, by default uses latest iov")
23 print (
"-l, --lumi= specify lumi block number, default is 0")
24 print (
"-s2, --schema2= specify schema2 to use, ONL or OFL for RUN1 or ONL2 or OFL2 for RUN2 or MC")
25 print (
"-S2, --server2= specify server2 - ORACLE or FRONTIER, default is FRONTIER")
26 print (
"-f2, --folder2= specify status folder2 to use f.i. /TILE/OFL02/NOISE/CELL or /CALO/Noise/CellNoise ")
27 print (
"-t2, --tag2= specify tag2 to use, f.i. UPD1 or UPD4 or tag suffix like 14TeV-N200_dT50-01")
28 print (
"-r2, --run2= specify 2-nd run number, by default uses latest iov")
29 print (
"-l2, --lumi2= specify 2-nd lumi block number, default is 0")
30 print (
"-m, --maxdiff= specify an absolute maximal difference to compare constants")
31 print (
"-m2, --maxdiffpercent= specify the maximal difference in percents to compare constants")
32 print (
"-n, --channel= specify cool channel to read (48 by defalt)")
33 print (
"-c, --cell= specify cell hash (0-5183), default is -1, means all cells")
34 print (
"-g, --gain= specify gain to print (0-3), default is -1, means all gains")
35 print (
"-i, --index= specify parameter index (0-4), default is -1, means all parameters")
36 print (
"-z, --zero= zero threshold - treat values in DB below this threshold as zeros")
37 print (
"-w, --wide wide format - print all values per cell in one line")
38 print (
"-b, --brief print only numbers without character names")
39 print (
"-d, --double print values with double precision")
41 letters =
"hS:s:t:f:r:l:S2:s2:t2:f2:r2:l2:m:m2:n:c:g:i:z:wbd"
42 keywords = [
"help",
"server=",
"schema=",
"tag=",
"folder=",
"run=",
"lumi=",
"server2=",
"schema2=",
"tag2=",
"folder2=",
"run2=",
"lumi2=",
"maxdiff=",
"maxdiffpercent=",
"channel=",
"cell=",
"gain=",
"index=",
"zero=",
"wide",
"brief",
"double"]
45 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
46 except getopt.GetoptError
as err:
60 folderPath =
'/TILE/OFL02/NOISE/CELL'
77 if o
in (
"-s",
"--schema"):
79 elif o
in (
"-s2",
"--schema2"):
81 elif o
in (
"-S",
"--server"):
83 elif o
in (
"-S2",
"--server2"):
85 elif o
in (
"-f",
"--folder"):
87 elif o
in (
"-f2",
"--folder2"):
89 elif o
in (
"-t",
"--tag"):
91 elif o
in (
"-t2",
"--tag2"):
93 elif o
in (
"-n",
"--channel"):
95 elif o
in (
"-c",
"--cell"):
97 elif o
in (
"-g",
"--gain"):
99 elif o
in (
"-i",
"--index"):
101 elif o
in (
"-r",
"--run"):
103 elif o
in (
"-r2",
"--run2"):
105 elif o
in (
"-l",
"--lumi"):
107 elif o
in (
"-l2",
"--lumi2"):
109 elif o
in (
"-l",
"--lumi"):
111 elif o
in (
'--maxdiff'):
113 elif o
in (
'--maxdiffpercent'):
114 maxdiffpercent =
float(a)
115 elif o
in (
"-z",
"--zero"):
117 elif o
in (
"-w",
"--wide"):
119 elif o
in (
"-b",
"--brief"):
121 elif o
in (
"-d",
"--double"):
123 elif o
in (
"-h",
"--help"):
134 if folderPath2==
"none":
135 folderPath2=folderPath
147 from CaloCondBlobAlgs
import CaloCondTools, CaloCondLogger
148 from TileCalibBlobPython
import TileCalibTools
149 from TileCalibBlobPython
import TileCellTools
152 log = CaloCondLogger.getLogger(
"ReadCellNoise")
157 schema=
'COOLONL_CALO/COMP200'
158 folderPath=
'/CALO/Noise/CellNoise'
162 schema=
'COOLONL_CALO/CONDBR2'
163 folderPath=
'/CALO/Noise/CellNoise'
168 schema=
'COOLOFL_LAR/COMP200'
169 folderPath=
'/LAR/NoiseOfl/CellNoise'
173 schema=
'COOLOFL_TILE/COMP200'
174 folderPath=
'/TILE/OFL02/NOISE/CELL'
179 schema=
'COOLOFL_LAR/CONDBR2'
180 folderPath=
'/LAR/NoiseOfl/CellNoise'
182 schema=
'COOLOFL_TILE/CONDBR2'
183 folderPath=
'/TILE/OFL02/NOISE/CELL'
184 elif schema==
'ONLMC':
185 schema=
'COOLONL_CALO/OFLP200'
186 folderPath=
'/CALO/Noise/CellNoise'
189 elif schema==
'OFLMC':
190 schema=
'COOLOFL_CALO/OFLP200'
191 folderPath=
'/CALO/Ofl/Noise/CellNoise'
196 schema=
'COOLOFL_LAR/OFLP200'
197 folderPath=
'/LAR/NoiseOfl/CellNoise'
201 schema=
'COOLOFL_TILE/OFLP200'
202 folderPath=
'/TILE/OFL02/NOISE/CELL'
206 if run<222222
or 'COMP200' in schema:
209 if (
'OFLP200' in schema
and run>=330000)
or run>=400000:
211 elif (
'OFLP200' in schema
and run>=310000)
or run>=342550:
215 hashMgr=TileCellTools.TileCellHashMgr(cabling=cabling)
217 db = CaloCondTools.openDbConn(schema, server)
219 if folderPath.startswith(
'/TILE')
or tag==
'UPD1' or tag==
'UPD4' or 'COND'in tag:
220 folderTag = TileCalibTools.getFolderTag(db, folderPath, tag )
221 elif folderPath.startswith(
'/CALO/Ofl'):
222 folderTag =
'CaloOflNoiseCellnoise-'+tag
223 elif folderPath.startswith(
'/CALO'):
224 folderTag =
'CaloNoiseCellnoise-'+tag
225 elif folderPath.startswith(
'/LAR'):
226 folderTag =
'LARNoiseOflCellNoise-'+tag
231 schema2=
'COOLONL_CALO/COMP200'
232 folderPath2=
'/CALO/Noise/CellNoise'
235 elif schema2==
'ONL2':
236 schema2=
'COOLONL_CALO/CONDBR2'
237 folderPath2=
'/CALO/Noise/CellNoise'
242 schema2=
'COOLOFL_LAR/COMP200'
243 folderPath2=
'/LAR/NoiseOfl/CellNoise'
247 schema2=
'COOLOFL_TILE/COMP200'
248 folderPath=
'/TILE/OFL02/NOISE/CELL'
251 elif schema2==
'OFL2':
253 schema2=
'COOLOFL_LAR/CONDBR2'
254 folderPath2=
'/LAR/NoiseOfl/CellNoise'
256 schema2=
'COOLOFL_TILE/CONDBR2'
257 folderPath2=
'/TILE/OFL02/NOISE/CELL'
258 elif schema2==
'ONLMC':
259 schema2=
'COOLONL_CALO/OFLP200'
260 folderPath2=
'/CALO/Noise/CellNoise'
263 elif schema2==
'OFLMC':
264 schema2=
'COOLOFL_CALO/OFLP200'
265 folderPath2=
'/CALO/Ofl/Noise/CellNoise'
270 schema2=
'COOLOFL_LAR/OFLP200'
271 folderPath2=
'/LAR/NoiseOfl/CellNoise'
275 schema2=
'COOLOFL_TILE/OFLP200'
276 folderPath2=
'/TILE/OFL02/NOISE/CELL'
280 db2 = CaloCondTools.openDbConn(schema2, server2)
282 if folderPath2.startswith(
'/TILE')
or tag2==
'UPD1' or tag2==
'UPD4' or 'COND'in tag2:
283 folderTag2 = TileCalibTools.getFolderTag(db2, folderPath2, tag2 )
284 elif folderPath2.startswith(
'/CALO/Ofl'):
285 folderTag2 =
'CaloOflNoiseCellnoise-'+tag2
286 elif folderPath2.startswith(
'/CALO'):
287 folderTag2 =
'CaloNoiseCellnoise-'+tag2
288 elif folderPath.startswith(
'/LAR'):
289 folderTag2 =
'LARNoiseOflCellNoise-'+tag2
292 log.info(
"Initializing folder %s with tag %s", folderPath, folderTag)
293 log.info(
"Initializing folder2 %s with tag2 %s", folderPath2, folderTag2)
295 folder = db.getFolder(folderPath)
296 folder2 = db2.getFolder(folderPath2)
299 iov = CaloCondTools.iovFromRunLumi( run, lumi )
300 iov2 = CaloCondTools.iovFromRunLumi( run2, lumi2 )
302 obj = folder.findObject( iov, chan, folderTag )
303 obj2 = folder2.findObject( iov2, chan, folderTag2 )
305 blob = obj.payload()[0]
306 blob2 = obj2.payload()[0]
309 blobFlt = cppyy.gbl.CaloCondBlobFlt.getInstance(blob)
310 blobFlt2 = cppyy.gbl.CaloCondBlobFlt.getInstance(blob2)
317 ncell=blobFlt.getNChans()
318 ngain=blobFlt.getNGains()
319 nval=blobFlt.getObjSizeUint32()
321 if cell<0
or cell>=ncell:
328 if gain<0
or gain>=ngain:
335 if index<0
or index>=nval:
342 log.info(
"From DB: ncell: %d ngain %d index nval %d", ncell, ngain, nval)
345 name1 = [
"",
"",
"0.0 "]
346 names = [
"S0 ",
"Pl ",
"S1 ",
"S2 ",
"Ra "]
349 name1 = [
"Noise cell ",
"gain ",
"0.00 "]
350 names = [
" RMS ",
"pileup ",
" RMS1 ",
" RMS2 ",
" Ratio "]
351 for i
in range(len(names),indexmax):
352 names += [
"c"+
str(i)+
" "]
354 for cell
in range(cellmin,cellmax):
355 if tile
and len(name1[0]):
356 name1[0] =
"%s %6s hash " % hashMgr.getNames(cell)
357 for gain
in range(gainmin,gainmax):
358 msg=
"%s%4d %s%d\t" % ( name1[0], cell, name1[1], gain)
362 for index
in range(indexmin,indexmax):
363 v=blobFlt.getData(cell, gain, index)
364 v2=blobFlt2.getData(cell, gain, index)
376 if abs(dv12) > maxdiff
and abs(dp12) > maxdiffpercent:
380 s3 =
"{0:<14.9g}".
format(dv12)
if dv12<0
else "{0:<15.10g}".
format(dv12)
381 s4 =
"{0:<14.9g}".
format(dp12)
if dp12<0
else "{0:<15.10g}".
format(dp12)
382 msg +=
"%s v1 %s v2 %s diff %s diffpercent %s%s" % (names[index],s1.ljust(15),s2.ljust(15),s3.ljust(15),s4.ljust(15),dm)
384 s1 = name1[2]
if abs(v)<zthr
else "%8.6f" % v
if abs(v)<1
else "{0:<8.7g}".
format(v).ljust(8)
385 s2 = name1[2]
if abs(v2)<zthr
else "%8.6f" % v2
if abs(v2)<1
else "{0:<8.7g}".
format(v2).ljust(8)
386 s3 = name1[2]
if abs(dv12)<zthr
else "%8.6f" % dv12
if abs(dv12)<1
else "{0:<8.7g}".
format(dv12).ljust(8)
387 s4 = name1[2]
if abs(dp12)<zthr
else "%8.6f" % dp12
if abs(dp12)<1
else "{0:<8.7g}".
format(dp12).ljust(8)
388 msg +=
"%s v1 %s v2 %s diff %s diffpercent %s%s" % (names[index],s1[:8],s2[:8],s3[:8],s4[:8],dm)
391 print (msg[:len(msg)-len(dm)])