14 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15 from TileConfiguration.TileConfigFlags
import TileRunType
16 from AthenaPython.PyAthenaComps
import Alg, StatusCode
29 OptFilterDspCompressed = 3
35 WienerFilterOffline = 9
47 LASER_OBJ_FRAG = 0x016
53 [(1, 1, 0, 1, 1, 0, 1), [ 0.2, 22.1, 2.4, 42.9]],
54 [(1, 1, 0, 1, 1, 1, 1), [-0.4, 75.0, 2.7, 31.4]],
55 [(1, 1, 0, 1, 0, 0, 1), [-0.9, -13.3, 1.5, 37.4]],
56 [(1, 1, 0, 2, 0, 1, 1), [41.8, 0.1, 2.5, 45.7]],
57 [(1, 1, 0, 2, 0, 0, 1), [30.6, -0.4, 2.0, 33.1]],
58 [(1, 1, 0, 2, 1, 1, 1), [ 1.4, 12.9, 4.7, 43.1]],
59 [(1, 1, 0, 2, 1, 0, 1), [ 3.4, 3.5, 1.9, 54.2]],
63 [(3, 1, 8, 13, 3, 0, 1), [26.9, 4.8, 5.2, 45.4]],
67 [(3, 1, 18, 13, 3, 0, 1), [ 4.4, -26.5, 23.9, 51.2]],
68 [(3, 1, 18, 15, 3, 0, 1), [-0.1, -75.0, 3.7, 51.0]],
69 [(3, 1, 18, 8, 2, 0, 1), [-0.1, 75.0, 4.2, 41.7]],
70 [(3, 1, 18, 8, 2, 1, 1), [ 3.5, -11.9, 2.6, 44.7]],
71 [(3, 1, 18, 9, 1, 0, 1), [ 0.8, -17.6, 1.8, 49.2]],
72 [(3, 1, 18, 9, 1, 1, 1), [ 0.1, -75.0, 3.4, 48.4]],
73 [(2, 1, 18, 11, 0, 0, 1), [ 8.7, 0.4, 2.7, 50.2]],
74 [(2, 1, 18, 11, 0, 1, 1), [ 6.3, 1.9, 1.6, 48.6]],
75 [(2, 1, 18, 10, 1, 0, 1), [53.3, 1.3, 3.8, 38.4]],
76 [(2, 1, 18, 10, 1, 1, 1), [64.1, 1.0, 3.5, 36.9]],
77 [(2, 1, 18, 12, 0, 0, 1), [-0.2, -75.0, 2.8, 38.1]],
78 [(2, 1, 18, 12, 0, 1, 1), [ 0.5, -32.7, 1.9, 40.3]],
79 [(3, 1, 18, 10, 3, 0, 1), [ 5.4, 7.7, 8.2, 57.0]],
80 [(3, 1, 18, 11, 3, 0, 1), [48.9, 0.4, 4.0, 32.3]],
81 [(2, 1, 18, 11, 1, 0, 1), [38.5, 0.5, 1.7, 46.8]],
82 [(2, 1, 18, 11, 1, 1, 1), [48.1, 0.3, 1.6, 46.3]],
83 [(2, 1, 18, 10, 2, 0, 1), [ 0.3, 75.0, 2.0, 34.9]],
84 [(2, 1, 18, 10, 2, 1, 1), [0.1, -75.0, 3.7, 54.7]],
88 [135, [ [(4, 1, 0, 1, 0, 0, 0), [ 59.1, 2.8, 6.9, 56.2]] ]],
89 [181, [ [(4, 1, 6, 1, 0, 0, 0), [ 56.4, 1.2, 2.9, 39.9]] ]],
90 [182, [ [(4, 1, 6, 0, 0, 0, 0), [ 44.9, 0.5, 1.4, 42.1]] ]],
91 [231, [ [(4, -1, 3, 0, 0, 0, 0), [107.9, 1.7, 7.8, 47.8]] ]],
94 [220, [ [(4, -1, 0, 2, 0, 0, 0), [ 2.3, 3.2, 2.5, 44.4]] ]],
95 [223, [ [(4, -1, 1, 2, 0, 0, 0), [ 3.1, -5.3, 2.4, 44.4]] ]],
96 [225, [ [(4, -1, 2, 2, 0, 0, 0), [ -0.4, 27.6, 1.3, 32.5]] ]],
97 [228, [ [(4, -1, 3, 2, 0, 0, 0), [ 0.2, -75.0, 2.4, 35.4]] ]],
101 [4706026383833300992, [ 0, 0, 0, 50000]],
102 [4706027483344928768, [ 0, 0, 0, 50000]] ], ],
104 [4706157225717006336, [ 0, 0, 0, 80000]],
105 [4706158325228634112, [ 0, 0, 0, 80000]] ], ],
115 rc_key, digits_key, be_key=''):
116 Alg.__init__ (self, name)
119 self.
rc_typ = TileFragHash.OptFilterOffline
134 return StatusCode.Success
142 return StatusCode.Failure
147 return StatusCode.Failure
151 return StatusCode.Failure
152 return StatusCode.Success
156 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
159 cont = ROOT.TileRawChannelContainer (
False, typ, unit)
160 cont.set_bsflags (0x32002000)
161 hashFunc = cont.hashFunc()
163 for icoll, colldata
in hits:
164 coll = ROOT.TileRawChannelCollection (hashFunc.identifier(icoll))
167 for chan
in baddq.get (icoll, []):
168 mask |= (1<<(chan/3))
169 coll.setFragMemoryPar(mask)
171 for addr, data
in colldata:
172 if isinstance(addr, tuple):
173 adc_id = idHelper.adc_id (*addr)
174 chan = ROOT.TileRawChannel (adc_id, *data)
176 hwid = ROOT.HWIdentifier (addr)
177 chan = ROOT.TileRawChannel (hwid, *data)
178 coll.push_back (chan)
180 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
181 ROOT.SetOwnership (coll,
False)
183 return self.evtStore.record (cont, key,
False)
187 cont = ROOT.TileDigitsContainer()
188 hashFunc = cont.hashFunc()
189 hwidHelper = self.detStore[
'TileHWID']
192 for frag
in [(1, 3), emptyfrag]:
193 id = hwidHelper.frag (*frag)
194 coll = ROOT.TileDigitsCollection (id)
196 if frag == emptyfrag:
197 v = getattr(ROOT,
'vector<unsigned>')()
202 coll.setFragChipHeaderWords (v)
205 if frag == emptyfrag
and incomplete:
207 elif frag == emptyfrag
and isCalib:
212 digits = getattr(ROOT,
'vector<float>')()
214 for idig
in range(ndig):
215 dig = ROOT.TileDigits(ROOT.HWIdentifier(), digits)
218 cont.addCollection (coll, ROOT.IdentifierHash (hashFunc(id)))
219 ROOT.SetOwnership (coll,
False)
220 return self.evtStore.record (cont, key,
False)
224 cont = ROOT.TileBeamElemContainer()
226 coll = ROOT.TileBeamElemCollection (frag)
227 coll.setLvl1Type (123)
229 if frag == LASE_PTN_FRAG:
230 v = getattr(ROOT,
'vector<unsigned>')()
233 elem = ROOT.TileBeamElem (ROOT.Identifier(), v)
234 coll.push_back (elem)
236 elif frag == DIGI_PAR_FRAG:
238 hwidHelper = self.detStore[
'TileHWID']
244 return hwidHelper.adc_id (ros, drawer, cha, adc)
246 for cha
in range(15):
248 elem = ROOT.TileBeamElem (hwid, cha + 100)
249 coll.push_back (elem)
252 v = getattr(ROOT,
'vector<unsigned>')()
258 elem = ROOT.TileBeamElem (hwid, v)
259 coll.push_back (elem)
261 elif frag == LASER_OBJ_FRAG:
265 cont.addCollection (coll, ROOT.IdentifierHash (frag))
266 ROOT.SetOwnership (coll,
False)
268 return self.evtStore.record (cont, key,
False)
277 Alg.__init__ (self, name)
283 return StatusCode.Success
287 dq = self.evtStore[self.
dq_key]
289 assert dq.isFilled()
is True
290 assert dq.isBiGain()
is False
291 assert dq.nonZeroCounter()
is True
292 assert dq.incompleteDigits()
is False
293 assert dq.calibMode() == 0
294 assert dq.trigType() == 0
298 return StatusCode.Success
302 for part
in range(5):
303 for drawer
in range(64):
304 for dmu
in range (16):
305 is_empty = (part==3
and drawer==13
and
307 assert dq.checkEmptyEvent(part, drawer, dmu) == is_empty
317 acc.addEventAlgo(
RecordAlg(
'record1',
'RC1',
'Dig1') )
319 from TileRecUtils.TileDQstatusConfig
import TileDQstatusAlgCfg
321 TileRawChannelContainer=
'RC1',
322 TileDigitsContainer=
'Dig1',
325 acc.addEventAlgo(
CheckAlg(
'check1',
'DQ1') )
330 if __name__ ==
"__main__":
332 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
333 from AthenaConfiguration.TestDefaults
import defaultTestFiles
334 from AthenaCommon.Logging
import log
341 flags.Input.Files = defaultTestFiles.ESD
342 flags.Tile.RunType = TileRunType.PHY
343 flags.Exec.MaxEvents = 2
348 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
352 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
358 cfg.printConfig(withDetails=
True)
359 cfg.store(
open(
'TileDQstatusTest.pkl',
'wb') )
365 sys.exit(
not sc.isSuccess())