14from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15from AthenaConfiguration.ComponentFactory
import CompFactory
16from TileConfiguration.TileConfigFlags
import TileRunType
21 [(1, 1, 0, 1, 1, 0, 1), [ 0.2, 22.1]],
22 [(1, 1, 0, 1, 1, 1, 1), [-0.4, 75.0]],
23 [(1, 1, 0, 1, 0, 0, 1), [-0.9, -13.3]],
24 [(1, 1, 0, 2, 0, 1, 1), [41.8, 0.1]],
25 [(1, 1, 0, 2, 0, 0, 1), [30.6, -0.4]],
26 [(1, 1, 0, 2, 1, 1, 1), [ 1.4, 12.9]],
27 [(1, 1, 0, 2, 1, 0, 1), [ 3.4, 3.5]],
31 [(3, 1, 8, 13, 3, 0, 1), [26.9, 4.8]],
35 [(3, 1, 18, 13, 3, 0, 1), [ 4.4, -26.5]],
36 [(3, 1, 18, 15, 3, 0, 1), [-0.1, -75.0]],
37 [(3, 1, 18, 8, 2, 0, 1), [-0.1, 75.0]],
38 [(3, 1, 18, 8, 2, 1, 1), [ 3.5, -11.9]],
39 [(3, 1, 18, 9, 1, 0, 1), [ 0.8, -17.6]],
40 [(3, 1, 18, 9, 1, 1, 1), [ 0.1, -75.0]],
41 [(2, 1, 18, 11, 0, 0, 1), [ 8.7, 0.4]],
42 [(2, 1, 18, 11, 0, 1, 1), [ 6.3, 1.9]],
43 [(2, 1, 18, 10, 1, 0, 1), [53.3, 1.3]],
44 [(2, 1, 18, 10, 1, 1, 1), [64.1, 1.0]],
45 [(2, 1, 18, 12, 0, 0, 1), [-0.2, -75.0]],
46 [(2, 1, 18, 12, 0, 1, 1), [ 0.5, -32.7]],
47 [(3, 1, 18, 10, 3, 0, 1), [ 5.4, 7.7]],
48 [(3, 1, 18, 11, 3, 0, 1), [48.9, 0.4]],
49 [(2, 1, 18, 11, 1, 0, 1), [38.5, 0.5]],
50 [(2, 1, 18, 11, 1, 1, 1), [48.1, 0.3]],
51 [(2, 1, 18, 10, 2, 0, 1), [ 0.3, 75.0]],
52 [(2, 1, 18, 10, 2, 1, 1), [0.1, -75.0]],
56 [135, [ [(4, 1, 0, 1, 0, 0, 0), [ 59.1, 2.8]] ]],
57 [181, [ [(4, 1, 6, 1, 0, 0, 0), [ 56.4, 1.2]] ]],
58 [182, [ [(4, 1, 6, 0, 0, 0, 0), [ 44.9, 0.5]] ]],
59 [231, [ [(4, -1, 3, 0, 0, 0, 0), [107.9, 1.7]] ]],
62 [220, [ [(4, -1, 0, 2, 0, 0, 0), [ 2.3, 3.2]] ]],
63 [223, [ [(4, -1, 1, 2, 0, 0, 0), [ 3.1, -5.3]] ]],
64 [225, [ [(4, -1, 2, 2, 0, 0, 0), [ -0.4, 3.6]] ]],
65 [228, [ [(4, -1, 3, 2, 0, 0, 0), [ 0.2, -3.0]] ]],
78 (1, 1, 0, 1, 0) : [ -30.6, 0.0, -13.3, -13.3, 0, 0, 128, 0, 1, -1],
79 (1, 1, 0, 1, 1) : [ 6.8, 0.0, 22.1, 0.0, 0, 0, 128, 0, 1, 1],
80 (1, 1, 0, 2, 0) : [1040.4, 1421.2, -0.4, 0.1, 0, 0, 160, 160, 1, 1],
81 (1, 1, 0, 2, 1) : [ 115.6, 47.6, 3.5, 12.9, 0, 0, 160, 160, 1, 1],
83 (2, 1, 18, 10, 1):[1812.2, 2179.4, 1.3, 1.0, 0, 0, 160, 160, 1, 1],
84 (2, 1, 18, 10, 2):[ 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 1, 1],
85 (2, 1, 18, 11, 0):[ 295.8, 214.2, 0.4, 1.9, 0, 0, 160, 160, 1, 1],
86 (2, 1, 18, 11, 1):[1309.0, 1635.4, 0.5, 0.3, 0, 0, 160, 160, 1, 1],
87 (2, 1, 18, 12, 0):[ 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 1, 1],
88 (3, 1, 18, 8, 2):[ 0.0, 119.0, 0.0, -11.9, 0, 0, 0, 160, 1, 1],
89 (3, 1, 18, 9, 1):[ 27.2, 0.0, -17.6, 0.0, 0, 0, 128, 0, 1, 1],
90 (3, 1, 18, 10, 3):[ 675.0, 0.0, 7.7, 7.7, 0, 0, 160, 0, 1, -1],
91 (3, 1, 18, 11, 3):[5232.3, 0.0, 0.4, 0.4, 0, 0, 160, 0, 1, -1],
92 (3, 1, 18, 13, 3):[ 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 1, -1],
93 (3, 1, 18, 15, 3):[ 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 1, -1],
96 (3, 1, 8, 13, 3) :[2609.3, 0.0, 4.8, 4.8, 0, 0, 160, 0, 1, -1],
101 (4, 1, 0, 1, 0) : [0.0931, 0.0, 2.8, 2.8, 0, 0, 160, 0, 1, -1],
102 (4, 1, 6, 1, 0) : [0.0888, 0.0, 1.2, 1.2, 0, 0, 160, 0, 1, -1],
103 (4, 1, 6, 0, 0) : [0.0566, 0.0, 0.5, 0.5, 0, 0, 160, 0, 1, -1],
104 (4, -1, 3, 0, 0) : [0.1360, 0.0, 1.7, 1.7, 0, 0, 160, 0, 1, -1],
109 (4, -1, 0, 2, 0) : [172.5, 0.0, 3.2, 3.2, 0, 0, 160, 0, 1, -1],
110 (4, -1, 1, 2, 0) : [232.5, 0.0, -5.3, -5.3, 0, 0, 160, 0, 1, -1],
111 (4, -1, 2, 2, 0) : [-30.0, 0.0, 3.6, 3.6, 0, 0, 128, 0, 1, -1],
112 (4, -1, 3, 2, 0) : [ 15.0, 0.0, -3.0, -3.0, 0, 0, 128, 0, 1, -1],
123exp_cells_1 = exp_merge (exp_cells_0, {
124 (1, 1, 0, 1, 0) : [-30.6, -30.6, -13.3, -13.3, 0, 0, 128, 136, 1, 1],
125 (2, 1, 18, 11, 0) : [295.8, 214.2, 1.9, 1.9, 0, 0, 32, 160, 1, 1],
126 (2, 1, 18, 12, 0) : [ 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 8, 1, 1],
127 (3, 1, 18, 8, 2) : [119.0, 119.0, -11.9, -11.9, 0, 0, 168, 160, 1, 1],
129exp_mbts_1 = exp_merge (exp_mbts_0, {
130 (4, 1, 0, 1, 0) : [0.0, 0.0, -100.0, -100.0, 255, 0, 8, 8, 1, -1],
131 (4, 1, 6, 1, 0) : [0.0888, 0.0, 0.0, 0.0, 0, 0, 32, 0, 1, -1],
142 OptFilterDspCompressed = 3
150from AthenaPython.PyAthenaComps
import Alg, StatusCode
158 Alg.__init__ (self, name)
162 ROOT.ICaloCellMakerTool
165 tool = ROOT.ToolHandle(ROOT.ICaloCellMakerTool)(
'TileCellBuilderFromHit/' + name)
166 if not tool.retrieve():
174 return StatusCode.Success
178 iev = self.getContext().evt()
180 rctype = TileFragHash.OptFilterOffline
183 exp_cells = exp_cells_0
184 exp_mbts = exp_mbts_0
192 exp_cells = exp_cells_1
193 exp_mbts = exp_mbts_1
202 self.
record_hits (hits, rctype, bsflags,
'TileHitCnt')
204 ccc = ROOT.CaloCellContainer(ROOT.SG.VIEW_ELEMENTS)
205 if not tool.process (ccc, self.getContext()):
206 return StatusCode.Failure
209 self.
compare_cells (self.evtStore[
'MBTSContainer'], exp_mbts)
210 self.
compare_cells (self.evtStore[
'E4prContainer'], exp_e4_0)
212 return StatusCode.Success
216 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
219 cont = ROOT.TileHitContainer (
False, typ, unit)
220 cont.set_bsflags (bsflags)
221 hashFunc = cont.hashFunc()
223 for icoll, colldata
in hits:
224 coll = ROOT.TileHitCollection (hashFunc.identifier(icoll))
226 for addr, data
in colldata:
227 adc_id = idHelper.adc_id (*addr)
228 hit = ROOT.TileHit (adc_id, *data)
230 ROOT.SetOwnership (hit,
False)
232 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
233 ROOT.SetOwnership (coll,
False)
235 self.evtStore.record (cont, key,
False)
240 exp_cells = exp_cells.copy()
241 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
244 lcell = [c.ene1(), c.ene2(), c.time1(), c.time2(),
245 c.qual1(), c.qual2(),
246 c.qbit1(), c.qbit2(),
247 c.gain1(), c.gain2()]
250 addr = (idHelper.section(cid),
252 idHelper.module(cid),
254 idHelper.sampling(cid))
255 l = exp_cells.get (addr)
257 if abs(lcell[0]) > noise_thresh:
258 print (
'xxx unexpected cell', addr, lcell, flush=
True)
264 thr = max (1e-3, noise_thresh)
265 if (abs (lcell[0] - l[0]) > thr
or
266 abs (lcell[1] - l[1]) > thr
or
267 abs (lcell[2] - l[2]) > thr
or
268 abs (lcell[3] - l[3]) > thr
or
269 abs (lcell[4] != l[4])
or
270 abs (lcell[5] != l[5])
or
271 abs (lcell[6] != l[6])
or
272 abs (lcell[7] != l[7])
or
273 abs (lcell[8] != l[8])
or
274 abs (lcell[9] != l[9])):
275 print (
'xxx cell mismatch: ', addr, lcell, l, flush=
True)
279 for extra
in exp_cells:
280 print (
'xxx unfound cell', extra, flush=
True)
289BAD_LOW = [1<<1, 0, 0]
290BAD_HIGH = [ 0, 1<<1, 0]
291BAD_BOTH = [ 0, 0, 1<<1]
292BADTIMING = [ 0, 0, 1<<9]
298 chans: [(sec, side, mod, tow, samp, pmt), [DATA0, DATA1, DATA2]]
299 We'd like to specify cells using offline addressing, but the bad cell
300 file uses online addressing. We can convert, but that requires
301 idhelpers, etc, that aren't available until after initialization.
302 So we pass in both representations; in finalize(), we'll check
303 that they match and print out the correct bad cell lines
306 File data line format:
307 frag channel dummy adcStatus0 adcStatus1 chnStatus
308 chnStatus + adcStatusN are given to TileBchDecoder.
309 Offline problem masks:
311 0 GeneralMaskChannel GeneralMaskAdc
314 3 WrongHV DataCorruption
315 4 NoLaser VeryLargeHfNoise
317 6 NoCesium WrongDspConfig
318 7 BadCesium LargeHfNoise
319 8 NoTiming CorrelatedNoise
320 9 BadTiming LargeLfNoise
321 10 TrigGeneralMask NoCis
323 12 TrigHalfGain SevereStuckBit
324 13 TrigNoisy SevereDataCorruption
325 14 Emergency IgnoredByDQV
332 Online problem masks:
334 0 IgnoredInDsp OnlineGeneralMaskAdc
345 TileBchList =
'TileNoBad.oflBch'
347 TileBchList = badChannels +
'.bch'
348 f = open (TileBchList,
'w')
349 print (
'OBJVERSION 0', file=f)
350 print (
'0x000 0 0 0 0 0', file=f)
353 baddefs[badChannels] = (chans, lines)
356 TileCondProxyFileBch = CompFactory.getComp(
"TileCondProxyFile<TileCalibDrawerBch>")
358 offlineBadChannelsProxy =
TileCondProxyFileBch(
'TileCondProxyFile_OflBch', Source=
'TileNoBad.oflBch')
360 TileBadChannelsCondAlg = CompFactory.TileBadChannelsCondAlg
362 OnlBchProxy=onlineBadChannelsProxy,
363 OflBchProxy=offlineBadChannelsProxy,
364 TileBadChannels=badChannels)
366 acc = ComponentAccumulator()
367 acc.addCondAlgo(badChannelsCondAlg)
372badChannelsLines =
"""
383 TileBadChanTool = CompFactory.TileBadChanTool
386 TileCellBuilderFromHit = CompFactory.TileCellBuilderFromHit
390 TileHitContainer=
'TileHitCnt',
397 acc = ComponentAccumulator()
399 from TileGeoModel.TileGMConfig
import TileGMCfg
400 acc.merge( TileGMCfg(flags) )
402 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
403 acc.merge(LArGMCfg(flags))
405 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
406 acc.merge( TileCablingSvcCfg(flags) )
408 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
409 acc.merge( TileInfoLoaderCfg(flags) )
411 from TileConditions.TileEMScaleConfig
import TileEMScaleCondAlgCfg
412 acc.merge( TileEMScaleCondAlgCfg(flags) )
414 from RngComps.RngCompsConfig
import AthRNGSvcCfg
415 acc.merge( AthRNGSvcCfg(flags) )
417 from TileConditions.TileSamplingFractionConfig
import TileSamplingFractionCondAlgCfg
418 acc.merge( TileSamplingFractionCondAlgCfg(flags, Source=
'FILE') )
419 acc.getCondAlgo(
'TileSamplingFractionCondAlg').G4Version=-1
421 bc1 =
'tilecellbuilder_bc1'
424 bc2 =
'tilecellbuilder_bc2'
426 [[(3, 1, 18, 8, 2, 0), BAD_HIGH],
427 [(2, 1, 18, 9, 1, 0), BAD_LOW],
428 [(2, 1, 18, 12, 0, 1), BAD_BOTH],
429 [(2, 1, 18, 11, 0, 0), BADTIMING],
430 [(4, 1, 0, 1, 0, 0), BAD_BOTH],
431 [(4, 1, 6, 1, 0, 0), BADTIMING],
432 ], badChannelsLines) )
435 acc.addPublicTool( maketool (
'tool1', bc1) )
436 acc.addPublicTool( maketool (
'tool2', bc2, maskBadChannels=
True) )
437 acc.addPublicTool( maketool (
'tool3', bc1, noise=0.1) )
439 acc.addEventAlgo(
TestAlg(
'testalg1') )
444if __name__ ==
"__main__":
446 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
447 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultTestFiles
448 from AthenaCommon.Logging
import log
454 flags = initConfigFlags()
455 flags.Input.Files = defaultTestFiles.HITS_RUN2
456 flags.Input.ConditionsRunNumber = 1
457 flags.Input.OverrideRunNumber =
True
458 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
459 flags.Tile.RunType = TileRunType.PHY
460 flags.Exec.MaxEvents = 3
465 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
466 cfg = MainServicesCfg(flags)
469 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
470 cfg.merge(PoolReadCfg(flags))
472 from xAODEventInfoCnv.xAODEventInfoCnvConfig
import EventInfoCnvAlgCfg
473 cfg.merge (EventInfoCnvAlgCfg (flags, disableBeamSpot =
True))
478 cfg.printConfig(withDetails=
True)
479 cfg.store( open(
'TileCellBuilderFromHitTest.pkl',
'wb') )
485 sys.exit(
not sc.isSuccess())
Condition algorithm to prepare TileBadChannels and put it into condition store.
compare_cells(self, ccc, exp_cells, noise_thresh=0)
record_hits(self, hits, typ, bsflags, key)
This class creates Cells from RawChannels and stores them in a container.
TileBadChannelsCfg(flags, badChannels, chans=[], lines='')
maketool(name, badChannels, noise=0, **kw)
TileRawChannelBuilderFromHitTestCfg(flags)