ATLAS Offline Software
Loading...
Searching...
No Matches
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
6from AthenaCommon.Logging import logging
7from AthenaConfiguration.ComponentFactory import CompFactory
8from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9
10from egammaTools.EMClusterToolConfig import EMClusterToolCfg
11from egammaTools.EMShowerBuilderConfig import EMShowerBuilderCfg
12from egammaTools.egammaOQFlagsBuilderConfig import egammaOQFlagsBuilderCfg
13from egammaTools.EMPIDBuilderConfig import (
14 EMPIDBuilderElectronCfg, EMPIDBuilderPhotonCfg)
15
16
17def 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
71if __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)
xAODEgammaBuilderCfg(flags, name='xAODEgammaBuilder', sequenceName=None, **kwargs)