diff --git a/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifier.cxx b/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifier.cxx index 5939e390d9b52a7e417885616d2d9d36743f1e99..cffcca275732bcaca81bc7e9493451a652f1e61f 100644 --- a/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifier.cxx +++ b/PhysicsAnalysis/MCTruthClassifier/Root/MCTruthClassifier.cxx @@ -64,8 +64,8 @@ MCTruthClassifier::MCTruthClassifier(const std::string& type) : asg::AsgTool(type) #ifndef XAOD_ANALYSIS //Add Athena Specific parts in the init list of the constructor , - m_caloExtensionTool("Trk::ParticleCaloExtensionTool/ParticleCaloExtensionTool"), - m_truthInConeTool ("xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool") + m_caloExtensionTool("Trk::ParticleCaloExtensionTool/ParticleCaloExtensionTool", this), + m_truthInConeTool ("xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool", this) #endif { diff --git a/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py b/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py index 1dea579fc1f583ab33d41599ee4d615c90ad82ae..30e4c1a27b70811edf7790f3bcc4eba4140ea10f 100644 --- a/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py +++ b/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py @@ -1,9 +1,52 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -from AthenaCommon import CfgMgr +__doc__ = "Tool configuration to instantiate MCTruthClassifier with default configurations." + +#--------------------------------------- +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from MCTruthClassifier.MCTruthClassifierConf import MCTruthClassifier +from TrackToCalo.TrackToCaloConfig import ParticleCaloExtensionToolCfg + +def MCTruthClassifierCfg(flags, **kwargs): + """ + This is the default configuration allowing all options. + By default, it does not do calo truth matching. + """ + kwargs.setdefault("ParticleCaloExtensionTool","") + return MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs) + +def MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs): + """ + This is the default configuration allowing all options. + By default, it does calo truth matching. + """ + + acc=ComponentAccumulator() + + if "ParticleCaloExtensionTool" not in kwargs: + extAcc = ParticleCaloExtensionToolCfg(flags) + kwargs["ParticleCaloExtensionTool"] = extAcc.popPrivateTools() + acc.merge(extAcc) + + kwargs.setdefault("barcodeG4Shift", flags.Sim.SimBarcodeOffset + 1) + acc.setPrivateTools(MCTruthClassifier(**kwargs)) + return acc + +########################################################## +# The functions below are for the old style and should be +# condsidered deprecated +########################################################## def firstSimCreatedBarcode(): - "Return the simulation barcode offset for G4 particles from metadata" + """DEPRECATED!!! Return the simulation barcode offset for G4 particles from metadata + + In the new configuration scheme use the Sim.SimBarcodeOffset flag instead + """ + + from AthenaCommon.Logging import logging + mlog = logging.getLogger("firstSimCreatedBarcode") + mlog.info("This function should not be used in the new configuration scheme. Use Sim.SimBarcodeOffset flag insted") + offset = 200e3 # Don't try to run the input peeker for a generator job; it will fail @@ -23,9 +66,43 @@ def firstSimCreatedBarcode(): def getMCTruthClassifier(name="MCTruthClassifier", **kwargs): + from AthenaCommon import CfgMgr kwargs.setdefault("barcodeG4Shift", firstSimCreatedBarcode()) return CfgMgr.MCTruthClassifier(name, **kwargs) def getJetMCTruthClassifier(name="JetMCTruthClassifier", **kwargs): + from AthenaCommon import CfgMgr kwargs.setdefault("ParticleCaloExtensionTool","") return getMCTruthClassifier(name, **kwargs) + +########################################################## + +if __name__ == "__main__": + + from AthenaConfiguration.AllConfigFlags import ConfigFlags + from AthenaCommon.Logging import log, logging + from AthenaCommon.Constants import DEBUG + from AthenaCommon.Configurable import Configurable + from AthenaConfiguration.ComponentAccumulator import printProperties + Configurable.configurableRun3Behavior = 1 + log.setLevel(DEBUG) + + ConfigFlags.Input.isMC = True + ConfigFlags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/q221/21.0/myRDO.pool.root"] + ConfigFlags.lock() + + mlog = logging.getLogger("MCTruthClassifierConfigTest") + + cfg = ComponentAccumulator() + + mlog.info("Configuring standard MCTruthClassifier") + acc1 = MCTruthClassifierCfg(ConfigFlags) + printProperties(mlog, acc1.popPrivateTools(), 1) + + mlog.info("Configuring MCTruthClassifier with calo truth matching") + acc2 = MCTruthClassifierCaloTruthMatchCfg(ConfigFlags) + printProperties(mlog, acc2.popPrivateTools(), 1) + + f = open("mctruthclassifer.pkl", "w") + cfg.store(f) + f.close() diff --git a/Reconstruction/egamma/egammaTrackTools/python/egammaTrackToolsConfig.py b/Reconstruction/egamma/egammaTrackTools/python/egammaTrackToolsConfig.py index e275466985765d0adcccea60b6e7732c4f38cf4e..89056968e78e2a11be46bb482b3908f8358d5004 100644 --- a/Reconstruction/egamma/egammaTrackTools/python/egammaTrackToolsConfig.py +++ b/Reconstruction/egamma/egammaTrackTools/python/egammaTrackToolsConfig.py @@ -72,6 +72,6 @@ if __name__ == "__main__": acc.popPrivateTools() cfg.merge(acc) - f = open("egmvatools.pkl", "w") + f = open("egtracktools.pkl", "w") cfg.store(f) f.close() diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py b/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py index ea336d7e8eec98b2965214472db68ac5682b2bbc..f8a30cb28fa41a01b165d3cde18ba473fdd4c2e3 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py @@ -15,6 +15,9 @@ def createSimConfigFlags(): scf.addFlag("Sim.WorldRRange", 12500) #int or float scf.addFlag("Sim.WorldZRange", 22031) #int or float + # the G4 offset. It was never changed, so no need to peek in file + scf.addFlag("Sim.SimBarcodeOffset", 200000) + #for forward region scf.addFlag("Sim.TwissFileBeam1",False) scf.addFlag("Sim.TwissFileBeam2",False)