ATLAS Offline Software
Loading...
Searching...
No Matches
python.MuonAnalysisConfig.MuonMomentumCalibrationConfig Class Reference
Inheritance diagram for python.MuonAnalysisConfig.MuonMomentumCalibrationConfig:
Collaboration diagram for python.MuonAnalysisConfig.MuonMomentumCalibrationConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeAlgs (self, config)

Public Attributes

str calibMode = 'correctData_CB':
 inputContainer
 containerName
 addGlobalFELinksDep
 useZeroPixMuons
 recalibratePhyslite

Detailed Description

the ConfigBlock for the muon four-momentum correction

Definition at line 15 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.__init__ ( self)

Definition at line 18 of file MuonAnalysisConfig.py.

18 def __init__ (self) :
19 super (MuonMomentumCalibrationConfig, self).__init__ ()
20 self.setBlockName('Muons')
21 self.addOption ('inputContainer', '', type=str,
22 info="the name of the input muon container. If left empty, automatically defaults "
23 "to `AnalysisMuons` for PHYSLITE or `Muons` otherwise.")
24 self.addOption ('containerName', '', type=str,
25 noneAction='error',
26 info="the name of the output container after calibration.",
27 meta={'role':'container'})
28 self.addOption ('postfix', "", type=str,
29 info="a postfix to apply to decorations and algorithm names. "
30 "Typically not needed here since the calibration is common to "
31 "all muons.")
32 self.addOption ('minPt', 3.0*GeV, type=float,
33 info=r"$p_\mathrm{T}$ cut (in MeV) to apply to calibrated muons.")
34 self.addOption ('recalibratePhyslite', True, type=bool,
35 info="whether to run the `CP::MuonCalibrationAndSmearingAlg` on "
36 "PHYSLITE derivations.")
37 self.addOption ('maxEta', 2.7, type=float,
38 info=r"maximum muon $\vert\eta\vert$.")
39 self.addOption ('excludeNSWFromPrecisionLayers', False, type=bool,
40 info="only for testing purposes, turn on to ignore NSW hits and "
41 "fix a crash with older derivations (p-tag <p5834).")
42 self.addOption ('calibMode', 'correctData_CB', type=str, info='calibration mode of the `MuonCalibTool` needed to turn on the sagitta bias corrections and to select the muon track calibration type (CB or ID+MS), see https://atlas-mcp.docs.cern.ch/guidelines/muonmomentumcorrections/index.html#cpmuoncalibtool-tool.', meta={'choices':(['correctData_CB','correctData_IDMS','notCorrectData_IDMS','notCorrectData_CB','correctData_IDonly','correctData_MSonly'],1)})
43 self.addOption ('useZeroPixMuons', False, type=bool, info='if True, a second `MuonCalibTool` instance with calibMode=correctData_MSonly is scheduled and applied only to ZeroPixelHit muons.')
44 self.addOption ('zeroPixMuonType', None, type=int, info='muonType value used for the ZeroPix calibration tool. If left as None, the default xAOD::Muon::MuonType::ZeroPixelHit is used.')
45 self.addOption ('decorateTruth', False, type=bool,
46 info="decorate truth particle information on the reconstructed one.")
47 self.addOption ('writeColumnarToolVariables', False, type=bool,
48 info="whether to add variables needed for running the columnar muon tool(s) on the output n-tuple (EXPERIMENTAL).",
49 expertMode=True)
50 self.addOption ('addGlobalFELinksDep', False, type=bool,
51 info="whether to add dependencies for the global FE links (needed for PHYSLITE production)",
52 expertMode=True)
53

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.instanceName ( self)

Definition at line 54 of file MuonAnalysisConfig.py.

54 def instanceName (self) :
55 if self.postfix != "":
56 return self.postfix
57 else :
58 return self.containerName
59

◆ makeAlgs()

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.makeAlgs ( self,
config )

Definition at line 60 of file MuonAnalysisConfig.py.

60 def makeAlgs (self, config) :
61
62 log = logging.getLogger('MuonCalibrationConfig')
63
64 #make sure that this is sync with
65 #PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections/MuonMomentumCorrections/MuonCalibTool.h#L31-37
66 if self.calibMode == 'correctData_CB':
67 calibMode = 0
68 elif self.calibMode == 'correctData_IDMS':
69 calibMode = 1
70 elif self.calibMode == 'notCorrectData_IDMS':
71 calibMode = 2
72 elif self.calibMode == 'notCorrectData_CB':
73 calibMode = 3
74 elif self.calibMode == 'correctData_IDonly':
75 calibMode = 4
76 elif self.calibMode == 'correctData_MSonly':
77 calibMode = 5
78 else :
79 raise ValueError ("invalid calibMode: \"" + self.calibMode + "\". Allowed values are correctData_CB, correctData_IDMS, notCorrectData_IDMS, notCorrectData_CB, correctData_IDonly, correctData_MSonly")
80
81 inputContainer = "AnalysisMuons" if config.isPhyslite() else "Muons"
82 if self.inputContainer:
83 inputContainer = self.inputContainer
84 config.setSourceName (self.containerName, inputContainer)
85 config.setContainerMeta (self.containerName, 'calibMode', calibMode)
86
87 # Set up a shallow copy to decorate
88 if config.wantCopy (self.containerName) :
89 alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'MuonShallowCopyAlg' )
90 alg.input = config.readName (self.containerName)
91 alg.output = config.copyName (self.containerName)
92 alg.outputType = 'xAOD::MuonContainer'
93 decorationList = ['DFCommonJetDr',
94 'DFCommonMuonPassIDCuts',
95 'DFCommonMuonPassPreselection',
96 'neflowisol20_CloseByCorr',
97 'ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt1000_CloseByCorr',
98 'ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt500_CloseByCorr',
99 'topoetcone20_CloseByCorr']
100 if self.addGlobalFELinksDep:
101 decorationList += ['neutralGlobalFELinks', 'chargedGlobalFELinks']
102 if config.dataType() is not DataType.Data:
103 decorationList += ['TruthLink']
104 if self.addGlobalFELinksDep or config.dataType() is not DataType.Data:
105 alg.declareDecorations = decorationList
106
107 # Set up the eta-cut on all muons prior to everything else
108 alg = config.createAlgorithm( 'CP::AsgSelectionAlg',
109 'MuonEtaCutAlg' )
110 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
111 alg.selectionTool.maxEta = self.maxEta
112 alg.selectionDecoration = 'selectEta' + self.postfix + ',as_bits'
113 alg.particles = config.readName (self.containerName)
114 alg.preselection = config.getPreselection (self.containerName, '')
115 config.addSelection (self.containerName, '', alg.selectionDecoration)
116
117 # Set up the muon calibration and smearing algorithm:
118 alg = config.createAlgorithm( 'CP::MuonCalibrationAndSmearingAlg',
119 'MuonCalibrationAndSmearingAlg' )
120 config.addPrivateTool( 'calibrationAndSmearingTool',
121 'CP::MuonCalibTool' )
122
123 alg.calibrationAndSmearingTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
124 alg.calibrationAndSmearingTool.calibMode = calibMode
125 if config.geometry() is LHCPeriod.Run4:
126 log.warning("Disabling NSW hits for Run4 geometry")
127 alg.calibrationAndSmearingTool.ExcludeNSWFromPrecisionLayers = True
128 else:
129 alg.calibrationAndSmearingTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
130
131 # Optionally set up a second calibration tool applied only to ZPH muons
132 # The calibMode is set to 'correctData_MSonly'.
133 if self.useZeroPixMuons:
134 config.addPrivateTool( 'calibrationAndSmearingTool_ZeroPix',
135 'CP::MuonCalibTool' )
136 alg.calibrationAndSmearingTool_ZeroPix.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
137 alg.calibrationAndSmearingTool_ZeroPix.calibMode = 5 # correctData_MSonly
138 alg.calibrationAndSmearingTool_ZeroPix.ExcludeNSWFromPrecisionLayers = alg.calibrationAndSmearingTool.ExcludeNSWFromPrecisionLayers
139 if self.zeroPixMuonType is not None:
140 alg.zeroPixMuonType = self.zeroPixMuonType
141
142 alg.muons = config.readName (self.containerName)
143 alg.muonsOut = config.copyName (self.containerName)
144 alg.preselection = config.getPreselection (self.containerName, '')
145 if config.isPhyslite() and not self.recalibratePhyslite :
146 alg.skipNominal = True
147
148 # Set up the the pt selection
149 if self.minPt > 0:
150 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'MuonPtCutAlg' )
151 alg.selectionDecoration = 'selectPt' + self.postfix + ',as_bits'
152 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
153 alg.particles = config.readName (self.containerName)
154 alg.selectionTool.minPt = self.minPt
155 alg.preselection = config.getPreselection (self.containerName, '')
156 config.addSelection (self.containerName, '', alg.selectionDecoration,
157 preselection = True)
158
159 alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' )
160 alg.particles = config.readName (self.containerName)
161
162 config.addOutputVar (self.containerName, 'pt', 'pt')
163 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
164 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
165 config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
166 config.addOutputVar (self.containerName, 'charge', 'charge', noSys=True)
167
168 # decorate truth information on the reconstructed object:
169 if self.decorateTruth and config.dataType() is not DataType.Data:
170 config.addOutputVar (self.containerName, "truthType", "truth_type", noSys=True)
171 config.addOutputVar (self.containerName, "truthOrigin", "truth_origin", noSys=True)
172
173 config.addOutputVar (self.containerName, 'muonType', 'muonType', noSys=True, enabled=self.writeColumnarToolVariables)
174
175

Member Data Documentation

◆ addGlobalFELinksDep

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.addGlobalFELinksDep

Definition at line 100 of file MuonAnalysisConfig.py.

◆ calibMode

str python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.calibMode = 'correctData_CB':

Definition at line 66 of file MuonAnalysisConfig.py.

◆ containerName

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.containerName

Definition at line 84 of file MuonAnalysisConfig.py.

◆ inputContainer

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.inputContainer

Definition at line 82 of file MuonAnalysisConfig.py.

◆ recalibratePhyslite

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.recalibratePhyslite

Definition at line 145 of file MuonAnalysisConfig.py.

◆ useZeroPixMuons

python.MuonAnalysisConfig.MuonMomentumCalibrationConfig.useZeroPixMuons

Definition at line 133 of file MuonAnalysisConfig.py.


The documentation for this class was generated from the following file: