ATLAS Offline Software
Loading...
Searching...
No Matches
ThinGeantTruthConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3__doc__ = """
4 Instantiate the TRT Standalone Thinning
5 """
6
7from AthenaCommon.Logging import logging
8from AthenaConfiguration.ComponentFactory import CompFactory
9from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10from AthenaConfiguration.Enums import LHCPeriod
11
12def ThinGeantTruthCfg(flags, name="ThinGeantTruthAlg", **kwargs):
13
14 mlog = logging.getLogger(name)
15 mlog.info("Starting Geant4 Truth Thinning configuration")
16 acc = ComponentAccumulator()
17 kwargs.setdefault("StreamName", "StreamAOD")
18 kwargs.setdefault("keepEGamma", flags.Reco.EnableEgamma)
19 kwargs.setdefault("keepMuons", flags.Reco.EnableCombinedMuon)
20 if flags.GeoModel.Run >= LHCPeriod.Run4:
21 kwargs.setdefault("EtaMaxEGammaTruth", 4.1)
22 kwargs.setdefault("FwdElectronsKey", "ForwardElectrons")
23 if flags.Tracking.doLargeD0:
24 kwargs.setdefault("LRTElectronsKey",
25 f"LRT{flags.Egamma.Keys.Output.Electrons}")
26 kwargs.setdefault("LRTMuonsKey", "MuonsLRT")
27
28 acc.addEventAlgo(CompFactory.ThinGeantTruthAlg(name, **kwargs))
29 mlog.info("Geant4 Truth Thinning configured")
30 return acc
31
32
33if __name__ == "__main__":
34 from AthenaConfiguration.AllConfigFlags import initConfigFlags
35 from AthenaConfiguration.TestDefaults import defaultTestFiles
36 from AthenaConfiguration.ComponentAccumulator import printProperties
37 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
38 flags = initConfigFlags()
39 flags.Input.Files = defaultTestFiles.RDO_RUN2
40 flags.Output.doWriteAOD = True # To test the AOD parts
41 flags.lock()
42 acc = MainServicesCfg(flags)
43 acc.merge(ThinGeantTruthCfg(flags))
44 mlog = logging.getLogger("ThinGeantTruthConfigTest")
45 printProperties(
46 mlog,
47 acc.getEventAlgo("ThinGeantTruthAlg"),
48 nestLevel=1,
49 printDefaults=True,
50 )
51
52 with open("thingeanttruchcfg.pkl", "wb") as f:
53 acc.store(f)
ThinGeantTruthCfg(flags, name="ThinGeantTruthAlg", **kwargs)