diff --git a/Calorimeter/CaloRec/src/CaloCellMaker.cxx b/Calorimeter/CaloRec/src/CaloCellMaker.cxx index c56c2a07f8bfb277af704aba7ca54609b4e5e886..eaa52f3d10af2ec75c451aa293ab76976d6fb66e 100644 --- a/Calorimeter/CaloRec/src/CaloCellMaker.cxx +++ b/Calorimeter/CaloRec/src/CaloCellMaker.cxx @@ -12,7 +12,7 @@ CREATED: May 11, 2004 PURPOSE: Create a CaloCellContainer by calling a set of tools - sharing interface CaloUtils/ICaloCellMakerTool.h + sharing interface CaloInterface/ICaloCellMakerTool.h FIXME : should see how Chronostat and MemStat report could still be obtained ********************************************************************/ @@ -31,7 +31,6 @@ #include "CaloEvent/CaloCellContainer.h" #include "CLHEP/Units/SystemOfUnits.h" -#include "CxxUtils/make_unique.h" using CLHEP::microsecond; using CLHEP::second; @@ -41,7 +40,7 @@ using CLHEP::second; ///////////////////////////////////////////////////////////////////// CaloCellMaker::CaloCellMaker(const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) , m_chrono("ChronoStatSvc", name) , m_ownPolicy(static_cast<int>(SG::VIEW_ELEMENTS)) , m_caloCellsOutputKey("") @@ -100,26 +99,21 @@ StatusCode CaloCellMaker::initialize() { } -StatusCode CaloCellMaker::execute() { +StatusCode CaloCellMaker::execute (const EventContext& ctx) const { - const EventContext& ctx = Gaudi::Hive::currentContext(); SG::WriteHandle<CaloCellContainer> caloCellsOutput(m_caloCellsOutputKey, ctx); - ATH_CHECK( caloCellsOutput.record(CxxUtils::make_unique<CaloCellContainer>(static_cast<SG::OwnershipPolicy>(m_ownPolicy))) ); - - ToolHandleArray<ICaloCellMakerTool>::iterator itrTool = m_caloCellMakerTools.begin(); - ToolHandleArray<ICaloCellMakerTool>::iterator endTool = m_caloCellMakerTools.end(); + ATH_CHECK( caloCellsOutput.record(std::make_unique<CaloCellContainer>(static_cast<SG::OwnershipPolicy>(m_ownPolicy))) ); // loop on tools // note that finalization and checks are also done with tools - // ++m_evCounter; - for (; itrTool != endTool; ++itrTool) { - ATH_MSG_DEBUG( "Calling tool " << itrTool->name() ); + for (const ToolHandle<ICaloCellMakerTool>& tool : m_caloCellMakerTools) { + ATH_MSG_DEBUG( "Calling tool " << tool.name() ); - std::string chronoName = this->name() + "_" + itrTool->name(); + std::string chronoName = this->name() + "_" + tool.name(); m_chrono->chronoStart(chronoName); - StatusCode sc = (*itrTool)->process(caloCellsOutput.ptr(), ctx); + StatusCode sc = tool->process(caloCellsOutput.ptr(), ctx); m_chrono->chronoStop(chronoName); ATH_MSG_DEBUG( "Chrono stop : delta " @@ -127,7 +121,7 @@ StatusCode CaloCellMaker::execute() { << " second " ); if (sc.isFailure()) { - ATH_MSG_ERROR( "Error executing tool " << itrTool->name() ); + ATH_MSG_ERROR( "Error executing tool " << tool.name() ); } } diff --git a/Calorimeter/CaloRec/src/CaloCellMaker.h b/Calorimeter/CaloRec/src/CaloCellMaker.h index 9aaf7ce3323d7d67cb3ed428c18a82e3ac83792a..b57dc4a029119fc1d552a806d47e70cf798f8cb5 100644 --- a/Calorimeter/CaloRec/src/CaloCellMaker.h +++ b/Calorimeter/CaloRec/src/CaloCellMaker.h @@ -24,7 +24,7 @@ //#include "GaudiKernel/IChronoStatSvc.h" // Athena includes -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "StoreGate/WriteHandleKey.h" // Calo includes @@ -34,16 +34,16 @@ class IChronoStatSvc; class ICaloCellMakerTool; class CaloCellContainer; -class CaloCellMaker: public AthAlgorithm { +class CaloCellMaker: public AthReentrantAlgorithm { public: CaloCellMaker(const std::string& name, ISvcLocator* pSvcLocator); - ~CaloCellMaker(); + virtual ~CaloCellMaker(); - StatusCode initialize(); - StatusCode execute(); - StatusCode finalize(); + virtual StatusCode initialize() override; + virtual StatusCode execute (const EventContext& ctx) const override; + virtual StatusCode finalize() override; private: diff --git a/Calorimeter/CaloRec/src/CaloConstCellMaker.cxx b/Calorimeter/CaloRec/src/CaloConstCellMaker.cxx index 872ca23bbd31fa444dace248a99eaf76852ad448..8a8447cb4e5cee79e1ab60e5a57faed330957c5a 100644 --- a/Calorimeter/CaloRec/src/CaloConstCellMaker.cxx +++ b/Calorimeter/CaloRec/src/CaloConstCellMaker.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 */ // $Id$ @@ -31,10 +31,9 @@ using CLHEP::second; */ CaloConstCellMaker::CaloConstCellMaker (const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator), + : AthReentrantAlgorithm(name, pSvcLocator), m_caloCellsOutputKey(""), - m_chrono("ChronoStatSvc", name), - m_evCounter(0) + m_chrono("ChronoStatSvc", name) { declareProperty("OwnPolicy", m_ownPolicy = static_cast<int>(SG::VIEW_ELEMENTS), "Will the new container own its cells? Default is no."); @@ -74,21 +73,19 @@ StatusCode CaloConstCellMaker::initialize() /** * @brief Standard Gaudi execute method. */ -StatusCode CaloConstCellMaker::execute() +StatusCode CaloConstCellMaker::execute (const EventContext& ctx) const { // Create empty container. - SG::WriteHandle<CaloConstCellContainer> theContainer( m_caloCellsOutputKey); + SG::WriteHandle<CaloConstCellContainer> theContainer( m_caloCellsOutputKey, ctx); ATH_CHECK( theContainer.record (std::make_unique<CaloConstCellContainer>(static_cast<SG::OwnershipPolicy>(m_ownPolicy))) ); - ++m_evCounter; - // Loop on tools. // Note that finalization and checks are also done with tools. for (auto& tool : m_caloCellMakerTools) { // For performance reasons want to remove the cell-checker tool // from the list of tools after the fifth event. - if (m_evCounter > 5) { + if (ctx.evt() > 5) { if (tool.typeAndName() == "CaloCellContainerCheckerTool/CaloCellContainerCheckerTool") continue; } @@ -101,7 +98,7 @@ StatusCode CaloConstCellMaker::execute() sc.ignore(); { Athena::Chrono (chronoName, &*m_chrono); - sc = tool->process(theContainer.ptr()); + sc = tool->process(theContainer.ptr(), ctx); } ATH_MSG_DEBUG( "Chrono stop : delta " diff --git a/Calorimeter/CaloRec/src/CaloConstCellMaker.h b/Calorimeter/CaloRec/src/CaloConstCellMaker.h index bbc58121ca4e25f8fe96d73ae5f2705b2a0682d9..3a593a220b788280aa08ef103544ee7e4b27b202 100644 --- a/Calorimeter/CaloRec/src/CaloConstCellMaker.h +++ b/Calorimeter/CaloRec/src/CaloConstCellMaker.h @@ -1,7 +1,7 @@ // This file's extension implies that it's C, but it's really -*- 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 */ // $Id$ @@ -17,7 +17,7 @@ #define CALOREC_CALOCONSTCELLMAKER_H -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" #include "CaloEvent/CaloConstCellContainer.h" @@ -33,7 +33,7 @@ class ICaloConstCellMakerTool; * cell pointers between containers. */ class CaloConstCellMaker - : public AthAlgorithm + : public AthReentrantAlgorithm { public: /** @@ -48,7 +48,7 @@ public: virtual StatusCode initialize() override; /// Standard Gaudi execute method. - virtual StatusCode execute() override; + virtual StatusCode execute(const EventContext& ctx) const override; private: @@ -63,9 +63,6 @@ private: /// For timekeeping. ServiceHandle<IChronoStatSvc> m_chrono; - - /// Count events processed, for statistics. - unsigned m_evCounter; }; diff --git a/Calorimeter/CaloRec/test/CaloCellContainerFromClusterTool_test.cxx b/Calorimeter/CaloRec/test/CaloCellContainerFromClusterTool_test.cxx index 0324f8a0fd315e4f31a7086fa02273879db34599..592ee40629c50f62f12c22111004400e13d49223 100644 --- a/Calorimeter/CaloRec/test/CaloCellContainerFromClusterTool_test.cxx +++ b/Calorimeter/CaloRec/test/CaloCellContainerFromClusterTool_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /* */ @@ -156,7 +156,7 @@ void make_cluster_lists (StoreGateSvc& sg, } -void test1 (CaloTester& calotest, StoreGateSvc& sg) +void test1 (CaloTester& calotest, StoreGateSvc& sg, const EventContext& ctx) { std::cout << "test1\n"; @@ -175,7 +175,7 @@ void test1 (CaloTester& calotest, StoreGateSvc& sg) assert( tool.retrieve().isSuccess() ); CaloConstCellContainer ccc (SG::VIEW_ELEMENTS); - assert( tool->process (&ccc).isSuccess() ); + assert( tool->process (&ccc, ctx).isSuccess() ); assert (ccc.size() == usedCells1.size()); for (const CaloCell* cell : ccc) { assert (usedCells1.count (cell->caloDDE()->calo_hash()) == 1); @@ -188,7 +188,7 @@ void test1 (CaloTester& calotest, StoreGateSvc& sg) assert( tool.retrieve().isSuccess() ); CaloConstCellContainer ccc (SG::VIEW_ELEMENTS); - assert( tool->process (&ccc).isSuccess() ); + assert( tool->process (&ccc, ctx).isSuccess() ); assert (ccc.size() == usedCells.size()); for (const CaloCell* cell : ccc) { assert (usedCells.count (cell->caloDDE()->calo_hash()) == 1); @@ -201,7 +201,7 @@ void test1 (CaloTester& calotest, StoreGateSvc& sg) assert( tool.retrieve().isSuccess() ); CaloConstCellContainer ccc (SG::VIEW_ELEMENTS); - assert( tool->process (&ccc).isSuccess() ); + assert( tool->process (&ccc, ctx).isSuccess() ); assert (ccc.size() == usedCells.size() + otherCells.size()); for (const CaloCell* cell : ccc) { assert (usedCells.count (cell->caloDDE()->calo_hash()) + @@ -227,7 +227,7 @@ int main (int /*argc*/, char** argv) ctx.setExtension( Atlas::ExtendedEventContext (&*sg, 0) ); Gaudi::Hive::setCurrentContext (ctx); - test1 (calotest, *sg); + test1 (calotest, *sg, ctx); return 0; }