ATLAS Offline Software
MuonConfigFlags.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.AthConfigFlags import AthConfigFlags
4 from AthenaConfiguration.Enums import BeamType, LHCPeriod, ProductionStep, Project, FlagEnum
5 
6 import 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 
13 # MuonByteStream
14 # - MuonByteStreamFlags.py - AFAICS this is only used here MuonCnv/MuonCnvExample/python/MuonCablingConfig.py & duplicates global flag functionality.
15 
16 # MuonRecExample
17 # - MuonAlignFlags.py - looks necessary
18 # - MuonStandaloneFlags.py - necessary, but should be cleaned up (and probably merged with MuonRecFlags i.e. here)
19 # https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonStandaloneFlags.py
20 # - MuonRecFlags.py - necessary, but needs cleaning up.
21 # https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonRecFlags.py
22 
23 
24 class MMClusterBuilderEnum(FlagEnum):
25  """Flag values for Muon.MMClusterCalibRecoTool"""
26  Centroid = "Centroid"
27  ClusterTimeProjection = "ClusterTimeProjection"
28 
29 def _muonAlignMode(flags):
30  # Small function that determines if the alignment flags should be true or false
31  # follows the logic in https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonAlignFlags.py
32  problematic_tags = ['COMCOND-HLT[A-C]-00[01]-00', 'COMCOND-ES1C-00[01]-00', 'COMCOND-REPC-001', 'COMCOND-SIM-01-00']
33  if any(re.match(tag,flags.IOVDb.DatabaseInstance) for tag in problematic_tags):
34  return False
35  elif flags.Input.isMC:
36  return False
37  else:
38  return True
39 
41  mcf=AthConfigFlags()
42 
43  # stages of processing
44  # 0. Geometry
45 
46 
47  from AthenaConfiguration.AutoConfigFlags import DetDescrInfo
48 
49  mcf.addFlag("Muon.usePhaseIIGeoSetup",lambda prevFlags : DetDescrInfo(prevFlags.GeoModel.AtlasVersion,
50  prevFlags.GeoModel.SQLiteDB ,
51  prevFlags.GeoModel.SQLiteDBFullPath)["Muon"]["useR4Plugin"] )
52  # 1. Digitization
53  mcf.addFlag("Muon.doDigitization",True)
54  # 2. Reco MuonRecFlags
55  mcf.addFlag("Muon.doTGCClusterSegmentFinding", False) # Run cluster segment finding
56  mcf.addFlag("Muon.doRPCClusterSegmentFinding", False) # Run cluster segment finding
57  mcf.addFlag("Muon.prdToxAOD", False) # Run clusterization
58  mcf.addFlag("Muon.rpcRawToxAOD", False) # Add RPC RDO to xAOD
59  mcf.addFlag("Muon.doMSVertex", True) # Run MS vertex (arXiv:1311.7070)
60  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.
61  mcf.addFlag("Muon.enableErrorTuning",True) # turn on error tuning to account for misalignments
62  mcf.addFlag("Muon.useLooseErrorTuning",False)
63  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.
64  mcf.addFlag("Muon.useAlignmentCorrections",True) # Apply alignment corrections to MuonGeoModel. The corrections are read from a COOL database
65  mcf.addFlag("Muon.useWireSagCorrections",False) # tApply wire sag corrections.
66 
67  mcf.addFlag("Muon.makePRDs",True) # Disable when e.g. re-running from ESD
68 
69  mcf.addFlag("Muon.enableNRPC",False) # To be enabled for NRPC processing. Disabled by default for backward compatibility
70 
71  # MuonStandaloneFlags.py
72  mcf.addFlag("Muon.printSummary", False) # Print out a summary for each event at each reco stage
73  mcf.addFlag("Muon.segmentOrigin", "Muon") # Can be 'Muon','TruthTracking'
74  # reconstructionMode - I think this is a complete duplication of global.BeamType. Dropping.
75  mcf.addFlag("Muon.strategy", []) # CutSeedsOnTracks, CombineSegInStation, DynamicSeeding, PreferOutsideIn, AllowOneSharedHit, DoRefinement, DoAmbiSolving
76  mcf.addFlag("Muon.trackBuilder", "Moore") # Allowed: 'Moore','TruthTracking','None'
77  mcf.addFlag("Muon.refinementTool", "Moore") # Allowed: Moore TODO surely we can drop this if there is only one option?
78  mcf.addFlag("Muon.patternsOnly", False) # TODO probably can be dropped? Just disable later steps.
79  mcf.addFlag("Muon.straightLineFitMomentum", 2000.0 )
80  #mcf.addFlag("Muon.doSegmentsOnly", True) # Also in MuonRecFlags ... redundant in both?
81  mcf.addFlag("Muon.Chi2NDofCut", 20.0 ) # chi-squared per degree of freedom cut in fitter.
82  mcf.addFlag("Muon.enableCurvedSegmentFinding", False ) # TODO I think this one could possibly be removed, since it really is a Tool level configuration.
83  mcf.addFlag("Muon.updateSegmentSecondCoordinate", lambda prevFlags : prevFlags.Beam.Type is BeamType.Collisions) # Do not use for cosmics or singlebeam
84 
85  mcf.addFlag("Muon.useSegmentMatching", lambda prevFlags : prevFlags.Beam.Type is BeamType.Collisions) # Do not use for cosmics or singlebeam
86  mcf.addFlag("Muon.useTrackSegmentMatching", True )
87  mcf.addFlag("Muon.runCommissioningChain", lambda prevFlags: ( False and (prevFlags.Detector.EnableMM or prevFlags.Detector.EnablesTGC) \
88  and prevFlags.Beam.Type is BeamType.Collisions) )
89 
90  mcf.addFlag("Muon.applyMMPassivation", lambda prevFlags: prevFlags.Detector.EnableMM and not prevFlags.Common.isOnline and (prevFlags.Common.Project is not Project.AthSimulation \
91  and (prevFlags.Common.ProductionStep not in [ProductionStep.Simulation, ProductionStep.FastChain] or prevFlags.Overlay.DataOverlay)))
92  # CalibFlags
93  mcf.addFlag("Muon.Calib.readMDTCalibFromBlob", True) # Read mdt tube calibration from blob-folders
94  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)
95  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)
96  mcf.addFlag("Muon.Calib.useMLRt", True) # use ML-RT functions from COOL
97  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
98  mcf.addFlag("Muon.Calib.correctMdtRtWireSag", False) # Apply RT wiresag correction
99  mcf.addFlag("Muon.Calib.mdtCalibrationSource", "MDT") # Source for MDT t0s and rts
100  mcf.addFlag("Muon.Calib.mdtPropagationSpeedBeta", lambda prevFlags : 1.0 if prevFlags.Input.isMC else 0.85) #
101 
102  mcf.addFlag("Muon.Calib.CscPedFromLocalFile", False)
103  mcf.addFlag("Muon.Calib.CscNoiseFromLocalFile", False)
104  mcf.addFlag("Muon.Calib.CscPSlopeFromLocalFile", False)
105  mcf.addFlag("Muon.Calib.CscStatusFromLocalFile", False)
106  mcf.addFlag("Muon.Calib.CscRmsFromLocalFile", False)
107  mcf.addFlag("Muon.Calib.CscF001FromLocalFile", False)
108  mcf.addFlag("Muon.Calib.CscT0BaseFromLocalFile", False)
109  mcf.addFlag("Muon.Calib.CscT0PhaseFromLocalFile", False)
110 
111  mcf.addFlag("Muon.Calib.EventTag", "MoMu")
112 
113  # Choose the (MDT) calibration mode.
114  # 'ntuple' : write standard calibration ntuple (up to segments)
115  # 'trackNtuple' : write standard ntuple + tracks
116  # 'regionNtuple' : write one ntuple per calibration region
117  # 't0Classic' : do classic t0 calibration
118  # 't0MT' : do MT t0 calibration
119  # 'rtClassic' : do classic rt calibration
120  # 'rtAnalytic' : do analytic rt calibration
121  mcf.addFlag("Muon.Calib.mdtMode", "ntuple")
122 
123  # 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
124  # do not apply NSW T0 calibration if we are running online or MC or a RUN4 geometry
125  mcf.addFlag("Muon.Calib.applyMmT0Correction", lambda prevFlags: prevFlags.GeoModel.Run<LHCPeriod.Run4 and not prevFlags.Common.isOnline and not prevFlags.Input.isMC and False)
126  mcf.addFlag("Muon.Calib.applysTgcT0Correction", lambda prevFlags: prevFlags.GeoModel.Run<LHCPeriod.Run4 and not prevFlags.Common.isOnline and not prevFlags.Input.isMC and False)
127  mcf.addFlag("Muon.Calib.applyMmBFieldCalib", True)
128 
129  # Muon Align flags
130 
131  mcf.addFlag("Muon.Align.UseALines", lambda prevFlags: (_muonAlignMode(prevFlags)))
132  mcf.addFlag("Muon.Align.UseBLines", lambda prevFlags: 'all' if _muonAlignMode(prevFlags) else 'none') # Can be ['none','all','barrel','endcaps']
133  mcf.addFlag("Muon.Align.UseILines", lambda prevFlags: (_muonAlignMode(prevFlags)))
134  mcf.addFlag("Muon.Align.UseAsBuilt", lambda prevFlags: (_muonAlignMode(prevFlags)))
135 
136  # Muon Trigger Flags
137  mcf.addFlag("Muon.MuonTrigger", False)
138  mcf.addFlag("Muon.SAMuonTrigger", False)
139  mcf.addFlag("Muon.disableNSWForL2SA", False)
140 
141  mcf.addFlag("Muon.enableAlignment",lambda flags: (flags.Common.Project is not Project.AthSimulation \
142  and (flags.Common.ProductionStep not in [ProductionStep.Simulation, ProductionStep.FastChain] or flags.Overlay.DataOverlay)))
143  mcf.addFlag("Muon.enableTrigIDtrackReuse", False)
144  # configuration of the DESDM_MCP output format
145 
146  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.
147 
148  # configuration to write out RPC RDO for trigger timing calibration
149  mcf.addFlag("Muon.doWriteRpcRDO", True)
150 
151  mcf.addFlag("Muon.writeSDOs", lambda prevFlags : prevFlags.Output.doWriteESD and prevFlags.Input.isMC)
152 
153  # configure the MM cluster reco method that is used in the cluster calibration step
154  mcf.addFlag("Muon.MMClusterCalibRecoTool", lambda prevFlags : MMClusterBuilderEnum.ClusterTimeProjection if prevFlags.Input.isMC else MMClusterBuilderEnum.Centroid, type=MMClusterBuilderEnum)
155 
156  mcf.addFlag("Muon.writexAODPRD", False) # Output new xAOD format from convertors (to be removed once the old format is deprecated)
157 
158 
159 
160 
161 
162  # TODO - add configuration for above
163 
164  return mcf
165 
python.MuonConfigFlags.createMuonConfigFlags
def createMuonConfigFlags()
Definition: MuonConfigFlags.py:40
python.MuonConfigFlags.MMClusterBuilderEnum
Definition: MuonConfigFlags.py:24
python.AutoConfigFlags.DetDescrInfo
def DetDescrInfo(geoTag, sqliteDB, sqliteDBFullPath)
Definition: AutoConfigFlags.py:117
python.MuonConfigFlags._muonAlignMode
def _muonAlignMode(flags)
Definition: MuonConfigFlags.py:29