ATLAS Offline Software
ParticleLevelPhotonsConfig.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 ParticleLevelPhotonsBlock(ConfigBlock):
7  """ConfigBlock for particle-level truth photons"""
8 
9  def __init__(self):
10  super(ParticleLevelPhotonsBlock, self).__init__()
11  self.addOption('containerName', 'TruthPhotons', type=str,
12  info='the name of the input truth photons 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 photons.')
16  self.addOption('isolated', True, type=bool,
17  info='select only truth photons that are isolated.')
18  self.addOption('isolationVariable', '', type=str,
19  info='variable to use in isolation cuts of the form "var/pT < cut".')
20  self.addOption('isolationCut', -1, type=float,
21  info='threshold to use in isolation cuts of the form "var/pT < cut".')
22  # Always skip on data
23  self.setOptionValue('skipOnData', True)
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', 'ParticleLevelPtEtaPhiDecoratorPhotons' + self.selectionName)
30  alg.particles = self.containerName
31 
32  # check for prompt isolation
33  alg = config.createAlgorithm('CP::ParticleLevelIsolationAlg', 'ParticleLevelIsolationPhotons' + self.selectionName)
34  alg.particles = self.containerName
35  alg.isolation = 'isIsolated' + self.selectionName if self.isolated else 'isIsolatedButNotRequired' + self.selectionName
36  alg.notTauOrigin = 'notFromTauButNotRequired' + self.selectionName
37  alg.checkType = 'IsoPhoton'
38  if self.isolationVariable != '':
39  alg.isoVar = self.isolationVariable
40  alg.isoCut = self.isolationCut
41 
42  if self.isolated:
43  config.addSelection (self.containerName, self.selectionName, alg.isolation+',as_char')
44 
45  # output branches to be scheduled only once
46  if ParticleLevelPhotonsBlock.get_instance_count() == 1:
47  outputVars = [
48  ['pt', 'pt'],
49  ['eta', 'eta'],
50  ['phi', 'phi'],
51  ['e', 'e'],
52  ['classifierParticleType', 'type'],
53  ['classifierParticleOrigin', 'origin'],
54  ]
55  for decoration, branch in outputVars:
56  config.addOutputVar (self.containerName, decoration, branch, noSys=True)
ParticleLevelPhotonsConfig.ParticleLevelPhotonsBlock.__init__
def __init__(self)
Definition: ParticleLevelPhotonsConfig.py:9
ParticleLevelPhotonsConfig.ParticleLevelPhotonsBlock
Definition: ParticleLevelPhotonsConfig.py:6
ParticleLevelPhotonsConfig.ParticleLevelPhotonsBlock.makeAlgs
def makeAlgs(self, config)
Definition: ParticleLevelPhotonsConfig.py:25