ATLAS Offline Software
egammaTruthAssociationConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from MCTruthClassifier.MCTruthClassifierConfig import (
4  MCTruthClassifierCaloTruthMatchCfg)
5 __doc__ = "Configure egammaTruthAssociation"
6 
7 from AthenaCommon.Logging import logging
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10 
11 
12 def egammaTruthAssociationCfg(flags, name='egammaTruthAssociation',
13  sequenceName = None,
14  **kwargs):
15 
16  seqkw = {'sequence': sequenceName} if sequenceName else {}
17  acc = ComponentAccumulator (**seqkw)
18 
19  if "MCTruthClassifier" not in kwargs:
20  kwargs["MCTruthClassifier"] = acc.popToolsAndMerge(
22 
23  kwargs.setdefault(
24  "ClusterContainerName",
25  flags.Egamma.Keys.Output.CaloClusters)
26  kwargs.setdefault(
27  "ElectronContainerName",
28  flags.Egamma.Keys.Output.Electrons)
29  kwargs.setdefault(
30  "PhotonContainerName",
31  flags.Egamma.Keys.Output.Photons)
32  kwargs.setdefault(
33  "FwdElectronContainerName",
34  flags.Egamma.Keys.Output.ForwardElectrons)
35  kwargs.setdefault(
36  "TruthEventContainerName",
37  flags.Egamma.Keys.Input.TruthEvents)
38  kwargs.setdefault(
39  "TruthParticleContainerName",
40  flags.Egamma.Keys.Input.TruthParticles)
41  kwargs.setdefault(
42  "EgammaTruthContainerName",
43  flags.Egamma.Keys.Output.TruthParticles)
44  kwargs.setdefault(
45  "MatchForwardElectrons",
46  flags.Egamma.doForward)
47 
48  egtruthAlg = CompFactory.egammaTruthAssociationAlg(name, **kwargs)
49 
50  acc.addEventAlgo(egtruthAlg)
51  return acc
52 
53 
54 if __name__ == "__main__":
55  from AthenaConfiguration.AllConfigFlags import initConfigFlags
56  from AthenaConfiguration.TestDefaults import defaultTestFiles
57  from AthenaConfiguration.ComponentAccumulator import printProperties
58  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
59  flags = initConfigFlags()
60  flags.Input.Files = defaultTestFiles.RDO_RUN2
61  flags.lock()
62  acc = MainServicesCfg(flags)
63  mlog = logging.getLogger("egammaTruthAssociationConfigTest")
64  mlog.info("Configuring egammaTruthAssociation: ")
65  acc.merge(egammaTruthAssociationCfg(flags))
66  printProperties(mlog,
67  acc.getEventAlgo("egammaTruthAssociation"),
68  nestLevel=1,
69  printDefaults=True)
70  with open("egammatruthassociation.pkl", "wb") as f:
71  acc.store(f)
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
extractSporadic.printProperties
def printProperties(h, q, hLB)
Definition: extractSporadic.py:8
Trk::open
@ open
Definition: BinningType.h:40
MCTruthClassifierConfig.MCTruthClassifierCaloTruthMatchCfg
def MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs)
Definition: MCTruthClassifier/python/MCTruthClassifierConfig.py:18
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
egammaTruthAssociationConfig.egammaTruthAssociationCfg
def egammaTruthAssociationCfg(flags, name='egammaTruthAssociation', sequenceName=None, **kwargs)
Definition: egammaTruthAssociationConfig.py:12