ATLAS Offline Software
MCTruthClassifier/python/MCTruthClassifierConfig.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  Tool configuration to instantiate MCTruthClassifier
5  with default configurations."""
6 
7 
8 def MCTruthClassifierCfg(flags, **kwargs):
9  """
10  This is the default configuration allowing all options.
11  By default, it does not do calo truth matching.
12  """
13  kwargs.setdefault("ParticleCaloExtensionTool", "")
14  kwargs.setdefault("CaloDetDescrManager", "")
15  return MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs)
16 
17 
19  """
20  This is the default configuration allowing all options.
21  By default, it does calo truth matching using a
22  dedicated instance of the ParticleCaloExtensionTool
23  """
24  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
25  from AthenaConfiguration.Enums import LHCPeriod
26 
27  acc = ComponentAccumulator()
28 
29  if "ParticleCaloExtensionTool" not in kwargs:
30 
31  from TrkConfig.AtlasExtrapolatorConfig import (
32  MCTruthClassifierExtrapolatorCfg)
33  extrapolator = acc.popToolsAndMerge(
35 
36  from TrackToCalo.TrackToCaloConfig import (
37  EMParticleCaloExtensionToolCfg)
39  flags, Extrapolator=extrapolator)
40  kwargs["ParticleCaloExtensionTool"] = acc.popToolsAndMerge(extension)
41 
42  kwargs.setdefault("CaloDetDescrManager", "CaloDetDescrManager")
43 
44  if flags.GeoModel.Run >= LHCPeriod.Run4:
45  kwargs.setdefault("FwdElectronUseG4Sel", False)
46 
47  from AthenaConfiguration.ComponentFactory import CompFactory
48  acc.setPrivateTools(CompFactory.MCTruthClassifier(**kwargs))
49  return acc
50 
51 
52 if __name__ == "__main__":
53 
54  from AthenaConfiguration.AllConfigFlags import initConfigFlags
55  from AthenaConfiguration.TestDefaults import defaultTestFiles
56  from AthenaCommon.Logging import logging
57 
58  from AthenaConfiguration.ComponentAccumulator import (
59  ComponentAccumulator, printProperties)
60 
61  flags = initConfigFlags()
62  flags.Input.isMC = True
63  flags.Input.Files = defaultTestFiles.RDO_RUN2
64  flags.lock()
65 
66  mlog = logging.getLogger("MCTruthClassifierConfigTest")
67 
69 
70  mlog.info("Configuring standard MCTruthClassifier")
71  printProperties(mlog,
72  cfg.getPrimaryAndMerge(
73  MCTruthClassifierCfg(flags)),
74  nestLevel=1,
75  printDefaults=True)
76 
77  mlog.info("Configuring MCTruthClassifier with calo truth matching")
78  printProperties(mlog,
79  cfg.getPrimaryAndMerge(
81  nestLevel=1,
82  printDefaults=True)
83 
84  f = open("mctruthclassifer.pkl", "wb")
85  cfg.store(f)
86  f.close()
MCTruthClassifierConfig.MCTruthClassifierCfg
def MCTruthClassifierCfg(flags, **kwargs)
Definition: MCTruthClassifier/python/MCTruthClassifierConfig.py:8
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.AtlasExtrapolatorConfig.MCTruthClassifierExtrapolatorCfg
def MCTruthClassifierExtrapolatorCfg(flags, name='MCTruthClassifierExtrapolator')
Definition: AtlasExtrapolatorConfig.py:277
extractSporadic.printProperties
def printProperties(h, q, hLB)
Definition: extractSporadic.py:8
Trk::open
@ open
Definition: BinningType.h:40
MCTruthClassifierConfig.MCTruthClassifierCaloTruthMatchCfg
def MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs)
Definition: MCTruthClassifier/python/MCTruthClassifierConfig.py:18
TrackToCaloConfig.EMParticleCaloExtensionToolCfg
def EMParticleCaloExtensionToolCfg(flags, name='EMParticleCaloExtensionTool', **kwargs)
Definition: TrackToCaloConfig.py:30
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19