ATLAS Offline Software
Loading...
Searching...
No Matches
python.MuonAnalysisConfig.MuonWorkingPointConfig Class Reference
Inheritance diagram for python.MuonAnalysisConfig.MuonWorkingPointConfig:
Collaboration diagram for python.MuonAnalysisConfig.MuonWorkingPointConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeAlgs (self, config)

Public Attributes

str quality = 'Tight' :
 trackSelection
 containerName
 selectionName
 onlyRecoEffSF
 saveDetailedSF
 noEffSF
 saveCombinedSF

Detailed Description

the ConfigBlock for the muon working point

This may at some point be split into multiple blocks (10 Mar 22).

Definition at line 161 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonWorkingPointConfig.__init__ ( self)

Definition at line 166 of file MuonAnalysisConfig.py.

166 def __init__ (self) :
167 super (MuonWorkingPointConfig, self).__init__ ()
168 self.setBlockName('MuonsWorkingPoint')
169 self.addOption ('containerName', '', type=str,
170 noneAction='error',
171 info="the name of the input container.")
172 self.addOption ('selectionName', '', type=str,
173 noneAction='error',
174 info="the name of the muon selection to define (e.g. tight or loose).")
175 self.addOption ('postfix', None, type=str,
176 info="a postfix to apply to decorations and algorithm names. "
177 "Typically not needed here as selectionName is used internally.")
178 self.addOption ('trackSelection', True, type=bool,
179 info="whether or not to set up an instance of "
180 "CP::AsgLeptonTrackSelectionAlg, with the recommended d_0 and "
181 "z_0 sin(theta) cuts. The default is True.")
182 self.addOption ('maxD0Significance', 3, type=float,
183 info="maximum d0 significance used for the trackSelection"
184 "The default is 3")
185 self.addOption ('maxDeltaZ0SinTheta', 0.5, type=float,
186 info="maximum Delta z0sinTheta in mm used for the trackSelection"
187 "The default is 0.5 mm")
188 self.addOption ('quality', None, type=str,
189 info="the ID WP (string) to use. Supported ID WPs: Tight, Medium, "
190 "Loose, LowPt, HighPt.")
191 self.addOption ('isolation', None, type=str,
192 info="the isolation WP (string) to use. Supported isolation WPs: "
193 "PflowLoose_VarRad, PflowTight_VarRad, Loose_VarRad, "
194 "Tight_VarRad, NonIso.")
195 self.addOption ('addSelectionToPreselection', True, type=bool,
196 info="whether to retain only muons satisfying the working point "
197 "requirements. The default is True.")
198 self.addOption ('isoDecSuffix', '', type=str,
199 info="isoDecSuffix if using close-by-corrected isolation working points.")
200 self.addOption ('systematicBreakdown', False, type=bool,
201 info="enables the full breakdown of efficiency SF systematics "
202 "(1 NP per uncertainty source, instead of 1 NP in total). "
203 "The default is False.")
204 self.addOption ('onlyRecoEffSF', False, type=bool,
205 info="same as noEffSF, but retains the ID scale factor. "
206 "Experimental! only useful for CI tests. The default is False.",
207 expertMode=True)
208 self.addOption ('noEffSF', False, type=bool,
209 info="disables the calculation of efficiencies and scale factors. "
210 "Experimental! only useful to test a new WP for which scale "
211 "factors are not available. The default is False.",
212 expertMode=True)
213 self.addOption ('saveDetailedSF', True, type=bool,
214 info="save all the independent detailed object scale factors. "
215 "The default is True.")
216 self.addOption ('saveCombinedSF', False, type=bool,
217 info="save the combined object scale factor. "
218 "The default is False.")
219 self.addOption ('excludeNSWFromPrecisionLayers', False, type=bool,
220 info="only for testing purposes, turn on to ignore NSW hits and "
221 "fix a crash with older derivations (p-tag <p5834)")
222

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonWorkingPointConfig.instanceName ( self)

Definition at line 223 of file MuonAnalysisConfig.py.

223 def instanceName (self) :
224 if self.postfix is not None:
225 return self.containerName + '_' + self.postfix
226 else:
227 return self.containerName + '_' + self.selectionName
228

◆ makeAlgs()

python.MuonAnalysisConfig.MuonWorkingPointConfig.makeAlgs ( self,
config )

Definition at line 229 of file MuonAnalysisConfig.py.

229 def makeAlgs (self, config) :
230 log = logging.getLogger('MuonWorkingPointConfig')
231
232 from xAODMuon.xAODMuonEnums import xAODMuonEnums
233 if self.quality == 'Tight' :
234 quality = xAODMuonEnums.Quality.Tight
235 elif self.quality == 'Medium' :
236 quality = xAODMuonEnums.Quality.Medium
237 elif self.quality == 'Loose' :
238 quality = xAODMuonEnums.Quality.Loose
239 elif self.quality == 'VeryLoose' :
240 quality = xAODMuonEnums.Quality.VeryLoose
241 elif self.quality == 'HighPt' :
242 quality = 4
243 elif self.quality == 'LowPt' :
244 quality = 5
245 else :
246 raise ValueError ("invalid muon quality: \"" + self.quality +
247 "\", allowed values are Tight, Medium, Loose, " +
248 "VeryLoose, HighPt, LowPt")
249
250 # The setup below is inappropriate for Run 1
251 if config.geometry() is LHCPeriod.Run1:
252 raise ValueError ("Can't set up the MuonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
253
254 postfix = self.postfix
255 if postfix is None :
256 postfix = self.selectionName
257 if postfix != '' and postfix[0] != '_' :
258 postfix = '_' + postfix
259
260 # Set up the track selection algorithm:
261 if self.trackSelection:
262 alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
263 'MuonTrackSelectionAlg',
264 reentrant=True )
265 alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
266 alg.maxD0Significance = self.maxD0Significance
267 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
268 alg.particles = config.readName (self.containerName)
269 alg.preselection = config.getPreselection (self.containerName, '')
270 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
271
272 # Setup the muon quality selection
273 alg = config.createAlgorithm( 'CP::MuonSelectionAlgV2',
274 'MuonSelectionAlg' )
275 config.addPrivateTool( 'selectionTool', 'CP::MuonSelectionTool' )
276 alg.selectionTool.MuQuality = quality
277 alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
278 if config.geometry() is LHCPeriod.Run4:
279 log.warning("Disabling NSW hits for Run4 geometry")
280 alg.selectionTool.ExcludeNSWFromPrecisionLayers = True
281 else:
282 alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
283 alg.selectionDecoration = 'good_muon' + postfix + ',as_char'
284 alg.badMuonVetoDecoration = 'is_bad' + postfix + ',as_char'
285 alg.muons = config.readName (self.containerName)
286 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
287 config.addSelection (self.containerName, self.selectionName,
288 alg.selectionDecoration,
289 preselection=self.addSelectionToPreselection)
290 if self.quality == 'HighPt':
291 config.addOutputVar (self.containerName, 'is_bad' + postfix, 'is_bad' + postfix)
292
293 # Set up the isolation calculation algorithm:
294 if self.isolation != 'NonIso' :
295 alg = config.createAlgorithm( 'CP::MuonIsolationAlg',
296 'MuonIsolationAlg' )
297 config.addPrivateTool( 'isolationTool', 'CP::IsolationSelectionTool' )
298 alg.isolationTool.MuonWP = self.isolation
299 alg.isolationTool.IsoDecSuffix = self.isoDecSuffix
300 alg.isolationDecoration = 'isolated_muon' + postfix + ',as_char'
301 alg.muons = config.readName (self.containerName)
302 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
303 config.addSelection (self.containerName, self.selectionName,
304 alg.isolationDecoration,
305 preselection=self.addSelectionToPreselection)
306
307 sfList = []
308 # Set up the reco/ID efficiency scale factor calculation algorithm:
309 if config.dataType() is not DataType.Data and (not self.noEffSF or self.onlyRecoEffSF):
310 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
311 'MuonEfficiencyScaleFactorAlgReco' )
312 config.addPrivateTool( 'efficiencyScaleFactorTool',
313 'CP::MuonEfficiencyScaleFactors' )
314 alg.scaleFactorDecoration = 'muon_reco_effSF' + postfix + "_%SYS%"
315 alg.outOfValidity = 2 #silent
316 alg.outOfValidityDeco = 'muon_reco_bad_eff' + postfix
317 alg.efficiencyScaleFactorTool.WorkingPoint = self.quality
318 if config.geometry() >= LHCPeriod.Run3:
319 alg.efficiencyScaleFactorTool.CalibrationRelease = '250418_Preliminary_r24run3'
320 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
321 alg.muons = config.readName (self.containerName)
322 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
323 if self.saveDetailedSF:
324 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
325 'reco_effSF' + postfix)
326 sfList += [alg.scaleFactorDecoration]
327
328 # Set up the HighPt-specific BadMuonVeto efficiency scale factor calculation algorithm:
329 if config.dataType() is not DataType.Data and self.quality == 'HighPt' and not self.onlyRecoEffSF and not self.noEffSF:
330 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
331 'MuonEfficiencyScaleFactorAlgBMVHighPt' )
332 config.addPrivateTool( 'efficiencyScaleFactorTool',
333 'CP::MuonEfficiencyScaleFactors' )
334 alg.scaleFactorDecoration = 'muon_BadMuonVeto_effSF' + postfix + "_%SYS%"
335 alg.outOfValidity = 2 #silent
336 alg.outOfValidityDeco = 'muon_BadMuonVeto_bad_eff' + postfix
337 alg.efficiencyScaleFactorTool.WorkingPoint = 'BadMuonVeto_HighPt'
338 if config.geometry() >= LHCPeriod.Run3:
339 alg.efficiencyScaleFactorTool.CalibrationRelease = '220817_Preliminary_r22run3' # not available as part of '230123_Preliminary_r22run3'!
340 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
341 alg.muons = config.readName (self.containerName)
342 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
343 if self.saveDetailedSF:
344 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
345 'BadMuonVeto_effSF' + postfix)
346 sfList += [alg.scaleFactorDecoration]
347
348 # Set up the isolation efficiency scale factor calculation algorithm:
349 if config.dataType() is not DataType.Data and self.isolation != 'NonIso' and not self.onlyRecoEffSF and not self.noEffSF:
350 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
351 'MuonEfficiencyScaleFactorAlgIsol' )
352 config.addPrivateTool( 'efficiencyScaleFactorTool',
353 'CP::MuonEfficiencyScaleFactors' )
354 alg.scaleFactorDecoration = 'muon_isol_effSF' + postfix + "_%SYS%"
355 alg.outOfValidity = 2 #silent
356 alg.outOfValidityDeco = 'muon_isol_bad_eff' + postfix
357 alg.efficiencyScaleFactorTool.WorkingPoint = self.isolation + 'Iso'
358 if config.geometry() >= LHCPeriod.Run3:
359 alg.efficiencyScaleFactorTool.CalibrationRelease = '250418_Preliminary_r24run3'
360 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
361 alg.muons = config.readName (self.containerName)
362 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
363 if self.saveDetailedSF:
364 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
365 'isol_effSF' + postfix)
366 sfList += [alg.scaleFactorDecoration]
367
368 # Set up the TTVA scale factor calculation algorithm:
369 if config.dataType() is not DataType.Data and self.trackSelection and not self.onlyRecoEffSF and not self.noEffSF:
370 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
371 'MuonEfficiencyScaleFactorAlgTTVA' )
372 config.addPrivateTool( 'efficiencyScaleFactorTool',
373 'CP::MuonEfficiencyScaleFactors' )
374 alg.scaleFactorDecoration = 'muon_TTVA_effSF' + postfix + "_%SYS%"
375 alg.outOfValidity = 2 #silent
376 alg.outOfValidityDeco = 'muon_TTVA_bad_eff' + postfix
377 alg.efficiencyScaleFactorTool.WorkingPoint = 'TTVA'
378 if config.geometry() >= LHCPeriod.Run3:
379 alg.efficiencyScaleFactorTool.CalibrationRelease = '250418_Preliminary_r24run3'
380 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
381 alg.muons = config.readName (self.containerName)
382 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
383 if self.saveDetailedSF:
384 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
385 'TTVA_effSF' + postfix)
386 sfList += [alg.scaleFactorDecoration]
387
388 if config.dataType() is not DataType.Data and not self.noEffSF and self.saveCombinedSF:
389 alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
390 'MuonCombinedEfficiencyScaleFactorAlg' )
391 alg.particles = config.readName (self.containerName)
392 alg.inScaleFactors = sfList
393 alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
394 config.addOutputVar (self.containerName, alg.outScaleFactor, 'effSF' + postfix)
395

Member Data Documentation

◆ containerName

python.MuonAnalysisConfig.MuonWorkingPointConfig.containerName

Definition at line 270 of file MuonAnalysisConfig.py.

◆ noEffSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.noEffSF

Definition at line 369 of file MuonAnalysisConfig.py.

◆ onlyRecoEffSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.onlyRecoEffSF

Definition at line 309 of file MuonAnalysisConfig.py.

◆ quality

str python.MuonAnalysisConfig.MuonWorkingPointConfig.quality = 'Tight' :

Definition at line 233 of file MuonAnalysisConfig.py.

◆ saveCombinedSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.saveCombinedSF

Definition at line 388 of file MuonAnalysisConfig.py.

◆ saveDetailedSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.saveDetailedSF

Definition at line 323 of file MuonAnalysisConfig.py.

◆ selectionName

python.MuonAnalysisConfig.MuonWorkingPointConfig.selectionName

Definition at line 270 of file MuonAnalysisConfig.py.

◆ trackSelection

python.MuonAnalysisConfig.MuonWorkingPointConfig.trackSelection

Definition at line 261 of file MuonAnalysisConfig.py.


The documentation for this class was generated from the following file: