ATLAS Offline Software
Loading...
Searching...
No Matches
egammaForwardBuilderConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from ElectronPhotonSelectorTools.EgammaPIDdefs import egammaPID
4from egammaTools.EMTrackMatchBuilderConfig import EMTrackMatchBuilderCfg
5from ElectronPhotonSelectorTools.AsgForwardElectronIsEMSelectorsConfig import (
6 AsgForwardElectronIsEMSelectorCfg)
7from ElectronPhotonSelectorTools.ForwardElectronSelectorConfig import (
8 AsgForwardElectronSelectorToolCfg, AsgForwardElectronCalibrationToolCfg)
9from AthenaCommon.Logging import logging
10from AthenaConfiguration.ComponentFactory import CompFactory
11from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12from egammaTools.egammaOQFlagsBuilderConfig import egammaOQFlagsBuilderCfg
13
14
15def egammaForwardBuilderCfg(flags, name='egammaForwardElectron', **kwargs):
16
17 acc = ComponentAccumulator()
18 extraInputs = []
19
20 if flags.Detector.GeometryITk:
21 kwargs["doTrackMatching"] = True
22 kwargs["doCookieCutting"] = True
23 if flags.Reco.EnableHGTDExtension:
24 if "forwardelectronNNselectors" not in kwargs:
25 LooseFwdElectronSelector_NN = AsgForwardElectronSelectorToolCfg(
26 flags,
27 "LooseForwardNNElectronSelector",
28 "Loose")
29 MediumFwdElectronSelector_NN = AsgForwardElectronSelectorToolCfg(
30 flags,
31 "MediumForwardNNElectronSelector",
32 "Medium")
33 TightFwdElectronSelector_NN = AsgForwardElectronSelectorToolCfg(
34 flags,
35 "TightForwardNNElectronSelector",
36 "Tight")
37
38 kwargs["dofwdDNN"] = True
39 kwargs.setdefault("forwardelectronNNselectors",
40 [LooseFwdElectronSelector_NN.popPrivateTools(),
41 MediumFwdElectronSelector_NN.popPrivateTools(),
42 TightFwdElectronSelector_NN.popPrivateTools()])
43 kwargs.setdefault(
44 "forwardelectronNNselectorResultNames",
45 ["Loose", "Medium", "Tight"])
46 acc.merge(LooseFwdElectronSelector_NN)
47 acc.merge(MediumFwdElectronSelector_NN)
48 acc.merge(TightFwdElectronSelector_NN)
49
50 kwargs["dopTCal"] = True
51 forward_elecpTCalib = AsgForwardElectronCalibrationToolCfg (flags,
52 "forwardelectronNNpTCalib")
53 kwargs.setdefault("forwardelectronNNCalib",forward_elecpTCalib.popPrivateTools())
54 kwargs.setdefault("ExtraInputs", extraInputs)
55 kwargs.setdefault("TrackMatchBuilderTool", acc.popToolsAndMerge(EMTrackMatchBuilderCfg(flags)))
56
57
58 if "forwardelectronIsEMselectors" not in kwargs:
59 LooseFwdElectronSelector = AsgForwardElectronIsEMSelectorCfg(
60 flags,
61 "LooseForwardElectronSelector",
62 egammaPID.ForwardElectronIDLoose)
63 MediumFwdElectronSelector = AsgForwardElectronIsEMSelectorCfg(
64 flags,
65 "MediumForwardElectronSelector",
66 egammaPID.ForwardElectronIDMedium)
67 TightFwdElectronSelector = AsgForwardElectronIsEMSelectorCfg(
68 flags,
69 "TightForwardElectronSelector",
70 egammaPID.ForwardElectronIDTight)
71
72 kwargs.setdefault("forwardelectronIsEMselectors",
73 [LooseFwdElectronSelector.popPrivateTools(),
74 MediumFwdElectronSelector.popPrivateTools(),
75 TightFwdElectronSelector.popPrivateTools()])
76 kwargs.setdefault(
77 "forwardelectronIsEMselectorResultNames",
78 ["Loose", "Medium", "Tight"])
79
80 acc.merge(LooseFwdElectronSelector)
81 acc.merge(MediumFwdElectronSelector)
82 acc.merge(TightFwdElectronSelector)
83
84
85
86 if "ObjectQualityTool" not in kwargs and not flags.Common.isOnline:
87 egOQ = egammaOQFlagsBuilderCfg(flags)
88 kwargs["ObjectQualityTool"] = egOQ.popPrivateTools()
89 acc.merge(egOQ)
90
91 if flags.Egamma.doForwardCalib:
92 kwargs["doEnergyCal"] = True
93 kwargs["PrimaryVerticesContainerKey"] = "PrimaryVertices"
94 kwargs["EventInfoKey"] = "EventInfo"
95 from egammaMVACalib.egammaMVACalibConfig import egammaMVASvcCfg
96 kwargs["MVACalibSvc"] = acc.getPrimaryAndMerge(egammaMVASvcCfg(flags))
97
98 kwargs.setdefault("ElectronOutputName",
99 flags.Egamma.Keys.Output.ForwardElectrons)
100 kwargs.setdefault("TopoClusterName",
101 flags.Egamma.Keys.Internal.ForwardTopoClusters)
102 kwargs.setdefault("ClusterContainerName",
103 flags.Egamma.Keys.Output.ForwardClusters)
104 fwdAlg = CompFactory.egammaForwardBuilder(name, **kwargs)
105
106 acc.addEventAlgo(fwdAlg)
107 return acc
108
109
110if __name__ == "__main__":
111 from AthenaConfiguration.AllConfigFlags import initConfigFlags
112 from AthenaConfiguration.TestDefaults import defaultTestFiles
113 from AthenaConfiguration.ComponentAccumulator import printProperties
114 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
115 flags = initConfigFlags()
116 flags.Input.Files = defaultTestFiles.RDO_RUN2
117 flags.lock()
118
119 acc = MainServicesCfg(flags)
120 mlog = logging.getLogger("egammaForwardBuilderConfigTest")
121 mlog.info("Configuring egammaForwardBuilder: ")
122 acc.merge(egammaForwardBuilderCfg(flags))
123 printProperties(mlog,
124 acc.getEventAlgo("egammaForwardElectron"),
125 nestLevel=1,
126 printDefaults=True)
127 with open("egammaforwardbuilder.pkl", "wb") as f:
128 acc.store(f)
egammaForwardBuilderCfg(flags, name='egammaForwardElectron', **kwargs)