14 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
15 from AthenaConfiguration.ComponentFactory
import CompFactory
16 from 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],
123 exp_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],
129 exp_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
150 from 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()
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)
231 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
232 ROOT.SetOwnership (coll,
False)
234 self.evtStore.record (cont, key,
False)
239 exp_cells = exp_cells.copy()
240 idHelper = self.detStore[
'CaloCell_ID'].tile_idHelper()
243 lcell = [c.ene1(), c.ene2(), c.time1(), c.time2(),
244 c.qual1(), c.qual2(),
245 c.qbit1(), c.qbit2(),
246 c.gain1(), c.gain2()]
249 addr = (idHelper.section(cid),
251 idHelper.module(cid),
253 idHelper.sampling(cid))
254 l = exp_cells.get (addr)
256 if abs(lcell[0]) > noise_thresh:
257 print (
'xxx unexpected cell', addr, lcell, flush=
True)
263 thr = max (1e-3, noise_thresh)
264 if (abs (lcell[0] - l[0]) > thr
or
265 abs (lcell[1] - l[1]) > thr
or
266 abs (lcell[2] - l[2]) > thr
or
267 abs (lcell[3] - l[3]) > thr
or
268 abs (lcell[4] != l[4])
or
269 abs (lcell[5] != l[5])
or
270 abs (lcell[6] != l[6])
or
271 abs (lcell[7] != l[7])
or
272 abs (lcell[8] != l[8])
or
273 abs (lcell[9] != l[9])):
274 print (
'xxx cell mismatch: ', addr, lcell, l, flush=
True)
278 for extra
in exp_cells:
279 print (
'xxx unfound cell', extra, flush=
True)
288 BAD_LOW = [1<<1, 0, 0]
289 BAD_HIGH = [ 0, 1<<1, 0]
290 BAD_BOTH = [ 0, 0, 1<<1]
291 BADTIMING = [ 0, 0, 1<<9]
297 chans: [(sec, side, mod, tow, samp, pmt), [DATA0, DATA1, DATA2]]
298 We'd like to specify cells using offline addressing, but the bad cell
299 file uses online addressing. We can convert, but that requires
300 idhelpers, etc, that aren't available until after initialization.
301 So we pass in both representations; in finalize(), we'll check
302 that they match and print out the correct bad cell lines
305 File data line format:
306 frag channel dummy adcStatus0 adcStatus1 chnStatus
307 chnStatus + adcStatusN are given to TileBchDecoder.
308 Offline problem masks:
310 0 GeneralMaskChannel GeneralMaskAdc
313 3 WrongHV DataCorruption
314 4 NoLaser VeryLargeHfNoise
316 6 NoCesium WrongDspConfig
317 7 BadCesium LargeHfNoise
318 8 NoTiming CorrelatedNoise
319 9 BadTiming LargeLfNoise
320 10 TrigGeneralMask NoCis
322 12 TrigHalfGain SevereStuckBit
323 13 TrigNoisy SevereDataCorruption
324 14 Emergency IgnoredByDQV
331 Online problem masks:
333 0 IgnoredInDsp OnlineGeneralMaskAdc
344 TileBchList =
'TileNoBad.oflBch'
346 TileBchList = badChannels +
'.bch'
347 f = open (TileBchList,
'w')
348 print (
'OBJVERSION 0', file=f)
349 print (
'0x000 0 0 0 0 0', file=f)
352 baddefs[badChannels] = (chans, lines)
355 TileCondProxyFileBch = CompFactory.getComp(
"TileCondProxyFile<TileCalibDrawerBch>")
357 offlineBadChannelsProxy =
TileCondProxyFileBch(
'TileCondProxyFile_OflBch', Source=
'TileNoBad.oflBch')
359 TileBadChannelsCondAlg = CompFactory.TileBadChannelsCondAlg
361 OnlBchProxy=onlineBadChannelsProxy,
362 OflBchProxy=offlineBadChannelsProxy,
363 TileBadChannels=badChannels)
366 acc.addCondAlgo(badChannelsCondAlg)
371 badChannelsLines =
"""
382 TileBadChanTool = CompFactory.TileBadChanTool
385 TileCellBuilderFromHit = CompFactory.TileCellBuilderFromHit
389 TileHitContainer=
'TileHitCnt',
398 from TileGeoModel.TileGMConfig
import TileGMCfg
401 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
404 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
407 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
410 from TileConditions.TileEMScaleConfig
import TileEMScaleCondAlgCfg
413 from RngComps.RngCompsConfig
import AthRNGSvcCfg
416 from TileConditions.TileSamplingFractionConfig
import TileSamplingFractionCondAlgCfg
418 acc.getCondAlgo(
'TileSamplingFractionCondAlg').G4Version=-1
420 bc1 =
'tilecellbuilder_bc1'
423 bc2 =
'tilecellbuilder_bc2'
425 [[(3, 1, 18, 8, 2, 0), BAD_HIGH],
426 [(2, 1, 18, 9, 1, 0), BAD_LOW],
427 [(2, 1, 18, 12, 0, 1), BAD_BOTH],
428 [(2, 1, 18, 11, 0, 0), BADTIMING],
429 [(4, 1, 0, 1, 0, 0), BAD_BOTH],
430 [(4, 1, 6, 1, 0, 0), BADTIMING],
431 ], badChannelsLines) )
434 acc.addPublicTool( maketool (
'tool1', bc1) )
435 acc.addPublicTool( maketool (
'tool2', bc2, maskBadChannels=
True) )
436 acc.addPublicTool( maketool (
'tool3', bc1, noise=0.1) )
438 acc.addEventAlgo(
TestAlg(
'testalg1') )
443 if __name__ ==
"__main__":
445 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
446 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultTestFiles
447 from AthenaCommon.Logging
import log
454 flags.Input.Files = defaultTestFiles.HITS_RUN2
455 flags.Input.ConditionsRunNumber = 1
456 flags.Input.OverrideRunNumber =
True
457 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
458 flags.Tile.RunType = TileRunType.PHY
459 flags.Exec.MaxEvents = 3
464 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
468 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
471 from xAODEventInfoCnv.xAODEventInfoCnvConfig
import EventInfoCnvAlgCfg
472 cfg.merge (EventInfoCnvAlgCfg (flags, disableBeamSpot =
True))
477 cfg.printConfig(withDetails=
True)
478 cfg.store(
open(
'TileCellBuilderFromHitTest.pkl',
'wb') )
484 sys.exit(
not sc.isSuccess())