ATLAS Offline Software
Loading...
Searching...
No Matches
CaloThinCellsBySamplingAlg_test.py
Go to the documentation of this file.
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration.
3#
4# File: CaloRec/python/CaloThinCellsBySamplingAlg_test.py
5# Author: scott snyder
6# Date: Nov, 2019
7# Brief: Test for CaloThinCellsBySamplingAlg.
8#
9
10from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
11from AthenaConfiguration.ComponentFactory import CompFactory
12from AthenaPython.PyAthenaComps import Alg, StatusCode
13import ROOT
14
15
17 ccc = ROOT.CaloCellContainer()
18 for i in range (mgr.element_size()):
19 elt = mgr.get_element (ROOT.IdentifierHash (i))
20 if not elt: break
21 cc = ROOT.CaloCell (elt, 0, 0, 0, 0)
22 ccc.push_back (cc)
23 ROOT.SetOwnership (cc, False)
24 ccc.order()
25 ccc.updateCaloIterators()
26 return ccc
27
28
29class CreateDataAlg (Alg):
30 def execute (self):
31 ctx = self.getContext()
32 mgr = self.condStore['CaloDetDescrManager'].find (ctx.eventID())
33 ccc = make_calo_cells (mgr)
34 self.evtStore.record (ccc, 'AllCalo', False)
35 return StatusCode.Success
36
37
38class CheckThinningAlg (Alg):
39 def execute (self):
40 ctx = self.getContext()
41 mgr = self.condStore['CaloDetDescrManager'].find (ctx.eventID())
42 dec = self.evtStore['AllCalo_THINNED_StreamAOD.thinAlg']
43
44 for i in range (dec.size()):
45 elt = mgr.get_element (ROOT.IdentifierHash (i))
46 if elt.getSampling() == 3 or elt.getSampling() == 17:
47 assert not dec.thinned(i)
48 else:
49 assert dec.thinned(i)
50 return StatusCode.Success
51
52
53def testCfg (flags):
54 result = ComponentAccumulator()
55
56 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
57 from TileGeoModel.TileGMConfig import TileGMCfg
58 result.merge(LArGMCfg(flags))
59 result.merge(TileGMCfg(flags))
60
61 from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
62 result.merge(LArOnOffIdMappingCfg(flags))
63
64 result.addEventAlgo (CreateDataAlg ('CreateDataAlg'))
65
66 CaloThinCellsBySamplingAlg=CompFactory.CaloThinCellsBySamplingAlg
67 result.addEventAlgo (CaloThinCellsBySamplingAlg ('thinAlg',
68 StreamName = 'StreamAOD',
69 SamplingCellsName = ['EMB3',
70 'TileGap3']))
71
72 result.addEventAlgo (CheckThinningAlg ('CheckThinningAlg'))
73 return result
74
75
76from AthenaConfiguration.AllConfigFlags import initConfigFlags
77from AthenaConfiguration.TestDefaults import defaultTestFiles
78flags = initConfigFlags()
79flags.Input.Files = defaultTestFiles.RDO_RUN2
80flags.Input.TimeStamps = [1000]
81flags.Detector.GeometryLAr = True
82flags.Detector.GeometryTile = True
83flags.needFlagsCategory('Tile')
84flags.needFlagsCategory('LAr')
85
86flags.lock()
87from AthenaConfiguration.MainServicesConfig import MainServicesCfg
88acc=MainServicesCfg(flags)
89
90from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
91acc.merge (McEventSelectorCfg (flags))
92
93acc.merge (testCfg (flags))
94acc.run(1)
95
96