Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ParticleLevelMuonsConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
4 
5 
6 class ParticleLevelMuonsBlock(ConfigBlock):
7  """ConfigBlock for particle-level truth muons"""
8 
9  def __init__(self):
10  super(ParticleLevelMuonsBlock, self).__init__()
11  self.addOption('containerName', 'TruthMuons', type=str,
12  info='the name of the input truth muons container')
13  self.addOption('selectionName', '', type=str,
14  info='the name of the selection to create. The default is "",'
15  ' which applies the selection to all truth muons.')
16  self.addOption('isolated', True, type=bool,
17  info='select only truth muons that are isolated.')
18  self.addOption('notFromTau', True, type=bool,
19  info='select only truth muons that did not orginate '
20  'from a tau decay.')
21  # Always skip on data
22  self.setOptionValue('skipOnData', True)
23 
24  def makeAlgs(self, config):
25  config.setSourceName (self.containerName, self.containerName)
26 
27  # decorate the charge so we can save it later
28  alg = config.createAlgorithm('CP::ParticleLevelChargeDecoratorAlg',
29  'ParticleLevelChargeDecoratorMuons' + self.selectionName,
30  reentrant=True)
31  alg.particles = self.containerName
32 
33  # check for prompt isolation and possible origin from tau decays
34  alg = config.createAlgorithm('CP::ParticleLevelIsolationAlg',
35  'ParticleLevelIsolationMuons' + self.selectionName,
36  reentrant=True)
37  alg.particles = self.containerName
38  alg.isolation = 'isIsolated' + self.selectionName if self.isolated else 'isIsolatedButNotRequired' + self.selectionName
39  alg.notTauOrigin = 'notFromTau' + self.selectionName if self.notFromTau else 'notFromTauButNotRequired' + self.selectionName
40  alg.checkType = 'IsoMuon'
41 
42  if self.isolated:
43  config.addSelection (self.containerName, self.selectionName, alg.isolation+',as_char')
44  if self.notFromTau:
45  config.addSelection (self.containerName, self.selectionName, alg.notTauOrigin+',as_char')
46 
47  # output branches to be scheduled only once
48  if ParticleLevelMuonsBlock.get_instance_count() == 1:
49  outputVars = [
50  ['pt_dressed', 'pt'],
51  ['eta_dressed', 'eta'],
52  ['phi_dressed', 'phi'],
53  ['e_dressed', 'e'],
54  ['charge', 'charge'],
55  ['classifierParticleType', 'type'],
56  ['classifierParticleOrigin', 'origin'],
57  ]
58  for decoration, branch in outputVars:
59  config.addOutputVar (self.containerName, decoration, branch, noSys=True)
60 
61 
ParticleLevelMuonsConfig.ParticleLevelMuonsBlock
Definition: ParticleLevelMuonsConfig.py:6
ParticleLevelMuonsConfig.ParticleLevelMuonsBlock.makeAlgs
def makeAlgs(self, config)
Definition: ParticleLevelMuonsConfig.py:24
ParticleLevelMuonsConfig.ParticleLevelMuonsBlock.__init__
def __init__(self)
Definition: ParticleLevelMuonsConfig.py:9