ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleLevelMuonsConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
4
5
6class 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 meta={'role':'container'})
14 self.addOption('selectionName', '', type=str,
15 info='the name of the selection to create. If left empty, '
16 'applies the selection to all truth muons.',
17 meta={'role':'selection'})
18 self.addOption('isolated', True, type=bool,
19 info='select only truth muons that are isolated.')
20 self.addOption('notFromTau', True, type=bool,
21 info='select only truth muons that did not orginate '
22 'from a tau-lepton decay.')
23 self.addOption('saveUID', False, type=bool,
24 info='save unique ID in output.')
25 # Always skip on data
26 self.setOptionValue('skipOnData', True)
27
28 def instanceName (self) :
29 """Return the instance name for this block"""
30 name = self.containerName
31 if self.selectionName: name = name + '_' + self.selectionName
32 return name
33
34 def makeAlgs(self, config):
35 config.setSourceName (self.containerName, self.containerName)
36
37 # decorate the charge so we can save it later
38 alg = config.createAlgorithm('CP::ParticleLevelChargeDecoratorAlg',
39 'ParticleLevelChargeDecoratorMuons',
40 reentrant=True)
41 alg.particles = self.containerName
42
43 # check for prompt isolation and possible origin from tau decays
44 alg = config.createAlgorithm('CP::ParticleLevelIsolationAlg',
45 'ParticleLevelIsolationMuons',
46 reentrant=True)
47 alg.particles = self.containerName
48 alg.isolation = 'isIsolated' + self.selectionName if self.isolated else 'isIsolatedButNotRequired' + self.selectionName
49 alg.notTauOrigin = 'notFromTau' + self.selectionName if self.notFromTau else 'notFromTauButNotRequired' + self.selectionName
50 alg.checkType = 'IsoMuon'
51
52 if self.isolated:
53 config.addSelection (self.containerName, self.selectionName, alg.isolation+',as_char')
54 if self.notFromTau:
55 config.addSelection (self.containerName, self.selectionName, alg.notTauOrigin+',as_char')
56
57 # output branches to be scheduled only once
58 if 'pt' not in config.getOutputVars(self.containerName):
59 outputVars = [
60 ['pt_dressed', 'pt', 'float'],
61 ['eta_dressed', 'eta', 'float'],
62 ['phi_dressed', 'phi', 'float'],
63 ['e_dressed', 'e', 'float'],
64 ['charge', 'charge', 'float'],
65 ['classifierParticleType', 'type', 'unsigned'],
66 ['classifierParticleOrigin', 'origin', 'unsigned'],
67 ]
68 if self.saveUID:
69 outputVars += [['uid', 'uid', 'int']]
70 for decoration, branch, auxType in outputVars:
71 config.addOutputVar (self.containerName, decoration, branch, noSys=True, auxType=auxType)