ATLAS Offline Software
TileDigitsMakerConfig.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 Tile digits maker algorithm"""
4 
5 from TileSimAlgs.TileHitVecToCntConfig import TileHitVecToCntCfg
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import ProductionStep
8 from TileConfiguration.TileConfigFlags import TileRunType
9 
10 def TileDigitsMakerCfg(flags, **kwargs):
11  """Return component accumulator with configured Tile digits maker algorithm
12 
13  Arguments:
14  flags -- Athena configuration flags
15  Keyword arguments:
16  name -- name of TileDigitsMaker algorithm. Defaults to TileDigitsMaker.
17  UseCoolPulseShapes -- flag to use pulse shape from database. Defaults to True.
18  RndmEvtOverlay -- flag to add PileUp or noise by overlaying random events.
19  True if flag.Common.isOverlay equals to True.
20  MaskBadChannels -- flag to mask channels tagged bad. Defaults to False.
21  """
22 
23  kwargs.setdefault('name', 'TileDigitsMaker')
24  kwargs.setdefault('UseCoolPulseShapes', True)
25  kwargs.setdefault('MaskBadChannels', False)
26  kwargs.setdefault('RndmEvtOverlay', flags.Common.isOverlay)
27  kwargs.setdefault('OnlyUseContainerName', not flags.Common.isOverlay)
28 
29  acc = TileHitVecToCntCfg(flags)
30 
31  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
32  infoLoaderAcc = TileInfoLoaderCfg(flags)
33  infoLoader = infoLoaderAcc.getPrimary()
34  acc.merge( infoLoaderAcc )
35 
36  infoLoaderProperties = infoLoader._properties.items()
37 
38  if 'TileNoise' in infoLoaderProperties:
39  tileNoise = infoLoaderProperties['TileNoise']
40  else:
41  tileNoise = infoLoader._descriptors['TileNoise'].default
42 
43  if 'TileCoherNoise' in infoLoaderProperties:
44  tileCoherNoise = infoLoaderProperties['TileCoherNoise']
45  else:
46  tileCoherNoise = infoLoader._descriptors['TileCoherNoise'].default
47 
48  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
49  acc.merge(TileCablingSvcCfg(flags))
50 
51  from TileConditions.TileSampleNoiseConfig import TileSampleNoiseCondAlgCfg
52  acc.merge( TileSampleNoiseCondAlgCfg(flags) )
53 
54  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
55  acc.merge( TileEMScaleCondAlgCfg(flags) )
56 
57  from TileConditions.TileSamplingFractionConfig import TileSamplingFractionCondAlgCfg
58  acc.merge( TileSamplingFractionCondAlgCfg(flags) )
59 
60  if kwargs['RndmEvtOverlay']:
61  tileNoise = False
62  tileCoherNoise = False
63 
64  kwargs['InputTileDigitContainer'] = f'{flags.Overlay.BkgPrefix}TileDigitsCnt'
65  kwargs['TileDQstatus'] = 'TileDQstatus'
66 
67  if flags.Overlay.ByteStream:
68  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
69  acc.merge(TileRawDataReadingCfg(flags, readMuRcv=False))
70  else:
71  from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
72  acc.merge(SGInputLoaderCfg(flags, [f'TileDigitsContainer#{kwargs["InputTileDigitContainer"]}']))
73 
74  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
75  acc.merge(TileDQstatusAlgCfg(flags))
76 
77  if tileNoise or tileCoherNoise or kwargs['RndmEvtOverlay']:
78  if 'RndmSvc' not in kwargs:
79  from RngComps.RngCompsConfig import AthRNGSvcCfg
80  kwargs['RndmSvc'] = acc.getPrimaryAndMerge( AthRNGSvcCfg(flags) ).name
81  else:
82  kwargs['RndmSvc'] = None
83 
84  if kwargs['UseCoolPulseShapes']:
85  from TileConditions.TilePulseShapeConfig import TilePulseShapeCondAlgCfg
86  acc.merge( TilePulseShapeCondAlgCfg(flags) )
87 
88  if kwargs['MaskBadChannels'] or kwargs['RndmEvtOverlay']:
89  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
90  acc.merge( TileBadChannelsCondAlgCfg(flags) )
91 
92  if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
93  kwargs.setdefault('TileDigitsContainer', flags.Overlay.BkgPrefix + 'TileDigitsCnt')
94  else:
95  kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt')
96 
97  kwargs.setdefault('DoHSTruthReconstruction', flags.Digitization.EnableCaloHSTruthRecoInputs)
98  if kwargs['DoHSTruthReconstruction']:
99  kwargs.setdefault('TileHitContainer_DigiHSTruth', 'TileHitCnt_DigiHSTruth')
100  kwargs.setdefault('TileDigitsContainer_DigiHSTruth', 'TileDigitsCnt_DigiHSTruth')
101  else:
102  kwargs.setdefault('TileHitContainer_DigiHSTruth', '')
103  kwargs.setdefault('TileDigitsContainer_DigiHSTruth', '')
104 
105 
106  kwargs.setdefault('IntegerDigits', flags.Common.ProductionStep != ProductionStep.PileUpPresampling)
107 
108  TileDigitsMaker=CompFactory.TileDigitsMaker
109  digitsMaker = TileDigitsMaker(**kwargs)
110 
111  acc.addEventAlgo(digitsMaker, primary = True)
112 
113  return acc
114 
115 def TileDigitsMakerOutputCfg(flags, **kwargs):
116  """Return component accumulator with configured Tile digits maker algorithm and Output Stream
117 
118  Arguments:
119  flags -- Athena configuration flags
120  Keyword arguments:
121  name -- name of TileDigitsMaker algorithm. Defaults to TileDigitsMaker.
122  UseCoolPulseShapes -- flag to use pulse shape from database. Defaults to True.
123  RndmEvtOverlay -- flag to add PileUp or noise by overlaying random events.
124  True if Common.ProductionStep equals to ProductionStep.Overlay.
125  MaskBadChannels -- flag to mask channels tagged bad. Defaults to False.
126  """
127 
128  acc = TileDigitsMakerCfg(flags, **kwargs)
129  tileDigitsMaker = acc.getPrimary()
130 
131  if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
132  if hasattr(tileDigitsMaker, 'TileDigitsContainer'):
133  tileDigitsContainer = tileDigitsMaker.TileDigitsContainer
134  else:
135  tileDigitsContainer = tileDigitsMaker.getDefaultProperty('TileDigitsContainer')
136  else:
137  if hasattr(tileDigitsMaker, 'TileFilteredContainer'):
138  tileDigitsContainer = tileDigitsMaker.TileFilteredContainer
139  else:
140  tileDigitsContainer = tileDigitsMaker.getDefaultProperty('TileFilteredContainer')
141 
142  tileDigitsContainer = str(tileDigitsContainer).split('+').pop()
143  if flags.Digitization.AddCaloDigi:
144  outputItemList = ['TileDigitsContainer#*']
145  else:
146  outputItemList = ['TileDigitsContainer#' + tileDigitsContainer]
147 
148  if flags.Output.doWriteRDO:
149  if flags.Digitization.EnableTruth:
150  outputItemList += ["CaloCalibrationHitContainer#*"]
151  from DigitizationConfig.TruthDigitizationOutputConfig import TruthDigitizationOutputCfg
152  acc.merge(TruthDigitizationOutputCfg(flags))
153  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
154  acc.merge( OutputStreamCfg(flags, streamName = 'RDO', ItemList = outputItemList) )
155 
156  return acc
157 
158 
159 if __name__ == "__main__":
160 
161  from AthenaConfiguration.AllConfigFlags import initConfigFlags
162  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultTestFiles
163  from AthenaCommon.Logging import log
164  from AthenaCommon.Constants import DEBUG
165 
166  # Test setup
167  log.setLevel(DEBUG)
168 
169  flags = initConfigFlags()
170  flags.Input.Files = defaultTestFiles.HITS_RUN2
171  flags.Tile.RunType = TileRunType.PHY
172  flags.Output.RDOFileName = 'myRDO-TileDigitsMaker.pool.root'
173  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
174  flags.Digitization.PileUp = False
175  flags.Exec.MaxEvents = 3
176 
177  flags.fillFromArgs()
178 
179  flags.lock()
180  flags.dump()
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( TileDigitsMakerOutputCfg(flags) )
196 
197  acc.printConfig(withDetails = True, summariseProps = True)
198  acc.store( open('TileDigitsMaker.pkl','wb') )
199 
200  sc = acc.run()
201  # Success should be 0
202  import sys
203  sys.exit(not sc.isSuccess())
204 
TileDigitsMaker
This algorithm performs digitization in TileCal, obtaining TileDigits from TileHits.
Definition: TileDigitsMaker.h:79
python.TilePulseShapeConfig.TilePulseShapeCondAlgCfg
def TilePulseShapeCondAlgCfg(flags, **kwargs)
Definition: TilePulseShapeConfig.py:9
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
python.TileSamplingFractionConfig.TileSamplingFractionCondAlgCfg
def TileSamplingFractionCondAlgCfg(flags, **kwargs)
Definition: TileSamplingFractionConfig.py:9
TileDigitsMakerConfig.TileDigitsMakerCfg
def TileDigitsMakerCfg(flags, **kwargs)
Definition: TileDigitsMakerConfig.py:10
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
SGInputLoaderConfig.SGInputLoaderCfg
def SGInputLoaderCfg(flags, Load=None, **kwargs)
Definition: SGInputLoaderConfig.py:7
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 -------------------------------------------------—
TileDigitsMakerConfig.TileDigitsMakerOutputCfg
def TileDigitsMakerOutputCfg(flags, **kwargs)
Definition: TileDigitsMakerConfig.py:115
python.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
Trk::open
@ open
Definition: BinningType.h:40
python.TileSampleNoiseConfig.TileSampleNoiseCondAlgCfg
def TileSampleNoiseCondAlgCfg(flags, **kwargs)
Definition: TileSampleNoiseConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
str
Definition: BTagTrackIpAccessor.cxx:11
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
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