ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleLevelTausConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
4
5
6class ParticleLevelTausBlock(ConfigBlock):
7 """ConfigBlock for particle-level truth taus"""
8
9 def __init__(self):
10 super(ParticleLevelTausBlock, self).__init__()
11 self.addOption('containerName', 'TruthTaus', type=str,
12 info='the name of the input truth taus 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 taus.')
16 self.addOption('isolated', True, type=bool,
17 info='select only truth taus that are isolated.')
18 self.addOption('saveUID', False, type=bool,
19 info='save unique ID in output')
20 # Always skip on data
21 self.setOptionValue('skipOnData', True)
22
23 def instanceName (self) :
24 """Return the instance name for this block"""
25 name = self.containerName
26 if self.selectionName: name = name + '_' + self.selectionName
27 return name
28
29 def makeAlgs(self, config):
30 config.setSourceName (self.containerName, self.containerName)
31
32 # decorate the missing elements of the 4-vector so we can save it later
33 alg = config.createAlgorithm('CP::ParticleLevelPtEtaPhiDecoratorAlg',
34 'ParticleLevelPtEtaPhiDecoratorTaus',
35 reentrant=True)
36 alg.particles = self.containerName
37
38 # decorate the charge so we can save it later
39 alg = config.createAlgorithm('CP::ParticleLevelChargeDecoratorAlg',
40 'ParticleLevelChargeDecoratorTaus',
41 reentrant=True)
42 alg.particles = self.containerName
43
44 # check for prompt isolation and possible origin from tau decays
45 alg = config.createAlgorithm('CP::ParticleLevelIsolationAlg',
46 'ParticleLevelIsolationTaus',
47 reentrant=True)
48 alg.particles = self.containerName
49 alg.isolation = 'isIsolated' + self.selectionName if self.isolated else 'isIsolatedButNotRequired' + self.selectionName
50 alg.notTauOrigin = 'notFromTauButNotRequired' + self.selectionName
51 alg.checkType = 'IsoTau'
52
53 if self.isolated:
54 config.addSelection (self.containerName, self.selectionName, alg.isolation+',as_char')
55
56 # output branches to be scheduled only once
57 if ParticleLevelTausBlock.get_instance_count() == 1 or 'pt' not in config.getOutputVars(self.containerName):
58 outputVars = [
59 ['pt', 'pt'],
60 ['eta', 'eta'],
61 ['phi', 'phi'],
62 ['e', 'e'],
63 ['charge', 'charge'],
64 ]
65 if self.saveUID:
66 outputVars += [['uid', 'uid']]
67 for decoration, branch in outputVars:
68 config.addOutputVar (self.containerName, decoration, branch, noSys=True)