ATLAS Offline Software
EGammaLRTConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 # ********************************************************************
4 # EGammaLRTConfig.py
5 # Configures all tools needed for LRT e-gamma object selection and sets
6 # up the kernel algorithms so the results can be accessed/written to
7 # the DAODs. Copied and modified from EGammaCommonConfig.py.
8 # Component accumulator version.
9 # ********************************************************************
10 
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 
14 
15 def EGammaLRTCfg(ConfigFlags):
16  """Main config method for LRT e-gamma decorations"""
17 
18  acc = ComponentAccumulator()
19 
20  # ====================================================================
21  # DISPLACED ELECTRON LH SELECTORS
22  # see Reconstruction/egamma/egammaTools/python/EMPIDBuilderBase.py
23  # on how to configure the selectors
24  # ====================================================================
25  # Setting conf file not supported. These are currently setup in the
26  # LLP1.py config TODO: implement common ID in egamma tools
27 
28  # ====================================================================
29  # ELECTRON CHARGE SELECTION
30  # ====================================================================
31  if not hasattr(acc, "ElectronChargeIDSelectorLoose"):
32  if ConfigFlags.Derivation.Egamma.addECIDS:
33  from ElectronPhotonSelectorTools.AsgElectronChargeIDSelectorToolConfig import (
34  AsgElectronChargeIDSelectorToolCfg,
35  )
36 
37  ElectronChargeIDSelector = acc.popToolsAndMerge(
39  ConfigFlags, name="ElectronChargeIDSelectorLoose"
40  )
41  )
42  ElectronChargeIDSelector.primaryVertexContainer = "PrimaryVertices"
43  ElectronChargeIDSelector.TrainingFile = (
44  "ElectronPhotonSelectorTools/ChargeID/"
45  + "ECIDS_20180731rel21Summer2018.root"
46  )
47  acc.addPublicTool(ElectronChargeIDSelector)
48 
49  # ====================================================================
50  # AUGMENTATION TOOLS
51  # ====================================================================
52  from DerivationFrameworkEGamma.EGammaToolsConfig import (
53  EGElectronLikelihoodToolWrapperCfg,
54  )
55 
56  # decorate electrons with the output of LH very loose
57  # TODO same as above, update with central ID
58 
59  # decorate electrons with the output of ECIDS
60  if ConfigFlags.Derivation.Egamma.addECIDS:
61  LRTElectronPassECIDS = acc.getPrimaryAndMerge(
63  ConfigFlags,
64  name="LRTElectronPassECIDS",
65  EGammaElectronLikelihoodTool=ElectronChargeIDSelector,
66  EGammaFudgeMCTool="",
67  CutType="",
68  StoreGateEntryName="DFCommonElectronsECIDS",
69  ContainerName="LRTElectrons",
70  StoreTResult=True,
71  )
72  )
73 
74  # decorate central electrons and photons with a flag to tell the the
75  # candidates are affected by the crack bug in mc16a and data 2015+2016
76  from DerivationFrameworkEGamma.EGammaToolsConfig import EGCrackVetoCleaningToolCfg
77 
78  LRTElectronPassCrackVeto = acc.getPrimaryAndMerge(
80  ConfigFlags,
81  name="LRTElectronPassCrackVeto",
82  StoreGateEntryName="DFCommonCrackVetoCleaning",
83  ContainerName="LRTElectrons",
84  )
85  )
86 
87  # decorate some electrons with an additional ambiguity flag
88  # against internal and early material conversion
89  from DerivationFrameworkEGamma.EGammaToolsConfig import EGElectronAmbiguityToolCfg
90 
91  LRTElectronAmbiguity = acc.getPrimaryAndMerge(
93  ConfigFlags,
94  name="LRTElectronAdditionnalAmbiguity",
95  idCut="DFCommonElectronsLHLooseNoPix",
96  ContainerName="LRTElectrons",
97  isMC=ConfigFlags.Input.isMC,
98  )
99  )
100 
101  # list of all the decorators so far
102  LRTEGAugmentationTools = [LRTElectronPassCrackVeto, LRTElectronAmbiguity]
103  if ConfigFlags.Derivation.Egamma.addECIDS:
104  LRTEGAugmentationTools.extend([LRTElectronPassECIDS])
105 
106  # ==================================================
107  # Truth Related tools
108  if ConfigFlags.Input.isMC:
109  # Decorate Electron with bkg electron type/origin
110  from MCTruthClassifier.MCTruthClassifierConfig import MCTruthClassifierCfg
111 
112  BkgElectronMCTruthClassifier = acc.popToolsAndMerge(
114  ConfigFlags,
115  name="BkgElectronMCTruthClassifier",
116  ParticleCaloExtensionTool="",
117  )
118  )
119  acc.addPublicTool(BkgElectronMCTruthClassifier)
120 
121  from DerivationFrameworkEGamma.EGammaToolsConfig import (
122  BkgElectronClassificationCfg,
123  )
124 
125  BkgLRTElectronClassificationTool = acc.getPrimaryAndMerge(
127  ConfigFlags,
128  name="BkgLRTElectronClassificationTool",
129  MCTruthClassifierTool=BkgElectronMCTruthClassifier,
130  ElectronContainerName="LRTElectrons",
131  )
132  )
133  LRTEGAugmentationTools.append(BkgLRTElectronClassificationTool)
134 
135  # =======================================
136  # CREATE THE DERIVATION KERNEL ALGORITHM
137  # =======================================
138 
139  acc.addEventAlgo(
140  CompFactory.DerivationFramework.CommonAugmentation(
141  "EGammaLRTKernel", AugmentationTools=LRTEGAugmentationTools
142  )
143  )
144 
145  # =======================================
146  # ADD TOOLS : custom electron, photon and muon track isolation
147  # =======================================
148  from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
149 
150  acc.merge(
152  ConfigFlags, object_types=("Electrons", "Muons"), postfix="LRT"
153  )
154  )
155 
156  if not hasattr(acc, "LRTElectronCaloIsolationBuilder"):
157  from IsolationAlgs.IsolationSteeringDerivConfig import (
158  LRTElectronIsolationSteeringDerivCfg,
159  )
160 
161  acc.merge(LRTElectronIsolationSteeringDerivCfg(ConfigFlags))
162 
163  from IsolationAlgs.IsolationBuilderConfig import egIsolationCfg
164 
165  acc.merge(
167  ConfigFlags,
168  name="electronIsolationLRT",
169  # Avoid overlap with the previously-configured IsolationBuilder.
170  noCalo=True,
171  ElectronCollectionContainerName="LRTElectrons",
172  )
173  )
174 
175  return acc
MCTruthClassifierConfig.MCTruthClassifierCfg
def MCTruthClassifierCfg(flags, **kwargs)
Definition: MCTruthClassifier/python/MCTruthClassifierConfig.py:8
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.EGammaLRTConfig.EGammaLRTCfg
def EGammaLRTCfg(ConfigFlags)
Definition: EGammaLRTConfig.py:15
python.EGammaToolsConfig.EGElectronAmbiguityToolCfg
def EGElectronAmbiguityToolCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:60
IsolationSteeringDerivConfig.LRTElectronIsolationSteeringDerivCfg
def LRTElectronIsolationSteeringDerivCfg(flags, name='LRTElectronCaloIsolationSteeringDeriv')
Definition: IsolationSteeringDerivConfig.py:60
python.AsgElectronChargeIDSelectorToolConfig.AsgElectronChargeIDSelectorToolCfg
def AsgElectronChargeIDSelectorToolCfg(ConfigFlags, name, **kwargs)
Definition: AsgElectronChargeIDSelectorToolConfig.py:6
IsolationBuilderConfig.egIsolationCfg
def egIsolationCfg(flags, name='egIsolation', noCalo=False, **kwargs)
Definition: IsolationBuilderConfig.py:11
python.EGammaToolsConfig.EGElectronLikelihoodToolWrapperCfg
def EGElectronLikelihoodToolWrapperCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:31
python.EGammaToolsConfig.BkgElectronClassificationCfg
def BkgElectronClassificationCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:69
DerivationTrackIsoConfig.DerivationTrackIsoCfg
def DerivationTrackIsoCfg(flags, **jwarg)
Definition: DerivationTrackIsoConfig.py:11
python.EGammaToolsConfig.EGCrackVetoCleaningToolCfg
def EGCrackVetoCleaningToolCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:51