ATLAS Offline Software
egammaForwardBuilderConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from ElectronPhotonSelectorTools.EgammaPIDdefs import egammaPID
4 from egammaTools.EMTrackMatchBuilderConfig import EMTrackMatchBuilderCfg
5 from ElectronPhotonSelectorTools.AsgForwardElectronIsEMSelectorsConfig import (
6  AsgForwardElectronIsEMSelectorCfg)
7 from AthenaCommon.Logging import logging
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10 from egammaTools.egammaOQFlagsBuilderConfig import egammaOQFlagsBuilderCfg
11 
12 
13 def egammaForwardBuilderCfg(flags, name='egammaForwardElectron', **kwargs):
14 
15  acc = ComponentAccumulator()
16 
17  if flags.Detector.GeometryITk:
18  kwargs["doTrackMatching"] = True
19  kwargs["doCookieCutting"] = True
20  kwargs.setdefault("TrackMatchBuilderTool", acc.popToolsAndMerge(EMTrackMatchBuilderCfg(flags)))
21  if "forwardelectronIsEMselectors" not in kwargs:
22  LooseFwdElectronSelector = AsgForwardElectronIsEMSelectorCfg(
23  flags,
24  "LooseForwardElectronSelector",
25  egammaPID.ForwardElectronIDLoose)
26  MediumFwdElectronSelector = AsgForwardElectronIsEMSelectorCfg(
27  flags,
28  "MediumForwardElectronSelector",
29  egammaPID.ForwardElectronIDMedium)
30  TightFwdElectronSelector = AsgForwardElectronIsEMSelectorCfg(
31  flags,
32  "TightForwardElectronSelector",
33  egammaPID.ForwardElectronIDTight)
34 
35  kwargs.setdefault("forwardelectronIsEMselectors",
36  [LooseFwdElectronSelector.popPrivateTools(),
37  MediumFwdElectronSelector.popPrivateTools(),
38  TightFwdElectronSelector.popPrivateTools()])
39  kwargs.setdefault(
40  "forwardelectronIsEMselectorResultNames",
41  ["Loose", "Medium", "Tight"])
42 
43  acc.merge(LooseFwdElectronSelector)
44  acc.merge(MediumFwdElectronSelector)
45  acc.merge(TightFwdElectronSelector)
46 
47  if "ObjectQualityTool" not in kwargs and not flags.Common.isOnline:
48  egOQ = egammaOQFlagsBuilderCfg(flags)
49  kwargs["ObjectQualityTool"] = egOQ.popPrivateTools()
50  acc.merge(egOQ)
51 
52  kwargs.setdefault("ElectronOutputName",
53  flags.Egamma.Keys.Output.ForwardElectrons)
54  kwargs.setdefault("TopoClusterName",
55  flags.Egamma.Keys.Internal.ForwardTopoClusters)
56  kwargs.setdefault("ClusterContainerName",
57  flags.Egamma.Keys.Output.ForwardClusters)
58  fwdAlg = CompFactory.egammaForwardBuilder(name, **kwargs)
59 
60  acc.addEventAlgo(fwdAlg)
61  return acc
62 
63 
64 if __name__ == "__main__":
65  from AthenaConfiguration.AllConfigFlags import initConfigFlags
66  from AthenaConfiguration.TestDefaults import defaultTestFiles
67  from AthenaConfiguration.ComponentAccumulator import printProperties
68  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
69  flags = initConfigFlags()
70  flags.Input.Files = defaultTestFiles.RDO_RUN2
71  flags.lock()
72 
73  acc = MainServicesCfg(flags)
74  mlog = logging.getLogger("egammaForwardBuilderConfigTest")
75  mlog.info("Configuring egammaForwardBuilder: ")
76  acc.merge(egammaForwardBuilderCfg(flags))
77  printProperties(mlog,
78  acc.getEventAlgo("egammaForwardElectron"),
79  nestLevel=1,
80  printDefaults=True)
81  with open("egammaforwardbuilder.pkl", "wb") as f:
82  acc.store(f)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.AsgForwardElectronIsEMSelectorsConfig.AsgForwardElectronIsEMSelectorCfg
def AsgForwardElectronIsEMSelectorCfg(flags, name, quality, menu=forwardelectronPIDmenu.menuMC15)
Definition: AsgForwardElectronIsEMSelectorsConfig.py:14
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
EMTrackMatchBuilderConfig.EMTrackMatchBuilderCfg
def EMTrackMatchBuilderCfg(flags, name='EMTrackMatchBuilder', **kwargs)
Definition: EMTrackMatchBuilderConfig.py:13
egammaForwardBuilderConfig.egammaForwardBuilderCfg
def egammaForwardBuilderCfg(flags, name='egammaForwardElectron', **kwargs)
Definition: egammaForwardBuilderConfig.py:13
egammaOQFlagsBuilderConfig.egammaOQFlagsBuilderCfg
def egammaOQFlagsBuilderCfg(flags, name='egammaOQFlagsBuilder', **kwargs)
Definition: egammaOQFlagsBuilderConfig.py:10
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