247 def makeAlgs (self, config) :
248 log = logging.getLogger('MuonWorkingPointSelectionConfig')
249
250 from xAODMuon.xAODMuonEnums import xAODMuonEnums
251 if self.quality == 'Tight' :
252 quality = xAODMuonEnums.Quality.Tight
253 elif self.quality == 'Medium' :
254 quality = xAODMuonEnums.Quality.Medium
255 elif self.quality == 'Loose' :
256 quality = xAODMuonEnums.Quality.Loose
257 elif self.quality == 'VeryLoose' :
258 quality = xAODMuonEnums.Quality.VeryLoose
259 elif self.quality == 'HighPt' :
260 quality = 4
261 elif self.quality == 'LowPt' :
262 quality = 5
263 else :
264 raise ValueError ("invalid muon quality: \"" + self.quality +
265 "\", allowed values are Tight, Medium, Loose, " +
266 "VeryLoose, HighPt, LowPt")
267
268
269 if config.geometry() is LHCPeriod.Run1:
270 raise ValueError ("Can't set up the MuonWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
271
272 postfix = self.postfix
273 if postfix is None :
274 postfix = self.selectionName
275 if postfix != '' and postfix[0] != '_' :
276 postfix = '_' + postfix
277
278
279 if self.trackSelection:
280 alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
281 'MuonTrackSelectionAlg',
282 reentrant=True )
283 alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
284 alg.maxD0Significance = self.maxD0Significance
285 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
286 alg.particles = config.readName (self.containerName)
287 alg.preselection = config.getPreselection (self.containerName, '')
288 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
289
290
291 alg = config.createAlgorithm( 'CP::MuonSelectionAlgV2',
292 'MuonSelectionAlg' )
293 config.addPrivateTool( 'selectionTool', 'CP::MuonSelectionTool' )
294 alg.selectionTool.MuQuality = quality
295 alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
296 alg.selectionTool.UseLRT = self.useLRT
297 if config.geometry() is LHCPeriod.Run4:
298 log.warning("Disabling NSW hits for Run4 geometry")
299 alg.selectionTool.ExcludeNSWFromPrecisionLayers = True
300 else:
301 alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
302 alg.selectionDecoration = 'good_muon' + postfix + ',as_char'
303 alg.badMuonVetoDecoration = 'is_bad' + postfix + ',as_char'
304 alg.muons = config.readName (self.containerName)
305 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
306 config.addSelection (self.containerName, self.selectionName,
307 alg.selectionDecoration,
308 preselection=self.addSelectionToPreselection)
309 if self.quality == 'HighPt':
310 config.addOutputVar (self.containerName, 'is_bad' + postfix, 'is_bad' + postfix)
311
312
313 if self.isolation != 'NonIso' :
314 alg = config.createAlgorithm( 'CP::MuonIsolationAlg',
315 'MuonIsolationAlg' )
316 config.addPrivateTool( 'isolationTool', 'CP::IsolationSelectionTool' )
317 alg.isolationTool.MuonWP = self.isolation
318 alg.isolationTool.IsoDecSuffix = self.isoDecSuffix
319 alg.isolationDecoration = 'isolated_muon' + postfix + ',as_char'
320 alg.muons = config.readName (self.containerName)
321 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
322 config.addSelection (self.containerName, self.selectionName,
323 alg.isolationDecoration,
324 preselection=self.addSelectionToPreselection)
325
326