ATLAS Offline Software
Loading...
Searching...
No Matches
MuonConfigFlags.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, LHCPeriod, ProductionStep, Project, FlagEnum
5
6import re
7
8# Some comments from Ed about existing flags
9# MuonCnvExample
10# - MuonCnvFlags - not sure we need this - it really only configures single properties of the various cablings - we can just do this directly.
11# - MuonCalibFlags - looks like we need this
12
13class GeoTrfCacheMode(FlagEnum):
14
16 SlopyCache = 1
17
21 ActsSlopyALineCond = 2
22
24 SplitCache = 3
25
28 ActsSplitALineCond = 4
29
30 FullCacheCond = 5
31
32class MMClusterBuilderEnum(FlagEnum):
33 """Flag values for Muon.MMClusterCalibRecoTool"""
34 Centroid = "Centroid"
35 ClusterTimeProjection = "ClusterTimeProjection"
36
37def _muonAlignMode(flags):
38 # Small function that determines if the alignment flags should be true or false
39 # follows the logic in https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonAlignFlags.py
40 problematic_tags = ['COMCOND-HLT[A-C]-00[01]-00', 'COMCOND-ES1C-00[01]-00', 'COMCOND-REPC-001', 'COMCOND-SIM-01-00']
41 if any(re.match(tag,flags.IOVDb.DatabaseInstance) for tag in problematic_tags):
42 return False
43 elif flags.Input.isMC or not flags.Muon.enableAlignment:
44 return False
45 else:
46 return True
47
49 mcf=AthConfigFlags()
50
51 # stages of processing
52 # 0. Geometry
53
54
55 from AthenaConfiguration.AutoConfigFlags import DetDescrInfo
56
57 mcf.addFlag("Muon.usePhaseIIGeoSetup",lambda prevFlags : prevFlags.Detector.GeometryMuon and
58 DetDescrInfo(prevFlags.GeoModel.AtlasVersion,
59 prevFlags.GeoModel.SQLiteDB ,
60 prevFlags.GeoModel.SQLiteDBFullPath)["Muon"]["useR4Plugin"] )
61
62 mcf.addFlag("Muon.AlignedGeoTrfCacheMode", GeoTrfCacheMode.FullCacheCond, type = GeoTrfCacheMode)
63
64
66 mcf.addFlag("Muon.trackGeometryActiveMaterial", True)
67
69 mcf.addFlag("Muon.trackGeometryPassiveMaterial", lambda prevFlags: prevFlags.Muon.usePhaseIIGeoSetup and \
70 len(prevFlags.Muon.trackGeometryMaterialMap) > 0)
71
72 mcf.addFlag("Muon.trackGeometryMaterialMap", "")
73 # 1. Digitization
74 mcf.addFlag("Muon.doFastMMDigitization", False)
75 mcf.addFlag("Muon.doFastsTGCDigitization",True)
76 mcf.addFlag("Muon.doFastRpcDigitization",False)
78 mcf.addFlag("Muon.setupTruthAlgorithms", lambda prevFlags: prevFlags.Muon.usePhaseIIGeoSetup and \
79 prevFlags.Input.isMC and \
80 not prevFlags.Trigger.doHLT)
81
82
83 # 2. Reco MuonRecFlags
84
85
87 try:
88 from TrkConfig.TrkConfigFlags import TrackingComponent
89 mcf.addFlag("Muon.scheduleActsReco", lambda prevFlags: prevFlags.Muon.usePhaseIIGeoSetup and \
90 prevFlags.Tracking.recoChain[0] in [TrackingComponent.ActsChain , TrackingComponent.ActsLegacyChain ])
91 except ImportError:
92 mcf.addFlag("Muon.scheduleActsReco", False)
93
94 try:
95 from ActsConfig.ActsConfigFlags import TrackFitterType
96 mcf.addFlag("Muon.TrackFitterType", TrackFitterType.GlobalChiSquareFitter)
97 except ImportError:
98 mcf.addFlag("Muon.TrackFitterType", "None")
99
100
102 mcf.addFlag("Muon.includePileUpTruth", False)
103
104 mcf.addFlag("Muon.enableMLBucketFilter", False)
105
107 mcf.addFlag("Muon.expressMsTrackAtEntrance", False)
108
112 mcf.addFlag("Muon.buildMETrack", lambda prevFlags: prevFlags.Reco.EnableTracking and\
113 not prevFlags.Muon.MuonTrigger )
114
115 mcf.addFlag("Muon.doMSVertex", True) # Run MS vertex (arXiv:1311.7070)
116 mcf.addFlag("Muon.doSegmentT0Fit",lambda prevFlags : prevFlags.Beam.Type is not BeamType.Collisions) # Fit MDT segments using a variable t0. Used for cosmics and single beam to compensate for large errors on the trigger time.
117 mcf.addFlag("Muon.enableErrorTuning",True) # turn on error tuning to account for misalignments
118 mcf.addFlag("Muon.useLooseErrorTuning",False)
119 mcf.addFlag("Muon.useTGCPriorNextBC",False) # Use TGC measurements from Prior and Next Bunch Crossings. These measurements are available in the real data since somewhere in 2008.
120 mcf.addFlag("Muon.useAlignmentCorrections",True) # Apply alignment corrections to MuonGeoModel. The corrections are read from a COOL database
121
122 mcf.addFlag("Muon.makePRDs",True) # Disable when e.g. re-running from ESD
123
124 mcf.addFlag("Muon.enableNRPC", lambda prevFlags: prevFlags.Detector.GeometryRPC and \
125 prevFlags.Muon.usePhaseIIGeoSetup )
126 # MuonStandaloneFlags.py
127 mcf.addFlag("Muon.printSummary", False) # Print out a summary for each event at each reco stage
128 mcf.addFlag("Muon.segmentOrigin", "Muon") # Can be 'Muon','TruthTracking'
129 # reconstructionMode - I think this is a complete duplication of global.BeamType. Dropping.
130 mcf.addFlag("Muon.strategy", []) # CutSeedsOnTracks, CombineSegInStation, DynamicSeeding, PreferOutsideIn, AllowOneSharedHit, DoRefinement, DoAmbiSolving
131 mcf.addFlag("Muon.straightLineFitMomentum", 2000.0 )
132 #mcf.addFlag("Muon.doSegmentsOnly", True) # Also in MuonRecFlags ... redundant in both?
133 mcf.addFlag("Muon.Chi2NDofCut", 20.0 ) # chi-squared per degree of freedom cut in fitter.
134 mcf.addFlag("Muon.enableCurvedSegmentFinding", False ) # TODO I think this one could possibly be removed, since it really is a Tool level configuration.
135 mcf.addFlag("Muon.updateSegmentSecondCoordinate", lambda prevFlags : prevFlags.Beam.Type is BeamType.Collisions) # Do not use for cosmics or singlebeam
136
137 mcf.addFlag("Muon.useSegmentMatching", lambda prevFlags : prevFlags.Beam.Type is BeamType.Collisions) # Do not use for cosmics or singlebeam
138 mcf.addFlag("Muon.useTrackSegmentMatching", True )
139 mcf.addFlag("Muon.runCommissioningChain", lambda prevFlags: ( False and (prevFlags.Detector.EnableMM or prevFlags.Detector.EnablesTGC) \
140 and prevFlags.Beam.Type is BeamType.Collisions) )
141
142 mcf.addFlag("Muon.applyMMPassivation", lambda prevFlags: prevFlags.Detector.EnableMM and not prevFlags.Common.isOnline and (prevFlags.Common.Project is not Project.AthSimulation \
143 and (prevFlags.Common.ProductionStep not in [ProductionStep.Simulation, ProductionStep.FastChain] or prevFlags.Overlay.DataOverlay)))
144 # CalibFlags
145 mcf.addFlag("Muon.Calib.readMdtJSON", lambda prevFlags: prevFlags.GeoModel.Run > LHCPeriod.Run3 and prevFlags.Muon.usePhaseIIGeoSetup) # Toggle whether the calibration constants are read from the JSON format. Enabled by default for a Run4 geometry read by the muon phase II geometry setup
146 mcf.addFlag("Muon.Calib.fitAnalyticRt", False) #Toggle whether the look-up R-t tables shall undergo an intermediate polynomial fit
147
148 mcf.addFlag("Muon.Calib.readMDTCalibFromBlob", True) # Read mdt tube calibration from blob-folders
149 mcf.addFlag("Muon.Calib.correctMdtRtForBField", lambda prevFlags : (prevFlags.Input.isMC is False and prevFlags.Beam.Type is BeamType.Collisions)) # Apply B-field correction to drift times only for collision data (as done in https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py#0028)
150 mcf.addFlag("Muon.Calib.correctMdtRtForTimeSlewing", lambda prevFlags : prevFlags.Input.isMC is False) # Apply time slewing correction to drift time only for data (as done in https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py#0028)
151
152 mcf.addFlag("Muon.Calib.applySigPropUncert", lambda prevFlags: prevFlags.Muon.usePhaseIIGeoSetup )
153 mcf.addFlag("Muon.Calib.useMLRt", True) # use ML-RT functions from COOL
154 mcf.addFlag("Muon.Calib.applyRtScaling", False) # TODO - apparently not needed, but currently used in MuonCalibConfig. Set false to match https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py#0072
155 mcf.addFlag("Muon.Calib.mdtCalibrationSource", "MDT") # Source for MDT t0s and rts
156 mcf.addFlag("Muon.Calib.mdtPropagationSpeedBeta", lambda prevFlags : 1.0 if prevFlags.Input.isMC else 0.85) #
157
158 mcf.addFlag("Muon.Calib.CscPedFromLocalFile", False)
159 mcf.addFlag("Muon.Calib.CscNoiseFromLocalFile", False)
160 mcf.addFlag("Muon.Calib.CscPSlopeFromLocalFile", False)
161 mcf.addFlag("Muon.Calib.CscStatusFromLocalFile", False)
162 mcf.addFlag("Muon.Calib.CscRmsFromLocalFile", False)
163 mcf.addFlag("Muon.Calib.CscF001FromLocalFile", False)
164 mcf.addFlag("Muon.Calib.CscT0BaseFromLocalFile", False)
165 mcf.addFlag("Muon.Calib.CscT0PhaseFromLocalFile", False)
166
167 mcf.addFlag("Muon.Calib.EventTag", "MoMu")
168
169 # Choose the (MDT) calibration mode.
170 # 'ntuple' : write standard calibration ntuple (up to segments)
171 # 'trackNtuple' : write standard ntuple + tracks
172 # 'regionNtuple' : write one ntuple per calibration region
173 # 't0Classic' : do classic t0 calibration
174 # 't0MT' : do MT t0 calibration
175 # 'rtClassic' : do classic rt calibration
176 # 'rtAnalytic' : do analytic rt calibration
177 mcf.addFlag("Muon.Calib.mdtMode", "ntuple")
178
179
180 # for now the T0 calibration in the NSW should be disabled by default until a final calibration is available. Introducing the flags anyhow to allow for studies of the calibration
181 # do not apply NSW T0 calibration if we are running online or MC or a RUN4 geometry, keep only for 23 or 24
182 mcf.addFlag("Muon.Calib.applyMmT0Correction", lambda prevFlags: prevFlags.GeoModel.Run==LHCPeriod.Run3 and prevFlags.Input.DataYear != 2022 and not prevFlags.Common.isOnline and not prevFlags.Input.isMC )
183 mcf.addFlag("Muon.Calib.applysTgcT0Correction", lambda prevFlags: prevFlags.GeoModel.Run<LHCPeriod.Run4 and not prevFlags.Common.isOnline and not prevFlags.Input.isMC and False)
184 mcf.addFlag("Muon.Calib.applyMmBFieldCalib", True)
185
186 # Muon Align flags
187
188 mcf.addFlag("Muon.Align.UseALines", lambda prevFlags: (_muonAlignMode(prevFlags)))
189 mcf.addFlag("Muon.Align.UseBLines", lambda prevFlags: prevFlags.Muon.Align.UseALines)
190 mcf.addFlag("Muon.Align.UseILines", lambda prevFlags: (_muonAlignMode(prevFlags)) and \
191 prevFlags.Detector.GeometryCSC and 'HLT' not in prevFlags.IOVDb.GlobalTag)
192 mcf.addFlag("Muon.Align.UseAsBuilt", lambda prevFlags: (_muonAlignMode(prevFlags)) and not \
193 (prevFlags.IOVDb.DatabaseInstance == 'COMP200' or \
194 'HLT' in prevFlags.IOVDb.GlobalTag or prevFlags.Common.isOnline) )
195 mcf.addFlag("Muon.Align.UsesTGCAsBuild", lambda prevFlags: (_muonAlignMode(prevFlags)) and not prevFlags.Common.isOnline and prevFlags.GeoModel.Run == LHCPeriod.Run3)
196
197 # Muon Trigger Flags
198 mcf.addFlag("Muon.MuonTrigger", False)
199 mcf.addFlag("Muon.SAMuonTrigger", False)
200 mcf.addFlag("Muon.disableNSWForL2SA", True)
201
202 mcf.addFlag("Muon.enableAlignment",lambda flags: (flags.Common.Project is not Project.AthSimulation \
203 and not (flags.Common.ProductionStep in [ProductionStep.Simulation, ProductionStep.FastChain] or flags.Overlay.DataOverlay)))
204 mcf.addFlag("Muon.enableTrigIDtrackReuse", False)
205 # configuration of the DESDM_MCP output format
206
207 mcf.addFlag("Muon.DESDM_MCP.doAlignmentFormat", False) # Flag to stear the DESDM_MCP format which switches to a looser event selection for toroid off runs used for alignment.
208 mcf.addFlag("Muon.DESDM_MCP.doExtendedAlignmentContent", False) # Flag to enable electron, photon and jet containers in DESDM_MCP for dedicate studies of the toroid off data.
209
210 # configuration to write out RPC RDO for trigger timing calibration
211 mcf.addFlag("Muon.doWriteRpcRDO", True)
212
213 mcf.addFlag("Muon.writeSDOs", lambda prevFlags : prevFlags.Output.doWriteESD and prevFlags.Input.isMC)
214
215 # configure the MM cluster reco method that is used in the cluster calibration step
216 #Use charge weighted only for trigger and 2022 where not sure if the t0 calibrations that we have are ok dor the commissioning phase of the NSW in 2022
217 mcf.addFlag("Muon.MMClusterCalibRecoTool", lambda prevFlags: MMClusterBuilderEnum.Centroid if (prevFlags.Common.isOnline or prevFlags.Input.DataYear == 2022 or prevFlags.Beam.Type is not BeamType.Collisions) else MMClusterBuilderEnum.ClusterTimeProjection, type=MMClusterBuilderEnum)
218
219 mcf.addFlag("Muon.writexAODPRD", lambda prevFlags: prevFlags.Muon.usePhaseIIGeoSetup) # Output new xAOD format from convertors (to be removed once the old format is deprecated)
220 # use the MDT DCS data to determine if a chamber is alive or not. This is used in the hole search and the region selector. Needs to be false if the job is running online or is the reconstruction of the MDT calib stream
221 mcf.addFlag("Muon.useMdtDcsData", lambda prevFlags : not prevFlags.Common.isOnline and prevFlags.Detector.GeometryMDT)
222
223
224 # TODO - add configuration for above
225
226 return mcf
227