14 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15 from AthenaConfiguration.ComponentFactory
import CompFactory
16 from TileConfiguration.TileConfigFlags
import TileRunType
28 [(1, 1, 0, 1, 1, 0, 1), [ 0.2, 22.1, 2.4, 42.9]],
29 [(1, 1, 0, 1, 1, 1, 1), [-0.4, 75.0, 2.7, 31.4]],
30 [(1, 1, 0, 1, 0, 0, 1), [-0.9, -13.3, 1.5, 37.4]],
31 [(1, 1, 0, 2, 0, 1, 1), [41.8, 0.1, 2.5, 45.7]],
32 [(1, 1, 0, 2, 0, 0, 1), [30.6, -0.4, 2.0, 33.1]],
33 [(1, 1, 0, 2, 1, 1, 1), [ 1.4, 12.9, 4.7, 43.1]],
34 [(1, 1, 0, 2, 1, 0, 1), [ 3.4, 3.5, 1.9, 54.2]],
38 [(3, 1, 8, 13, 3, 0, 1), [26.9, 4.8, 5.2, 45.4]],
42 [(3, 1, 18, 13, 3, 0, 1), [ 4.4, -26.5, 23.9, 51.2]],
43 [(3, 1, 18, 15, 3, 0, 1), [-0.1, -75.0, 3.7, 51.0]],
44 [(3, 1, 18, 8, 2, 0, 1), [-0.1, 75.0, 4.2, 41.7]],
45 [(3, 1, 18, 8, 2, 1, 1), [ 3.5, -11.9, 2.6, 44.7]],
46 [(3, 1, 18, 9, 1, 0, 1), [ 0.8, -17.6, 1.8, 49.2]],
47 [(3, 1, 18, 9, 1, 1, 1), [ 0.1, -75.0, 3.4, 48.4]],
48 [(2, 1, 18, 11, 0, 0, 1), [ 8.7, 0.4, 2.7, 50.2]],
49 [(2, 1, 18, 11, 0, 1, 1), [ 6.3, 1.9, 1.6, 48.6]],
50 [(2, 1, 18, 10, 1, 0, 1), [53.3, 1.3, 3.8, 38.4]],
51 [(2, 1, 18, 10, 1, 1, 1), [64.1, 1.0, 3.5, 36.9]],
52 [(2, 1, 18, 12, 0, 0, 1), [-0.2, -75.0, 2.8, 38.1]],
53 [(2, 1, 18, 12, 0, 1, 1), [ 0.5, -32.7, 1.9, 40.3]],
54 [(3, 1, 18, 10, 3, 0, 1), [ 5.4, 7.7, 8.2, 57.0]],
55 [(3, 1, 18, 11, 3, 0, 1), [48.9, 0.4, 4.0, 32.3]],
56 [(2, 1, 18, 11, 1, 0, 1), [38.5, 0.5, 1.7, 46.8]],
57 [(2, 1, 18, 11, 1, 1, 1), [48.1, 0.3, 1.6, 46.3]],
58 [(2, 1, 18, 10, 2, 0, 1), [ 0.3, 75.0, 2.0, 34.9]],
59 [(2, 1, 18, 10, 2, 1, 1), [0.1, -75.0, 3.7, 54.7]],
63 [135, [ [(4, 1, 0, 1, 0, 0, 0), [ 59.1, 2.8, 6.9, 56.2]] ]],
64 [181, [ [(4, 1, 6, 1, 0, 0, 0), [ 56.4, 1.2, 2.9, 39.9]] ]],
65 [182, [ [(4, 1, 6, 0, 0, 0, 0), [ 44.9, 0.5, 1.4, 42.1]] ]],
66 [231, [ [(4, -1, 3, 0, 0, 0, 0), [107.9, 1.7, 7.8, 47.8]] ]],
69 [220, [ [(4, -1, 0, 2, 0, 0, 0), [ 2.3, 3.2, 2.5, 44.4]] ]],
70 [223, [ [(4, -1, 1, 2, 0, 0, 0), [ 3.1, -5.3, 2.4, 44.4]] ]],
71 [225, [ [(4, -1, 2, 2, 0, 0, 0), [ -0.4, 27.6, 1.3, 32.5]] ]],
72 [228, [ [(4, -1, 3, 2, 0, 0, 0), [ 0.2, -75.0, 2.4, 35.4]] ]],
77 (1, 1, 0, 1, 1, 0) : [ 0.2, 22.1, 2.4, 42.9],
78 (1, 1, 0, 1, 1, 1) : [ -0.4, 75.0, 2.7, 120031.4],
79 (1, 1, 0, 1, 0, 0) : [ -0.9, -13.3, 1.5, 120037.4],
80 (1, 1, 0, 2, 0, 1) : [ 41.8, 0.1, 2.5, 45.7],
81 (1, 1, 0, 2, 0, 0) : [ 30.6, -0.4, 2.0, 120033.1],
82 (1, 1, 0, 2, 1, 1) : [ 1.4, 12.9, 4.7, 43.1],
83 (1, 1, 0, 2, 1, 0) : [ 3.4, 3.5, 1.9, 54.2],
84 (4, 1, 0, 1, 0, 0) : [ 59.1, 2.8, 6.9, 56.2],
85 (3, 1, 8, 13, 3, 0) : [ 26.9, 4.8, 5.2, 45.4],
86 (3, 1, 18, 13, 3, 0) : [ 4.4, -26.5, 23.9, 60051.2],
87 (3, 1, 18, 15, 3, 0) : [ -0.1, -75.0, 3.7, 120051.0],
88 (3, 1, 18, 8, 2, 0) : [ -0.1, 75.0, 4.2, 120041.7],
89 (3, 1, 18, 8, 2, 1) : [ 3.5, -11.9, 2.6, 120044.7],
90 (3, 1, 18, 9, 1, 0) : [ 0.8, -17.6, 1.8, 120049.2],
91 (3, 1, 18, 9, 1, 1) : [ 0.1, -75.0, 3.4, 120048.4],
92 (2, 1, 18, 11, 0, 0) : [ 8.7, 0.4, 2.7, 60050.2],
93 (2, 1, 18, 11, 0, 1) : [ 6.3, 1.9, 1.6, 60048.6],
94 (2, 1, 18, 10, 1, 0) : [ 53.3, 1.3, 3.8, 60038.4],
95 (2, 1, 18, 10, 1, 1) : [ 64.1, 1.0, 3.5, 60036.9],
96 (2, 1, 18, 12, 0, 0) : [ -0.2, -75.0, 2.8, 120038.1],
97 (2, 1, 18, 12, 0, 1) : [ 0.5, -32.7, 1.9, 120040.3],
98 (3, 1, 18, 10, 3, 0) : [ 5.4, 7.7, 8.2, 60057.0],
99 (3, 1, 18, 11, 3, 0) : [ 48.9, 0.4, 4.0, 60032.3],
100 (2, 1, 18, 11, 1, 0) : [ 38.5, 0.5, 1.7, 60046.8],
101 (2, 1, 18, 11, 1, 1) : [ 48.1, 0.3, 1.6, 60046.3],
102 (2, 1, 18, 10, 2, 0) : [ 0.3, 75.0, 2.0, 170034.9],
103 (2, 1, 18, 10, 2, 1) : [ 0.1, -75.0, 3.7, 120054.7],
104 (4, 1, 6, 1, 0, 0) : [ 56.4, 1.2, 2.9, 39.9],
105 (4, 1, 6, 0, 0, 0) : [ 44.9, 0.5, 1.4, 42.1],
106 (4, -1, 0, 2, 0, 0) : [ 2.3, 3.2, 2.5, 44.4],
107 (4, -1, 1, 2, 0, 0) : [ 3.1, -5.3, 2.4, 10044.4],
108 (4, -1, 2, 2, 0, 0) : [ -0.4, 27.6, 1.3, 10032.5],
109 (4, -1, 3, 2, 0, 0) : [ 0.2, -75.0, 2.4, 10035.4],
110 (4, -1, 3, 0, 0, 0) : [107.9, 1.7, 7.8, 47.8],
121 exp_chans_1 = exp_merge (exp_chans_0, {
122 (3, 1, 18, 13, 3, 0) : [ 4.4, -26.5, 23.9, 70051.2],
123 (3, 1, 18, 15, 3, 0) : [ -0.1, -75.0, 3.7, 70051.0],
124 (3, 1, 18, 8, 2, 0) : [ -0.1, 75.0, 4.2, 70041.7],
125 (2, 1, 18, 10, 1, 1) : [ 64.1, 1.0, 3.5, 70036.9],
126 (2, 1, 18, 12, 0, 0) : [ -0.2, -75.0, 2.8, 70038.1],
127 (2, 1, 18, 12, 0, 1) : [ 0.5, -32.7, 1.9, 70040.3],
132 exp_chans_2 = exp_merge (exp_chans_0, {
133 (1, 1, 0, 1, 1, 0) : [ -0.6, 22.1, 2.4, 43.7],
134 (1, 1, 0, 2, 0, 1) : [ 41.0, 0.1, 2.5, 46.5],
135 (1, 1, 0, 2, 1, 1) : [ 0.6, 12.9, 4.7, 43.9],
140 exp_chans_3 = exp_merge (exp_chans_0, {
141 (1, 1, 0, 1, 1, 0) : [ 0.125, 22.1, 2.4, 42.975],
142 (1, 1, 0, 1, 1, 1) : [ -0.475, 75.0, 2.7, 120031.477],
143 (1, 1, 0, 1, 0, 0) : [ -0.975, -13.3, 1.5, 120037.477],
144 (1, 1, 0, 2, 0, 1) : [ 41.725, 0.1, 2.5, 45.775],
145 (1, 1, 0, 2, 0, 0) : [ 30.525, -0.4, 2.0, 120033.180],
146 (1, 1, 0, 2, 1, 1) : [ 1.325, 12.9, 4.7, 43.175],
158 OptFilterDspCompressed = 3
164 WienerFilterOffline = 9
167 from AthenaPython.PyAthenaComps
import Alg, StatusCode
173 Alg.__init__ (self, name)
178 return StatusCode.Success
182 iev = self.getContext().
evt()
185 baddq = {146: (2, 10)}
192 self.evtStore.record (rc,
'TRCDQ',
False)
194 return StatusCode.Success
198 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
201 typ = TileFragHash.Default
202 cont = ROOT.TileRawChannelContainer (
False, typ, unit)
203 hashFunc = cont.hashFunc()
205 digits = dict (digits)
206 for icoll
in range(256):
207 colldata = digits.get (icoll, [])
209 coll = self.
make_rc_coll (idHelper, hashFunc, icoll, colldata)
210 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
211 ROOT.SetOwnership (coll,
False)
217 coll = ROOT.TileRawChannelCollection (hashFunc.identifier(icoll))
219 for addr, data
in colldata:
220 if isinstance(addr, tuple):
221 adc_id = idHelper.adc_id (*addr)
222 chan = ROOT.TileRawChannel (adc_id, *data)
224 hwid = ROOT.HWIdentifier (addr)
225 chan = ROOT.TileRawChannel (hwid, *data)
227 coll.push_back (chan)
233 cont = ROOT.TileRawChannelContainer (
False, TileFragHash.OptFilterDsp, 0)
234 hashFunc = cont.hashFunc()
235 for icoll, chans
in baddq.items():
236 coll = ROOT.TileRawChannelCollection (hashFunc.identifier (icoll))
239 mask |= (1<<(chan//3))
240 coll.setFragMemoryPar(mask)
241 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
242 ROOT.SetOwnership (coll,
False)
252 Alg.__init__ (self, name)
256 ROOT.ICaloCellMakerTool
259 tool = ROOT.ToolHandle(ROOT.TileRawChannelBuilder)(
'TileRawChannelBuilderTest/' + name)
260 if not tool.retrieve():
267 return StatusCode.Success
272 return StatusCode.Success
276 ctx = self.getContext()
280 return StatusCode.Success
283 exp_chans = exp_chans_0
291 exp_chans = exp_chans_1
296 exp_chans = exp_chans_2
300 exp_chans = exp_chans_3
304 if not tool.createContainer(ctx):
305 return StatusCode.Failure
308 if not tool.build (coll, ctx):
309 return StatusCode.Failure
311 if not tool.commitContainer(ctx):
312 return StatusCode.Failure
314 chans = self.evtStore[
'TileRawChannelFiltered']
317 return StatusCode.Success
322 v = getattr(ROOT,
'std::vector<float>')()
323 v.reserve (len (data))
330 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
333 typ = TileFragHash.Default
334 cont = ROOT.TileDigitsContainer (
False, typ, unit)
335 hashFunc = cont.hashFunc()
337 for icoll, colldata
in digits:
340 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
341 ROOT.SetOwnership (coll,
False)
347 coll = ROOT.TileDigitsCollection (hashFunc.identifier(icoll))
349 for addr, data
in colldata:
350 if isinstance(addr, tuple):
351 adc_id = idHelper.adc_id (*addr)
352 chan = ROOT.TileDigits (adc_id, TestAlg.make_vec (data))
354 hwid = ROOT.HWIdentifier (addr)
355 chan = ROOT.TileDigits (hwid, TestAlg.make_vec (data))
356 coll.push_back (chan)
362 assert chans.get_type() == 0
363 assert chans.get_unit() == 0
364 assert chans.get_bsflags() == (3<<28)
366 exp_chans = exp_chans.copy()
367 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
371 lchan = [c.amplitude(),
377 addr = (idHelper.section(cid),
379 idHelper.module(cid),
381 idHelper.sampling(cid),
384 l = exp_chans.get (addr)
386 print (
'xxx unexpected chan', addr, lchan)
392 if (reldiff (lchan[0], l[0]) > 1e-3
or
393 reldiff (lchan[1], l[1]) > 1e-3
or
394 reldiff (lchan[2], l[2]) > 1e-3
or
395 reldiff (lchan[3], l[3]) > 1e-3):
396 print (
'xxx chan mismatch: ', addr, lchan, l)
400 for extra
in exp_chans:
401 print (
'xxx unfound chan', extra)
413 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
416 from TileConditions.TileEMScaleConfig
import TileEMScaleCondAlgCfg
419 from TileConditions.TileSampleNoiseConfig
import TileSampleNoiseCondAlgCfg
422 TileRawChannelBuilderTest = CompFactory.TileRawChannelBuilderTest
425 TileRawChannelNoiseFilter = CompFactory.TileRawChannelNoiseFilter
431 from TileRecUtils.TileDQstatusConfig
import TileDQstatusAlgCfg
433 TileRawChannelContainer=
'TRCDQ'))
435 acc.addEventAlgo(
TestAlg(
'testalg1') )
440 if __name__ ==
"__main__":
442 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
443 from AthenaConfiguration.TestDefaults
import defaultTestFiles
444 from AthenaCommon.Logging
import log
451 flags.Input.Files = defaultTestFiles.ESD_RUN2_MC
452 flags.Tile.RunType = TileRunType.PHY
453 flags.Exec.MaxEvents = 4
458 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
462 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
468 cfg.printConfig(withDetails=
True)
469 cfg.store(
open(
'TileRawChannelBuilderTest.pkl',
'wb') )
475 sys.exit(
not sc.isSuccess())