ATLAS Offline Software
xAODEgammaBuilderConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 """ Instantiate the two supercluster builders with default configuration
4 """
5 
6 from AthenaCommon.Logging import logging
7 from AthenaConfiguration.ComponentFactory import CompFactory
8 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9 
10 from egammaTools.EMClusterToolConfig import EMClusterToolCfg
11 from egammaTools.EMShowerBuilderConfig import EMShowerBuilderCfg
12 from egammaTools.egammaOQFlagsBuilderConfig import egammaOQFlagsBuilderCfg
13 from egammaTools.EMPIDBuilderConfig import (
14  EMPIDBuilderElectronCfg, EMPIDBuilderPhotonCfg)
15 
16 
17 def xAODEgammaBuilderCfg(flags, name='xAODEgammaBuilder',
18  sequenceName = None,
19  **kwargs):
20 
21  seqkw = {'sequence': sequenceName} if sequenceName else {}
22  acc = ComponentAccumulator (**seqkw)
23 
24  if "EMClusterTool" not in kwargs:
25  emclustool = EMClusterToolCfg(flags)
26  kwargs["EMClusterTool"] = acc.popToolsAndMerge(emclustool)
27 
28  if "EMShowerTool" not in kwargs:
29  emshowerbuilder = EMShowerBuilderCfg(flags)
30  kwargs["EMShowerTool"] = acc.popToolsAndMerge(emshowerbuilder)
31 
32  if "ObjectQualityTool" not in kwargs and not flags.Common.isOnline:
33  oqtool = egammaOQFlagsBuilderCfg(flags)
34  kwargs["ObjectQualityTool"] = acc.popToolsAndMerge(oqtool)
35 
36  eleTools = [acc.popToolsAndMerge(EMPIDBuilderElectronCfg(flags))]
37  phoTools = [acc.popToolsAndMerge(EMPIDBuilderPhotonCfg(flags))]
38 
39  kwargs.setdefault(
40  "InputElectronRecCollectionName",
41  flags.Egamma.Keys.Internal.ElectronSuperRecs)
42  kwargs.setdefault(
43  "InputPhotonRecCollectionName",
44  flags.Egamma.Keys.Internal.PhotonSuperRecs)
45  kwargs.setdefault(
46  "ElectronOutputName",
47  flags.Egamma.Keys.Output.Electrons)
48  kwargs.setdefault(
49  "PhotonOutputName",
50  flags.Egamma.Keys.Output.Photons)
51  kwargs.setdefault(
52  "AmbiguityTool",
53  CompFactory.EGammaAmbiguityTool())
54  kwargs.setdefault(
55  "ElectronTools",
56  eleTools)
57  kwargs.setdefault(
58  "PhotonTools",
59  phoTools)
60  kwargs.setdefault(
61  "isTruth",
62  flags.Input.isMC
63  )
64 
65  topoegAlg = CompFactory.xAODEgammaBuilder(name, **kwargs)
66 
67  acc.addEventAlgo(topoegAlg)
68  return acc
69 
70 
71 if __name__ == "__main__":
72  from AthenaConfiguration.AllConfigFlags import initConfigFlags
73  from AthenaConfiguration.TestDefaults import defaultTestFiles
74  from AthenaConfiguration.ComponentAccumulator import printProperties
75  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
76  flags = initConfigFlags()
77  flags.Input.Files = defaultTestFiles.RDO_RUN2
78  flags.lock()
79 
80  acc = MainServicesCfg(flags)
81  acc.merge(xAODEgammaBuilderCfg(flags))
82  mlog = logging.getLogger("xAODEgammaBuilderConfigTest")
83  mlog.info("Configuring xAODEgammaBuilder: ")
84  printProperties(mlog,
85  acc.getEventAlgo("xAODEgammaBuilder"),
86  nestLevel=1,
87  printDefaults=True)
88  with open("xaodegammabuilder.pkl", "wb") as f:
89  acc.store(f)
EMPIDBuilderConfig.EMPIDBuilderElectronCfg
def EMPIDBuilderElectronCfg(flags, name='EMPIDBuilderElectron', **kwargs)
Definition: EMPIDBuilderConfig.py:11
EMShowerBuilderConfig.EMShowerBuilderCfg
def EMShowerBuilderCfg(flags, name='EMShowerBuilder', **kwargs)
Definition: EMShowerBuilderConfig.py:12
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
EMPIDBuilderConfig.EMPIDBuilderPhotonCfg
def EMPIDBuilderPhotonCfg(flags, name='EMPIDBuilderPhoton', **kwargs)
Definition: EMPIDBuilderConfig.py:69
egammaOQFlagsBuilderConfig.egammaOQFlagsBuilderCfg
def egammaOQFlagsBuilderCfg(flags, name='egammaOQFlagsBuilder', **kwargs)
Definition: egammaOQFlagsBuilderConfig.py:10
xAODEgammaBuilderConfig.xAODEgammaBuilderCfg
def xAODEgammaBuilderCfg(flags, name='xAODEgammaBuilder', sequenceName=None, **kwargs)
Definition: xAODEgammaBuilderConfig.py:17
extractSporadic.printProperties
def printProperties(h, q, hLB)
Definition: extractSporadic.py:7
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
EMClusterToolConfig.EMClusterToolCfg
def EMClusterToolCfg(flags, name='EMClusterTool', **kwargs)
Definition: EMClusterToolConfig.py:13