diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/CellsInConeThinning.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/CellsInConeThinning.h index ddff34add9cbfcc322c40539547901c82e602183..91f301868d075f6acf63f1abe1e3213ded5b4210 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/CellsInConeThinning.h +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/DerivationFrameworkCalo/CellsInConeThinning.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -15,6 +15,12 @@ #include "xAODCaloEvent/CaloClusterFwd.h" #include "xAODEgamma/EgammaFwd.h" #include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" +#include "xAODEgamma/EgammaContainer.h" +#include "CaloEvent/CaloCellContainer.h" +#include "xAODCaloEvent/CaloCluster.h" + namespace ExpressionParsing { class ExpressionParser; @@ -33,9 +39,11 @@ namespace DerivationFramework { StatusCode addBranches() const; private: - std::string m_SGKey; - std::string m_InputCellsSGKey; - std::string m_OutputClusterSGKey; + SG::ReadHandleKey<xAOD::EgammaContainer> m_SGKey{this, "InputSGKey", "Electrons", "SG key for input container"}; + SG::ReadHandleKey<CaloCellContainer> m_InputCellsSGKey{this, "InputCellsSGKey", "AllCalo", "SG key for input cells container"}; + SG::WriteHandleKey<xAOD::CaloClusterContainer> m_OutputClusterSGKey{this, "OutputClusterSGKey", "EgammaDummyClusters", "SG key for output"}; + SG::WriteHandleKey<CaloClusterCellLinkContainer> m_OutputCellLinkSGKey{this, "OutputCellLinksSGKey", "EgammaDummyCellLink", "SG key for output cell links"}; + std::string m_selectionString; double m_dr; ExpressionParsing::ExpressionParser *m_parser; diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/CellsInConeThinning.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/CellsInConeThinning.cxx index 4735593d3861ebb318c983dbbcc8009b4315eece..a58e9d22ebf5ea1bbff082579a12888969078563 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/CellsInConeThinning.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkCalo/src/CellsInConeThinning.cxx @@ -1,12 +1,9 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ -#include "xAODCaloEvent/CaloCluster.h" #include "CaloUtils/CaloClusterStoreHelper.h" -#include "CaloEvent/CaloCellContainer.h" #include "CaloEvent/CaloCellLinkContainer.h" -#include "xAODEgamma/EgammaContainer.h" #include "ExpressionEvaluation/ExpressionParser.h" #include "ExpressionEvaluation/SGxAODProxyLoader.h" @@ -20,22 +17,21 @@ DerivationFramework::CellsInConeThinning::CellsInConeThinning(const std::string& const std::string& name, const IInterface* parent) : AthAlgTool(type, name, parent), - m_SGKey("Electrons"), - m_InputCellsSGKey("AllCalo"), - m_OutputClusterSGKey("EgammaDummyClusters"), m_selectionString(""), m_dr(0.5), m_parser(0) { declareInterface<DerivationFramework::IAugmentationTool>(this); - declareProperty("InputSGKey", m_SGKey="Electrons"); - declareProperty("InputCellsSGKey",m_InputCellsSGKey="AllCalo"); - declareProperty("OutputClusterSGKey",m_OutputClusterSGKey="dummyCluster"); declareProperty("deltaR",m_dr=0.5); } StatusCode DerivationFramework::CellsInConeThinning::initialize(){ + ATH_CHECK(m_SGKey.initialize()); + ATH_CHECK(m_InputCellsSGKey.initialize()); + ATH_CHECK(m_OutputClusterSGKey.initialize()); + ATH_CHECK(m_OutputCellLinkSGKey.initialize()); + if (m_selectionString!="") { ExpressionParsing::MultipleProxyLoader *proxyLoaders = new ExpressionParsing::MultipleProxyLoader(); proxyLoaders->push_back(new ExpressionParsing::SGxAODProxyLoader(evtStore())); @@ -59,11 +55,11 @@ StatusCode DerivationFramework::CellsInConeThinning::finalize(){ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{ ///Make new container - xAOD::CaloClusterContainer* dummyClusterContainer = CaloClusterStoreHelper::makeContainer(&*evtStore(), - m_OutputClusterSGKey, - msg()); + SG::WriteHandle<xAOD::CaloClusterContainer> dclHdl(m_OutputClusterSGKey); + ATH_CHECK(CaloClusterStoreHelper::AddContainerWriteHandle(&(*evtStore()), dclHdl, msg())); /// Input objects - const xAOD::EgammaContainer* egammas = evtStore()->retrieve< const xAOD::EgammaContainer >(m_SGKey); + SG::ReadHandle<xAOD::EgammaContainer> egHdl(m_SGKey); + const xAOD::EgammaContainer *egammas = egHdl.cptr(); if(!egammas ) { ATH_MSG_ERROR( "Couldn't retrieve egamma container with key: " <<m_SGKey); return StatusCode::FAILURE; @@ -74,7 +70,8 @@ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{ return StatusCode::SUCCESS; } - const CaloCellContainer* cells = evtStore()->retrieve< const CaloCellContainer >(m_InputCellsSGKey); + SG::ReadHandle<CaloCellContainer> cellHdl(m_InputCellsSGKey); + const CaloCellContainer* cells = cellHdl.cptr(); if(!cells) { ATH_MSG_ERROR( "Couldn't retrieve cell container with key: " <<m_InputCellsSGKey); return StatusCode::FAILURE; @@ -94,7 +91,7 @@ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{ if(entries.at(index)==true){ xAOD::CaloCluster *dummy = CaloClusterStoreHelper::makeCluster(cells); DerivationFramework::CellsInCone::egammaSelect(dummy,cells,eg,m_dr); - dummyClusterContainer->push_back(dummy); + dclHdl->push_back(dummy); } ++index; } @@ -104,14 +101,12 @@ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{ for (const xAOD::Egamma* eg : *egammas){ xAOD::CaloCluster *dummy = CaloClusterStoreHelper::makeCluster(cells); DerivationFramework::CellsInCone::egammaSelect(dummy,cells,eg,m_dr); - dummyClusterContainer->push_back(dummy); + dclHdl->push_back(dummy); } } ///Finalize clusters - CHECK( CaloClusterStoreHelper::finalizeClusters(&*evtStore(), - dummyClusterContainer, - m_OutputClusterSGKey, - msg())); + SG::WriteHandle<CaloClusterCellLinkContainer> cellLinks(m_OutputCellLinkSGKey); + ATH_CHECK( CaloClusterStoreHelper::finalizeClusters(cellLinks, dclHdl.ptr())); ///Return return StatusCode::SUCCESS; }