ATLAS Offline Software
TileRawChannelCorrectionConfig.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 correction tools and algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from TileConfiguration.TileConfigFlags import TileRunType
8 
9 def TileRawChannelOF1CorrectorCfg(flags, **kwargs):
10  """Return component accumulator with configured private Tile OF1 raw channel correction tool
11 
12  Arguments:
13  flags -- Athena configuration flags
14  """
15 
16  acc = ComponentAccumulator()
17 
18  kwargs.setdefault('CorrectPedestalDifference', flags.Tile.correctPedestalDifference)
19  kwargs.setdefault('ZeroAmplitudeWithoutDigits', flags.Tile.zeroAmplitudeWithoutDigits)
20  kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt')
21 
22  if kwargs['CorrectPedestalDifference']:
23  from TileConditions.TileSampleNoiseConfig import TileSampleNoiseCondAlgCfg
24  acc.merge( TileSampleNoiseCondAlgCfg(flags, TileSampleNoise="TileSampleNoise") )
25  acc.merge( TileSampleNoiseCondAlgCfg(flags, ForceOnline=True, TileSampleNoise="TileOnlineSampleNoise") )
26 
27  if 'TileCondToolTiming' not in kwargs:
28  from TileConditions.TileTimingConfig import TileCondToolOnlineTimingCfg
29  kwargs['TileCondToolTiming'] = acc.popToolsAndMerge( TileCondToolOnlineTimingCfg(flags) )
30 
31  if 'TileCondToolOfc' not in kwargs:
32  from TileConditions.TileOFCConfig import TileCondToolOfcCoolCfg
33  kwargs['TileCondToolOfc'] = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(flags, OfcType = 'OF1') )
34 
35  if kwargs['ZeroAmplitudeWithoutDigits']:
36 
37  if 'TileCondToolDspThreshold' not in kwargs:
38  from TileConditions.TileDSPThresholdConfig import TileCondToolDspThresholdCfg
39  kwargs['TileCondToolDspThreshold'] = acc.popToolsAndMerge( TileCondToolDspThresholdCfg(flags) )
40 
41  if kwargs['CorrectPedestalDifference'] or kwargs['ZeroAmplitudeWithoutDigits']:
42  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
43  acc.merge( TileEMScaleCondAlgCfg(flags) )
44 
45  TileRawChannelOF1Corrector=CompFactory.TileRawChannelOF1Corrector
46  acc.setPrivateTools( TileRawChannelOF1Corrector(**kwargs) )
47 
48  return acc
49 
50 
51 
52 def TileRawChannelNoiseFilterCfg(flags, **kwargs):
53  """Return component accumulator with configured private Tile raw channel noise filter tool
54 
55  Arguments:
56  flags -- Athena configuration flags (ConfigFlags)
57  """
58 
59  acc = ComponentAccumulator()
60 
61  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
62  acc.merge( TileDQstatusAlgCfg(flags) )
63 
64  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
65  acc.merge( TileInfoLoaderCfg(flags) )
66 
67  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
68  acc.merge( TileEMScaleCondAlgCfg(flags) )
69 
70  from TileConditions.TileSampleNoiseConfig import TileSampleNoiseCondAlgCfg
71  acc.merge( TileSampleNoiseCondAlgCfg(flags) )
72 
73  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
74  acc.merge( TileBadChannelsCondAlgCfg(flags) )
75 
76  TileRawChannelNoiseFilter=CompFactory.TileRawChannelNoiseFilter
77  acc.setPrivateTools( TileRawChannelNoiseFilter(**kwargs) )
78 
79  return acc
80 
81 
82 
83 def TileTimeBCOffsetFilterCfg(flags, **kwargs):
84  """Return component accumulator with configured private Tile raw channel timing jump correction tool
85 
86  Arguments:
87  flags -- Athena configuration flags (ConfigFlags)
88  EneThreshold3 - energy threshold on 3 channels in one DMU (in MeV)
89  EneThreshold1 - energy threshold on 1 channel (in MeV)
90  TimeThreshold - threshold on time difference (in ns)
91  """
92 
93  acc = ComponentAccumulator()
94  kwargs.setdefault('CheckDCS', flags.Tile.useDCS)
95  kwargs.setdefault('EneThreshold3', 1000)
96  kwargs.setdefault('EneThreshold1', 3000)
97  kwargs.setdefault('TimeThreshold', 15)
98  kwargs.setdefault('AverTimeEneThreshold', 500)
99  kwargs.setdefault('RefTimeThreshold', 10)
100  kwargs.setdefault('SampleDiffMaxMin_HG', 15)
101  kwargs.setdefault('SampleDiffMaxMin_LG', -1)
102 
103  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
104  acc.merge( TileDQstatusAlgCfg(flags) )
105 
106  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
107  acc.merge(TileCablingSvcCfg(flags))
108 
109  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
110  acc.merge( TileEMScaleCondAlgCfg(flags) )
111 
112  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
113  acc.merge( TileBadChannelsCondAlgCfg(flags) )
114 
115  if kwargs['CheckDCS']:
116  from TileConditions.TileDCSConfig import TileDCSCondAlgCfg
117  acc.merge( TileDCSCondAlgCfg(flags) )
118 
119  TileTimeBCOffsetFilter=CompFactory.TileTimeBCOffsetFilter
120  acc.setPrivateTools( TileTimeBCOffsetFilter(**kwargs) )
121 
122  return acc
123 
124 
125 
126 def TileRawChannelCorrectionToolsCfg(flags, **kwargs):
127  """Return component accumulator with configured private Tile raw channel correction tools
128 
129  Arguments:
130  flags -- Athena configuration flags (ConfigFlags)
131  """
132 
133  acc = ComponentAccumulator()
134 
135  noiseFilterTools = []
136 
137  if flags.Tile.correctPedestalDifference or flags.Tile.zeroAmplitudeWithoutDigits:
138  noiseFilterTools += [ acc.popToolsAndMerge( TileRawChannelOF1CorrectorCfg(flags) ) ]
139 
140  if flags.Tile.NoiseFilter == 1:
141  noiseFilterTools += [ acc.popToolsAndMerge( TileRawChannelNoiseFilterCfg(flags) ) ]
142 
143  if flags.Tile.correctTimeJumps:
144  noiseFilterTools += [ acc.popToolsAndMerge( TileTimeBCOffsetFilterCfg(flags) ) ]
145 
146  acc.setPrivateTools( noiseFilterTools )
147 
148  return acc
149 
150 
151 def TileRawChannelCorrectionAlgCfg(flags, **kwargs):
152  """Return component accumulator with configured Tile raw channel correction algorithm
153 
154  Arguments:
155  flags -- Athena configuration flags (ConfigFlags)
156 
157  Keyword arguments:
158  InputRawChannelContainer -- input Tile raw channel container. Defaults to TileRawChannelCnt.
159  OutputRawChannelContainer -- output Tile raw channel container. Defaults to TileRawChannelCntCorrected.
160  """
161 
162  acc = ComponentAccumulator()
163 
164  kwargs.setdefault('InputRawChannelContainer', 'TileRawChannelCnt')
165  kwargs.setdefault('OutputRawChannelContainer', 'TileRawChannelCntCorrected')
166 
167  if 'NoiseFilterTools' not in kwargs:
168  kwargs['NoiseFilterTools'] = acc.popToolsAndMerge( TileRawChannelCorrectionToolsCfg(flags) )
169 
170  TileRawChannelCorrectionAlg=CompFactory.TileRawChannelCorrectionAlg
171  acc.addEventAlgo(TileRawChannelCorrectionAlg(**kwargs), primary = True)
172 
173  return acc
174 
175 
176 
177 if __name__ == "__main__":
178 
179  from AthenaConfiguration.AllConfigFlags import initConfigFlags
180  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
181  from AthenaCommon.Logging import log
182  from AthenaCommon.Constants import DEBUG
183 
184  # Test setup
185  log.setLevel(DEBUG)
186 
187  flags = initConfigFlags()
188  flags.Input.Files = defaultTestFiles.RAW_RUN2
189  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
190  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
191  flags.Tile.RunType = TileRunType.PHY
192  flags.Tile.correctPedestalDifference = True
193  flags.Tile.zeroAmplitudeWithoutDigits = True
194  flags.lock()
195 
196  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
197  acc = MainServicesCfg(flags)
198 
199  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
200  acc.merge( TileRawDataReadingCfg(flags, readMuRcv=False) )
201 
202  acc.merge( TileRawChannelCorrectionAlgCfg(flags) )
203 
204  flags.dump()
205  acc.printConfig(withDetails = True, summariseProps = True)
206  acc.store( open('TileRawChannelCorrection.pkl','wb') )
207 
208  sc = acc.run(maxEvents = 3)
209 
210  import sys
211  # Success should be 0
212  sys.exit(not sc.isSuccess())
213 
TileRawChannelCorrectionConfig.TileRawChannelNoiseFilterCfg
def TileRawChannelNoiseFilterCfg(flags, **kwargs)
Definition: TileRawChannelCorrectionConfig.py:52
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileRawChannelCorrectionConfig.TileRawChannelOF1CorrectorCfg
def TileRawChannelOF1CorrectorCfg(flags, **kwargs)
Definition: TileRawChannelCorrectionConfig.py:9
python.TileDSPThresholdConfig.TileCondToolDspThresholdCfg
def TileCondToolDspThresholdCfg(flags, **kwargs)
Definition: TileDSPThresholdConfig.py:60
TileTimeBCOffsetFilter
This tool sets bad status for channels with 25ns or 50ns timing jump.
Definition: TileTimeBCOffsetFilter.h:54
python.TileOFCConfig.TileCondToolOfcCoolCfg
def TileCondToolOfcCoolCfg(flags, **kwargs)
Definition: TileOFCConfig.py:66
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
python.TileTimingConfig.TileCondToolOnlineTimingCfg
def TileCondToolOnlineTimingCfg(flags, **kwargs)
Definition: TileTimingConfig.py:111
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
TileRawChannelCorrectionAlg
This algorithm applies noise filter tools to input Tile raw channel container.
Definition: TileRawChannelCorrectionAlg.h:24
python.TileBadChannelsConfig.TileBadChannelsCondAlgCfg
def TileBadChannelsCondAlgCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:10
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
TileRawChannelOF1Corrector
This tool correct TileRawChannels amplitudes which came from OF1 DSP if pedestal changed.
Definition: TileRawChannelOF1Corrector.h:38
python.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
python.TileDCSConfig.TileDCSCondAlgCfg
def TileDCSCondAlgCfg(flags, **kwargs)
Definition: TileDCSConfig.py:8
Trk::open
@ open
Definition: BinningType.h:40
TileRawChannelCorrectionConfig.TileTimeBCOffsetFilterCfg
def TileTimeBCOffsetFilterCfg(flags, **kwargs)
Definition: TileRawChannelCorrectionConfig.py:83
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
TileRawChannelNoiseFilter
This tool subtracts common-mode noise from all TileRawChannels in one container.
Definition: TileRawChannelNoiseFilter.h:39
TileRawChannelCorrectionConfig.TileRawChannelCorrectionAlgCfg
def TileRawChannelCorrectionAlgCfg(flags, **kwargs)
Definition: TileRawChannelCorrectionConfig.py:151
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileRawChannelCorrectionConfig.TileRawChannelCorrectionToolsCfg
def TileRawChannelCorrectionToolsCfg(flags, **kwargs)
Definition: TileRawChannelCorrectionConfig.py:126