272 def makeAlgs (self, config) :
273 log = logging.getLogger('MuonWorkingPointSelectionConfig')
274
275 from xAODMuon.xAODMuonEnums import xAODMuonEnums
276 qualityMap = {
277 'Tight' : xAODMuonEnums.Quality.Tight,
278 'Medium' : xAODMuonEnums.Quality.Medium,
279 'Loose' : xAODMuonEnums.Quality.Loose,
280 'VeryLoose' : xAODMuonEnums.Quality.VeryLoose,
281
282
283 'HighPt' : 4,
284 'LowPt' : 5,
285 }
286 if self.quality not in qualityMap :
287 raise ValueError ("invalid muon quality: \"" + str(self.quality) +
288 "\", allowed values are Tight, Medium, Loose, " +
289 "VeryLoose, HighPt, LowPt")
290 quality = qualityMap[self.quality]
291
292 if self.isolation is None :
293 raise ValueError ("muon isolation working point not set, "
294 "use e.g. \"NonIso\" to disable the isolation selection")
295
296
297 if config.geometry() is LHCPeriod.Run1:
298 raise ValueError ("Can't set up the MuonWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
299
300 postfix = self.postfix
301 if postfix is None :
302 postfix = self.selectionName
303 if postfix != '' and postfix[0] != '_' :
304 postfix = '_' + postfix
305
306
307 if self.trackSelection:
308 alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
309 'MuonTrackSelectionAlg',
310 reentrant=True )
311 alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
312 alg.maxD0Significance = self.maxD0Significance
313 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
314 alg.particles = config.readName (self.containerName)
315 alg.preselection = config.getPreselection (self.containerName, '')
316 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
317
318
319 alg = config.createAlgorithm( 'CP::MuonSelectionAlgV2',
320 'MuonSelectionAlg' )
321 config.addPrivateTool( 'selectionTool', 'CP::MuonSelectionTool' )
322 alg.selectionTool.MuQuality = quality
323 alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
324 alg.selectionTool.UseLRT = self.useLRT
325 if config.geometry() is LHCPeriod.Run4:
326 log.warning("Disabling NSW hits for Run4 geometry")
327 alg.selectionTool.ExcludeNSWFromPrecisionLayers = True
328 else:
329 alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
330 alg.selectionDecoration = 'good_muon' + postfix + ',as_char'
331 alg.badMuonVetoDecoration = 'is_bad' + postfix + ',as_char'
332 alg.muons = config.readName (self.containerName)
333 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
334 config.addSelection (self.containerName, self.selectionName,
335 alg.selectionDecoration,
336 preselection=self.addSelectionToPreselection)
337 if self.quality == 'HighPt':
338 config.addOutputVar (self.containerName, 'is_bad' + postfix, 'is_bad' + postfix)
339
340
341 if self.isolation != 'NonIso' :
342 alg = config.createAlgorithm( 'CP::MuonIsolationAlg',
343 'MuonIsolationAlg' )
344 config.addPrivateTool( 'isolationTool', 'CP::IsolationSelectionTool' )
345 alg.isolationTool.MuonWP = self.isolation
346 alg.isolationTool.IsoDecSuffix = self.isoDecSuffix
347 alg.isolationDecoration = 'isolated_muon' + postfix + ',as_char'
348 alg.muons = config.readName (self.containerName)
349 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
350 config.addSelection (self.containerName, self.selectionName,
351 alg.isolationDecoration,
352 preselection=self.addSelectionToPreselection)
353
354