ATLAS Offline Software
TileRawChannelMakerConfig.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 raw channel maker algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import ProductionStep
8 from TileConfiguration.TileConfigFlags import TileRunType
9 
10 def TileRawChannelMakerCfg(flags, **kwargs):
11  """Return component accumulator with configured Tile raw channel maker algorithm
12 
13  Arguments:
14  flags -- Athena configuration flags
15  """
16 
17  acc = ComponentAccumulator()
18 
19  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
20  acc.merge( TileInfoLoaderCfg(flags) )
21 
22  kwargs.setdefault('name', 'TileRChMaker')
23  name = kwargs['name']
24 
25  if flags.Common.ProductionStep in [ProductionStep.PileUpPresampling, ProductionStep.PileUpPretracking]:
26  kwargs.setdefault('TileDigitsContainer', flags.Overlay.BkgPrefix + 'TileDigitsCnt')
27  else:
28  kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt')
29 
30  from AthenaCommon.Logging import logging
31  mlog = logging.getLogger( 'TileRawChannelMakerCfg' )
32 
33  if flags.Tile.doOverflowFit:
34  kwargs.setdefault('FitOverflow', True)
35  from TileRecUtils.TileRawChannelBuilderFitConfig import TileRawChannelBuilderFitOverflowCfg
36  tileRawChannelBuilderFitOverflow = acc.popToolsAndMerge( TileRawChannelBuilderFitOverflowCfg(flags) )
37  kwargs.setdefault('TileRawChannelBuilderFitOverflow', tileRawChannelBuilderFitOverflow)
38  else:
39  kwargs.setdefault('FitOverflow', False)
40 
41  tileRawChannelBuilder = []
42 
43  if flags.Tile.doFit:
44  from TileRecUtils.TileRawChannelBuilderFitConfig import TileRawChannelBuilderFitFilterCfg
45  tileRawChannelBuilderFitFilter = acc.popToolsAndMerge( TileRawChannelBuilderFitFilterCfg(flags) )
46  tileRawChannelBuilder += [tileRawChannelBuilderFitFilter]
47  mlog.info(" adding now TileRawChannelBuilderFitFilter with name %s to the algorithm: %s",
48  tileRawChannelBuilderFitFilter.name, name)
49 
50  if flags.Tile.doOF1:
51  from TileRecUtils.TileRawChannelBuilderOptConfig import TileRawChannelBuilderOF1Cfg
52  tileRawChannelBuilderOF1 = acc.popToolsAndMerge( TileRawChannelBuilderOF1Cfg(flags) )
53  tileRawChannelBuilder += [tileRawChannelBuilderOF1]
54  mlog.info(" adding now TileRawChannelBuilderOpt2Filter with name %s to the algorithm: %s",
55  tileRawChannelBuilderOF1.name, name)
56 
57  if flags.Tile.doWiener:
58  from TileRecUtils.TileRawChannelBuilderWienerConfig import TileRawChannelBuilderWienerCfg
59  tileRawChannelBuilderWiener = acc.popToolsAndMerge( TileRawChannelBuilderWienerCfg(flags) )
60  tileRawChannelBuilder += [tileRawChannelBuilderWiener]
61  mlog.info(" adding now TileRawChannelBuilderWienerFilter with name %s to the algorithm: %s",
62  tileRawChannelBuilderWiener.name, name)
63 
64  if flags.Tile.doOpt2:
65  from TileRecUtils.TileRawChannelBuilderOptConfig import TileRawChannelBuilderOpt2Cfg
66  tileRawChannelBuilderOpt2 = acc.popToolsAndMerge( TileRawChannelBuilderOpt2Cfg(flags) )
67  tileRawChannelBuilder += [tileRawChannelBuilderOpt2]
68  mlog.info(" adding now TileRawChannelBuilderOpt2Filter with name %s to the algorithm: %s",
69  tileRawChannelBuilderOpt2.name, name)
70 
71  if flags.Tile.doOptATLAS:
72  from TileRecUtils.TileRawChannelBuilderOptConfig import TileRawChannelBuilderOptATLASCfg
73  tileRawChannelBuilderOptATLAS = acc.popToolsAndMerge( TileRawChannelBuilderOptATLASCfg(flags) )
74  tileRawChannelBuilder += [tileRawChannelBuilderOptATLAS]
75  mlog.info(" adding now TileRawChannelBuilderOpt2Filter with name %s to the algorithm: %s",
76  tileRawChannelBuilderOptATLAS.name, name)
77 
78  kwargs.setdefault('TileRawChannelBuilder', tileRawChannelBuilder)
79 
80  if flags.Common.isOverlay and flags.Concurrency.NumThreads > 0:
81  kwargs.setdefault('Cardinality', flags.Concurrency.NumThreads)
82 
83  TileRawChannelMaker=CompFactory.TileRawChannelMaker
84  acc.addEventAlgo(TileRawChannelMaker(**kwargs), primary = True)
85 
86  return acc
87 
88 
89 def TileRawChannelMakerDigiHSTruthCfg(flags, **kwargs):
90  """Return component accumulator with configured Tile raw channel maker algorithm for HS
91 
92  Arguments:
93  flags -- Athena configuration flags
94  """
95 
96  kwargs.setdefault('name', 'TileRChMaker_DigiHSTruth')
97  kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt_DigiHSTruth')
98 
99  acc = TileRawChannelMakerCfg(flags, **kwargs)
100  rawChannelMaker = acc.getPrimary()
101 
102  rawChannelbuilders = rawChannelMaker.TileRawChannelBuilder
103 
104  for rawChannelBuilder in rawChannelbuilders:
105  rawChannelBuilder.TileRawChannelContainer = f'{rawChannelBuilder.TileRawChannelContainer}_DigiHSTruth'
106 
107  return acc
108 
109 
110 def TileRawChannelOutputCfg(flags, tileRawChannelMaker, streamName):
111  """Return component accumulator with configured Output stream for Tile raw channel maker algorithm
112 
113  Arguments:
114  flags -- Athena configuration flags
115  tileRawChannelMaker -- Tile raw channel maker algorithm
116  streamName -- name of output stream.
117  """
118 
119  outputItemList = []
120  rawChannelbuilders = tileRawChannelMaker.TileRawChannelBuilder
121 
122  for rawChannelBuilder in rawChannelbuilders:
123  outputItemList += [f'TileRawChannelContainer#{rawChannelBuilder.TileRawChannelContainer}']
124 
125  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
126  acc = OutputStreamCfg(flags, streamName, ItemList = outputItemList)
127 
128  return acc
129 
130 
131 def TileRawChannelMakerOutputCfg(flags, streamName = 'ESD', **kwargs):
132  """Return component accumulator with configured Tile raw channel maker algorithm and Output stream
133 
134  Arguments:
135  flags -- Athena configuration flags
136  streamName -- name of output stream. Defaults to ESD.
137  """
138 
139  acc = TileRawChannelMakerCfg(flags, **kwargs)
140  acc.merge( TileRawChannelOutputCfg(flags, acc.getPrimary(), streamName) )
141 
142  return acc
143 
144 
145 def TileRawChannelMakerDigiHSTruthOutputCfg(flags, streamName = 'ESD', **kwargs):
146  """Return component accumulator with configured Tile raw channel maker algorithm and Output stream
147 
148  Arguments:
149  flags -- Athena configuration flags
150  streamName -- name of output stream. Defaults to ESD.
151  """
152 
153  acc = TileRawChannelMakerDigiHSTruthCfg(flags, **kwargs)
154  acc.merge( TileRawChannelOutputCfg(flags, acc.getPrimary(), streamName) )
155 
156  return acc
157 
158 
159 if __name__ == "__main__":
160 
161  from AthenaConfiguration.AllConfigFlags import initConfigFlags
162  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, 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.RAW_RUN2
171  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
172  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
173  flags.Tile.RunType = TileRunType.PHY
174  flags.Tile.doFit = True
175  flags.Tile.doOF1 = True
176  flags.Tile.doWiener = True
177  flags.Tile.doOpt2 = True
178  flags.Tile.doOptATLAS = True
179  flags.Tile.correctTimeJumps = True
180  flags.Tile.NoiseFilter = 1
181  flags.Output.ESDFileName = "myESD.pool.root"
182  flags.Exec.MaxEvents=3
183  flags.fillFromArgs()
184 
185  flags.lock()
186 
187  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
188  acc = MainServicesCfg(flags)
189 
190  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
191  acc.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
192 
193  acc.merge( TileRawChannelMakerOutputCfg(flags) )
194 
195  flags.dump()
196  acc.printConfig(withDetails = True, summariseProps = True)
197  acc.store( open('TileRawChannelMaker.pkl','wb') )
198 
199  sc = acc.run()
200 
201  import sys
202  # Success should be 0
203  sys.exit(not sc.isSuccess())
204 
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
TileRawChannelMakerConfig.TileRawChannelMakerOutputCfg
def TileRawChannelMakerOutputCfg(flags, streamName='ESD', **kwargs)
Definition: TileRawChannelMakerConfig.py:131
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOpt2Cfg
def TileRawChannelBuilderOpt2Cfg(flags)
Definition: TileRawChannelBuilderOptConfig.py:82
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOptATLASCfg
def TileRawChannelBuilderOptATLASCfg(flags)
Definition: TileRawChannelBuilderOptConfig.py:85
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
TileRawChannelMakerConfig.TileRawChannelMakerDigiHSTruthCfg
def TileRawChannelMakerDigiHSTruthCfg(flags, **kwargs)
Definition: TileRawChannelMakerConfig.py:89
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOF1Cfg
def TileRawChannelBuilderOF1Cfg(flags)
Definition: TileRawChannelBuilderOptConfig.py:79
TileRawChannelBuilderFitConfig.TileRawChannelBuilderFitFilterCfg
def TileRawChannelBuilderFitFilterCfg(flags, **kwargs)
Definition: TileRawChannelBuilderFitConfig.py:9
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
TileRawChannelMaker
Definition: TileRawChannelMaker.h:42
TileRawChannelBuilderWienerConfig.TileRawChannelBuilderWienerCfg
def TileRawChannelBuilderWienerCfg(flags, **kwargs)
Definition: TileRawChannelBuilderWienerConfig.py:9
TileRawChannelBuilderFitConfig.TileRawChannelBuilderFitOverflowCfg
def TileRawChannelBuilderFitOverflowCfg(flags, **kwargs)
Definition: TileRawChannelBuilderFitConfig.py:41
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileRawChannelMakerConfig.TileRawChannelMakerDigiHSTruthOutputCfg
def TileRawChannelMakerDigiHSTruthOutputCfg(flags, streamName='ESD', **kwargs)
Definition: TileRawChannelMakerConfig.py:145
TileRawChannelMakerConfig.TileRawChannelOutputCfg
def TileRawChannelOutputCfg(flags, tileRawChannelMaker, streamName)
Definition: TileRawChannelMakerConfig.py:110
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
TileRawChannelMakerConfig.TileRawChannelMakerCfg
def TileRawChannelMakerCfg(flags, **kwargs)
Definition: TileRawChannelMakerConfig.py:10