ATLAS Offline Software
Loading...
Searching...
No Matches
TileHitVecToCntConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3"""Define method to construct configured private Tile hit vector to container tool"""
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from AthenaConfiguration.Enums import BeamType
8from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
9from DigitizationConfig.PileUpMergeSvcConfig import PileUpMergeSvcCfg, PileUpXingFolderCfg
10from DigitizationConfig.PileUpToolsConfig import PileUpToolsCfg
11
13 """Return the earliest bunch crossing time for which interactions will be sent to the TileHitVecToCntTool"""
14 return -200
15
16
18 """Return the latest bunch crossing time for which interactions will be sent to the TileHitVecToCntTool"""
19 return 150
20
21
22def TileRangeCfg(flags, name = 'TileRange', **kwargs):
23 """Return a PileUpXingFolder tool for Tile"""
24 item_list = ['TileHitVector#TileHitVec']
25 if flags.Detector.EnableMBTS:
26 item_list += ['TileHitVector#MBTSHits']
27 kwargs.setdefault('FirstXing', getTileFirstXing() )
28 kwargs.setdefault('LastXing', getTileLastXing() )
29 kwargs.setdefault('ItemList', item_list )
30 return PileUpXingFolderCfg(flags, name, **kwargs)
31
32
33def TileHitVecToCntToolCfg(flags, **kwargs):
34 """Return component accumulator with configured private Tile hit vector to container tool
35
36 Arguments:
37 flags -- Athena configuration flags
38 """
39
40 kwargs.setdefault('name', 'TileHitVecToCntTool')
41 kwargs.setdefault('RndmEvtOverlay', flags.Common.isOverlay)
42 if flags.Common.isOverlay:
43 kwargs.setdefault('OnlyUseContainerName', False)
44 else:
45 kwargs.setdefault('OnlyUseContainerName', flags.Digitization.PileUp)
46
47 acc = ComponentAccumulator()
48
49 from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
50 acc.merge( TileInfoLoaderCfg(flags) )
51
52 from TileConditions.TileSamplingFractionConfig import TileSamplingFractionCondAlgCfg
53 acc.merge( TileSamplingFractionCondAlgCfg(flags) )
54
55 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
56 acc.merge(TileCablingSvcCfg(flags))
57
58 if flags.Detector.EnableMBTS:
59 kwargs.setdefault('TileHitVectors', ['TileHitVec', 'MBTSHits'])
60 else:
61 kwargs.setdefault('TileHitVectors', ['TileHitVec'])
62 kwargs.setdefault('TileHitContainer', 'TileHitCnt')
63
64 if flags.Common.isOverlay and not flags.Sim.DoFullChain:
65 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
66 acc.merge(SGInputLoaderCfg(flags, [f'TileHitVector#{vec}' for vec in kwargs['TileHitVectors']]))
67
68 kwargs.setdefault('DoHSTruthReconstruction', flags.Digitization.EnableCaloHSTruthRecoInputs)
69 if kwargs['DoHSTruthReconstruction']:
70 kwargs.setdefault('TileHitContainer_DigiHSTruth', 'TileHitCnt_DigiHSTruth')
71 else:
72 kwargs.setdefault('TileHitContainer_DigiHSTruth', '')
73
74 if 'RndmSvc' not in kwargs:
75 from RngComps.RngCompsConfig import AthRNGSvcCfg
76 kwargs['RndmSvc'] = acc.getPrimaryAndMerge(AthRNGSvcCfg(flags))
77
78 if kwargs['RndmEvtOverlay']:
79 kwargs.setdefault('PileUp', False)
80 else:
81 kwargs.setdefault('PileUp', flags.Digitization.PileUp)
82
83 if flags.Beam.Type is BeamType.Cosmics:
84 kwargs.setdefault('HitTimeFlag', 2)
85 kwargs.setdefault('UseTriggerTime', True)
86 kwargs.setdefault('CosTimeKey', 'CosTrigTime')
87 acc.addEventAlgo(CompFactory.CosTriggerTimeAlg())
88
89 if flags.Digitization.PileUp:
90 intervals = []
91 if flags.Digitization.DoXingByXingPileUp: # PileUpTool approach
92 kwargs.setdefault("FirstXing", getTileFirstXing() )
93 kwargs.setdefault("LastXing", getTileLastXing() )
94 else:
95 intervals += [acc.popToolsAndMerge(TileRangeCfg(flags))]
96 kwargs.setdefault("PileUpMergeSvc", acc.getPrimaryAndMerge(PileUpMergeSvcCfg(flags, Intervals=intervals)))
97 else:
98 kwargs.setdefault("PileUpMergeSvc", '')
99
100 acc.setPrivateTools(CompFactory.TileHitVecToCntTool(**kwargs))
101
102 return acc
103
104
105def TileHitVecToCntCfg(flags, **kwargs):
106 """Return component accumulator with configured Tile hit vector to container algorithm
107
108 Arguments:
109 flags -- Athena configuration flags
110 """
111
112 acc = ComponentAccumulator()
113
114 if 'DigitizationTool' not in kwargs:
115 tool = acc.popToolsAndMerge( TileHitVecToCntToolCfg(flags) )
116 kwargs.setdefault('DigitizationTool', tool)
117
118 # choose which alg to attach to, following PileUpToolsCfg
119 if flags.Common.isOverlay:
120 if flags.Concurrency.NumThreads > 0:
121 kwargs.setdefault('Cardinality', flags.Concurrency.NumThreads)
122
123 kwargs.setdefault('name', 'TileHitVecToCnt')
124 Alg = CompFactory.TileHitVecToCnt
125 acc.addEventAlgo(Alg(**kwargs))
126 else:
127 kwargs["PileUpTools"] = [kwargs.pop("DigitizationTool")]
128 acc.merge(PileUpToolsCfg(flags, **kwargs))
129
130 return acc
131
132
133def TileHitOutputCfg(flags, **kwargs):
134 """Return component accumulator with Output Stream configuration for Tile hits
135
136 Arguments:
137 flags -- Athena configuration flags
138 """
139
140 if flags.Output.doWriteRDO:
141 acc = OutputStreamCfg(flags, 'RDO', ['TileHitContainer#*'])
142 else:
143 acc = ComponentAccumulator()
144
145 return acc
146
147
148def TileHitVecToCntOutputCfg(flags, **kwargs):
149 """Return component accumulator with configured Tile hit vector to container algorithm and Output Stream
150
151 Arguments:
152 flags -- Athena configuration flags
153 """
154
155 acc = TileHitVecToCntCfg(flags, **kwargs)
156 acc.merge(TileHitOutputCfg(flags))
157
158 return acc
159
160
161
162if __name__ == "__main__":
163
164 from AthenaConfiguration.AllConfigFlags import initConfigFlags
165 from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultTestFiles
166 from AthenaCommon.Logging import log
167 from AthenaCommon.Constants import DEBUG
168
169 # Test setup
170 log.setLevel(DEBUG)
171
172 flags = initConfigFlags()
173 flags.Input.Files = defaultTestFiles.HITS_RUN2
174 flags.Output.RDOFileName = 'myRDO-TileHitVecToCnt.pool.root'
175 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
176 flags.Digitization.PileUp = False
177 flags.Exec.MaxEvents = 3
178
179 flags.fillFromArgs()
180 flags.lock()
181
182 # Construct our accumulator to run
183 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
184 acc = MainServicesCfg(flags)
185
186 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
187 acc.merge(PoolReadCfg(flags))
188
189 if 'EventInfo' not in flags.Input.Collections:
190 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
191 acc.merge(EventInfoCnvAlgCfg(flags,
192 inputKey='McEventInfo',
193 outputKey='EventInfo'))
194
195 acc.merge(TileHitVecToCntOutputCfg(flags))
196
197 acc.getService('StoreGateSvc').Dump = True
198 acc.printConfig(withDetails = True, summariseProps = True)
199 flags.dump()
200 acc.store( open('TileHitVecToCnt.pkl','wb') )
201
202 sc = acc.run()
203 # Success should be 0
204 import sys
205 sys.exit(not sc.isSuccess())
TileHitVecToCntOutputCfg(flags, **kwargs)
TileHitOutputCfg(flags, **kwargs)
TileRangeCfg(flags, name='TileRange', **kwargs)
TileHitVecToCntCfg(flags, **kwargs)
TileHitVecToCntToolCfg(flags, **kwargs)