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