ATLAS Offline Software
egammaMVACalibConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon.Logging import logging
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from xAODEgamma.xAODEgammaParameters import xAOD
7 
8 
9 def egammaMVAToolCfg(flags, **kwargs):
10  acc = ComponentAccumulator()
11  acc.setPrivateTools(CompFactory.egammaMVACalibTool(**kwargs))
12  return acc
13 
14 
15 def egammaMVASvcCfg(flags, name="egammaMVASvc", **kwargs):
16 
17  acc = ComponentAccumulator()
18 
19  kwargs.setdefault("folder", flags.Egamma.Calib.MVAVersion)
20 
21  if "ElectronTool" not in kwargs:
22  kwargs["ElectronTool"] = acc.popToolsAndMerge(
24  flags,
25  name="electronMVATool",
26  ParticleType=xAOD.EgammaParameters.electron,
27  folder=kwargs['folder'])
28  )
29 
30  if "UnconvertedPhotonTool" not in kwargs:
31  kwargs["UnconvertedPhotonTool"] = acc.popToolsAndMerge(
33  flags,
34  name="unconvertedPhotonMVATool",
35  ParticleType=xAOD.EgammaParameters.unconvertedPhoton,
36  folder=kwargs['folder'])
37  )
38 
39  if "ConvertedPhotonTool" not in kwargs:
40  kwargs["ConvertedPhotonTool"] = acc.popToolsAndMerge(
42  flags,
43  name="convertedPhotonMVATool",
44  ParticleType=xAOD.EgammaParameters.convertedPhoton,
45  folder=kwargs['folder'])
46  )
47 
48  acc.addService(
49  CompFactory.egammaMVASvc(
50  name=name,
51  **kwargs), primary=True)
52  return acc
53 
54 
55 if __name__ == "__main__":
56 
57  from AthenaConfiguration.AllConfigFlags import initConfigFlags
58  from AthenaConfiguration.ComponentAccumulator import printProperties
59  from AthenaConfiguration.TestDefaults import defaultTestFiles
60  flags = initConfigFlags()
61  flags.Input.Files = defaultTestFiles.RDO_RUN2
62  flags.fillFromArgs()
63  flags.lock()
64 
66  mlog = logging.getLogger("egammaMVASvcConfigTest")
67  mlog.info("Configuring egammaMVASvc :")
68  printProperties(mlog, cfg.getPrimaryAndMerge(
69  egammaMVASvcCfg(flags,
70  folder=flags.Egamma.Calib.MVAVersion)),
71  nestLevel=1,
72  printDefaults=True)
73  cfg.printConfig()
74 
75  f = open("egmvatools.pkl", "wb")
76  cfg.store(f)
77  f.close()
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.egammaMVACalibConfig.egammaMVASvcCfg
def egammaMVASvcCfg(flags, name="egammaMVASvc", **kwargs)
Definition: egammaMVACalibConfig.py:15
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
python.egammaMVACalibConfig.egammaMVAToolCfg
def egammaMVAToolCfg(flags, **kwargs)
Definition: egammaMVACalibConfig.py:9