Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TileConfigFlags.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.AthConfigFlags import AthConfigFlags
4 from AthenaConfiguration.Enums import BeamType, Format, FlagEnum
5 
6 
7 class TileRunType(FlagEnum):
8  PHY = 'PHY'
9  PED = 'PED'
10  CIS = 'CIS'
11  MONOCIS = 'MONOCIS'
12  GAPCIS = 'GAP/CIS'
13  L1CALO = 'L1CALO'
14  LAS = 'LAS'
15  BILAS = 'BILAS'
16  GAPLAS = 'GAP/LAS'
17  UNDEFINED = 'UNDEFINED'
18 
19  def getCommonType(self):
20  commonType = self
21  if self in [TileRunType.PHY, TileRunType.PED]:
22  commonType = TileRunType.PHY
23  elif self in [TileRunType.LAS, TileRunType.BILAS, TileRunType.GAPLAS]:
24  commonType = TileRunType.LAS
25  elif self in [TileRunType.CIS, TileRunType.MONOCIS, TileRunType.GAPCIS, TileRunType.L1CALO]:
26  commonType = TileRunType.CIS
27  return commonType
28 
29  def getTimingType(self):
30  if self is TileRunType.L1CALO:
31  return TileRunType.PHY
32  else:
33  return self if self in [TileRunType.GAPLAS] else self.getCommonType()
34 
35  def getIntValue(self):
36  _runTypeInt = {TileRunType.PHY: 1, TileRunType.LAS: 2,
37  TileRunType.GAPLAS: 2, TileRunType.BILAS: 2,
38  TileRunType.PED: 4, TileRunType.CIS: 8,
39  TileRunType.GAPCIS: 8, TileRunType.MONOCIS: 9,
40  TileRunType.L1CALO: 9}
41  return _runTypeInt.get(self, 0)
42 
43  def isBiGain(self):
44  return True if self in [TileRunType.CIS, TileRunType.PED] else False
45 
46 
48 
49  tcf = AthConfigFlags()
50 
51  tcf.addFlag('Tile.doQIE', False)
52  tcf.addFlag('Tile.doManyAmps', False)
53  tcf.addFlag('Tile.doFlat', False)
54  tcf.addFlag('Tile.doFit', False)
55  tcf.addFlag('Tile.doFitCOOL', False)
56  tcf.addFlag('Tile.doMF', False)
57  tcf.addFlag('Tile.doOF1', False)
58  tcf.addFlag('Tile.doWiener', False)
59  tcf.addFlag('Tile.doOpt2', _doOpt2)
60  tcf.addFlag('Tile.doOptATLAS', _doOptATLAS)
61  tcf.addFlag('Tile.NoiseFilter', lambda prevFlags : -1 if prevFlags.Input.isMC else 1)
62  tcf.addFlag('Tile.RunType', _getRunType, type=TileRunType)
63  tcf.addFlag('Tile.correctTime', lambda prevFlags : not prevFlags.Input.isMC and prevFlags.Beam.Type is BeamType.Collisions)
64  tcf.addFlag('Tile.correctTimeNI', True)
65  tcf.addFlag('Tile.correctAmplitude', True)
66  tcf.addFlag('Tile.AmpMinForAmpCorrection', 15.0)
67  tcf.addFlag('Tile.TimeMinForAmpCorrection', lambda prevFlags : (prevFlags.Beam.BunchSpacing / -2.))
68  tcf.addFlag('Tile.TimeMaxForAmpCorrection', lambda prevFlags : (prevFlags.Beam.BunchSpacing / 2.))
69  tcf.addFlag('Tile.OfcFromCOOL', True)
70  tcf.addFlag('Tile.BestPhaseFromCOOL', lambda prevFlags : not prevFlags.Input.isMC and prevFlags.Beam.Type is BeamType.Collisions)
71  tcf.addFlag('Tile.readDigits', lambda prevFlags : not prevFlags.Input.isMC)
72  tcf.addFlag('Tile.doOverflowFit', True)
73  tcf.addFlag('Tile.zeroAmplitudeWithoutDigits', _zeroAmplitudeWithoutDigits)
74  tcf.addFlag('Tile.correctPedestalDifference', _correctPedestalDifference)
75  tcf.addFlag('Tile.correctTimeJumps', _correctTimeJumps)
76  tcf.addFlag('Tile.RawChannelContainer', _getRawChannelContainer)
77  tcf.addFlag('Tile.useDCS', _useDCS)
78  tcf.addFlag('Tile.doTimingHistogramsForGain', -1) # Production of Tile timing histograms per channel (< 0: switched off)
79  tcf.addFlag('Tile.doTimingHistogramsForCell', {'LBA14':['A4','B6','D1'],'LBA22':['A4','B6','D1'],'EBA22':['A13','B12','D5']}) # Production of Tile timing histograms per selected cells ({}: switched off)
80  tcf.addFlag('Tile.useOnlineChannelStatus', True) # Use online DB with channel/adc status
81 
82  return tcf
83 
84 
85 
86 def _doOpt2ByDefault(prevFlags):
87  #For online operation don't check run number
88  if prevFlags.Common.isOnline:
89  if prevFlags.Beam.Type is BeamType.Collisions:
90  return False # Use OF without iterations for collisions
91  else:
92  return True
93 
94  runNumber = prevFlags.Input.RunNumbers[0]
95  # Run Optimal Filter with iterations (Opt2) by default,
96  # both for cosmics and collisions data before 2011
97  if not prevFlags.Input.isMC and runNumber > 0 and runNumber < 171194:
98  return True
99  # Run Optimal Filter without iterations (OptATLAS)
100  # for collisions (data in 2011 and later and MC)
101  elif prevFlags.Beam.Type is BeamType.Collisions:
102  return False # Use OF without iterations for collisions
103  else:
104  return True
105 
106 
107 def _doExtraMethods(prevFlags):
108  # Check if any Optimal Filter, but Opt2 and OptATLAS, is already scheduled
109  if (prevFlags.Tile.doQIE or prevFlags.Tile.doManyAmps or prevFlags.Tile.doFlat
110  or prevFlags.Tile.doFit or prevFlags.Tile.doFitCOOL or prevFlags.Tile.doMF
111  or prevFlags.Tile.doOF1 or prevFlags.Tile.doWiener):
112  return True
113  else:
114  return False
115 
116 def _doOpt2(prevFlags):
117  # Do not run Opt2 method if any Optimal Filter is already scheduled
118  if _doExtraMethods(prevFlags) :
119  return False
120  # If no extra Optimal Filters are scheduled yet check if Opt2 should be used by default
121  else:
122  if _doOpt2ByDefault(prevFlags):
123  _flags = prevFlags.clone()
124  _flags.Tile.doOpt2 = True
125  # Opt2 should be run by default, but check if OptATLAS is already scheduled
126  return not _flags.Tile.doOptATLAS
127  else:
128  return False
129 
130 
131 def _doOptATLAS(prevFlags):
132  # Do not run OptATLAS method if any Optimal Filter is alredy scheduled
133  if _doExtraMethods(prevFlags) :
134  return False
135  # If no Optimal Filters are scheduled yet check if OptATLAS should be used by default
136  else:
137  if not _doOpt2ByDefault(prevFlags):
138  # OptATLAS should be run by default, but check if Opt2 is already scheduled
139  _flags = prevFlags.clone()
140  _flags.Tile.doOptATLAS = True
141  return not _flags.Tile.doOpt2
142  else:
143  return False
144 
145 
147  if not prevFlags.Input.isMC:
148  runNumber = prevFlags.Input.RunNumbers[0]
149  # Use OF1 corrections only for years 2015 - 2016
150  return runNumber > 269101 and runNumber < 324320
151  else:
152  return False
153 
154 
156  if not prevFlags.Common.isOnline:
157  return _zeroAmplitudeWithoutDigits(prevFlags)
158  else:
159  return False
160 
161 
162 def _correctTimeJumps(prevFlags):
163  if not (prevFlags.Input.isMC or prevFlags.Overlay.DataOverlay) and prevFlags.Input.Format is Format.BS:
164  return True
165  else:
166  return False
167 
168 
169 def _getRunType(prevFlags):
170  # Tile run types: UNDEFINED, PHY, PED, LAS, BILAS, CIS, MONOCIS
171  from AthenaConfiguration.AutoConfigFlags import GetFileMD
172  if not prevFlags.Input.isMC and 'calibration_Tile' in GetFileMD(prevFlags.Input.Files).get('triggerStreamOfFile', ''):
173  return TileRunType.UNDEFINED
174  else:
175  return TileRunType.PHY
176 
177 
178 def _useDCS(prevFlags):
179  if not (prevFlags.Common.isOnline or prevFlags.Input.isMC):
180  runNumber = prevFlags.Input.RunNumbers[0]
181  # Use Tile DCS only for 2011 data and later, excluding shutdown period
182  return (runNumber > 171194 and runNumber < 222222) or runNumber > 232498
183  else:
184  return False
185 
186 
187 def _getRawChannelContainer(prevFlags):
188 
189  rawChannelContainer = 'UNDEFINED'
190 
191  if prevFlags.Tile.doQIE:
192  rawChannelContainer = 'TileRawChannelQIE'
193  if prevFlags.Tile.doManyAmps:
194  rawChannelContainer = 'TileRawChannelManyAmp'
195  if prevFlags.Tile.doFlat:
196  rawChannelContainer = 'TileRawChannelFlat'
197  if prevFlags.Tile.doFit:
198  rawChannelContainer = 'TileRawChannelFit'
199  if prevFlags.Tile.doFitCOOL:
200  rawChannelContainer = 'TileRawChannelFitCool'
201  if prevFlags.Tile.doMF:
202  rawChannelContainer = 'TileRawChannelMF'
203  if prevFlags.Tile.doOF1:
204  rawChannelContainer = 'TileRawChannelOF1'
205  if prevFlags.Tile.doWiener:
206  rawChannelContainer = 'TileRawChannelWiener'
207  if prevFlags.Tile.doOpt2:
208  rawChannelContainer = 'TileRawChannelOpt2'
209  if prevFlags.Tile.doOptATLAS:
210  if not (prevFlags.Input.isMC or prevFlags.Overlay.DataOverlay) and prevFlags.Input.Format is Format.BS:
211  rawChannelContainer = 'TileRawChannelFixed'
212  else:
213  rawChannelContainer = 'TileRawChannelCnt'
214 
215  return rawChannelContainer
216 
217 
218 if __name__=="__main__":
219  import sys
220  from AthenaConfiguration.AllConfigFlags import initConfigFlags
221  from AthenaConfiguration.TestDefaults import defaultTestFiles
222  flags = initConfigFlags()
223  flags.Input.Files = defaultTestFiles.RAW_RUN2
224 
225  if len(sys.argv) > 1:
226  flags.fillFromArgs()
227 
228  flags.lock()
229 
230  flags.needFlagsCategory('Tile')
231  flags.initAll()
232  flags.dump()
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True, maxLevel='peeker')
Definition: AutoConfigFlags.py:65
python.TileConfigFlags.TileRunType.getCommonType
def getCommonType(self)
Definition: TileConfigFlags.py:19
python.TileConfigFlags._doExtraMethods
def _doExtraMethods(prevFlags)
Definition: TileConfigFlags.py:107
python.TileConfigFlags._getRawChannelContainer
def _getRawChannelContainer(prevFlags)
Definition: TileConfigFlags.py:187
python.TileConfigFlags._correctTimeJumps
def _correctTimeJumps(prevFlags)
Definition: TileConfigFlags.py:162
python.TileConfigFlags._useDCS
def _useDCS(prevFlags)
Definition: TileConfigFlags.py:178
python.TileConfigFlags.TileRunType.getIntValue
def getIntValue(self)
Definition: TileConfigFlags.py:35
python.TileConfigFlags.TileRunType
Definition: TileConfigFlags.py:7
python.TileConfigFlags.TileRunType.getTimingType
def getTimingType(self)
Definition: TileConfigFlags.py:29
python.TileConfigFlags.createTileConfigFlags
def createTileConfigFlags()
Definition: TileConfigFlags.py:47
python.TileConfigFlags._zeroAmplitudeWithoutDigits
def _zeroAmplitudeWithoutDigits(prevFlags)
Definition: TileConfigFlags.py:146
python.TileConfigFlags._correctPedestalDifference
def _correctPedestalDifference(prevFlags)
Definition: TileConfigFlags.py:155
python.TileConfigFlags._doOpt2
def _doOpt2(prevFlags)
Definition: TileConfigFlags.py:116
python.TileConfigFlags._getRunType
def _getRunType(prevFlags)
Definition: TileConfigFlags.py:169
python.TileConfigFlags._doOpt2ByDefault
def _doOpt2ByDefault(prevFlags)
Definition: TileConfigFlags.py:86
python.TileConfigFlags.TileRunType.isBiGain
def isBiGain(self)
Definition: TileConfigFlags.py:43
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.TileConfigFlags._doOptATLAS
def _doOptATLAS(prevFlags)
Definition: TileConfigFlags.py:131