diff --git a/Reconstruction/MET/METReconstruction/Root/METRecoTool.cxx b/Reconstruction/MET/METReconstruction/Root/METRecoTool.cxx index cece244e823593f5753ce7912ac8ad1d57e75606..ac454b15e2e8f1f1e78bb561446e132bcd22bddc 100644 --- a/Reconstruction/MET/METReconstruction/Root/METRecoTool.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METRecoTool.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // METRecoTool.cxx @@ -48,6 +48,8 @@ namespace met { METRecoTool::METRecoTool(const std::string& name) : AsgTool(name), m_doMetSum(false), + m_metbuilders(this), + m_metrefiners(this), m_nevt(0) { declareProperty( "METBuilders", m_metbuilders ); @@ -90,27 +92,8 @@ namespace met { ATH_MSG_INFO ("Will not sum MET in this container."); } - // retrieve builders - for(ToolHandleArray<IMETToolBase>::const_iterator iBuilder=m_metbuilders.begin(); - iBuilder != m_metbuilders.end(); ++iBuilder) { - ToolHandle<IMETToolBase> tool = *iBuilder; - if( tool.retrieve().isFailure() ) { - ATH_MSG_FATAL("Failed to retrieve tool: " << tool->name()); - return StatusCode::FAILURE; - }; - ATH_MSG_INFO("Retrieved tool: " << tool->name() ); - } - - // retrieve refiners - for(ToolHandleArray<IMETToolBase>::const_iterator iRefiner=m_metrefiners.begin(); - iRefiner != m_metrefiners.end(); ++iRefiner) { - ToolHandle<IMETToolBase> tool = *iRefiner; - if( tool.retrieve().isFailure() ) { - ATH_MSG_FATAL("Failed to retrieve tool: " << tool->name()); - return StatusCode::FAILURE; - }; - ATH_MSG_INFO("Retrieved tool: " << tool->name() ); - } + ATH_CHECK( m_metbuilders.retrieve() ); + ATH_CHECK( m_metrefiners.retrieve() ); // generate clocks unsigned int ntool = m_metbuilders.size()+m_metrefiners.size(); diff --git a/Reconstruction/MET/METReconstruction/python/METAssocConfig.py b/Reconstruction/MET/METReconstruction/python/METAssocConfig.py index 4e217139083f6ded89158e5d0d48aa4224d7bbe0..4e4ca3c274ad736d0180b7e805cb02a36e6d379c 100644 --- a/Reconstruction/MET/METReconstruction/python/METAssocConfig.py +++ b/Reconstruction/MET/METReconstruction/python/METAssocConfig.py @@ -1,4 +1,4 @@ -# 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 from GaudiKernel.Constants import INFO @@ -233,9 +233,7 @@ def getMETAssocAlg(algName='METAssociation',configs={},tools=[],msglvl=INFO): assocTools.append(assoctool) metFlags.METAssocTools()[key] = assoctool - from AthenaCommon.AppMgr import ToolSvc for tool in assocTools: - ToolSvc += tool print prefix, 'Added METAssocTool \''+tool.name()+'\' to alg '+algName assocAlg = CfgMgr.met__METRecoAlg(name=algName, diff --git a/Reconstruction/MET/METReconstruction/python/METAssocConfig_readAOD.py b/Reconstruction/MET/METReconstruction/python/METAssocConfig_readAOD.py index 51aa6d682256f85b9f99f905518454ef96e5b5cd..ed9499b25ee1bcd4ff098fc61b1f96720aef1058 100644 --- a/Reconstruction/MET/METReconstruction/python/METAssocConfig_readAOD.py +++ b/Reconstruction/MET/METReconstruction/python/METAssocConfig_readAOD.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration @@ -231,7 +231,6 @@ def getMETAssocAlg(algName='METAssociation',configs={},tools=[]): from AthenaCommon.AppMgr import ToolSvc for tool in assocTools: - ToolSvc += tool print prefix, 'Added METAssocTool \''+tool.name()+'\' to alg '+algName assocAlg = CfgMgr.met__METRecoAlg(name=algName, diff --git a/Reconstruction/MET/METReconstruction/python/METRecoConfig.py b/Reconstruction/MET/METReconstruction/python/METRecoConfig.py index ae0940762fa1beb00e0c5b5e256ea504d407727e..73c5cece643fd27a849ff5bbfecfeffae33dc181 100644 --- a/Reconstruction/MET/METReconstruction/python/METRecoConfig.py +++ b/Reconstruction/MET/METReconstruction/python/METRecoConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from AthenaCommon import CfgMgr @@ -135,8 +135,6 @@ def getBuilder(config,suffix,doTracks,doCells,doTriggerMET,doOriginCorrClus): else: tool.MissingETKey = config.outputKey from AthenaCommon.AppMgr import ToolSvc - if not hasattr(ToolSvc,tool.name()): - ToolSvc += tool return tool ################################################################################# @@ -169,8 +167,6 @@ def getRefiner(config,suffix,trkseltool=None,trkvxtool=None,trkisotool=None,calo if config.type == 'MuonEloss': tool = CfgMgr.met__METMuonElossTool('MET_MuonElossTool_'+suffix) tool.MissingETKey = config.outputKey - if not hasattr(ToolSvc,tool.name()): - ToolSvc += tool return tool ################################################################################# @@ -185,8 +181,6 @@ def getRegions(config,suffix): tool.InputMETKey = config.outputKey tool.RegionValues = [ 1.5, 3.2, 10 ] from AthenaCommon.AppMgr import ToolSvc - if not hasattr(ToolSvc,tool.name()): - ToolSvc += tool return tool ################################################################################# @@ -338,7 +332,6 @@ def getMETRecoAlg(algName='METReconstruction',configs={},tools=[]): from AthenaCommon.AppMgr import ToolSvc for tool in recoTools: - ToolSvc += tool print prefix, 'Added METRecoTool \''+tool.name()+'\' to alg '+algName recoAlg = CfgMgr.met__METRecoAlg(name=algName, diff --git a/Reconstruction/MET/METReconstruction/src/METRecoAlg.cxx b/Reconstruction/MET/METReconstruction/src/METRecoAlg.cxx index 8a0c6e39ff0a52757c5b0d372ae5e0096b2cf9d4..5b31c5cb8952fa650deffe3f538de09c9f7287c0 100644 --- a/Reconstruction/MET/METReconstruction/src/METRecoAlg.cxx +++ b/Reconstruction/MET/METReconstruction/src/METRecoAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // METRecoAlg.cxx @@ -15,7 +15,9 @@ namespace met { METRecoAlg::METRecoAlg(const std::string& name, ISvcLocator* pSvcLocator ) - : ::AthAlgorithm( name, pSvcLocator ) { + : ::AthAlgorithm( name, pSvcLocator ), + m_recotools (this) + { declareProperty( "RecoTools", m_recotools); } @@ -26,19 +28,9 @@ namespace met { //********************************************************************** StatusCode METRecoAlg::initialize() { - ATH_MSG_INFO("Initializing " << name() << "..."); - ATH_MSG_INFO("Retrieving tools..."); + ATH_MSG_VERBOSE("Initializing " << name() << "..."); - // retrieve tools - for(ToolHandleArray<IMETRecoTool>::const_iterator iTool=m_recotools.begin(); - iTool != m_recotools.end(); ++iTool) { - ToolHandle<IMETRecoTool> tool = *iTool; - if( tool.retrieve().isFailure() ) { - ATH_MSG_ERROR("Failed to retrieve tool: " << tool->name()); - return StatusCode::FAILURE; - }; - ATH_MSG_INFO("Retrieved tool: " << tool->name() ); - } + ATH_CHECK( m_recotools.retrieve() ); return StatusCode::SUCCESS; } @@ -46,7 +38,7 @@ namespace met { //********************************************************************** StatusCode METRecoAlg::finalize() { - ATH_MSG_INFO ("Finalizing " << name() << "..."); + ATH_MSG_VERBOSE ("Finalizing " << name() << "..."); return StatusCode::SUCCESS; }