ATLAS Offline Software
TileHitToTTL1Config.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 Tile hits to TTL1 algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import ProductionStep
8 from TileSimAlgs.TileHitVecToCntConfig import TileHitVecToCntCfg
9 
10 
11 def TileHitToTTL1Cfg(flags, **kwargs):
12  """Return component accumulator with configured Tile hits to TTL1 algorithm
13 
14  Arguments:
15  flags -- Athena configuration flags
16  """
17 
18  kwargs.setdefault('name', 'TileHitToTTL1')
19  kwargs.setdefault('TileHitContainer', 'TileHitCnt')
20  kwargs.setdefault('maskBadChannels', True)
21 
22  acc = TileHitVecToCntCfg(flags)
23 
24  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
25  acc.merge( TileInfoLoaderCfg(flags) )
26 
27  from TileConditions.TileSamplingFractionConfig import TileSamplingFractionCondAlgCfg
28  acc.merge( TileSamplingFractionCondAlgCfg(flags) )
29 
30  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
31  acc.merge(TileCablingSvcCfg(flags))
32 
33  if 'RndmSvc' not in kwargs:
34  from RngComps.RngCompsConfig import AthRNGSvcCfg
35  kwargs['RndmSvc'] = acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)).name
36 
37  if kwargs['maskBadChannels']:
38  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
39  acc.merge( TileBadChannelsCondAlgCfg(flags) )
40 
41  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
42  acc.merge( TileEMScaleCondAlgCfg(flags) )
43 
44  if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
45  kwargs.setdefault('TileTTL1Container', flags.Overlay.BkgPrefix + 'TileTTL1Cnt')
46  if flags.Detector.EnableMBTS:
47  kwargs.setdefault('TileMBTSTTL1Container', flags.Overlay.BkgPrefix + 'TileTTL1MBTS')
48  else:
49  kwargs.setdefault('TileMBTSTTL1Container', '')
50  elif flags.Common.isOverlay:
51  kwargs.setdefault('TileTTL1Container', flags.Overlay.SigPrefix + 'TileTTL1Cnt')
52  if flags.Detector.EnableMBTS:
53  kwargs.setdefault('TileMBTSTTL1Container', flags.Overlay.SigPrefix + 'TileTTL1MBTS')
54  else:
55  kwargs.setdefault('TileMBTSTTL1Container', '')
56  else:
57  kwargs.setdefault('TileTTL1Container', 'TileTTL1Cnt')
58  if flags.Detector.EnableMBTS:
59  kwargs.setdefault('TileMBTSTTL1Container', 'TileTTL1MBTS')
60  else:
61  kwargs.setdefault('TileMBTSTTL1Container', '')
62 
63  TileHitToTTL1=CompFactory.TileHitToTTL1
64  acc.addEventAlgo(TileHitToTTL1(**kwargs), primary = True)
65 
66  return acc
67 
68 
69 def TileHitToTTL1CosmicsCfg(flags, **kwargs):
70  """Return component accumulator with configured Tile hits to TTL1 algorithm for cosmics
71 
72  Arguments:
73  flags -- Athena configuration flags
74  """
75 
76  kwargs.setdefault('name', 'TileHitToTTL1_Cosmics')
77  kwargs.setdefault('TileTTL1Type', 'Cosmics')
78  kwargs.setdefault('TileTTL1Container', 'TileTTL1CosmicsCnt')
79  if flags.Detector.EnableMBTS:
80  kwargs.setdefault('TileMBTSTTL1Container', 'TileMBTSTTL1CosmicsContainer')
81  else:
82  kwargs.setdefault('TileMBTSTTL1Container', '')
83 
84  return TileHitToTTL1Cfg(flags, **kwargs)
85 
86 
87 def TileTTL1OutputCfg(flags, TileHitToTTL1):
88 
89  if hasattr(TileHitToTTL1, 'TileTTL1Container'):
90  tileTTL1Container = TileHitToTTL1.TileTTL1Container
91  else:
92  tileTTL1Container = TileHitToTTL1.getDefaultProperty('TileTTL1Container')
93  tileTTL1Container = str(tileTTL1Container).split('+').pop()
94  outputItemList = ['TileTTL1Container#' + tileTTL1Container]
95 
96  if hasattr(TileHitToTTL1, 'TileMBTSTTL1Container'):
97  mbtsTTL1Container = TileHitToTTL1.TileMBTSTTL1Container
98  else:
99  mbtsTTL1Container = TileHitToTTL1.getDefaultProperty('TileMBTSTTL1Container')
100  mbtsTTL1Container = str(mbtsTTL1Container).split('+').pop()
101  outputItemList += ['TileTTL1Container#' + mbtsTTL1Container]
102 
103  acc = ComponentAccumulator()
104  if flags.Output.doWriteRDO:
105  if flags.Digitization.EnableTruth:
106  outputItemList += ["CaloCalibrationHitContainer#*"]
107  from DigitizationConfig.TruthDigitizationOutputConfig import TruthDigitizationOutputCfg
108  acc.merge(TruthDigitizationOutputCfg(flags))
109  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
110  acc.merge(OutputStreamCfg(flags, streamName = 'RDO', ItemList = outputItemList))
111 
112  return acc
113 
114 
115 def TileHitToTTL1OutputCfg(flags, **kwargs):
116  """Return component accumulator with configured Tile hits to TTL1 algorithm and Output Stream
117 
118  Arguments:
119  flags -- Athena configuration flags
120  """
121 
122  acc = TileHitToTTL1Cfg(flags, **kwargs)
123  acc.merge( TileTTL1OutputCfg(flags, acc.getPrimary()) )
124 
125  return acc
126 
127 
128 def TileHitToTTL1CosmicsOutputCfg(flags, **kwargs):
129  """Return component accumulator with configured Tile hits to TTL1 algorithm for cosmics and Output Stream
130 
131  Arguments:
132  flags -- Athena configuration flags
133  """
134 
135  acc = TileHitToTTL1CosmicsCfg(flags, **kwargs)
136  acc.merge( TileTTL1OutputCfg(flags, acc.getPrimary()) )
137 
138  return acc
139 
140 
141 if __name__ == "__main__":
142 
143  from AthenaConfiguration.AllConfigFlags import initConfigFlags
144  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultTestFiles
145  from AthenaCommon.Logging import log
146  from AthenaCommon.Constants import DEBUG
147 
148  # Test setup
149  log.setLevel(DEBUG)
150 
151  flags = initConfigFlags()
152  flags.Input.Files = defaultTestFiles.HITS_RUN2
153  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
154  flags.Digitization.PileUp = False
155  flags.Output.RDOFileName = "myRDO-TileHitToTTL1.pool.root"
156  flags.Exec.MaxEvents = 3
157  flags.fillFromArgs()
158  flags.lock()
159 
160  # Construct our accumulator to run
161  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
162  acc = MainServicesCfg(flags)
163 
164  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
165  acc.merge(PoolReadCfg(flags))
166 
167  if 'EventInfo' not in flags.Input.Collections:
168  from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
169  acc.merge(EventInfoCnvAlgCfg(flags,
170  inputKey='McEventInfo',
171  outputKey='EventInfo'))
172 
173  acc.merge( TileHitToTTL1OutputCfg(flags) )
174  flags.dump()
175 
176  acc.printConfig(withDetails = True, summariseProps = True)
177  acc.store( open('TileHitToTTL1.pkl','wb') )
178 
179  sc = acc.run()
180  # Success should be 0
181  import sys
182  sys.exit(not sc.isSuccess())
183 
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
python.TruthDigitizationOutputConfig.TruthDigitizationOutputCfg
def TruthDigitizationOutputCfg(flags)
Definition: TruthDigitizationOutputConfig.py:9
TileHitToTTL1Config.TileTTL1OutputCfg
def TileTTL1OutputCfg(flags, TileHitToTTL1)
Definition: TileHitToTTL1Config.py:87
python.TileSamplingFractionConfig.TileSamplingFractionCondAlgCfg
def TileSamplingFractionCondAlgCfg(flags, **kwargs)
Definition: TileSamplingFractionConfig.py:9
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
python.TileBadChannelsConfig.TileBadChannelsCondAlgCfg
def TileBadChannelsCondAlgCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:10
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.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
Trk::open
@ open
Definition: BinningType.h:40
TileHitToTTL1Config.TileHitToTTL1OutputCfg
def TileHitToTTL1OutputCfg(flags, **kwargs)
Definition: TileHitToTTL1Config.py:115
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileHitToTTL1Config.TileHitToTTL1Cfg
def TileHitToTTL1Cfg(flags, **kwargs)
Definition: TileHitToTTL1Config.py:11
str
Definition: BTagTrackIpAccessor.cxx:11
TileHitToTTL1
This algorithm builds TileTTL1 objects from TileHits.
Definition: TileHitToTTL1.h:72
python.xAODEventInfoCnvConfig.EventInfoCnvAlgCfg
def EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg", inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=False, **kwargs)
Definition: xAODEventInfoCnvConfig.py:11
TileHitToTTL1Config.TileHitToTTL1CosmicsOutputCfg
def TileHitToTTL1CosmicsOutputCfg(flags, **kwargs)
Definition: TileHitToTTL1Config.py:128
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
TileHitToTTL1Config.TileHitToTTL1CosmicsCfg
def TileHitToTTL1CosmicsCfg(flags, **kwargs)
Definition: TileHitToTTL1Config.py:69
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
RngCompsConfig.AthRNGSvcCfg
def AthRNGSvcCfg(flags, name="AthRNGSvc")
Definition: RngCompsConfig.py:51