diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/GenFilterToolConfig.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/GenFilterToolConfig.py index 896e8dd807d0839d2537b47d9179dc0b42909393..8bf47916f63dc363d7077303c222b73cbeb1dd22 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/GenFilterToolConfig.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/GenFilterToolConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration # Common code for setting up the gen filter tools @@ -10,7 +10,7 @@ def GenFilterToolCfg(flags): acc = ComponentAccumulator() # Set up the MCTruthClassifier - from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import DFCommonMCTruthClassifierCfg + from MCTruthClassifier.MCTruthClassifierConfig import DFCommonMCTruthClassifierCfg acc.merge(DFCommonMCTruthClassifierCfg(flags)) #Save the post-shower HT and MET filter values that will make combining filtered samples easier (adds to the EventInfo) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/TruthDerivationToolsConfig.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/TruthDerivationToolsConfig.py index 0b64bb332f4c9c36f67a8c38d4d06c4611535b68..0ef8824aaa01f21d202ea2bc5eaa107364452e06 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/TruthDerivationToolsConfig.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMCTruth/python/TruthDerivationToolsConfig.py @@ -124,14 +124,6 @@ def TruthD2DecoratorCfg(flags, name, **kwargs): acc.addPublicTool(TruthD2Decorator(name, **kwargs), primary = True) return acc -def DFCommonMCTruthClassifierCfg(flags): - """Configure the MCTruthClassifier tool""" - acc = ComponentAccumulator() - MCTruthClassifier = CompFactory.MCTruthClassifier - acc.addPublicTool(MCTruthClassifier(name = "DFCommonTruthClassifier", ParticleCaloExtensionTool = ""), - primary = True) - return acc - def TruthClassificationDecoratorCfg(flags, name, **kwargs): """Configure the TruthClassificationDecorator tool""" acc = ComponentAccumulator() @@ -218,6 +210,7 @@ def HardScatterCollectionMakerCfg(flags, name, **kwargs): #add the 'decoration' tool to dress the main truth collection with the classification def DFCommonTruthClassificationToolCfg(flags): """dress the main truth collection with the classification""" + from MCTruthClassifier.MCTruthClassifierConfig import DFCommonMCTruthClassifierCfg accMCTC = DFCommonMCTruthClassifierCfg(flags) DFCommonTruthClassifier = accMCTC.getPrimary() acc = TruthClassificationDecoratorCfg(flags, diff --git a/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py b/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py index 7b4499a109eef317761eeaeefb143ae329c5bd04..9ea2b8dca51879ee159d4f8543dcb5968080c910 100644 --- a/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py +++ b/PhysicsAnalysis/MCTruthClassifier/python/MCTruthClassifierConfig.py @@ -4,26 +4,27 @@ __doc__ = """ Tool configuration to instantiate MCTruthClassifier with default configurations.""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.Enums import LHCPeriod -def MCTruthClassifierCfg(flags, **kwargs): + +def MCTruthClassifierCfg(flags, name="MCTruthClassifier", **kwargs): """ This is the default configuration allowing all options. By default, it does not do calo truth matching. """ kwargs.setdefault("ParticleCaloExtensionTool", "") kwargs.setdefault("CaloDetDescrManager", "") - return MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs) + return MCTruthClassifierCaloTruthMatchCfg(flags, name, **kwargs) -def MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs): +def MCTruthClassifierCaloTruthMatchCfg(flags, name="MCTruthClassifier", **kwargs): """ This is the default configuration allowing all options. By default, it does calo truth matching using a dedicated instance of the ParticleCaloExtensionTool """ - from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator - from AthenaConfiguration.Enums import LHCPeriod - acc = ComponentAccumulator() if "ParticleCaloExtensionTool" not in kwargs: @@ -44,19 +45,25 @@ def MCTruthClassifierCaloTruthMatchCfg(flags, **kwargs): if flags.GeoModel.Run >= LHCPeriod.Run4: kwargs.setdefault("FwdElectronUseG4Sel", False) - from AthenaConfiguration.ComponentFactory import CompFactory acc.setPrivateTools(CompFactory.MCTruthClassifier(**kwargs)) return acc +def DFCommonMCTruthClassifierCfg(flags): + """Configure the MCTruthClassifier tool""" + acc = ComponentAccumulator() + acc.addPublicTool(acc.popToolsAndMerge(MCTruthClassifierCfg(flags, name = "DFCommonTruthClassifier")), + primary = True) + return acc + + if __name__ == "__main__": from AthenaConfiguration.AllConfigFlags import initConfigFlags from AthenaConfiguration.TestDefaults import defaultTestFiles from AthenaCommon.Logging import logging - from AthenaConfiguration.ComponentAccumulator import ( - ComponentAccumulator, printProperties) + from AthenaConfiguration.ComponentAccumulator import printProperties flags = initConfigFlags() flags.Input.isMC = True