208 def makeAlgs (self, config) :
209 log = logging.getLogger('MuonWorkingPointSelectionConfig')
210
211 from xAODMuon.xAODMuonEnums import xAODMuonEnums
212 if self.quality == 'Tight' :
213 quality = xAODMuonEnums.Quality.Tight
214 elif self.quality == 'Medium' :
215 quality = xAODMuonEnums.Quality.Medium
216 elif self.quality == 'Loose' :
217 quality = xAODMuonEnums.Quality.Loose
218 elif self.quality == 'VeryLoose' :
219 quality = xAODMuonEnums.Quality.VeryLoose
220 elif self.quality == 'HighPt' :
221 quality = 4
222 elif self.quality == 'LowPt' :
223 quality = 5
224 else :
225 raise ValueError ("invalid muon quality: \"" + self.quality +
226 "\", allowed values are Tight, Medium, Loose, " +
227 "VeryLoose, HighPt, LowPt")
228
229
230 if config.geometry() is LHCPeriod.Run1:
231 raise ValueError ("Can't set up the MuonWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
232
233 postfix = self.postfix
234 if postfix is None :
235 postfix = self.selectionName
236 if postfix != '' and postfix[0] != '_' :
237 postfix = '_' + postfix
238
239
240 if self.trackSelection:
241 alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
242 'MuonTrackSelectionAlg',
243 reentrant=True )
244 alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
245 alg.maxD0Significance = self.maxD0Significance
246 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
247 alg.particles = config.readName (self.containerName)
248 alg.preselection = config.getPreselection (self.containerName, '')
249 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
250
251
252 alg = config.createAlgorithm( 'CP::MuonSelectionAlgV2',
253 'MuonSelectionAlg' )
254 config.addPrivateTool( 'selectionTool', 'CP::MuonSelectionTool' )
255 alg.selectionTool.MuQuality = quality
256 alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
257 if config.geometry() is LHCPeriod.Run4:
258 log.warning("Disabling NSW hits for Run4 geometry")
259 alg.selectionTool.ExcludeNSWFromPrecisionLayers = True
260 else:
261 alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
262 alg.selectionDecoration = 'good_muon' + postfix + ',as_char'
263 alg.badMuonVetoDecoration = 'is_bad' + postfix + ',as_char'
264 alg.muons = config.readName (self.containerName)
265 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
266 config.addSelection (self.containerName, self.selectionName,
267 alg.selectionDecoration,
268 preselection=self.addSelectionToPreselection)
269 if self.quality == 'HighPt':
270 config.addOutputVar (self.containerName, 'is_bad' + postfix, 'is_bad' + postfix)
271
272
273 if self.isolation != 'NonIso' :
274 alg = config.createAlgorithm( 'CP::MuonIsolationAlg',
275 'MuonIsolationAlg' )
276 config.addPrivateTool( 'isolationTool', 'CP::IsolationSelectionTool' )
277 alg.isolationTool.MuonWP = self.isolation
278 alg.isolationTool.IsoDecSuffix = self.isoDecSuffix
279 alg.isolationDecoration = 'isolated_muon' + postfix + ',as_char'
280 alg.muons = config.readName (self.containerName)
281 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
282 config.addSelection (self.containerName, self.selectionName,
283 alg.isolationDecoration,
284 preselection=self.addSelectionToPreselection)
285
286