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.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 not prevFlags.Overlay.DataOverlay 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 not prevFlags.Overlay.DataOverlay 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 def __tilesim():
83 from TileConfiguration.TileSimConfigFlags import createTileSimConfigFlags
84 return createTileSimConfigFlags()
85 tcf.addFlagsCategory('Tile.Sim', __tilesim, prefix=True)
86
87 return tcf
88
89
90
91def _doOpt2ByDefault(prevFlags):
92 #For online operation don't check run number
93 if prevFlags.Common.isOnline:
94 if prevFlags.Beam.Type is BeamType.Collisions:
95 return False # Use OF without iterations for collisions
96 else:
97 return True
98
99 runNumber = prevFlags.Input.RunNumbers[0]
100 # Run Optimal Filter with iterations (Opt2) by default,
101 # both for cosmics and collisions data before 2011
102 if not prevFlags.Input.isMC and runNumber > 0 and runNumber < 171194:
103 return True
104 # Run Optimal Filter without iterations (OptATLAS)
105 # for collisions (data in 2011 and later and MC)
106 elif prevFlags.Beam.Type is BeamType.Collisions:
107 return False # Use OF without iterations for collisions
108 else:
109 return True
110
111
112def _doExtraMethods(prevFlags):
113 # Check if any Optimal Filter, but Opt2 and OptATLAS, is already scheduled
114 if (prevFlags.Tile.doQIE or prevFlags.Tile.doManyAmps or prevFlags.Tile.doFlat
115 or prevFlags.Tile.doFit or prevFlags.Tile.doFitCOOL or prevFlags.Tile.doMF
116 or prevFlags.Tile.doOF1 or prevFlags.Tile.doWiener):
117 return True
118 else:
119 return False
120
121def _doOpt2(prevFlags):
122 # Do not run Opt2 method if any Optimal Filter is already scheduled
123 if _doExtraMethods(prevFlags) :
124 return False
125 # If no extra Optimal Filters are scheduled yet check if Opt2 should be used by default
126 else:
127 if _doOpt2ByDefault(prevFlags):
128 _flags = prevFlags.clone()
129 _flags.Tile.doOpt2 = True
130 # Opt2 should be run by default, but check if OptATLAS is already scheduled
131 return not _flags.Tile.doOptATLAS
132 else:
133 return False
134
135
136def _doOptATLAS(prevFlags):
137 # Do not run OptATLAS method if any Optimal Filter is alredy scheduled
138 if _doExtraMethods(prevFlags) :
139 return False
140 # If no Optimal Filters are scheduled yet check if OptATLAS should be used by default
141 else:
142 if not _doOpt2ByDefault(prevFlags):
143 # OptATLAS should be run by default, but check if Opt2 is already scheduled
144 _flags = prevFlags.clone()
145 _flags.Tile.doOptATLAS = True
146 return not _flags.Tile.doOpt2
147 else:
148 return False
149
150
152 if not prevFlags.Input.isMC:
153 runNumber = prevFlags.Input.RunNumbers[0]
154 # Use OF1 corrections only for years 2015 - 2016
155 return runNumber > 269101 and runNumber < 324320
156 else:
157 return False
158
159
161 if not prevFlags.Common.isOnline:
162 return _zeroAmplitudeWithoutDigits(prevFlags)
163 else:
164 return False
165
166
167def _correctTimeJumps(prevFlags):
168 if not (prevFlags.Input.isMC or prevFlags.Overlay.DataOverlay) and prevFlags.Input.Format is Format.BS:
169 return True
170 else:
171 return False
172
173
174def _getRunType(prevFlags):
175 # Tile run types: UNDEFINED, PHY, PED, LAS, BILAS, CIS, MONOCIS
176 from AthenaConfiguration.AutoConfigFlags import GetFileMD
177 if not prevFlags.Input.isMC and 'calibration_Tile' in GetFileMD(prevFlags.Input.Files).get('triggerStreamOfFile', ''):
178 return TileRunType.UNDEFINED
179 else:
180 return TileRunType.PHY
181
182
183def _useDCS(prevFlags):
184 if not (prevFlags.Common.isOnline or prevFlags.Input.isMC):
185 runNumber = prevFlags.Input.RunNumbers[0]
186 # Use Tile DCS only for 2011 data and later, excluding shutdown period
187 return (runNumber > 171194 and runNumber < 222222) or runNumber > 232498
188 else:
189 return False
190
191
193
194 rawChannelContainer = 'UNDEFINED'
195
196 if prevFlags.Tile.doQIE:
197 rawChannelContainer = 'TileRawChannelQIE'
198 if prevFlags.Tile.doManyAmps:
199 rawChannelContainer = 'TileRawChannelManyAmp'
200 if prevFlags.Tile.doFlat:
201 rawChannelContainer = 'TileRawChannelFlat'
202 if prevFlags.Tile.doFit:
203 rawChannelContainer = 'TileRawChannelFit'
204 if prevFlags.Tile.doFitCOOL:
205 rawChannelContainer = 'TileRawChannelFitCool'
206 if prevFlags.Tile.doMF:
207 rawChannelContainer = 'TileRawChannelMF'
208 if prevFlags.Tile.doOF1:
209 rawChannelContainer = 'TileRawChannelOF1'
210 if prevFlags.Tile.doWiener:
211 rawChannelContainer = 'TileRawChannelWiener'
212 if prevFlags.Tile.doOpt2:
213 rawChannelContainer = 'TileRawChannelOpt2'
214 if prevFlags.Tile.doOptATLAS:
215 rawChannelContainer = getRawChannelContainerOptATLAS(prevFlags)
216
217 return rawChannelContainer
218
219
221 if not (flags.Input.isMC or flags.Overlay.DataOverlay) and flags.Input.Format is Format.BS:
222 return 'TileRawChannelFixed'
223 else:
224 return 'TileRawChannelCnt'
225
226
227if __name__=="__main__":
228 import sys
229 from AthenaConfiguration.AllConfigFlags import initConfigFlags
230 from AthenaConfiguration.TestDefaults import defaultTestFiles
231 flags = initConfigFlags()
232 flags.Input.Files = defaultTestFiles.RAW_RUN2
233
234 if len(sys.argv) > 1:
235 flags.fillFromArgs()
236
237 flags.lock()
238
239 flags.needFlagsCategory('Tile')
240 flags.initAll()
241 flags.dump()
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
_correctPedestalDifference(prevFlags)
_zeroAmplitudeWithoutDigits(prevFlags)