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