ATLAS Offline Software
ParticleLevelTausConfig.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 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  # Always skip on data
19  self.setOptionValue('skipOnData', True)
20 
21  def instanceName (self) :
22  """Return the instance name for this block"""
23  return self.containerName + '_' + self.selectionName
24 
25  def makeAlgs(self, config):
26  config.setSourceName (self.containerName, self.containerName)
27 
28  # decorate the missing elements of the 4-vector so we can save it later
29  alg = config.createAlgorithm('CP::ParticleLevelPtEtaPhiDecoratorAlg',
30  'ParticleLevelPtEtaPhiDecoratorTaus',
31  reentrant=True)
32  alg.particles = self.containerName
33 
34  # decorate the charge so we can save it later
35  alg = config.createAlgorithm('CP::ParticleLevelChargeDecoratorAlg',
36  'ParticleLevelChargeDecoratorTaus',
37  reentrant=True)
38  alg.particles = self.containerName
39 
40  # check for prompt isolation and possible origin from tau decays
41  alg = config.createAlgorithm('CP::ParticleLevelIsolationAlg',
42  'ParticleLevelIsolationTaus',
43  reentrant=True)
44  alg.particles = self.containerName
45  alg.isolation = 'isIsolated' + self.selectionName if self.isolated else 'isIsolatedButNotRequired' + self.selectionName
46  alg.notTauOrigin = 'notFromTauButNotRequired' + self.selectionName
47  alg.checkType = 'IsoTau'
48 
49  if self.isolated:
50  config.addSelection (self.containerName, self.selectionName, alg.isolation+',as_char')
51 
52  # output branches to be scheduled only once
53  if ParticleLevelTausBlock.get_instance_count() == 1 or 'pt' not in config.getOutputVars(self.containerName):
54  outputVars = [
55  ['pt', 'pt'],
56  ['eta', 'eta'],
57  ['phi', 'phi'],
58  ['e', 'e'],
59  ['charge', 'charge'],
60  ['IsHadronicTau', 'IsHadronicTau'],
61  ['classifierParticleType', 'type'],
62  ['classifierParticleOrigin', 'origin'],
63  ]
64  for decoration, branch in outputVars:
65  config.addOutputVar (self.containerName, decoration, branch, noSys=True)
ParticleLevelTausConfig.ParticleLevelTausBlock.instanceName
def instanceName(self)
Definition: ParticleLevelTausConfig.py:21
ParticleLevelTausConfig.ParticleLevelTausBlock.makeAlgs
def makeAlgs(self, config)
Definition: ParticleLevelTausConfig.py:25
ParticleLevelTausConfig.ParticleLevelTausBlock.__init__
def __init__(self)
Definition: ParticleLevelTausConfig.py:9
ParticleLevelTausConfig.ParticleLevelTausBlock
Definition: ParticleLevelTausConfig.py:6