14 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15 from AthenaConfiguration.ComponentFactory
import CompFactory
16 from TileConfiguration.TileConfigFlags
import TileRunType
22 [(1, 1, 0, 1, 1, 0, 1), [ 0.2, 22.1, 2.4, 42.9]],
23 [(1, 1, 0, 1, 1, 1, 1), [-0.4, 75.0, 2.7, 31.4]],
24 [(1, 1, 0, 1, 0, 0, 1), [-0.9, -13.3, 1.5, 37.4]],
25 [(1, 1, 0, 2, 0, 1, 1), [41.8, 0.1, 2.5, 45.7]],
26 [(1, 1, 0, 2, 0, 0, 1), [30.6, -0.4, 2.0, 33.1]],
27 [(1, 1, 0, 2, 1, 1, 1), [ 1.4, 12.9, 4.7, 43.1]],
28 [(1, 1, 0, 2, 1, 0, 1), [ 3.4, 3.5, 1.9, 54.2]],
32 [(3, 1, 8, 13, 3, 0, 1), [26.9, 4.8, 5.2, 45.4]],
36 [(3, 1, 18, 13, 3, 0, 1), [ 4.4, -26.5, 23.9, 51.2]],
37 [(3, 1, 18, 15, 3, 0, 1), [-0.1, -75.0, 3.7, 51.0]],
38 [(3, 1, 18, 8, 2, 0, 1), [-0.1, 75.0, 4.2, 41.7]],
39 [(3, 1, 18, 8, 2, 1, 1), [ 3.5, -11.9, 2.6, 44.7]],
40 [(3, 1, 18, 9, 1, 0, 1), [ 0.8, -17.6, 1.8, 49.2]],
41 [(3, 1, 18, 9, 1, 1, 1), [ 0.1, -75.0, 3.4, 48.4]],
42 [(2, 1, 18, 11, 0, 0, 1), [ 8.7, 0.4, 2.7, 50.2]],
43 [(2, 1, 18, 11, 0, 1, 1), [ 6.3, 1.9, 1.6, 48.6]],
44 [(2, 1, 18, 10, 1, 0, 1), [53.3, 1.3, 3.8, 38.4]],
45 [(2, 1, 18, 10, 1, 1, 1), [64.1, 1.0, 3.5, 36.9]],
46 [(2, 1, 18, 12, 0, 0, 1), [-0.2, -75.0, 2.8, 38.1]],
47 [(2, 1, 18, 12, 0, 1, 1), [ 0.5, -32.7, 1.9, 40.3]],
48 [(3, 1, 18, 10, 3, 0, 1), [ 5.4, 7.7, 8.2, 57.0]],
49 [(3, 1, 18, 11, 3, 0, 1), [48.9, 0.4, 4.0, 32.3]],
50 [(2, 1, 18, 11, 1, 0, 1), [38.5, 0.5, 1.7, 46.8]],
51 [(2, 1, 18, 11, 1, 1, 1), [48.1, 0.3, 1.6, 46.3]],
52 [(2, 1, 18, 10, 2, 0, 1), [ 0.3, 75.0, 2.0, 34.9]],
53 [(2, 1, 18, 10, 2, 1, 1), [0.1, -75.0, 3.7, 54.7]],
57 [135, [ [(4, 1, 0, 1, 0, 0, 0), [ 59.1, 2.8, 6.9, 56.2]] ]],
58 [181, [ [(4, 1, 6, 1, 0, 0, 0), [ 56.4, 1.2, 2.9, 39.9]] ]],
59 [182, [ [(4, 1, 6, 0, 0, 0, 0), [ 44.9, 0.5, 1.4, 42.1]] ]],
60 [231, [ [(4, -1, 3, 0, 0, 0, 0), [107.9, 1.7, 7.8, 47.8]] ]],
63 [220, [ [(4, -1, 0, 2, 0, 0, 0), [ 2.3, 3.2, 2.5, 44.4]] ]],
64 [223, [ [(4, -1, 1, 2, 0, 0, 0), [ 3.1, -5.3, 2.4, 44.4]] ]],
65 [225, [ [(4, -1, 2, 2, 0, 0, 0), [ -0.4, 27.6, 1.3, 32.5]] ]],
66 [228, [ [(4, -1, 3, 2, 0, 0, 0), [ 0.2, -75.0, 2.4, 35.4]] ]],
70 [4706026383833300992, [ 0, 0, 0, 50000]],
71 [4706027483344928768, [ 0, 0, 0, 50000]] ], ],
73 [4706157225717006336, [ 0, 0, 0, 80000]],
74 [4706158325228634112, [ 0, 0, 0, 80000]] ], ],
81 for icoll, colldata
in hits_0:
83 for addr, data
in colldata:
87 colldata_out.append ([addr, data])
88 out.append ([icoll, colldata_out])
93 (1, 1, 0, 1, 0) : [-10.4734, -10.4734, -13.3, -13.3, 1, 1, 130, 138, 1, 1],
94 (1, 1, 0, 1, 1) : [ 2.3274, -4.6548, 22.1, 75.0, 2, 2, 130, 130, 1, 1],
95 (1, 1, 0, 2, 0) : [356.0956, 486.4312, -0.4, 0.1, 2, 2, 162, 162, 1, 1],
96 (1, 1, 0, 2, 1) : [ 39.5662, 16.2920, 3.5, 12.9, 1, 4, 162, 130, 1, 1],
98 (2, 1, 18, 10, 1):[620.25793, 745.93872, 1.3, 1.0, 3, 3, 162, 162, 1, 1],
99 (2, 1, 18, 10, 2):[ 3.49113, 1.16371, 75.0, -75.0, 2, 3, 130, 130, 1, 1],
100 (2, 1, 18, 11, 0):[101.24284, 73.31380, 0.4, 1.9, 2, 1, 162, 162, 1, 1],
101 (2, 1, 18, 11, 1):[448.02869, 559.74500, 0.5, 0.3, 1, 1, 162, 162, 1, 1],
102 (2, 1, 18, 12, 0):[ -2.32742, 5.81855,-75.0, -32.7, 2, 1, 130, 130, 1, 1],
103 (3, 1, 18, 8, 2):[ -0.96976, 33.94157, 75.0, -11.9, 4, 2, 130, 130, 1, 1],
104 (3, 1, 18, 9, 1):[ 7.75807, 0.96976,-17.6, -75.0, 1, 3, 130, 130, 1, 1],
105 (3, 1, 18, 10, 3):[ 41.89359, 0.0, 7.7, 7.7, 8, 0, 162, 0, 1,-1],
106 (3, 1, 18, 11, 3):[379.36975, 0.0, 0.4, 0.4, 4, 0, 162, 0, 1,-1],
107 (3, 1, 18, 13, 3):[ 34.13552, 0.0, -26.5, -26.5,23, 0, 130, 0, 1,-1],
108 (3, 1, 18, 15, 3):[ -0.77581, 0.0, -75.0, -75.0, 3, 0, 130, 0, 1, -1],
111 (3, 1, 8, 13, 3) : [208.6922, 0.0, 4.8, 4.8, 5, 0, 162, 0, 1, -1],
116 (4, 1, 0, 1, 0) : [0.7221, 0.0, 2.8, 2.8, 6, 0, 162, 0, 1, -1],
117 (4, 1, 6, 1, 0) : [0.6891, 0.0, 1.2, 1.2, 2, 0, 162, 0, 1, -1],
118 (4, 1, 6, 0, 0) : [0.5486, 0.0, 0.5, 0.5, 1, 0, 162, 0, 1, -1],
119 (4, -1, 3, 0, 0) : [1.318, 0.0, 1.7, 1.7, 7, 0, 162, 0, 1, -1],
124 (4, -1, 0, 2, 0) : [17.84357, 0.0, 3.2, 3.2, 2, 0, 130, 0, 1, -1],
125 (4, -1, 1, 2, 0) : [24.05003, 0.0, -5.3, -5.3, 2, 0, 130, 0, 1, -1],
126 (4, -1, 2, 2, 0) : [-3.10323, 0.0, 27.6, 27.6, 1, 0, 130, 0, 1, -1],
127 (4, -1, 3, 2, 0) : [1.551615, 0.0, -75.0, -75.0, 2, 0, 130, 0, 1, -1],
138 hits_1 = add_pedestal ((3, 1, 18, 15, 3, 0, 1), 10000)
139 exp_cells_1 = exp_merge (exp_cells_0, {
140 (3, 1, 18, 15, 3) : [-0.7758, 0.0, -75.0, -75.0, 3, 0, 146, 0, 1, -1],
144 hits_2 = add_pedestal ((3, 1, 18, 15, 3, 0, 1), 20000)
145 exp_cells_2 = exp_merge (exp_cells_0, {
146 (3, 1, 18, 15, 3) : [-0.7758, 0.0, -75.0, -75.0, 3, 0, 146, 0, 1, -1],
150 exp_cells_3 = exp_merge (exp_cells_0, {
151 (3, 1, 18, 8, 2) : [ 33.9416, 33.9416, -11.9, -11.9, 2, 2, 138, 130, 1, 1],
152 (2, 1, 18, 11, 0) : [101.2428, 73.3138, 1.9, 1.9, 2, 1, 34, 162, 1, 1],
153 (2, 1, 18, 12, 0) : [ -2.3274, -2.3274, -75.0, -75.0, 2, 2, 130, 138, 1, 1],
155 exp_mbts_3 = exp_merge (exp_mbts_0, {
156 (4, 1, 0, 1, 0) : [ 0.0, 0.0, -100.0,-100.0,255,0, 10, 8, 1,-1],
157 (4, 1, 6, 1, 0) : [ 0.6891, 0.0, 0.0, 0.0, 2, 0, 34, 0, 1,-1],
161 exp_cells_4 = exp_merge (exp_cells_0, {
162 (2, 1, 18, 10, 1):[620.2579,620.2579, 1.3, 1.3, 3, 3, 161, 169, 1, 1],
163 (2, 1, 18, 12, 0):[ 0.5, 0.5, 0.0, 0.0, 255, 255, 9, 9, 1, 1],
164 (3, 1, 18, 8, 2):[ 33.9416, 33.9416,-11.9,-11.9, 2, 2, 137, 129, 1, 1],
165 (3, 1, 18, 13, 3):[ 0.5, 0.0, 0.0, 0.0, 255, 0, 9, 8, 1,-1],
166 (3, 1, 18, 15, 3):[ 0.5, 0.0, 0.0, 0.0, 255, 0, 9, 8, 1,-1],
171 exp_cells_5 = exp_merge (exp_cells_0, {
172 (3, 1, 8, 8, 2) : [0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0],
173 (3, 1, 8, 9, 1) : [0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0],
174 (3, 1, 8, 10, 3) : [0.0, 0.0, 0.0, 0.0, 0, 0, 8, 8, 0, -1],
175 (3, 1, 8, 11, 3) : [0.0, 0.0, 0.0, 0.0, 0, 0, 8, 8, 0, -1],
176 (3, 1, 8, 15, 3) : [0.0, 0.0, 0.0, 0.0, 0, 0, 8, 8, 0, -1],
182 for addr, l
in base.items():
183 if l[0] >= thresh
or l[1] >= thresh:
188 exp_cells_6 = filter_e (exp_cells_0, 300)
193 exp_cells_7 = exp_merge (exp_cells_0, {
194 (1, 1, 0, 2, 0) : [356.1491, 486.4361, -0.4, 0.1, 2, 2, 162, 162, 1, 1],
195 (2, 1, 18, 10, 1) : [621.3283, 746.7004, 1.3, 1.0, 3, 3, 162, 162, 1, 1],
196 (2, 1, 18, 11, 1) : [448.1431, 559.7963, 0.5, 0.3, 1, 1, 162, 162, 1, 1],
197 (3, 1, 8, 13, 3) : [213.6019, 0.0, 4.8, 4.8, 5, 0, 162, 0, 1,-1],
198 (3, 1, 18, 11, 3) : [379.4317, 0.0, 0.4, 0.4, 4, 0, 162, 0, 1,-1],
200 exp_mbts_7 = exp_merge (exp_mbts_0, {
201 (4, 1, 0, 1, 0) : [0.7279, 0.0, 2.8, 2.8, 6, 0, 162, 0, 1, -1],
202 (4, 1, 6, 1, 0) : [0.6902, 0.0, 1.2, 1.2, 2, 0, 162, 0, 1, -1],
203 (4, -1, 3, 0, 0) : [1.3223, 0.0, 1.7, 1.7, 7, 0, 162, 0, 1, -1],
208 exp_cells_8 = exp_merge (exp_cells_0, {
209 (1, 1, 0, 1, 0) : [-11.3462, -11.3462, -13.3, -13.3, 1, 1, 130, 138, 1, 1],
210 (1, 1, 0, 1, 1) : [ 1.4546, -5.5276, 22.1, 75.0, 2, 2, 130, 130, 1, 1],
211 (1, 1, 0, 2, 0) : [355.2228, 485.5583, -0.4, 0.1, 2, 2, 162, 162, 1, 1],
212 (1, 1, 0, 2, 1) : [ 39.5662, 15.4192, 3.5, 12.9, 1, 4, 162, 130, 1, 1],
217 exp_cells_10 = exp_merge (exp_cells_7, {
218 (1, 1, 0, 2, 0) : [356.1227, 486.4159, -0.4, 0.1, 2, 2, 162, 162, 1, 1],
230 OptFilterDspCompressed = 3
236 WienerFilterOffline = 9
239 from AthenaPython.PyAthenaComps
import Alg, StatusCode
246 Alg.__init__ (self, name)
250 return StatusCode.Success
253 iev = self.getContext().
evt()
262 dspbsflags = 0x32002000
263 self.
rctype = TileFragHash.OptFilterOffline
291 self.
rctype = TileFragHash.OptFilterDsp
292 baddq = {146 : [2, 10]}
328 dspbsflags = 0x20000000
344 return StatusCode.Success
348 dspbsflags=0, dspcolls=set(),
349 rawname =
'TileRawChannelCnt'):
350 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
353 cont = ROOT.TileRawChannelContainer (
False, typ, unit)
354 cont.set_bsflags (bsflags)
355 hashFunc = cont.hashFunc()
359 dspcont = ROOT.TileRawChannelContainer (
False, typ, unit)
360 dspcont.set_bsflags (dspbsflags)
362 for icoll, colldata
in hits:
363 coll = ROOT.TileRawChannelCollection (hashFunc.identifier(icoll))
366 for chan
in baddq.get (icoll, []):
367 mask |= (1<<(chan//3))
368 coll.setFragMemoryPar(mask)
370 for addr, data
in colldata:
371 if isinstance(addr, tuple):
372 adc_id = idHelper.adc_id (*addr)
373 chan = ROOT.TileRawChannel (adc_id, *data)
375 hwid = ROOT.HWIdentifier (addr)
376 chan = ROOT.TileRawChannel (hwid, *data)
377 coll.push_back (chan)
379 if icoll
in dspcolls:
383 thiscont.addCollection (coll, ROOT.IdentifierHash(icoll))
384 ROOT.SetOwnership (coll,
False)
386 self.evtStore.record (cont, rawname,
False)
388 self.evtStore.record (dspcont,
'TileRawChannelCntDsp',
False)
397 Alg.__init__ (self, name)
402 ROOT.ICaloCellMakerTool
405 tool = ROOT.ToolHandle(ROOT.ICaloCellMakerTool)(
'TileCellBuilder/' + name)
406 if not tool.retrieve():
420 return StatusCode.Success
425 return StatusCode.Success
429 tool = getattr (self, self.
prepAlg.tool)
431 ccc = ROOT.CaloCellContainer()
432 if not tool.process (ccc, self.getContext()):
433 return StatusCode.Failure
438 self.
compare_cells (self.evtStore[
'E4prContainer'], exp_e4_0, rctype)
441 return StatusCode.Success
447 return qb&(~7) | rctype
451 exp_cells = exp_cells.copy()
452 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
455 lcell = [c.ene1(), c.ene2(), c.time1(), c.time2(),
456 c.qual1(), c.qual2(),
457 c.qbit1(), c.qbit2(),
458 c.gain1(), c.gain2()]
461 addr = (idHelper.section(cid),
463 idHelper.module(cid),
465 idHelper.sampling(cid))
466 l = exp_cells.get (addr)
468 print (
'xxx unexpected cell', addr, lcell)
475 if l[0] != 0: l[6] = TestAlg.update_qbit (l[6], rctype)
476 if l[1] != 0: l[7] = TestAlg.update_qbit (l[7], rctype)
478 if (abs (lcell[0] - l[0]) > 1e-3
or
479 abs (lcell[1] - l[1]) > 1e-3
or
480 abs (lcell[2] - l[2]) > 1e-3
or
481 abs (lcell[3] - l[3]) > 1e-3
or
482 abs (lcell[4] != l[4])
or
483 abs (lcell[5] != l[5])
or
484 abs (lcell[6] != l[6])
or
485 abs (lcell[7] != l[7])
or
486 abs (lcell[8] != l[8])
or
487 abs (lcell[9] != l[9])):
488 print (
'xxx cell mismatch: ', addr, lcell, l)
492 for extra
in exp_cells:
493 print (
'xxx unfound cell', extra)
499 ei = self.evtStore[
'EventInfo']
500 assert ei.eventFlags (ROOT.xAOD.EventInfo.Tile) == (0xf0f0005 | extra_flags)
501 assert ei.errorState (ROOT.xAOD.EventInfo.Tile) == ROOT.xAOD.EventInfo.Error
506 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
507 hwidHelper = self.detStore[
'TileHWID']
508 cabling = ROOT.TileCablingService.getInstance()
511 for addr, data
in chans:
512 pmt_id = idHelper.pmt_id (*addr)
513 channel_id = cabling.s2h_channel_id (pmt_id)
514 frag = hwidHelper.frag (channel_id)
515 channel = hwidHelper.channel (channel_id)
516 line =
'0x%03x %d 0 %d %d %d' % (frag, channel, data[0], data[1], data[2])
519 return '\n'.join (lines)
523 for name, (chans, lines)
in baddefs.items():
525 if xlines.strip() != lines.strip():
526 print (
'xxx Bad chan lines need updating: ', name)
535 BAD_LOW = [1<<1, 0, 0]
536 BAD_HIGH = [ 0, 1<<1, 0]
537 BAD_BOTH = [ 0, 0, 1<<1]
538 BADTIMING = [ 0, 0, 1<<9]
544 chans: [(sec, side, mod, tow, samp, pmt), [DATA0, DATA1, DATA2]]
545 We'd like to specify cells using offline addressing, but the bad cell
546 file uses online addressing. We can convert, but that requires
547 idhelpers, etc, that aren't available until after initialization.
548 So we pass in both representations; in finalize(), we'll check
549 that they match and print out the correct bad cell lines
552 File data line format:
553 frag channel dummy adcStatus0 adcStatus1 chnStatus
554 chnStatus + adcStatusN are given to TileBchDecoder.
555 Offline problem masks:
557 0 GeneralMaskChannel GeneralMaskAdc
560 3 WrongHV DataCorruption
561 4 NoLaser VeryLargeHfNoise
563 6 NoCesium WrongDspConfig
564 7 BadCesium LargeHfNoise
565 8 NoTiming CorrelatedNoise
566 9 BadTiming LargeLfNoise
567 10 TrigGeneralMask NoCis
569 12 TrigHalfGain SevereStuckBit
570 13 TrigNoisy SevereDataCorruption
571 14 Emergency IgnoredByDQV
578 Online problem masks:
580 0 IgnoredInDsp OnlineGeneralMaskAdc
591 TileBchList =
'TileNoBad.oflBch'
593 TileBchList = badChannels +
'.bch'
594 f = open (TileBchList,
'w')
595 print (
'OBJVERSION 0', file=f)
596 print (
'0x000 0 0 0 0 0', file=f)
599 baddefs[badChannels] = (chans, lines)
602 TileCondProxyFileBch = CompFactory.getComp(
"TileCondProxyFile<TileCalibDrawerBch>")
604 offlineBadChannelsProxy =
TileCondProxyFileBch(
'TileCondProxyFile_OflBch', Source=
'TileNoBad.oflBch')
606 TileBadChannelsCondAlg = CompFactory.TileBadChannelsCondAlg
608 OnlBchProxy=onlineBadChannelsProxy,
609 OflBchProxy=offlineBadChannelsProxy,
610 TileBadChannels=badChannels)
613 acc.addCondAlgo(badChannelsCondAlg)
618 badChannelsLines =
"""
628 TileCellBuilder = CompFactory.TileCellBuilder
636 from TileGeoModel.TileGMConfig
import TileGMCfg
639 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
642 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
645 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
648 from TileConditions.TileEMScaleConfig
import TileEMScaleCondAlgCfg
651 from TileConditions.TileTimingConfig
import TileTimingCondAlgCfg
654 from TileConditions.TileSampleNoiseConfig
import TileSampleNoiseCondAlgCfg
657 bc1 =
'tilecellbuilder_bc1'
660 bc2 =
'tilecellbuilder_bc2'
662 [[(3, 1, 18, 8, 2, 0), BAD_HIGH],
663 [(2, 1, 18, 9, 1, 0), BAD_LOW],
664 [(2, 1, 18, 12, 0, 1), BAD_BOTH],
665 [(2, 1, 18, 11, 0, 0), BADTIMING],
666 [(4, 1, 0, 1, 0, 0), BAD_BOTH],
667 [(4, 1, 6, 1, 0, 0), BADTIMING],
668 ], badChannelsLines) )
671 TileRawChannelNoiseFilter = CompFactory.TileRawChannelNoiseFilter
674 acc.addPublicTool( maketool (
'tool1', bc1) )
675 acc.addPublicTool( maketool (
'tool2', bc2) )
676 acc.addPublicTool( maketool (
'tool5', bc1, fakeCrackCells=
True) )
677 acc.addPublicTool( maketool (
'tool6', bc1, EThreshold=300) )
678 acc.addPublicTool( maketool (
'tool7', bc1, correctAmplitude=
True, correctTime=
True) )
679 acc.addPublicTool( maketool (
'tool8', bc1, NoiseFilterTools=[noisefilter]) )
680 acc.addPublicTool( maketool (
'tool9', bc1, TileDSPRawChannelContainer=
'TileRawChannelCntDsp') )
681 acc.addPublicTool( maketool (
'tool10', bc1, TileDSPRawChannelContainer =
'TileRawChannelCntDsp',
682 correctTime=
True, correctAmplitude=
True) )
683 acc.addPublicTool( maketool (
'tool11', bc1, TileDSPRawChannelContainer=
'TileRawChannelCntDsp',
684 NoiseFilterTools=[noisefilter]) )
687 prepalg1 = acc.getEventAlgo(
'prepalg1')
689 from TileRecUtils.TileDQstatusConfig
import TileDQstatusAlgCfg
691 TileRawChannelContainer=
'TRCDQ',
692 TileDigitsContainer=
''))
695 acc.addEventAlgo(
TestAlg(
'testalg1', prepalg1) )
701 if __name__ ==
"__main__":
703 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
704 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultTestFiles
705 from AthenaCommon.Logging
import log
712 flags.Input.Files = defaultTestFiles.HITS_RUN2
713 flags.Input.ConditionsRunNumber = 1
714 flags.Input.OverrideRunNumber =
True
715 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
716 flags.Tile.RunType = TileRunType.PHY
717 flags.Exec.MaxEvents = 12
722 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
726 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
729 from xAODEventInfoCnv.xAODEventInfoCnvConfig
import EventInfoCnvAlgCfg
730 cfg.merge (EventInfoCnvAlgCfg (flags, disableBeamSpot =
True))
735 cfg.printConfig(withDetails=
True)
736 cfg.store(
open(
'TileCellBuilderTest.pkl',
'wb') )
742 sys.exit(
not sc.isSuccess())