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

Constructor & Destructor Documentation

◆ __init__()

def python.MuonAnalysisConfig.MuonWorkingPointConfig.__init__ (   self)

Definition at line 157 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

def python.MuonAnalysisConfig.MuonWorkingPointConfig.instanceName (   self)

Definition at line 214 of file MuonAnalysisConfig.py.

214  def instanceName (self) :
215  if self.postfix is not None:
216  return self.containerName + '_' + self.postfix
217  else:
218  return self.containerName + '_' + self.selectionName
219 

◆ makeAlgs()

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

Definition at line 220 of file MuonAnalysisConfig.py.

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

Member Data Documentation

◆ quality

python.MuonAnalysisConfig.MuonWorkingPointConfig.quality

Definition at line 224 of file MuonAnalysisConfig.py.


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