14 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15 from AthenaConfiguration.ComponentAccumulator
import CompFactory
16 from TileConfiguration.TileConfigFlags
import TileRunType
17 from AthenaPython.PyAthenaComps
import Alg, StatusCode
31 OptFilterDspCompressed = 3
37 WienerFilterOffline = 9
49 LASER_OBJ_FRAG = 0x016
55 [(1, 1, 0, 1, 1, 0, 1), [ 0.2, 22.1, 2.4, 42.9]],
56 [(1, 1, 0, 1, 1, 1, 1), [-0.4, 75.0, 2.7, 31.4]],
57 [(1, 1, 0, 1, 0, 0, 1), [-0.9, -13.3, 1.5, 37.4]],
58 [(1, 1, 0, 2, 0, 1, 1), [41.8, 0.1, 2.5, 45.7]],
59 [(1, 1, 0, 2, 0, 0, 1), [30.6, -0.4, 2.0, 33.1]],
60 [(1, 1, 0, 2, 1, 1, 1), [ 1.4, 12.9, 4.7, 43.1]],
61 [(1, 1, 0, 2, 1, 0, 1), [ 3.4, 3.5, 1.9, 54.2]],
65 [(3, 1, 8, 13, 3, 0, 1), [26.9, 4.8, 5.2, 45.4]],
69 [(3, 1, 18, 13, 3, 0, 1), [ 4.4, -26.5, 23.9, 51.2]],
70 [(3, 1, 18, 15, 3, 0, 1), [-0.1, -75.0, 3.7, 51.0]],
71 [(3, 1, 18, 8, 2, 0, 1), [-0.1, 75.0, 4.2, 41.7]],
72 [(3, 1, 18, 8, 2, 1, 1), [ 3.5, -11.9, 2.6, 44.7]],
73 [(3, 1, 18, 9, 1, 0, 1), [ 0.8, -17.6, 1.8, 49.2]],
74 [(3, 1, 18, 9, 1, 1, 1), [ 0.1, -75.0, 3.4, 48.4]],
75 [(2, 1, 18, 11, 0, 0, 1), [ 8.7, 0.4, 2.7, 50.2]],
76 [(2, 1, 18, 11, 0, 1, 1), [ 6.3, 1.9, 1.6, 48.6]],
77 [(2, 1, 18, 10, 1, 0, 1), [53.3, 1.3, 3.8, 38.4]],
78 [(2, 1, 18, 10, 1, 1, 1), [64.1, 1.0, 3.5, 36.9]],
79 [(2, 1, 18, 12, 0, 0, 1), [-0.2, -75.0, 2.8, 38.1]],
80 [(2, 1, 18, 12, 0, 1, 1), [ 0.5, -32.7, 1.9, 40.3]],
81 [(3, 1, 18, 10, 3, 0, 1), [ 5.4, 7.7, 8.2, 57.0]],
82 [(3, 1, 18, 11, 3, 0, 1), [48.9, 0.4, 4.0, 32.3]],
83 [(2, 1, 18, 11, 1, 0, 1), [38.5, 0.5, 1.7, 46.8]],
84 [(2, 1, 18, 11, 1, 1, 1), [48.1, 0.3, 1.6, 46.3]],
85 [(2, 1, 18, 10, 2, 0, 1), [ 0.3, 75.0, 2.0, 34.9]],
86 [(2, 1, 18, 10, 2, 1, 1), [0.1, -75.0, 3.7, 54.7]],
90 [135, [ [(4, 1, 0, 1, 0, 0, 0), [ 59.1, 2.8, 6.9, 56.2]] ]],
91 [181, [ [(4, 1, 6, 1, 0, 0, 0), [ 56.4, 1.2, 2.9, 39.9]] ]],
92 [182, [ [(4, 1, 6, 0, 0, 0, 0), [ 44.9, 0.5, 1.4, 42.1]] ]],
93 [231, [ [(4, -1, 3, 0, 0, 0, 0), [107.9, 1.7, 7.8, 47.8]] ]],
96 [220, [ [(4, -1, 0, 2, 0, 0, 0), [ 2.3, 3.2, 2.5, 44.4]] ]],
97 [223, [ [(4, -1, 1, 2, 0, 0, 0), [ 3.1, -5.3, 2.4, 44.4]] ]],
98 [225, [ [(4, -1, 2, 2, 0, 0, 0), [ -0.4, 27.6, 1.3, 32.5]] ]],
99 [228, [ [(4, -1, 3, 2, 0, 0, 0), [ 0.2, -75.0, 2.4, 35.4]] ]],
103 [4706026383833300992, [ 0, 0, 0, 50000]],
104 [4706027483344928768, [ 0, 0, 0, 50000]] ], ],
106 [4706157225717006336, [ 0, 0, 0, 80000]],
107 [4706158325228634112, [ 0, 0, 0, 80000]] ], ],
115 if len(args) != len(pat):
return False
116 for i
in range(len(args)):
117 if args[i] != pat[i]
and pat[i] != -1:
122 if compare_args (args, exc):
return True
125 ret = getattr(dq, mname)(*args)
127 if check_exc (args, exc.get(mname, [])):
return
128 print (
'xxx', mname, ret, exp, *args)
135 Alg.__init__ (self, name)
140 ROOT.ICaloCellMakerTool
143 tool = ROOT.ToolHandle(ROOT.ITileDQstatusTool)(
'TileDQstatusTool/' + name)
144 if not tool.retrieve():
151 return StatusCode.Success
163 return StatusCode.Success
167 print (
'*** Starting test1')
170 flag_exc = {
'checkEmptyEvent' :
171 [(3,13,3), (3,13,9), (3,13,12)],
174 rctype = TileFragHash.OptFilterOffline
175 self.
do_test (rctype, flag_exc)
180 print (
'*** Starting test2')
183 flag_exc = {
'checkEmptyEvent' :
184 [(3,13,3), (3,13,9), (3,13,12)],
185 'checkMemoryParityErr' :
186 [(3,18,0,-1), (3,18,3,-1)],
188 [(3,18,0,-1), (3,18,1,-1), (3,18,2,-1),
189 (3,18,9,-1), (3,18,10,-1), (3,18,11,-1),],
191 [(3,18,0), (3,18,1), (3,18,2),
192 (3,18,9), (3,18,10), (3,18,11),],
195 rctype = TileFragHash.OptFilterDsp
196 rc_baddq = {146 : [(
'setFragMemoryPar', 0x09)]}
197 self.
do_test (rctype, flag_exc, rc_baddq = rc_baddq)
202 print (
'*** Starting test3')
205 flag_exc = {
'checkEmptyEvent' :
206 [(3,13,3), (3,13,9), (3,13,12)],
207 'isAdcDQgood' : [(3,18,-1,-1)],
208 'isChanDQgood' : [(3,18,-1)],
209 'checkBCIDErr' : [(3,18,-1,-1)],
210 'checkBCIDErrDetail' : [(3,18,-1,-1)],
213 rctype = TileFragHash.OptFilterDsp
214 rc_baddq = {146 : [(
'setFragBCID', 0x6565)]}
215 self.
do_test (rctype, flag_exc, rc_baddq = rc_baddq)
220 print (
'*** Starting test4')
223 flag_exc = {
'checkEmptyEvent' :
224 [(3,13,3), (3,13,9), (3,13,12)],
227 rctype = TileFragHash.OptFilterOffline
228 self.
do_test (rctype, flag_exc, isCalib =
True)
233 print (
'*** Starting test5')
236 flag_exc = {
'checkEmptyEvent' :
237 [(3,13,3), (3,13,9), (3,13,12)],
240 rctype = TileFragHash.OptFilterOffline
241 self.
do_test (rctype, flag_exc, incomplete =
True)
246 print (
'*** Starting test6')
249 flag_exc = {
'checkEmptyEvent' :
250 [(3,13,3), (3,13,9), (3,13,12)],
253 rctype = TileFragHash.OptFilterOffline
254 self.
do_test (rctype, flag_exc, beamfrag = DIGI_PAR_FRAG)
259 print (
'*** Starting test7')
262 flag_exc = {
'checkEmptyEvent' :
263 [(3,13,3), (3,13,9), (3,13,12)],
266 rctype = TileFragHash.OptFilterOffline
267 self.
do_test (rctype, flag_exc, beamfrag = LASER_OBJ_FRAG)
272 print (
'*** Starting test8')
275 flag_exc = {
'checkEmptyEvent' :
276 [(3,13,3), (3,13,9), (3,13,12)],
279 rctype = TileFragHash.OptFilterOffline
284 def do_test (self, rctype, flag_exc, rc_baddq={},
287 beamfrag = LASE_PTN_FRAG,
293 dq = ROOT.TileDQstatus()
295 eid = ROOT.EventIDBase()
296 eid.set_bunch_crossing_id (1234)
297 eid.set_run_number(self.getContext().eventID().
run_number())
298 eid.set_lumi_block(0)
299 ctx = ROOT.EventContext()
302 ctx.setExtension(ROOT.Atlas.ExtendedEventContext())
307 if beamfrag == LASE_PTN_FRAG:
310 elif beamfrag == DIGI_PAR_FRAG:
311 cispar = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
312 110, 111, 112, 113, 114, 111, 2, 5, 6, 7,
313 8, 117, 118, 119, 120] + 85*[0]
316 elif beamfrag == LASER_OBJ_FRAG:
321 assert tool.makeStatus (ctx, rc, digits, be, dq).isSuccess()
323 assert dq.isFilled()
is True
324 assert dq.isBiGain() == isCalib
325 assert dq.nonZeroCounter()
is True
326 assert dq.incompleteDigits() == incomplete
327 assert dq.calibMode() == isCalib
328 assert dq.trigType() == trigType
329 assert dq.RODBCID() == bcid
331 dq_cispar = [dq.cispar()[i]
for i
in range(110)]
332 assert dq_cispar == cispar
335 for partition
in range(5):
336 for drawer
in range(64):
337 for gain
in range(2):
338 check_flag (dq,
'checkGlobalErr',
False, flag_exc,
339 partition, drawer, gain)
340 check_flag (dq,
'checkGlobalCRCErr',
False, flag_exc,
341 partition, drawer, gain)
343 for gain
in range(2):
344 check_flag (dq,
'isAdcDQgood',
True, flag_exc,
345 partition, drawer, ch, gain)
346 check_flag (dq,
'isChanDQgood',
True, flag_exc,
347 partition, drawer, ch)
348 for dmu
in range(16):
349 check_flag (dq,
'checkEmptyEvent',
False, flag_exc,
350 partition, drawer, dmu)
351 for gain
in range(2):
352 check_flag (dq,
'checkROD_CRCErr',
False, flag_exc,
353 partition, drawer, dmu, gain)
354 check_flag (dq,
'checkFE_CRCErr',
False, flag_exc,
355 partition, drawer, dmu, gain)
356 check_flag (dq,
'checkBCIDErr',
False, flag_exc,
357 partition, drawer, dmu, gain)
358 check_flag (dq,
'checkBCIDErrDetail',
False, flag_exc,
359 partition, drawer, dmu, gain)
360 check_flag (dq,
'checkHeaderFormatErr',
False, flag_exc,
361 partition, drawer, dmu, gain)
362 check_flag (dq,
'checkHeaderParityErr',
False, flag_exc,
363 partition, drawer, dmu, gain)
364 check_flag (dq,
'checkSampleFormatErr',
False, flag_exc,
365 partition, drawer, dmu, gain)
366 check_flag (dq,
'checkSampleParityErr',
False, flag_exc,
367 partition, drawer, dmu, gain)
368 check_flag (dq,
'checkMemoryParityErr',
False, flag_exc,
369 partition, drawer, dmu, gain)
370 check_flag (dq,
'checkSingleStrobeErr',
False, flag_exc,
371 partition, drawer, dmu, gain)
372 check_flag (dq,
'checkDoubleStrobeErr',
False, flag_exc,
373 partition, drawer, dmu, gain)
375 return StatusCode.Success
379 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
382 cont = ROOT.TileRawChannelContainer (
False, typ, unit)
383 cont.set_bsflags (0x32002000)
384 hashFunc = cont.hashFunc()
386 for icoll, colldata
in hits:
387 coll = ROOT.TileRawChannelCollection (hashFunc.identifier(icoll))
388 coll.setFragFEChipMask (0)
390 for func, mask
in baddq.get (icoll, []):
391 getattr(coll, func)(mask)
393 for addr, data
in colldata:
394 if isinstance(addr, tuple):
395 adc_id = idHelper.adc_id (*addr)
396 chan = ROOT.TileRawChannel (adc_id, *data)
398 hwid = ROOT.HWIdentifier (addr)
399 chan = ROOT.TileRawChannel (hwid, *data)
400 coll.push_back (chan)
402 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
403 ROOT.SetOwnership (coll,
False)
409 cont = ROOT.TileDigitsContainer()
410 hashFunc = cont.hashFunc()
411 hwidHelper = self.detStore[
'TileHWID']
414 for frag
in [(1, 3), emptyfrag]:
415 id = hwidHelper.frag (*frag)
416 coll = ROOT.TileDigitsCollection (id)
418 if frag == emptyfrag:
419 v = getattr(ROOT,
'vector<unsigned>')()
424 coll.setFragChipHeaderWords (v)
427 if frag == emptyfrag
and incomplete:
429 elif frag == emptyfrag
and isCalib:
434 digits = getattr(ROOT,
'vector<float>')()
436 for idig
in range(ndig):
437 dig = ROOT.TileDigits(ROOT.HWIdentifier(), digits)
440 cont.addCollection (coll, ROOT.IdentifierHash (hashFunc(id)))
441 ROOT.SetOwnership (coll,
False)
447 cont = ROOT.TileBeamElemContainer()
449 coll = ROOT.TileBeamElemCollection (frag)
450 coll.setLvl1Type (123)
452 if frag == LASE_PTN_FRAG:
453 v = getattr(ROOT,
'vector<unsigned>')()
456 elem = ROOT.TileBeamElem (ROOT.HWIdentifier(), v)
457 coll.push_back (elem)
459 elif frag == DIGI_PAR_FRAG:
461 hwidHelper = self.detStore[
'TileHWID']
467 return hwidHelper.adc_id (ros, drawer, cha, adc)
469 for cha
in range(15):
471 elem = ROOT.TileBeamElem (hwid, cha + 100)
472 coll.push_back (elem)
475 v = getattr(ROOT,
'vector<unsigned>')()
481 elem = ROOT.TileBeamElem (hwid, v)
482 coll.push_back (elem)
484 elif frag == LASER_OBJ_FRAG:
488 cont.addCollection (coll, ROOT.IdentifierHash (frag))
489 ROOT.SetOwnership (coll,
False)
501 from TileGeoModel.TileGMConfig
import TileGMCfg
504 from RngComps.RngCompsConfig
import AthRNGSvcCfg
507 from TileConditions.TileBadChannelsConfig
import TileBadChannelsCondAlgCfg
510 TileDQstatusTool = CompFactory.TileDQstatusTool
514 acc.addEventAlgo(
TestAlg(
'test1') )
519 if __name__ ==
"__main__":
521 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
522 from AthenaConfiguration.TestDefaults
import defaultTestFiles
523 from AthenaCommon.Logging
import log
530 flags.Input.Files = defaultTestFiles.ESD
531 flags.Tile.RunType = TileRunType.PHY
532 flags.Exec.MaxEvents = 1
537 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
541 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
547 cfg.printConfig(withDetails=
True)
548 cfg.store(
open(
'TileDQstatusToolTest.pkl',
'wb') )
553 sys.exit(
not sc.isSuccess())