ATLAS Offline Software
TileHitVecToCntConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 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  kwargs.setdefault("OnlyUseContainerName", flags.Digitization.PileUp)
100  TileHitVecToCntTool=CompFactory.TileHitVecToCntTool
101  acc.setPrivateTools(TileHitVecToCntTool(**kwargs))
102 
103  return acc
104 
105 
106 def TileHitVecToCntCfg(flags, **kwargs):
107  """Return component accumulator with configured Tile hit vector to container algorithm
108 
109  Arguments:
110  flags -- Athena configuration flags
111  """
112 
113  acc = ComponentAccumulator()
114 
115  if 'DigitizationTool' not in kwargs:
116  tool = acc.popToolsAndMerge( TileHitVecToCntToolCfg(flags) )
117  kwargs.setdefault('DigitizationTool', tool)
118 
119  # choose which alg to attach to, following PileUpToolsCfg
120  if flags.Common.isOverlay:
121  if flags.Concurrency.NumThreads > 0:
122  kwargs.setdefault('Cardinality', flags.Concurrency.NumThreads)
123 
124  kwargs.setdefault('name', 'TileHitVecToCnt')
125  Alg = CompFactory.TileHitVecToCnt
126  acc.addEventAlgo(Alg(**kwargs))
127  else:
128  kwargs["PileUpTools"] = [kwargs.pop("DigitizationTool")]
129  acc.merge(PileUpToolsCfg(flags, **kwargs))
130 
131  return acc
132 
133 
134 def TileHitOutputCfg(flags, **kwargs):
135  """Return component accumulator with Output Stream configuration for Tile hits
136 
137  Arguments:
138  flags -- Athena configuration flags
139  """
140 
141  if flags.Output.doWriteRDO:
142  acc = OutputStreamCfg(flags, 'RDO', ['TileHitContainer#*'])
143  else:
144  acc = ComponentAccumulator()
145 
146  return acc
147 
148 
149 def TileHitVecToCntOutputCfg(flags, **kwargs):
150  """Return component accumulator with configured Tile hit vector to container algorithm and Output Stream
151 
152  Arguments:
153  flags -- Athena configuration flags
154  """
155 
156  acc = TileHitVecToCntCfg(flags, **kwargs)
157  acc.merge(TileHitOutputCfg(flags))
158 
159  return acc
160 
161 
162 
163 if __name__ == "__main__":
164 
165  from AthenaConfiguration.AllConfigFlags import initConfigFlags
166  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultTestFiles
167  from AthenaCommon.Logging import log
168  from AthenaCommon.Constants import DEBUG
169 
170  # Test setup
171  log.setLevel(DEBUG)
172 
173  flags = initConfigFlags()
174  flags.Input.Files = defaultTestFiles.HITS_RUN2
175  flags.Output.RDOFileName = 'myRDO-TileHitVecToCnt.pool.root'
176  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
177  flags.Digitization.PileUp = False
178  flags.Exec.MaxEvents = 3
179 
180  flags.fillFromArgs()
181  flags.lock()
182 
183  # Construct our accumulator to run
184  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
185  acc = MainServicesCfg(flags)
186 
187  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
188  acc.merge(PoolReadCfg(flags))
189 
190  if 'EventInfo' not in flags.Input.Collections:
191  from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
192  acc.merge(EventInfoCnvAlgCfg(flags,
193  inputKey='McEventInfo',
194  outputKey='EventInfo'))
195 
196  acc.merge(TileHitVecToCntOutputCfg(flags))
197 
198  acc.getService('StoreGateSvc').Dump = True
199  acc.printConfig(withDetails = True, summariseProps = True)
200  flags.dump()
201  acc.store( open('TileHitVecToCnt.pkl','wb') )
202 
203  sc = acc.run()
204  # Success should be 0
205  import sys
206  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:106
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
TileHitVecToCntTool
This AlgTool merges TileHits from different AthenaHitVectors and stores the result in a TileHitContai...
Definition: TileHitVecToCntTool.h:84
Trk::open
@ open
Definition: BinningType.h:40
TileHitVecToCntConfig.getTileLastXing
def getTileLastXing()
Definition: TileHitVecToCntConfig.py:17
TileHitVecToCntConfig.TileHitVecToCntOutputCfg
def TileHitVecToCntOutputCfg(flags, **kwargs)
Definition: TileHitVecToCntConfig.py:149
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:134
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