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