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