12 Python helper module for initializing db with default values
13 Note the COOL channels for default values:
14 - global default = channel 0
15 - default for LBA = channel 4
16 - default for LBC = channel 8
17 - default for EBA = channel 12
18 - default for EBA = channel 16
20 All offline constants are written to OFL02 folder
21 In the COOLONL_TILE schema and COMP200 DB
22 some constants exist also in OFL01 folder
23 To write constants to this folder special prefix can be used:
31 from TileCalibBlobPython
import TileCalibTools
32 from TileCalibBlobPython.TileCalibTools
import MINRUN, MINLBK, MAXRUN, MAXLBK, LASPARTCHAN
33 from TileCalibBlobPython.TileCalibLogger
import TileCalibLogger
34 from TileCalibBlobObjs.Classes
import TileCalibUtils, TileBchDecoder
38 pathDef =
"/afs/cern.ch/atlas/software/builds/AtlasConditions/latest/TileCalorimeter/TileConditions/share/"
44 This class provides methods to write default values for the various
47 __slots__ = [
"__author",
"__db",
"__tilePrefixOfl1",
"__tilePrefixOfl",
"__tilePrefixOnl"]
53 - db : db should be an open database connection
54 - globalTag: A tag used if nothing is specified in specialized functions
56 TileCalibLogger.__init__(self,
"DefaultWriter")
60 raise Exception (
"DB not open: ", db.databaseName())
68 except Exception
as e:
69 self.log().critical( e )
73 def writeCis(self, tag="", loGainDef=(1023./800.), hiGainDef=(64.*1023./800.)):
75 self.log().
info(
"*** Writing CIS with defaults loGain=%f, hiGain=%f and tag %s",
76 loGainDef,hiGainDef,tag )
79 loGainDefVec = cppyy.gbl.std.vector(
'float')()
80 loGainDefVec.push_back(loGainDef)
81 hiGainDefVec = cppyy.gbl.std.vector(
'float')()
82 hiGainDefVec.push_back(hiGainDef)
83 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
84 defVec.push_back(loGainDefVec)
85 defVec.push_back(hiGainDefVec)
96 for folder
in folders:
97 multiVers=(
'OFL' in folder)
101 util = cppyy.gbl.TileCalibUtils()
102 for ros
in range(util.max_ros()):
103 for drawer
in range(util.getMaxDrawer(ros)):
104 flt = blobWriter.zeroBlob(ros,drawer)
106 flt = blobWriter.getDrawer(0,0)
108 blobWriter.setComment(self.
__author,
"CIS defaults")
111 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
116 lut = cppyy.gbl.std.vector(
'float')()
120 defVec.push_back(lut)
125 for folder
in folders:
126 multiVers=(
'OFL' in folder)
130 for ros
in range(util.max_ros()):
131 for drawer
in range(util.getMaxDrawer(ros)):
132 flt = blobWriter.zeroBlob(ros,drawer)
134 flt = blobWriter.getDrawer(0,0)
135 flt.init(defVec,1,100)
136 blobWriter.setComment(self.
__author,
"non-linear CIS defaults")
139 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
145 self.log().
info(
"*** Writing Las default (1.) with tag %s", tag )
148 lasDef = cppyy.gbl.std.vector(
'float')()
150 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
151 defVec.push_back(lasDef)
158 for folder
in folders:
159 multiVers=(
'OFL' in folder)
163 util = cppyy.gbl.TileCalibUtils()
164 for ros
in range(util.max_ros()):
165 for drawer
in range(util.getMaxDrawer(ros)):
166 flt = blobWriter.zeroBlob(ros,drawer)
168 flt = blobWriter.getDrawer(0,0)
170 blobWriter.setComment(self.
__author,
"LAS default")
173 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
176 lut = cppyy.gbl.std.vector(
'float')()
180 defVec.push_back(lut)
186 for folder
in folders:
187 multiVers=(
'OFL' in folder)
191 util = cppyy.gbl.TileCalibUtils()
192 for ros
in range(util.max_ros()):
193 for drawer
in range(util.getMaxDrawer(ros)):
194 flt = blobWriter.zeroBlob(ros,drawer)
196 flt = blobWriter.getDrawer(0,0)
197 flt.init(defVec,1,100)
198 blobWriter.setComment(self.
__author,
"non-linear LAS default")
201 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
207 self.log().
info(
"*** Writing Las fiber and partition defaults (1.) with tag %s", tag )
211 lasDef = cppyy.gbl.std.vector(
'float')()
213 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
214 defVec.push_back(lasDef)
217 util = cppyy.gbl.TileCalibUtils()
218 for ros
in range(util.max_ros()):
219 for drawer
in range(util.getMaxDrawer(ros)):
220 blobWriter.zeroBlob(ros,drawer)
222 fltDrawer = blobWriter.getDrawer(0,0)
223 fltDrawer.init(defVec,1,1)
229 for ros
in range(1,util.max_ros()):
230 fltDrawer = blobWriter.getDrawer(ros,0)
231 fltDrawer.init(defVec,48,1)
232 fltDrawer.setData(LASPARTCHAN,adc,idx,val)
234 blobWriter.setComment(self.
__author,
"LAS fiber and partition default")
236 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
240 def writeCes(self, tag="", Simulation=True, MBTSflag="7TeV", dCellWeight=1.2, eCellWeight=1.5, since=(MINRUN,MINLBK), until=(MAXRUN, MAXLBK), mode=
'DEFAULT'):
242 Write default drawer/mod=0/0 only for LBA and LBC.
243 EBA & EBC setup is messy and so each drawer is stored individually.
244 These values with dCellWeight = 1.0 correspond to real M7 ones.
245 These values with dCellWeight = 1.2 correspond to real M8 ones.
246 Mode = 'DEFAULT' means standard settings, any other mode means put 1 everywhere
247 and ignore weight for D-sampling.
250 self.log().
info(
"*** Writing Ces with tag %s", tag )
256 for ros
in range(1,3):
257 for mod
in range(64):
258 special[(ros,mod, 0)] = dCellWeight
259 special[(ros,mod,13)] = dCellWeight
260 special[(ros,mod,14)] = dCellWeight
261 special[(ros,mod,24)] = dCellWeight
262 special[(ros,mod,25)] = dCellWeight
263 special[(ros,mod,41)] = dCellWeight
264 special[(ros,mod,44)] = dCellWeight
266 for ros
in range(3,5):
267 for mod
in range(64):
268 special[(ros,mod, 2)] = dCellWeight
269 special[(ros,mod, 3)] = dCellWeight
270 special[(ros,mod, 4)] = dCellWeight
271 special[(ros,mod, 5)] = dCellWeight
273 for ros
in range(3,5):
274 for mod
in range(64):
275 special[(ros,mod, 0)] = eCellWeight
276 special[(ros,mod, 1)] = eCellWeight
277 special[(ros,mod,12)] = eCellWeight
278 special[(ros,mod,13)] = eCellWeight
279 special[(ros,mod,18)] = 1.0
280 special[(ros,mod,19)] = 1.0
284 special[(3,14, 0)] = 1.0
285 special[(3,14, 1)] = 1.0
286 special[(3,14, 2)] = 1.0
287 special[(3,14, 3)] = 1.0
288 special[(4,17, 0)] = 1.0
289 special[(4,17, 1)] = 1.0
290 special[(4,17, 2)] = 1.0
291 special[(4,17, 3)] = 1.0
293 special[(3,14,16)] = 1.0
294 special[(3,14,17)] = 1.0
295 special[(4,17,16)] = 1.0
296 special[(4,17,17)] = 1.0
298 special[(3,14,18)] = eCellWeight
299 special[(3,14,19)] = eCellWeight
300 special[(4,17,18)] = eCellWeight
301 special[(4,17,19)] = eCellWeight
305 mbts_inner = [38,39,40,41,54,55,56,57]
306 mbts_outer = [ 7,23,42,53]
310 eba_mbts_inner = [ 3,12,23,30,35,43,52,60]
311 eba_mbts_outer = [ 2,11,22,29,34,44,53,59]
312 ebc_mbts_inner = [ 4,12,19,27,36,44,54,61]
313 ebc_mbts_outer = [ 3,11,18,26,35,43,53,60]
319 nomHV_EBA_inner = [ 694., 692.3, 697., 698., 695., 697., 696., 695.3 ]
320 beta_EBA_inner = [ 7.099, 7., 7.188, 6.995, 6.917, 7.217, 6.863, 6.97 ]
322 nomHV_EBA_outer = [ 687., 695., 697.7, 692., 695., 696., 694., 696. ]
323 beta_EBA_outer = [ 6.903, 7.01, betaMean, betaMean, 6.918, betaMean, 7.072, betaMean ]
325 nomHV_EBC_inner = [ 696., 697., 696., 693., 694., 698., 695., 690. ]
326 beta_EBC_inner = [ betaMean, 7.26, 7.281, 6.98, 7.002, 6.845, 6.955, 7.167 ]
328 nomHV_EBC_outer = [ 697., 695., 695., 696., 696., 695., 696., 697. ]
329 beta_EBC_outer = [ 7.209, 7.084, 7.272, 7.093, 7.207, 7.02, 7.298, betaMean ]
336 mev2pcb = 1.050/1000.
337 ces_mbts_inner = 2.5751/mev2pcb * corrFactor
338 ces_mbts_outer = 1.8438/mev2pcb * corrFactor
346 mbtsMipInnerC.append(0.155 * 8.2/5.9)
347 mbtsMipInnerA.append(0.155 * 8.2/5.9)
350 mbtsMipOuterC = [ 0.16, 0.14, 0.155, 0.165, 0.14, 0.15, 0.185, 0.145 ]
351 mbtsMipOuterA = [ 0.15, 0.165, 0.135, 0.155, 0.13, 0.155, 0.165, 0.18 ]
359 newCesMbtsOuterC.append( mbtsMipOuterC[i]/(10. * 5.9/8.2) * ces_mbts_outer )
360 newCesMbtsOuterA.append( mbtsMipOuterA[i]/(10. * 5.9/8.2) * ces_mbts_outer )
361 newCesMbtsInnerC.append( mbtsMipInnerC[i]/10. * ces_mbts_inner )
362 newCesMbtsInnerA.append( mbtsMipInnerA[i]/10. * ces_mbts_inner )
365 newCesMbtsOuterC[0] *= 1.15
367 if not MBTSflag==
"13TeV" and not MBTSflag==
"8TeV" and not MBTSflag==
"7TeV" and not MBTSflag==
"900GeV":
368 print (
"MBTS flag",MBTSflag,
"is not recognized, assuming 7TeV")
371 print (
"setting MBTS weights for",MBTSflag)
373 if MBTSflag==
"13TeV" :
375 print (
"RUN2 configuration for MC")
378 ces_mbts_inner = 157.5/1.05
379 ces_mbts_outer = 157.5/1.05
380 chan_mbts_inner = 5-1
381 chan_mbts_outer = 13-1
385 for i,mod
in enumerate(mbts_inner):
386 special[(3,mod,chan_mbts_inner)] = ces_mbts_inner
387 print (
"EBA",mod+1,
"ch",chan_mbts_inner,
" inner MBTS = ",special[(3,mod,chan_mbts_inner)] )
389 for i,mod
in enumerate(mbts_outer):
390 special[(3,mod,chan_mbts_outer)] = ces_mbts_outer
391 print (
"EBA",mod+1,
"ch",chan_mbts_outer,
" outer MBTS = ",special[(3,mod,chan_mbts_outer)] )
393 for i,mod
in enumerate(mbts_inner):
394 special[(4,mod,chan_mbts_inner)] = ces_mbts_inner
395 print (
"EBC",mod+1,
"ch",chan_mbts_inner,
" inner MBTS = ",special[(4,mod,chan_mbts_inner)] )
397 for i,mod
in enumerate(mbts_outer):
398 special[(4,mod,chan_mbts_outer)] = ces_mbts_outer
399 print (
"EBC",mod+1,
"ch",chan_mbts_outer,
" outer MBTS = ",special[(4,mod,chan_mbts_outer)] )
403 print (
"RUN1 configuration for MC")
406 if MBTSflag==
"7TeV" or MBTSflag==
"8TeV" :
411 newCesMbtsOuterC[i] *=
pow( newHV/nomHV_EBC_outer[i], beta_EBC_outer[i] )
412 newCesMbtsOuterA[i] *=
pow( newHV/nomHV_EBA_outer[i], beta_EBA_outer[i] )
413 newCesMbtsInnerC[i] *=
pow( newHV/nomHV_EBC_inner[i], beta_EBC_inner[i] )
414 newCesMbtsInnerA[i] *=
pow( newHV/nomHV_EBA_inner[i], beta_EBA_inner[i] )
418 newCesMbtsOuterA[i] *=
pow( 820./newHV, beta_EBA_outer[i] )
421 if MBTSflag==
"7TeV" :
422 newCesMbtsInnerC[0] = 1.0e-20
427 for i,mod
in enumerate(eba_mbts_inner):
428 special[(3,mod,0)] = newCesMbtsInnerA[i]
429 print (
"EBA",mod+1,
" inner MBTS = ",special[(3,mod,0)] )
431 for i,mod
in enumerate(eba_mbts_outer):
432 special[(3,mod,0)] = newCesMbtsOuterA[i]
433 print (
"EBA",mod+1,
" outer MBTS = ",special[(3,mod,0)] )
435 for i,mod
in enumerate(ebc_mbts_inner):
436 special[(4,mod,0)] = newCesMbtsInnerC[i]
437 print (
"EBC",mod+1,
" inner MBTS = ",special[(4,mod,0)] )
439 for i,mod
in enumerate(ebc_mbts_outer):
440 special[(4,mod,0)] = newCesMbtsOuterC[i]
441 print (
"EBC",mod+1,
" outer MBTS = ",special[(4,mod,0)] )
445 if MBTSflag==
"13TeV" :
447 print (
"RUN2 configuration for DATA")
450 ces_mbts_inner = (1.036 * 0.987)/1.05
451 ces_mbts_outer = 1.0/1.05
452 chan_mbts_inner = 5-1
453 chan_mbts_outer = 13-1
456 for i,mod
in enumerate(mbts_inner):
457 special[(3,mod,chan_mbts_inner)] = ces_mbts_inner
458 print (
"EBA",mod+1,
"ch",chan_mbts_inner,
" inner MBTS = ",special[(3,mod,chan_mbts_inner)] )
460 for i,mod
in enumerate(mbts_outer):
461 special[(3,mod,chan_mbts_outer)] = ces_mbts_outer
462 print (
"EBA",mod+1,
"ch",chan_mbts_outer,
" outer MBTS = ",special[(3,mod,chan_mbts_outer)] )
464 for i,mod
in enumerate(mbts_inner):
465 special[(4,mod,chan_mbts_inner)] = ces_mbts_inner
466 print (
"EBC",mod+1,
"ch",chan_mbts_inner,
" inner MBTS = ",special[(4,mod,chan_mbts_inner)] )
468 for i,mod
in enumerate(mbts_outer):
469 special[(4,mod,chan_mbts_outer)] = ces_mbts_outer
470 print (
"EBC",mod+1,
"ch",chan_mbts_outer,
" outer MBTS = ",special[(4,mod,chan_mbts_outer)] )
474 print (
"RUN1 configuration for DATA")
477 ces_mbts_inner = 1.0/1.05
478 ces_mbts_outer = 1.0/1.05
481 for mod
in eba_mbts_inner:
482 special[(3,mod,0)] = ces_mbts_inner
483 print (
"EBA",mod+1,
" inner MBTS = ",special[(3,mod,0)] )
485 for mod
in eba_mbts_outer:
486 special[(3,mod,0)] = ces_mbts_outer
487 print (
"EBA",mod+1,
" outer MBTS = ",special[(3,mod,0)] )
489 for mod
in ebc_mbts_inner:
490 special[(4,mod,0)] = ces_mbts_inner
491 print (
"EBC",mod+1,
" inner MBTS = ",special[(4,mod,0)] )
493 for mod
in ebc_mbts_outer:
494 special[(4,mod,0)] = ces_mbts_outer
495 print (
"EBC",mod+1,
" outer MBTS = ",special[(4,mod,0)] )
498 default = cppyy.gbl.std.vector(
'float')()
500 default.push_back( 1.)
501 default.push_back( 1.)
502 default.push_back(700.)
503 default.push_back( 20.)
505 default.push_back( 1.)
506 default.push_back( -1.)
507 default.push_back( 0.)
508 default.push_back( 20.)
509 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
510 defVec.push_back(default)
516 for folder
in folders:
517 multiVers=(
'OFL' in folder)
521 util = cppyy.gbl.TileCalibUtils()
522 for ros
in range(util.max_ros()):
523 for drawer
in range(util.getMaxDrawer(ros)):
524 flt = blobWriter.zeroBlob(ros,drawer)
527 det = blobWriter.getDrawer(0,0)
528 det.init(defVec,48,1)
532 self.log().
info(
"*** Writing Ces defaults with dCellWeight = %.1f eCellWeight = %.1f", dCellWeight,eCellWeight )
534 lba = blobWriter.getDrawer(0,4)
535 lba.init(defVec,48,1)
536 lbc = blobWriter.getDrawer(0,8)
537 lbc.init(defVec,48,1)
538 for chan
in range(48):
540 ces = special.get(key,1.)
541 lba.setData(chan,0,0,ces)
542 lbc.setData(chan,0,0,ces)
545 eba = blobWriter.getDrawer(0,12)
546 eba.init(defVec,48,1)
547 ebc = blobWriter.getDrawer(0,16)
548 ebc.init(defVec,48,1)
549 for chan
in range(48):
551 ces = special.get(key,1.)
552 eba.setData(chan,0,0,ces)
553 ebc.setData(chan,0,0,ces)
557 for ros
in range(3,5):
558 for mod
in range(64):
559 flt = blobWriter.getDrawer(ros,mod)
560 flt.init(defVec,48,1)
561 for chan
in range(48):
563 ces = special.get(key,1.)
564 flt.setData(chan,0,0,ces)
567 blobWriter.setComment(self.
__author,
"default cesium constants for Run %d and %s MBTS weights for %s" % (RUN,NEW,MBTSflag))
571 self.log().
info(
"*** Writing Ces = 1 everywhere" )
573 blobWriter.setComment(self.
__author,
"cesium constants = 1 everywhere")
577 blobWriter.register(since,until,folderTag)
581 def writeOldCes(self, tag="", dCellWeight=1.2, eCellWeight=1.5, since=(MINRUN,MINLBK), until=(MAXRUN, MAXLBK)):
583 Write default drawer/mod=0/0 only for LBA and LBC.
584 EBA & EBC setup is messy and so each drawer is stored individually.
585 MBTS in EBs connected in channel 47. No module type 11 anomaly.
586 These values with dCellWeight = 1.2 correspond to simulation with CSC and FDR global tags.
589 self.log().
info(
"*** Writing Ces with tag %s", tag )
594 for ros
in range(1,3):
595 for mod
in range(64):
596 special[(ros,mod, 0)] = dCellWeight
597 special[(ros,mod,13)] = dCellWeight
598 special[(ros,mod,14)] = dCellWeight
599 special[(ros,mod,24)] = dCellWeight
600 special[(ros,mod,25)] = dCellWeight
601 special[(ros,mod,41)] = dCellWeight
602 special[(ros,mod,44)] = dCellWeight
604 for ros
in range(3,5):
605 for mod
in range(64):
606 special[(ros,mod, 2)] = dCellWeight
607 special[(ros,mod, 3)] = dCellWeight
608 special[(ros,mod, 4)] = dCellWeight
609 special[(ros,mod, 5)] = dCellWeight
611 for ros
in range(3,5):
612 for mod
in range(64):
613 special[(ros,mod, 0)] = eCellWeight
614 special[(ros,mod, 1)] = eCellWeight
615 special[(ros,mod,12)] = eCellWeight
616 special[(ros,mod,13)] = eCellWeight
621 ces_mbts_inner = 1.0/1.05
622 ces_mbts_outer = 1.0/1.05
623 eb_mbts_inner = [ 0, 1, 2, 3,
632 eb_mbts_outer = [ 4, 5, 6, 7,
641 for mod
in eb_mbts_inner:
642 special[(3,mod,47)] = ces_mbts_inner
643 special[(4,mod,47)] = ces_mbts_inner
645 for mod
in eb_mbts_outer:
646 special[(3,mod,47)] = ces_mbts_outer
647 special[(4,mod,47)] = ces_mbts_outer
650 default = cppyy.gbl.std.vector(
'float')()
651 default.push_back( 1.)
652 default.push_back( 1.)
653 default.push_back(700.)
654 default.push_back( 20.)
655 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
656 defVec.push_back(default)
665 util = cppyy.gbl.TileCalibUtils()
666 for ros
in range(util.max_ros()):
667 for drawer
in range(util.getMaxDrawer(ros)):
668 fltOfl = blobWriterOfl.zeroBlob(ros,drawer)
669 fltOnl = blobWriterOnl.zeroBlob(ros,drawer)
672 detOfl = blobWriterOfl.getDrawer(0,0)
673 detOfl.init(defVec,48,1)
674 detOnl = blobWriterOnl.getDrawer(0,0)
675 detOnl.init(defVec,48,1)
678 self.log().
info(
"*** Writing Ces defaults with dCellWeight = %.1f eCellWeight = %.1f", dCellWeight,eCellWeight )
680 lbaOfl = blobWriterOfl.getDrawer(0,4)
681 lbaOfl.init(defVec,48,1)
682 lbaOnl = blobWriterOnl.getDrawer(0,4)
683 lbaOnl.init(defVec,48,1)
684 lbcOfl = blobWriterOfl.getDrawer(0,8)
685 lbcOfl.init(defVec,48,1)
686 lbcOnl = blobWriterOnl.getDrawer(0,8)
687 lbcOnl.init(defVec,48,1)
688 for chan
in range(48):
690 ces = special.get(key,1.)
691 lbaOfl.setData(chan,0,0,ces)
692 lbaOnl.setData(chan,0,0,ces)
693 lbcOfl.setData(chan,0,0,ces)
694 lbcOnl.setData(chan,0,0,ces)
698 for ros
in range(3,5):
699 for mod
in range(64):
700 fltOfl = blobWriterOfl.getDrawer(ros,mod)
701 fltOfl.init(defVec,48,1)
702 fltOnl = blobWriterOnl.getDrawer(ros,mod)
703 fltOnl.init(defVec,48,1)
704 for chan
in range(48):
706 ces = special.get(key,1.)
707 fltOfl.setData(chan,0,0,ces)
708 fltOnl.setData(chan,0,0,ces)
711 blobWriterOfl.setComment(self.
__author,
"default old cesium constants (CSC,FDR) with dCellWeight=%.1f" % dCellWeight)
712 blobWriterOnl.setComment(self.
__author,
"default old cesium constants (CSC,FDR) with dCellWeight=%.1f" % dCellWeight)
716 blobWriterOfl.register(since,until,folderTag)
717 blobWriterOnl.register(since,until,
"")
721 def writeEmscale(self, tag="", since=(MINRUN,MINLBK), until=(MAXRUN, MAXLBK)):
737 clbA = [1, 4, 5, 8, 9, 10, 15, 18, 19, 20, 23, 26, 29, 32, 35, 36, 37, 38, 45, 46]
738 clbB = [2, 3, 6, 7, 11, 12, 16, 17, 21, 22, 27, 28, 33, 34, 39, 40]
740 clbD = [0, 13, 14, 24, 25, 41, 44]
746 cebA = [6, 7, 10, 11, 20, 21, 31, 32, 40, 41]
747 cebB = [8, 9, 14, 15, 22, 23, 30, 35, 36, 39]
748 cebD = [16, 17, 37, 38]
756 self.log().
info(
"*** Writing Emscale with particle/Cesium factors with tag %s" , tag )
759 emsDef = cppyy.gbl.std.vector(
'float')()
760 emsDef.push_back(emscale)
761 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
762 defVec.push_back(emsDef)
767 for folder
in folders:
768 multiVers=(
'OFL' in folder)
772 util = cppyy.gbl.TileCalibUtils()
773 for ros
in range(util.max_ros()):
774 for drawer
in range(util.getMaxDrawer(ros)):
775 flt = blobWriter.zeroBlob(ros,drawer)
778 flt = blobWriter.getDrawer(0,0)
782 for ros
in range(1,3):
783 for mod
in range(64):
784 flt = blobWriter.getDrawer(ros,mod)
785 flt.init(defVec,48,1)
787 flt.setData(chan,0,0,emscale/flbA)
789 flt.setData(chan,0,0,emscale/flbB)
791 flt.setData(chan,0,0,emscale/flbB9)
793 flt.setData(chan,0,0,emscale/flbD)
796 for ros
in range(3,5):
797 for mod
in range(64):
798 flt = blobWriter.getDrawer(ros,mod)
799 flt.init(defVec,48,1)
801 flt.setData(chan,0,0,emscale/febA)
803 flt.setData(chan,0,0,emscale/febB)
805 flt.setData(chan,0,0,emscale/febD)
807 flt.setData(chan,0,0,emscale/fC10)
809 flt.setData(chan,0,0,emscale/fD4)
811 blobWriter.setComment(self.
__author,
"EMS with particle/Cesium factors (pC/MeV)")
813 blobWriter.register(since,until,folderTag)
817 def writeEmscaleMC(self, tag="", emscale=(1.05/1000.), since=(MINRUN,MINLBK), until=(MAXRUN, MAXLBK)):
819 self.log().
info(
"*** Writing Emscale default (%.2f) with tag %s", (emscale * 1000.),tag )
822 emsDef = cppyy.gbl.std.vector(
'float')()
823 emsDef.push_back(emscale)
824 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
825 defVec.push_back(emsDef)
830 for folder
in folders:
831 multiVers=(
'OFL' in folder)
834 util = cppyy.gbl.TileCalibUtils()
835 for ros
in range(util.max_ros()):
836 for drawer
in range(util.getMaxDrawer(ros)):
837 flt = blobWriter.zeroBlob(ros,drawer)
839 flt = blobWriter.getDrawer(0,0)
841 blobWriter.setComment(self.
__author,
"EMS default: %.2f/1000 pC/MeV" % (emscale * 1000.))
843 blobWriter.register(since,until,folderTag)
862 dv.append(( 2.814, 0.023, -1, -1, 80, -1, -1, -1))
863 dv.append(( 26.010, 0.230, -1, -1, 80, -1, -1, -1))
864 dv.append(( 28.810, 0.240, -1, -1, 80, -1, -1, -1))
865 dv.append(( 54.810, 0.480, -1, -1, 70, -1, -1, -1))
866 dv.append(( 75.790, 0.677, -1, -1, 70, -1, -1, -1))
867 dv.append((101.800, 0.900, -1, -1, 70, -1, -1, -1))
872 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
874 for i
in range(ngain):
875 defaultGain = cppyy.gbl.std.vector(
'float')()
877 defaultGain.push_back(v)
878 defVec.push_back(defaultGain)
884 writer.setComment(self.
__author,
"Integrator gain defaults")
886 util = cppyy.gbl.TileCalibUtils()
887 for ros
in range(util.max_ros()):
888 for drawer
in range(util.getMaxDrawer(ros)):
889 writer.zeroBlob(ros,drawer)
890 calibDrawer = writer.getDrawer(0,0)
891 calibDrawer.init(defVec,1,1)
894 writer.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
902 self.log().
info(
"*** Writing Tcfib defaults using tag %s", tag )
906 default = cppyy.gbl.std.vector(
'float')()
907 default.push_back(0.)
908 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
909 defVec.push_back(default)
913 util = cppyy.gbl.TileCalibUtils()
914 for ros
in range(util.max_ros()):
915 for drawer
in range(util.getMaxDrawer(ros)):
916 blobWriter.zeroBlob(ros,drawer)
919 det = blobWriter.getDrawer(0, 0)
920 det.init(defVec,48,0)
922 lba = blobWriter.getDrawer(0, 4)
923 lba.init(defVec,48,0)
925 lbc = blobWriter.getDrawer(0, 8)
926 lbc.init(defVec,48,0)
928 eba = blobWriter.getDrawer(0,12)
929 eba.init(defVec,48,0)
931 ebc = blobWriter.getDrawer(0,16)
932 ebc.init(defVec,48,0)
933 for chan
in range(48):
934 valLba =
float(parser.getData(1,0,chan)[0])
935 valLbc =
float(parser.getData(2,0,chan)[0])
936 valEba =
float(parser.getData(3,0,chan)[0])
937 valEbc =
float(parser.getData(4,0,chan)[0])
938 lba.setData(chan,0,0,valLba)
939 lbc.setData(chan,0,0,valLbc)
940 eba.setData(chan,0,0,valEba)
941 ebc.setData(chan,0,0,valEbc)
942 blobWriter.setComment(self.
__author,
"channel (laser) clear fiber length")
944 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
945 except Exception
as e:
946 self.log().critical( e )
952 self.log().
info(
"*** Writing Tclas defaults using tag %s", tag )
955 default = cppyy.gbl.std.vector(
'float')()
956 default.push_back(0.)
957 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
958 defVec.push_back(default)
962 util = cppyy.gbl.TileCalibUtils()
963 for ros
in range(util.max_ros()):
964 for drawer
in range(util.getMaxDrawer(ros)):
965 flt = blobWriter.zeroBlob(ros,drawer)
966 flt = blobWriter.getDrawer(0, 0)
968 blobWriter.setComment(self.
__author,
"no channel timing offset by default")
970 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
971 except Exception
as e:
972 self.log().critical( e )
978 self.log().
info(
"*** Writing Tdlas defaults using tag %s", tag )
981 default = cppyy.gbl.std.vector(
'float')()
982 default.push_back(0.)
983 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
984 defVec.push_back(default)
988 util = cppyy.gbl.TileCalibUtils()
989 for ros
in range(util.max_ros()):
990 for drawer
in range(util.getMaxDrawer(ros)):
991 flt = blobWriter.zeroBlob(ros,drawer)
992 flt = blobWriter.getDrawer(0, 0)
994 blobWriter.setComment(self.
__author,
"no drawer timing offset by default")
996 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
997 except Exception
as e:
998 self.log().critical( e )
1004 self.log().
info(
"*** Writing Tof defaults using tag %s", tag )
1008 default = cppyy.gbl.std.vector(
'float')()
1009 default.push_back(0.)
1010 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1011 defVec.push_back(default)
1015 util = cppyy.gbl.TileCalibUtils()
1016 for ros
in range(util.max_ros()):
1017 for drawer
in range(util.getMaxDrawer(ros)):
1018 blobWriter.zeroBlob(ros,drawer)
1019 calibDrawer = blobWriter.getDrawer(0,0)
1020 calibDrawer.init(defVec,1,1)
1024 for mod
in (4, 8, 12, 16):
1026 blobWriter.zeroBlob(ros,mod)
1027 for chn
in range(48):
1028 value = parser.getData(ros,mod,chn)
1030 self.log().warning(
"%i/%2i/%2i/x: No value found in file", ros,mod,chn)
1033 calibDrawer = blobWriter.getDrawer(ros,mod)
1034 if not calibDrawer.getNObjs():
1035 self.log().
info(
"Initializing drawer %i/%2i\t%i", ros,mod,calibDrawer.getNObjs())
1036 calibDrawer.init(defVec,48,1)
1040 line =
"%i/%2i/%2i/%i: " % (ros,mod,chn,adc)
1041 val =
float(value[0])
1042 calibDrawer.setData(chn,adc,0,val)
1043 line +=
"%f " % (val,)
1044 self.log().
debug(line)
1046 blobWriter.setComment(
"jose maneira",
"time-of-flight default values")
1048 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1049 except Exception
as e:
1050 self.log().critical( e )
1056 self.log().
info(
"*** Writing Fit Method Noise with defaults (ADC counts) loGain=%f, hiGain=%f and tag %s" ,
1057 loGainDef,hiGainDef,tag )
1060 loGainDefVec = cppyy.gbl.std.vector(
'float')()
1061 loGainDefVec.push_back(loGainDef)
1062 hiGainDefVec = cppyy.gbl.std.vector(
'float')()
1063 hiGainDefVec.push_back(hiGainDef)
1064 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1065 defVec.push_back(loGainDefVec)
1066 defVec.push_back(hiGainDefVec)
1073 for folder
in folders:
1075 multiVers=(
'OFL' in folder)
1078 util = cppyy.gbl.TileCalibUtils()
1079 for ros
in range(util.max_ros()):
1080 for drawer
in range(util.getMaxDrawer(ros)):
1081 flt = blobWriter.zeroBlob(ros,drawer)
1083 flt = blobWriter.getDrawer(0,0)
1084 flt.init(defVec,1,1)
1085 blobWriter.setComment(self.
__author,
"Fit Method Noise defaults (ADC)")
1087 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1088 except Exception
as e:
1089 self.log().critical( e )
1095 self.log().
info(
"*** Writing sample noise (lo=%f, hi=%f) defaults using tag %s",
1096 loGainDef,hiGainDef,tag )
1099 defaultLo = cppyy.gbl.std.vector(
'float')()
1100 defaultLo.push_back( 40.)
1101 defaultLo.push_back(loGainDef)
1102 defaultLo.push_back( 0.)
1103 defaultLo.push_back(loGainDef)
1104 defaultLo.push_back( 0.)
1105 defaultLo.push_back( 0.)
1106 defaultHi = cppyy.gbl.std.vector(
'float')()
1107 defaultHi.push_back( 40.)
1108 defaultHi.push_back(hiGainDef)
1109 defaultHi.push_back( 0.)
1110 defaultHi.push_back(hiGainDef)
1111 defaultHi.push_back( 0.)
1112 defaultHi.push_back( 0.)
1113 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1114 defVec.push_back(defaultLo)
1115 defVec.push_back(defaultHi)
1120 for folder
in folders:
1122 multiVers=(
'OFL' in folder)
1125 util = cppyy.gbl.TileCalibUtils()
1126 for ros
in range(util.max_ros()):
1127 for drawer
in range(util.getMaxDrawer(ros)):
1128 flt = blobWriter.zeroBlob(ros,drawer)
1129 flt = blobWriter.getDrawer(0, 0)
1130 flt.init(defVec,1,0)
1131 blobWriter.setComment(self.
__author,
"default noise")
1133 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1134 except Exception
as e:
1135 self.log().critical( e )
1141 self.log().
info(
"*** Writing dummy RODmap using tag %s",tag)
1143 default = cppyy.gbl.std.vector(
'int')()
1144 default.push_back(0x0)
1145 default.push_back(0x500000)
1146 default.push_back(0x0)
1147 default.push_back(0)
1148 defVec = cppyy.gbl.std.vector(
'std::vector<int>')()
1149 defVec.push_back(default)
1150 defVec.push_back(default)
1155 for folder
in folders:
1157 multiVers=(
'OFL' in folder)
1160 util = cppyy.gbl.TileCalibUtils()
1161 for ros
in range(util.max_ros()):
1162 for drawer
in range(util.getMaxDrawer(ros)):
1163 flt = blobWriter.zeroBlob(ros,drawer)
1164 flt = blobWriter.getDrawer(0, 0)
1165 flt.init(defVec,1,0)
1166 blobWriter.setComment(self.
__author,
"dummy ROD map")
1168 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1169 except Exception
as e:
1170 self.log().critical( e )
1176 self.log().
info(
"*** Writing 1-g noise(ADC counts)+pileup(MeV) defaults loGain=%f, hiGain=%f and tag %s",
1177 loGainDef,hiGainDef,tag )
1180 defaultLo = cppyy.gbl.std.vector(
'float')()
1181 defaultLo.push_back(loGainDef)
1182 defaultLo.push_back(0.)
1183 defaultHi = cppyy.gbl.std.vector(
'float')()
1184 defaultHi.push_back(hiGainDef)
1185 defaultHi.push_back(0.)
1187 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1188 defVec.push_back(defaultLo)
1189 defVec.push_back(defaultHi)
1194 for folder
in folders:
1196 multiVers=(
'OFL' in folder)
1199 util = cppyy.gbl.TileCalibUtils()
1200 for ros
in range(util.max_ros()):
1201 for drawer
in range(util.getMaxDrawer(ros)):
1202 flt = blobWriter.zeroBlob(ros,drawer)
1204 flt = blobWriter.getDrawer(0, 0)
1205 flt.init(defVec,48,1)
1207 blobWriter.setComment(self.
__author,
"default noise for DSP reco")
1209 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1210 except Exception
as e:
1211 self.log().critical( e )
1217 To be compatible with previous defaults for MC, the low and high
1218 gain pedestals are set to ped+(channel+1)/48. with
1219 ped = 30 and 50 ADC counts respecively
1222 self.log().
info(
"*** Writing sample noise MC defaults (lo=%f, hi=%f) using tag %s",
1223 loGainDef,hiGainDef,tag )
1228 for folder
in folders:
1230 multiVers=(
'OFL' in folder)
1233 util = cppyy.gbl.TileCalibUtils()
1234 for ros
in range(util.max_ros()):
1235 for drawer
in range(util.getMaxDrawer(ros)):
1236 flt = blobWriter.zeroBlob(ros,drawer)
1237 flt = blobWriter.getDrawer(0, 0)
1241 defaultLo = cppyy.gbl.std.vector(
'float')()
1242 defaultLo.push_back(0.)
1243 defaultLo.push_back(0.)
1244 defaultLo.push_back(0.)
1245 defaultLo.push_back(0.)
1246 defaultLo.push_back(0.)
1247 defaultLo.push_back(0.)
1249 defaultHi = cppyy.gbl.std.vector(
'float')()
1250 defaultHi.push_back(0.)
1251 defaultHi.push_back(0.)
1252 defaultHi.push_back(0.)
1253 defaultHi.push_back(0.)
1254 defaultHi.push_back(0.)
1255 defaultHi.push_back(0.)
1257 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1258 defVec.push_back(defaultLo)
1259 defVec.push_back(defaultHi)
1261 flt.init(defVec,48,0)
1264 for chan
in range(48):
1266 loPedDef = 30.+(chan+1)/48.
1267 hiPedDef = 50.+(chan+1)/48.
1270 flt.setData(chan, 0, 0, loPedDef)
1271 flt.setData(chan, 0, 1, loGainDef)
1272 flt.setData(chan, 0, 2, 0.)
1273 flt.setData(chan, 0, 3, loGainDef)
1274 flt.setData(chan, 0, 4, 0.)
1275 flt.setData(chan, 0, 5, 0.)
1277 flt.setData(chan, 1, 0, hiPedDef)
1278 flt.setData(chan, 1, 1, hiGainDef)
1279 flt.setData(chan, 1, 2, 0.)
1280 flt.setData(chan, 1, 3, hiGainDef)
1281 flt.setData(chan, 1, 4, 0.)
1282 flt.setData(chan, 1, 5, 0.)
1284 blobWriter.setComment(self.
__author,
"default noise")
1286 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1287 except Exception
as e:
1288 self.log().critical( e )
1294 self.log().
info(
"*** Writing default sample auto correlation using tag %s", tag)
1298 default = cppyy.gbl.std.vector(
'float')()
1300 default.push_back(0.)
1301 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1302 defVec.push_back(default)
1307 util = cppyy.gbl.TileCalibUtils()
1308 for ros
in range(util.max_ros()):
1309 for drawer
in range(util.getMaxDrawer(ros)):
1310 flt = blobWriter.zeroBlob(ros,drawer)
1311 flt = blobWriter.getDrawer(0, 0)
1312 flt.init(defVec,1,0)
1313 blobWriter.setComment(self.
__author,
"default auto correlation (unit matrix)")
1315 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1316 except Exception
as e:
1317 self.log().critical( e )
1323 self.log().
info(
"*** Writing BadChannel defaults using tag %s", tag )
1325 default = cppyy.gbl.std.vector(
'unsigned int')()
1326 default.push_back(0)
1327 defVec = cppyy.gbl.std.vector(
'std::vector<unsigned int>')()
1328 defVec.push_back(default)
1334 for folder
in folders:
1336 multiVers=(
'OFL' in folder)
1339 util = cppyy.gbl.TileCalibUtils()
1340 for ros
in range(util.max_ros()):
1341 for drawer
in range(util.getMaxDrawer(ros)):
1342 bch = blobWriter.zeroBlob(ros,drawer)
1343 bch = blobWriter.getDrawer(0, 0)
1344 bch.init(defVec,1,cppyy.gbl.TileBchDecoder.BitPat_ofl01
if multiVers
else TileBchDecoder.BitPat_onl01)
1346 blobWriter.setComment(self.
__author,
"no bad channels")
1348 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1349 except Exception
as e:
1350 self.log().critical( e )
1356 self.log().
info(
"*** Writing default pulse shapes with tag %s", tag)
1359 sources = {
'PHY' : (
'pulselo_physics.dat',
'pulsehi_physics.dat',
'TileDefault.plsPhy' ),
1360 'LAS' : (
'pulselo_laserMax1.dat',
'pulsehi_laserMax1.dat',
'TileDefault.plsLas' ),
1361 'CIS/PULSE100' : (
'pulselo_cis_100.dat',
'pulsehi_cis_100.dat',
'TileDefault.plsCisPulse100'),
1362 'CIS/PULSE5P2' : (
'pulselo.0230055.12.cap.5.2.dat',
'pulsehi.0230055.12.cap.5.2.dat',
'TileDefault.plsCisPulse5p2'),
1363 'CIS/LEAK100' : (
'leaklo_100.dat',
'leakhi_100.dat',
'TileDefault.plsCisLeak100'),
1364 'CIS/LEAK5P2' : (
'leaklo.0230055.12.cap.5.2.dat',
'leakhi.0230055.12.cap.5.2.dat',
'TileDefault.plsCisLeak5p2')
1368 for source, info
in list(sources.items()):
1375 lines =
open(path+info[0],
"r").readlines()
1377 fields = line.strip().
split()
1379 if not len(fields) :
1381 if fields[0].startswith(
"#"):
1383 if fields[0].startswith(
"*"):
1385 if len(fields) != 2 :
1388 xlo.append(
float(fields[0]))
1389 ylo.append(
float(fields[1]))
1394 lines =
open(path+info[1],
"r").readlines()
1396 fields = line.strip().
split()
1398 if not len(fields) :
1400 if fields[0].startswith(
"#"):
1402 if fields[0].startswith(
"*"):
1404 if len(fields) != 2 :
1407 xhi.append(
float(fields[0]))
1408 yhi.append(
float(fields[1]))
1411 fileStr =
"OBJVERSION 200"
1412 fileStr+=
"\n0x000\t0\t0\t"
1414 fileStr +=
"%f " % x
1416 fileStr +=
"%f " % y
1417 fileStr+=
"\n0x000\t0\t1\t"
1419 fileStr +=
"%f " % x
1421 fileStr +=
"%f " % y
1423 defFile =
open(info[2],
"w")
1424 defFile.write(fileStr)
1428 defaultLo = cppyy.gbl.std.vector(
'float')()
1430 defaultLo.push_back(x)
1432 defaultLo.push_back(y)
1433 defaultHi = cppyy.gbl.std.vector(
'float')()
1435 defaultHi.push_back(x)
1437 defaultHi.push_back(y)
1438 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1439 defVec.push_back(defaultLo)
1440 defVec.push_back(defaultHi)
1445 util = cppyy.gbl.TileCalibUtils()
1446 for ros
in range(util.max_ros()):
1447 for drawer
in range(util.getMaxDrawer(ros)):
1448 blobWriter.zeroBlob(ros,drawer)
1451 det = blobWriter.getDrawer(0, 0)
1452 det.init(defVec,1,200)
1454 blobWriter.setComment(self.
__author,
"default pulse shapes")
1456 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1458 except Exception
as e:
1459 self.log().critical( e )
1465 self.log().
info(
"*** Writing default pulse shapes for TileMuonReceiver board with tag %s", tag)
1467 folder_name =
'MURCV'
1468 source_file =
'pulse_adder_muonRcv_physics.dat'
1469 output_file =
'TileDefault.plsMuRcv'
1476 lines =
open(path + source_file,
"r").readlines()
1478 fields = line.strip().
split()
1480 if not len(fields) :
1482 if fields[0].startswith(
"#"):
1484 if fields[0].startswith(
"*"):
1486 if len(fields) != 2 :
1489 phases.append(
float(fields[0]))
1490 amplitudes.append(
float(fields[1]))
1493 fileStr =
"OBJVERSION 200"
1494 fileStr +=
"\n0x000\t0\t0\t"
1495 for phase
in phases:
1496 fileStr +=
"%f " % phase
1497 for amplitude
in amplitudes:
1498 fileStr +=
"%f " % amplitude
1500 defFile =
open(output_file,
"w")
1501 defFile.write(fileStr)
1505 defaultPls = cppyy.gbl.std.vector(
'float')()
1506 for phase
in phases:
1507 defaultPls.push_back(phase)
1508 for amplitude
in amplitudes:
1509 defaultPls.push_back(amplitude)
1510 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1511 defVec.push_back(defaultPls)
1516 util = cppyy.gbl.TileCalibUtils()
1517 for ros
in range(util.max_ros()):
1518 for drawer
in range(util.getMaxDrawer(ros)):
1519 blobWriter.zeroBlob(ros,drawer)
1522 det = blobWriter.getDrawer(0, 0)
1523 det.init(defVec,1,200)
1525 blobWriter.setComment(self.
__author,
"default pulse shape for tile muon receiver board")
1527 blobWriter.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),folderTag)
1529 except Exception
as e:
1530 self.log().critical( e )
1536 self.log().
info(
"*** Writing default Muid thresholds" )
1539 The TileMuId algorythm runs in DSPs and requires up to 40 energy cuts
1540 per module (in barrel, in extended barrel it is less). These 40 numbers
1541 are 20 pairs of lower ad upper energy cuts for 20 cells in the module.
1542 The values are stored as a vector of 40 numbers at channel 0 of every module.
1549 default = cppyy.gbl.std.vector(
'float')()
1551 default.push_back(150.)
1552 default.push_back(5000.)
1553 defVec = cppyy.gbl.std.vector(
'std::vector<float>')()
1554 defVec.push_back(default)
1555 defVec.push_back(default)
1559 writer.setComment(self.
__author,
"TileMuId default values")
1562 util = cppyy.gbl.TileCalibUtils()
1563 for ros
in range(util.max_ros()):
1564 for drawer
in range(util.getMaxDrawer(ros)):
1565 writer.zeroBlob(ros,drawer)
1566 calibDrawer = writer.getDrawer(0,0)
1567 calibDrawer.init(defVec,1,1)
1570 writer.register((MINRUN,MINLBK),(MAXRUN,MAXLBK),
"")