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