ATLAS Offline Software
TileRawChannelBuilderOptConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 """Define methods to construct configured Tile raw channel builder tools using Optimal Filtering methods"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from TileConfiguration.TileConfigFlags import TileRunType
8 
9 def TileRawChannelBuilderOpt2FilterCfg(flags, method = 'Opt2', **kwargs):
10  """Return component accumulator with configured private Tile raw channel builder tool (Opt2)
11 
12  Arguments:
13  flags -- Athena configuration flags
14  method -- flavour of Tile Optimal Filtering method. Defaults to Opt2. Possible values: Opt2, OptATLAS, OF1
15  """
16 
17  if method not in ['Opt2', 'OptATLAS', 'OF1']:
18  raise(Exception("Invalid Tile Optimal Filtering method: %s" % method))
19 
20  name = kwargs.pop('name', 'TileRawChannelBuilder' + method)
21  useIterations = (method == 'Opt2')
22 
23  acc = ComponentAccumulator()
24 
25  if 'TileCondToolOfc' not in kwargs:
26  if flags.Tile.OfcFromCOOL:
27  ofcType = 'OF2' if method != 'OF1' else 'OF1'
28  from TileConditions.TileOFCConfig import TileCondToolOfcCoolCfg
29  kwargs['TileCondToolOfc'] = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(flags, OfcType = ofcType) )
30  else:
31  from TileConditions.TileOFCConfig import TileCondToolOfcCfg
32  kwargs['TileCondToolOfc'] = acc.popToolsAndMerge( TileCondToolOfcCfg(flags) )
33 
34  outputContainer = flags.Tile.RawChannelContainer if method == 'OptATLAS' else 'TileRawChannel' + method
35  kwargs.setdefault('TileRawChannelContainer', outputContainer)
36 
37  maxIterations = 3 if flags.Tile.RunType is TileRunType.MONOCIS else 5
38 
39  kwargs['BestPhase'] = False if useIterations else flags.Tile.BestPhaseFromCOOL
40  kwargs['OF2'] = True if method != 'OF1' else False
41  kwargs['MaxIterations'] = maxIterations if useIterations else 1
42  kwargs['Minus1Iteration'] = True if useIterations else False
43  kwargs['AmplitudeCorrection'] = False if useIterations else flags.Tile.correctAmplitude
44  kwargs['TimeCorrection'] = False if method != 'OptATLAS' else flags.Tile.correctTimeNI
45 
46  if (flags.Tile.BestPhaseFromCOOL and not useIterations) or flags.Tile.correctTime:
47  if 'TileCondToolTiming' not in kwargs:
48  from TileConditions.TileTimingConfig import TileCondToolTimingCfg
49  kwargs['TileCondToolTiming'] = acc.popToolsAndMerge( TileCondToolTimingCfg(flags) )
50 
51  if flags.Tile.BestPhaseFromCOOL and not useIterations:
52  # Can't correct time and use best phase at the same time without iteration
53  kwargs['correctTime'] = False
54  else:
55  kwargs.setdefault('correctTime', flags.Tile.correctTime)
56 
57  if method == 'OptATLAS':
58  pedestalMode = 17
59  else:
60  pedestalMode = -1 if method == 'OF1' else 1
61 
62  kwargs.setdefault('PedestalMode', pedestalMode)
63 
64  if kwargs['PedestalMode'] == -1 and 'TileCondToolNoiseSample' not in kwargs:
65  # Use pedestal from conditions DB
66  from TileConditions.TileSampleNoiseConfig import TileCondToolNoiseSampleCfg
67  sampleNoiseTool = acc.popToolsAndMerge( TileCondToolNoiseSampleCfg(flags) )
68  kwargs['TileCondToolNoiseSample'] = sampleNoiseTool
69 
70  TileRawChannelBuilderOpt2Filter=CompFactory.TileRawChannelBuilderOpt2Filter
71  from TileRecUtils.TileRawChannelBuilderConfig import TileRawChannelBuilderCfg
72  builderTool = acc.popToolsAndMerge( TileRawChannelBuilderCfg(flags, name, TileRawChannelBuilderOpt2Filter, **kwargs) )
73 
74  acc.setPrivateTools( builderTool )
75  return acc
76 
77 
78 
80  return TileRawChannelBuilderOpt2FilterCfg(flags, method = 'OF1')
81 
83  return TileRawChannelBuilderOpt2FilterCfg(flags, method = 'Opt2')
84 
86  return TileRawChannelBuilderOpt2FilterCfg(flags, method = 'OptATLAS')
87 
88 
89 if __name__ == "__main__":
90 
91  from AthenaConfiguration.AllConfigFlags import initConfigFlags
92  from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultTestFiles
93  from AthenaCommon.Logging import log
94  from AthenaCommon.Constants import DEBUG
95 
96  # Test setup
97  log.setLevel(DEBUG)
98 
99  flags = initConfigFlags()
100  flags.Input.Files = defaultTestFiles.RAW_RUN2
101  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
102  flags.Tile.RunType = TileRunType.PHY
103  flags.Tile.NoiseFilter = 1
104  flags.lock()
105 
106  flags.dump()
107 
109 
110  #Comment for now, priting configurables isn't reliable with GaudiConfig2
111  acc.popToolsAndMerge( TileRawChannelBuilderOpt2Cfg(flags) )
112  acc.popToolsAndMerge( TileRawChannelBuilderOptATLASCfg(flags) )
113  acc.popToolsAndMerge( TileRawChannelBuilderOF1Cfg(flags) )
114 
115  acc.printConfig(withDetails = True, summariseProps = True)
116  acc.store( open('TileRawChannelBuilder.pkl','wb') )
117 
118 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TileSampleNoiseConfig.TileCondToolNoiseSampleCfg
def TileCondToolNoiseSampleCfg(flags, **kwargs)
Definition: TileSampleNoiseConfig.py:69
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOpt2Cfg
def TileRawChannelBuilderOpt2Cfg(flags)
Definition: TileRawChannelBuilderOptConfig.py:82
python.TileTimingConfig.TileCondToolTimingCfg
def TileCondToolTimingCfg(flags, **kwargs)
Definition: TileTimingConfig.py:77
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOptATLASCfg
def TileRawChannelBuilderOptATLASCfg(flags)
Definition: TileRawChannelBuilderOptConfig.py:85
python.TileOFCConfig.TileCondToolOfcCoolCfg
def TileCondToolOfcCoolCfg(flags, **kwargs)
Definition: TileOFCConfig.py:66
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOpt2FilterCfg
def TileRawChannelBuilderOpt2FilterCfg(flags, method='Opt2', **kwargs)
Definition: TileRawChannelBuilderOptConfig.py:9
TileRawChannelBuilderOptConfig.TileRawChannelBuilderOF1Cfg
def TileRawChannelBuilderOF1Cfg(flags)
Definition: TileRawChannelBuilderOptConfig.py:79
Constants
some useful constants -------------------------------------------------—
TileRawChannelBuilderConfig.TileRawChannelBuilderCfg
def TileRawChannelBuilderCfg(flags, name, TileRawChannelBuilder, **kwargs)
Definition: TileRawChannelBuilderConfig.py:9
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.TileOFCConfig.TileCondToolOfcCfg
def TileCondToolOfcCfg(flags, **kwargs)
Definition: TileOFCConfig.py:98