ATLAS Offline Software
TileHitVecToCntConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 """Define method to construct configured private Tile hit vector to container tool"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import BeamType
8 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
9 from DigitizationConfig.PileUpMergeSvcConfig import PileUpMergeSvcCfg, PileUpXingFolderCfg
10 from 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 
22 def 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 
33 def 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)).name
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  CosmicTriggerTimeTool=CompFactory.CosmicTriggerTimeTool
85  kwargs.setdefault('TriggerTimeTool', CosmicTriggerTimeTool())
86  kwargs.setdefault('HitTimeFlag', 2)
87  kwargs.setdefault('UseTriggerTime', True)
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)).name)
97  else:
98  kwargs.setdefault("PileUpMergeSvc", '')
99 
100  acc.setPrivateTools(CompFactory.TileHitVecToCntTool(**kwargs))
101 
102  return acc
103 
104 
105 def 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 
133 def 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 
148 def 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 
162 if __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())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
TileHitVecToCntConfig.TileRangeCfg
def TileRangeCfg(flags, name='TileRange', **kwargs)
Definition: TileHitVecToCntConfig.py:22
TileHitVecToCntConfig.getTileFirstXing
def getTileFirstXing()
Definition: TileHitVecToCntConfig.py:12
python.TileSamplingFractionConfig.TileSamplingFractionCondAlgCfg
def TileSamplingFractionCondAlgCfg(flags, **kwargs)
Definition: TileSamplingFractionConfig.py:9
TileHitVecToCntConfig.TileHitVecToCntToolCfg
def TileHitVecToCntToolCfg(flags, **kwargs)
Definition: TileHitVecToCntConfig.py:33
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
SGInputLoaderConfig.SGInputLoaderCfg
def SGInputLoaderCfg(flags, Load=None, **kwargs)
Definition: SGInputLoaderConfig.py:7
TileHitVecToCntConfig.TileHitVecToCntCfg
def TileHitVecToCntCfg(flags, **kwargs)
Definition: TileHitVecToCntConfig.py:105
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.PileUpToolsConfig.PileUpToolsCfg
def PileUpToolsCfg(flags, **kwargs)
Definition: PileUpToolsConfig.py:14
Trk::open
@ open
Definition: BinningType.h:40
TileHitVecToCntConfig.getTileLastXing
def getTileLastXing()
Definition: TileHitVecToCntConfig.py:17
TileHitVecToCntConfig.TileHitVecToCntOutputCfg
def TileHitVecToCntOutputCfg(flags, **kwargs)
Definition: TileHitVecToCntConfig.py:148
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PileUpMergeSvcConfig.PileUpXingFolderCfg
def PileUpXingFolderCfg(flags, name="PileUpXingFolder", **kwargs)
Definition: PileUpMergeSvcConfig.py:35
TileHitVecToCntConfig.TileHitOutputCfg
def TileHitOutputCfg(flags, **kwargs)
Definition: TileHitVecToCntConfig.py:133
python.xAODEventInfoCnvConfig.EventInfoCnvAlgCfg
def EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg", inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=False, **kwargs)
Definition: xAODEventInfoCnvConfig.py:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.PileUpMergeSvcConfig.PileUpMergeSvcCfg
def PileUpMergeSvcCfg(flags, name="PileUpMergeSvc", Intervals=[], **kwargs)
Definition: PileUpMergeSvcConfig.py:10
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
CosmicTriggerTimeTool
Definition: CosmicTriggerTimeTool.h:15
RngCompsConfig.AthRNGSvcCfg
def AthRNGSvcCfg(flags, name="AthRNGSvc")
Definition: RngCompsConfig.py:51