177 def makeAlgs (self, config) :
178 from xAODMuon.xAODMuonEnums
import xAODMuonEnums
179 if self.quality ==
'Tight' :
180 quality = xAODMuonEnums.Quality.Tight
181 elif self.quality ==
'Medium' :
182 quality = xAODMuonEnums.Quality.Medium
183 elif self.quality ==
'Loose' :
184 quality = xAODMuonEnums.Quality.Loose
185 elif self.quality ==
'VeryLoose' :
186 quality = xAODMuonEnums.Quality.VeryLoose
187 elif self.quality ==
'HighPt' :
189 elif self.quality ==
'LowPtEfficiency' :
192 raise ValueError (
"invalid muon quality: \"" + self.quality +
193 "\", allowed values are Tight, Medium, Loose, " +
194 "VeryLoose, HighPt, LowPtEfficiency")
197 if config.geometry()
is LHCPeriod.Run1:
198 raise ValueError (
"Can't set up the MuonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
200 postfix = self.postfix
201 if postfix !=
'' and postfix[0] !=
'_' :
202 postfix =
'_' + postfix
205 if self.writeTrackD0Z0
or self.trackSelection:
206 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
207 'MuonTrackSelectionAlg' + postfix )
208 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
209 alg.decorateTTVAVars = self.writeTrackD0Z0
210 alg.maxD0Significance = self.maxD0Significance
211 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
212 alg.particles = config.readName (self.containerName)
213 alg.preselection = config.getPreselection (self.containerName,
'')
214 if self.trackSelection :
215 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
216 if self.writeTrackD0Z0 :
217 alg.d0sigDecoration =
'd0sig' + postfix
218 alg.z0sinthetaDecoration =
'z0sintheta' + postfix
219 config.addOutputVar (self.containerName, alg.d0sigDecoration, alg.d0sigDecoration,noSys=
True)
220 config.addOutputVar (self.containerName, alg.z0sinthetaDecoration, alg.z0sinthetaDecoration,noSys=
True)
223 alg = config.createAlgorithm(
'CP::MuonSelectionAlgV2',
224 'MuonSelectionAlg' + postfix )
225 config.addPrivateTool(
'selectionTool',
'CP::MuonSelectionTool' )
226 alg.selectionTool.MuQuality = quality
227 alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
228 if config.geometry()
is LHCPeriod.Run4:
229 logging.warning(
"MuonCalibrationConfig: disabling NSW hits for Run4 geometry")
230 alg.selectionTool.ExcludeNSWFromPrecisionLayers =
True
232 alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers
and (config.geometry() >= LHCPeriod.Run3)
233 alg.selectionDecoration =
'good_muon' + postfix +
',as_char'
234 alg.badMuonVetoDecoration =
'is_bad' + postfix +
',as_char'
235 alg.muons = config.readName (self.containerName)
236 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
237 config.addSelection (self.containerName, self.selectionName,
238 alg.selectionDecoration,
239 preselection=self.addSelectionToPreselection)
242 if self.isolation !=
'NonIso' :
243 alg = config.createAlgorithm(
'CP::MuonIsolationAlg',
244 'MuonIsolationAlg' + postfix )
245 config.addPrivateTool(
'isolationTool',
'CP::IsolationSelectionTool' )
246 alg.isolationTool.MuonWP = self.isolation
247 if self.closeByCorrection:
248 alg.isolationTool.IsoDecSuffix =
"CloseByCorr"
249 alg.isolationDecoration =
'isolated_muon' + postfix +
',as_char'
250 alg.muons = config.readName (self.containerName)
251 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
252 config.addSelection (self.containerName, self.selectionName,
253 alg.isolationDecoration,
254 preselection=self.addSelectionToPreselection)
257 if config.dataType()
is not DataType.Data
and (
not self.noEffSF
or self.onlyRecoEffSF):
258 alg = config.createAlgorithm(
'CP::MuonEfficiencyScaleFactorAlg',
259 'MuonEfficiencyScaleFactorAlgReco' + postfix )
260 config.addPrivateTool(
'efficiencyScaleFactorTool',
261 'CP::MuonEfficiencyScaleFactors' )
262 alg.scaleFactorDecoration =
'muon_reco_effSF' + postfix +
"_%SYS%"
263 alg.outOfValidity = 2
264 alg.outOfValidityDeco =
'muon_reco_bad_eff' + postfix
265 alg.efficiencyScaleFactorTool.WorkingPoint = self.quality
266 if config.geometry() >= LHCPeriod.Run3:
267 alg.efficiencyScaleFactorTool.CalibrationRelease =
'240711_Preliminary_r24run3'
268 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
269 alg.muons = config.readName (self.containerName)
270 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
271 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'reco_effSF' + postfix)
274 if config.dataType()
is not DataType.Data
and self.quality ==
'HighPt' and not self.onlyRecoEffSF
and not self.noEffSF:
275 alg = config.createAlgorithm(
'CP::MuonEfficiencyScaleFactorAlg',
276 'MuonEfficiencyScaleFactorAlgBMVHighPt' + postfix )
277 config.addPrivateTool(
'efficiencyScaleFactorTool',
278 'CP::MuonEfficiencyScaleFactors' )
279 alg.scaleFactorDecoration =
'muon_BadMuonVeto_effSF' + postfix +
"_%SYS%"
280 alg.outOfValidity = 2
281 alg.outOfValidityDeco =
'muon_BadMuonVeto_bad_eff' + postfix
282 alg.efficiencyScaleFactorTool.WorkingPoint =
'BadMuonVeto_HighPt'
283 if config.geometry() >= LHCPeriod.Run3:
284 alg.efficiencyScaleFactorTool.CalibrationRelease =
'220817_Preliminary_r22run3'
285 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
286 alg.muons = config.readName (self.containerName)
287 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
288 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'BadMuonVeto_effSF' + postfix)
291 if config.dataType()
is not DataType.Data
and self.isolation !=
'NonIso' and not self.onlyRecoEffSF
and not self.noEffSF:
292 alg = config.createAlgorithm(
'CP::MuonEfficiencyScaleFactorAlg',
293 'MuonEfficiencyScaleFactorAlgIsol' + postfix )
294 config.addPrivateTool(
'efficiencyScaleFactorTool',
295 'CP::MuonEfficiencyScaleFactors' )
296 alg.scaleFactorDecoration =
'muon_isol_effSF' + postfix +
"_%SYS%"
297 alg.outOfValidity = 2
298 alg.outOfValidityDeco =
'muon_isol_bad_eff' + postfix
299 alg.efficiencyScaleFactorTool.WorkingPoint = self.isolation +
'Iso'
300 if config.geometry() >= LHCPeriod.Run3:
301 alg.efficiencyScaleFactorTool.CalibrationRelease =
'240711_Preliminary_r24run3'
302 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
303 alg.muons = config.readName (self.containerName)
304 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
305 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'isol_effSF' + postfix)
308 if config.dataType()
is not DataType.Data
and not self.onlyRecoEffSF
and not self.noEffSF:
309 alg = config.createAlgorithm(
'CP::MuonEfficiencyScaleFactorAlg',
310 'MuonEfficiencyScaleFactorAlgTTVA' + postfix )
311 config.addPrivateTool(
'efficiencyScaleFactorTool',
312 'CP::MuonEfficiencyScaleFactors' )
313 alg.scaleFactorDecoration =
'muon_TTVA_effSF' + postfix +
"_%SYS%"
314 alg.outOfValidity = 2
315 alg.outOfValidityDeco =
'muon_TTVA_bad_eff' + postfix
316 alg.efficiencyScaleFactorTool.WorkingPoint =
'TTVA'
317 if config.geometry() >= LHCPeriod.Run3:
318 alg.efficiencyScaleFactorTool.CalibrationRelease =
'240711_Preliminary_r24run3'
319 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
320 alg.muons = config.readName (self.containerName)
321 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
322 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'TTVA_effSF' + postfix)