14from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15from TileConfiguration.TileConfigFlags
import TileRunType
16from AthenaPython.PyAthenaComps
import Alg, StatusCode
29 OptFilterDspCompressed = 3
35 WienerFilterOffline = 9
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)
179 ROOT.SetOwnership (chan,
False)
181 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
182 ROOT.SetOwnership (coll,
False)
184 return self.evtStore.record (cont, key,
False)
188 cont = ROOT.TileDigitsContainer()
189 hashFunc = cont.hashFunc()
190 hwidHelper = self.detStore[
'TileHWID']
193 for frag
in [(1, 3), emptyfrag]:
194 id = hwidHelper.frag (*frag)
195 coll = ROOT.TileDigitsCollection (id)
197 if frag == emptyfrag:
198 v = getattr(ROOT,
'vector<unsigned>')()
203 coll.setFragChipHeaderWords (v)
206 if frag == emptyfrag
and incomplete:
208 elif frag == emptyfrag
and isCalib:
213 digits = getattr(ROOT,
'vector<float>')()
215 for idig
in range(ndig):
216 dig = ROOT.TileDigits(ROOT.HWIdentifier(), digits)
218 ROOT.SetOwnership (dig,
False)
220 cont.addCollection (coll, ROOT.IdentifierHash (hashFunc(id)))
221 ROOT.SetOwnership (coll,
False)
222 return self.evtStore.record (cont, key,
False)
226 cont = ROOT.TileBeamElemContainer()
228 coll = ROOT.TileBeamElemCollection (frag)
229 coll.setLvl1Type (123)
231 if frag == LASE_PTN_FRAG:
232 v = getattr(ROOT,
'vector<unsigned>')()
235 elem = ROOT.TileBeamElem (ROOT.Identifier(), v)
236 coll.push_back (elem)
237 ROOT.SetOwnership (elem,
False)
239 elif frag == DIGI_PAR_FRAG:
241 hwidHelper = self.detStore[
'TileHWID']
247 return hwidHelper.adc_id (ros, drawer, cha, adc)
249 for cha
in range(15):
251 elem = ROOT.TileBeamElem (hwid, cha + 100)
252 coll.push_back (elem)
253 ROOT.SetOwnership (elem,
False)
256 v = getattr(ROOT,
'vector<unsigned>')()
262 elem = ROOT.TileBeamElem (hwid, v)
263 coll.push_back (elem)
264 ROOT.SetOwnership (elem,
False)
266 elif frag == LASER_OBJ_FRAG:
270 cont.addCollection (coll, ROOT.IdentifierHash (frag))
271 ROOT.SetOwnership (coll,
False)
273 return self.evtStore.record (cont, key,
False)
282 Alg.__init__ (self, name)
288 return StatusCode.Success
292 dq = self.evtStore[self.
dq_key]
294 assert dq.isFilled()
is True
295 assert dq.isBiGain()
is False
296 assert dq.nonZeroCounter()
is True
297 assert dq.incompleteDigits()
is False
298 assert dq.calibMode() == 0
299 assert dq.trigType() == 0
303 return StatusCode.Success
307 for part
in range(5):
308 for drawer
in range(64):
309 for dmu
in range (16):
310 is_empty = (part==3
and drawer==13
and
312 assert dq.checkEmptyEvent(part, drawer, dmu) == is_empty
320 acc = ComponentAccumulator()
322 acc.addEventAlgo(
RecordAlg(
'record1',
'RC1',
'Dig1') )
324 from TileRecUtils.TileDQstatusConfig
import TileDQstatusAlgCfg
325 acc.merge(TileDQstatusAlgCfg(flags, name=
'alg1',
326 TileRawChannelContainer=
'RC1',
327 TileDigitsContainer=
'Dig1',
330 acc.addEventAlgo(
CheckAlg(
'check1',
'DQ1') )
335if __name__ ==
"__main__":
337 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
338 from AthenaConfiguration.TestDefaults
import defaultTestFiles
339 from AthenaCommon.Logging
import log
345 flags = initConfigFlags()
346 flags.Input.Files = defaultTestFiles.ESD
347 flags.Tile.RunType = TileRunType.PHY
348 flags.Exec.MaxEvents = 2
353 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
354 cfg = MainServicesCfg(flags)
357 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
358 cfg.merge(PoolReadCfg(flags))
363 cfg.printConfig(withDetails=
True)
364 cfg.store( open(
'TileDQstatusTest.pkl',
'wb') )
370 sys.exit(
not sc.isSuccess())
__init__(self, name, dq_key)
record_raw_data(self, key, hits, typ, baddq)
__init__(self, name, rc_key, digits_key, be_key='')
record_beamelem(self, key, frag)
record_digits(self, key, incomplete, isCalib)
TileDQstatusAlgTestCfg(flags)