ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.MuonAnalysisConfig.MuonWorkingPointConfig Class Reference
Inheritance diagram for python.MuonAnalysisConfig.MuonWorkingPointConfig:
Collaboration diagram for python.MuonAnalysisConfig.MuonWorkingPointConfig:

Public Member Functions

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

Public Attributes

 quality
 

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 151 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.MuonAnalysisConfig.MuonWorkingPointConfig.__init__ (   self)

Definition at line 156 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

def python.MuonAnalysisConfig.MuonWorkingPointConfig.instanceName (   self)

Definition at line 211 of file MuonAnalysisConfig.py.

211  def instanceName (self) :
212  if self.postfix is not None:
213  return self.containerName + '_' + self.postfix
214  else:
215  return self.containerName + '_' + self.selectionName
216 

◆ makeAlgs()

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

Definition at line 217 of file MuonAnalysisConfig.py.

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

Member Data Documentation

◆ quality

python.MuonAnalysisConfig.MuonWorkingPointConfig.quality

Definition at line 221 of file MuonAnalysisConfig.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18