ATLAS Offline Software
Loading...
Searching...
No Matches
TileConfigFlags.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.AthConfigFlags import AthConfigFlags
4from AthenaConfiguration.Enums import BeamType, Format, FlagEnum
5
6
7class 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.doTileNN', False)
62 tcf.addFlag('Tile.NoiseFilter', lambda prevFlags : -1 if prevFlags.Input.isMC else 1)
63 tcf.addFlag('Tile.RunType', _getRunType, type=TileRunType)
64 tcf.addFlag('Tile.correctTime', lambda prevFlags : not prevFlags.Input.isMC and not prevFlags.Overlay.DataOverlay and prevFlags.Beam.Type is BeamType.Collisions)
65 tcf.addFlag('Tile.correctTimeNI', True)
66 tcf.addFlag('Tile.correctAmplitude', True)
67 tcf.addFlag('Tile.AmpMinForAmpCorrection', 15.0)
68 tcf.addFlag('Tile.TimeMinForAmpCorrection', lambda prevFlags : (prevFlags.Beam.BunchSpacing / -2.))
69 tcf.addFlag('Tile.TimeMaxForAmpCorrection', lambda prevFlags : (prevFlags.Beam.BunchSpacing / 2.))
70 tcf.addFlag('Tile.OfcFromCOOL', True)
71 tcf.addFlag('Tile.BestPhaseFromCOOL', lambda prevFlags : not prevFlags.Input.isMC and not prevFlags.Overlay.DataOverlay and prevFlags.Beam.Type is BeamType.Collisions)
72 tcf.addFlag('Tile.readDigits', lambda prevFlags : not prevFlags.Input.isMC)
73 tcf.addFlag('Tile.doOverflowFit', True)
74 tcf.addFlag('Tile.zeroAmplitudeWithoutDigits', _zeroAmplitudeWithoutDigits)
75 tcf.addFlag('Tile.correctPedestalDifference', _correctPedestalDifference)
76 tcf.addFlag('Tile.correctTimeJumps', _correctTimeJumps)
77 tcf.addFlag('Tile.RawChannelContainer', _getRawChannelContainer)
78 tcf.addFlag('Tile.useDCS', _useDCS)
79 tcf.addFlag('Tile.doTimingHistogramsForGain', -1) # Production of Tile timing histograms per channel (< 0: switched off)
80 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)
81 tcf.addFlag('Tile.useOnlineChannelStatus', True) # Use online DB with channel/adc status
82
83 def __tilesim():
84 from TileConfiguration.TileSimConfigFlags import createTileSimConfigFlags
85 return createTileSimConfigFlags()
86 tcf.addFlagsCategory('Tile.Sim', __tilesim, prefix=True)
87
88 return tcf
89
90
91
92def _doOpt2ByDefault(prevFlags):
93 #For online operation don't check run number
94 if prevFlags.Common.isOnline:
95 if prevFlags.Beam.Type is BeamType.Collisions:
96 return False # Use OF without iterations for collisions
97 else:
98 return True
99
100 runNumber = prevFlags.Input.RunNumbers[0]
101 # Run Optimal Filter with iterations (Opt2) by default,
102 # both for cosmics and collisions data before 2011
103 if not prevFlags.Input.isMC and runNumber > 0 and runNumber < 171194:
104 return True
105 # Run Optimal Filter without iterations (OptATLAS)
106 # for collisions (data in 2011 and later and MC)
107 elif prevFlags.Beam.Type is BeamType.Collisions:
108 return False # Use OF without iterations for collisions
109 else:
110 return True
111
112
113def _doExtraMethods(prevFlags):
114 # Check if any Optimal Filter, but Opt2 and OptATLAS, is already scheduled
115 if (prevFlags.Tile.doQIE or prevFlags.Tile.doManyAmps or prevFlags.Tile.doFlat
116 or prevFlags.Tile.doFit or prevFlags.Tile.doFitCOOL or prevFlags.Tile.doMF
117 or prevFlags.Tile.doOF1 or prevFlags.Tile.doWiener):
118 return True
119 else:
120 return False
121
122def _doOpt2(prevFlags):
123 # Do not run Opt2 method if any Optimal Filter is already scheduled
124 if _doExtraMethods(prevFlags) :
125 return False
126 # If no extra Optimal Filters are scheduled yet check if Opt2 should be used by default
127 else:
128 if _doOpt2ByDefault(prevFlags):
129 _flags = prevFlags.clone()
130 _flags.Tile.doOpt2 = True
131 # Opt2 should be run by default, but check if OptATLAS is already scheduled
132 return not _flags.Tile.doOptATLAS
133 else:
134 return False
135
136
137def _doOptATLAS(prevFlags):
138 # Do not run OptATLAS method if any Optimal Filter is alredy scheduled
139 if _doExtraMethods(prevFlags) :
140 return False
141 # If no Optimal Filters are scheduled yet check if OptATLAS should be used by default
142 else:
143 if not _doOpt2ByDefault(prevFlags):
144 # OptATLAS should be run by default, but check if Opt2 is already scheduled
145 _flags = prevFlags.clone()
146 _flags.Tile.doOptATLAS = True
147 return not _flags.Tile.doOpt2
148 else:
149 return False
150
151
153 if not prevFlags.Input.isMC:
154 runNumber = prevFlags.Input.RunNumbers[0]
155 # Use OF1 corrections only for years 2015 - 2016
156 return runNumber > 269101 and runNumber < 324320
157 else:
158 return False
159
160
162 if not prevFlags.Common.isOnline:
163 return _zeroAmplitudeWithoutDigits(prevFlags)
164 else:
165 return False
166
167
168def _correctTimeJumps(prevFlags):
169 if not (prevFlags.Input.isMC or prevFlags.Overlay.DataOverlay) and prevFlags.Input.Format is Format.BS:
170 return True
171 else:
172 return False
173
174
175def _getRunType(prevFlags):
176 # Tile run types: UNDEFINED, PHY, PED, LAS, BILAS, CIS, MONOCIS
177 from AthenaConfiguration.AutoConfigFlags import GetFileMD
178 if not prevFlags.Input.isMC and 'calibration_Tile' in GetFileMD(prevFlags.Input.Files).get('triggerStreamOfFile', ''):
179 return TileRunType.UNDEFINED
180 else:
181 return TileRunType.PHY
182
183
184def _useDCS(prevFlags):
185 if not (prevFlags.Common.isOnline or prevFlags.Input.isMC):
186 runNumber = prevFlags.Input.RunNumbers[0]
187 # Use Tile DCS only for 2011 data and later, excluding shutdown period
188 return (runNumber > 171194 and runNumber < 222222) or runNumber > 232498
189 else:
190 return False
191
192
194
195 rawChannelContainer = 'UNDEFINED'
196
197 if prevFlags.Tile.doQIE:
198 rawChannelContainer = 'TileRawChannelQIE'
199 if prevFlags.Tile.doManyAmps:
200 rawChannelContainer = 'TileRawChannelManyAmp'
201 if prevFlags.Tile.doFlat:
202 rawChannelContainer = 'TileRawChannelFlat'
203 if prevFlags.Tile.doFit:
204 rawChannelContainer = 'TileRawChannelFit'
205 if prevFlags.Tile.doFitCOOL:
206 rawChannelContainer = 'TileRawChannelFitCool'
207 if prevFlags.Tile.doMF:
208 rawChannelContainer = 'TileRawChannelMF'
209 if prevFlags.Tile.doOF1:
210 rawChannelContainer = 'TileRawChannelOF1'
211 if prevFlags.Tile.doWiener:
212 rawChannelContainer = 'TileRawChannelWiener'
213 if prevFlags.Tile.doOpt2:
214 rawChannelContainer = 'TileRawChannelOpt2'
215 if prevFlags.Tile.doOptATLAS:
216 rawChannelContainer = getRawChannelContainerOptATLAS(prevFlags)
217
218 return rawChannelContainer
219
220
222 if not flags.Overlay.DataOverlay and flags.Input.Files and flags.Input.Format is Format.BS:
223 return 'TileRawChannelFixed'
224 else:
225 return 'TileRawChannelCnt'
226
227
228if __name__=="__main__":
229 import sys
230 from AthenaConfiguration.AllConfigFlags import initConfigFlags
231 from AthenaConfiguration.TestDefaults import defaultTestFiles
232 flags = initConfigFlags()
233 flags.Input.Files = defaultTestFiles.RAW_RUN2
234
235 if len(sys.argv) > 1:
236 flags.fillFromArgs()
237
238 flags.lock()
239
240 flags.needFlagsCategory('Tile')
241 flags.initAll()
242 flags.dump()
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132
_zeroAmplitudeWithoutDigits(prevFlags)
_correctPedestalDifference(prevFlags)