diff --git a/Control/AthenaKernel/AthenaKernel/IAthenaOutputTool.h b/Control/AthenaKernel/AthenaKernel/IAthenaOutputTool.h index 3335f0c4a55c1f57690ed67ecb01488eee9e96c8..a9b5f22da5ee8ca7fcfd5502ce256187104f320c 100644 --- a/Control/AthenaKernel/AthenaKernel/IAthenaOutputTool.h +++ b/Control/AthenaKernel/AthenaKernel/IAthenaOutputTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENAKERNEL_IATHENAOUTPUTTOOL_H @@ -27,6 +27,8 @@ public: virtual StatusCode postInitialize() = 0; /// Called at the beginning of execute virtual StatusCode preExecute() = 0; + /// Called before actually streaming objects. + virtual StatusCode preStream() = 0; /// Called at the end of execute virtual StatusCode postExecute() = 0; /// Called at the beginning of finalize diff --git a/Control/AthenaServices/src/AthenaOutputStream.cxx b/Control/AthenaServices/src/AthenaOutputStream.cxx index 70644ec3b4352f575a13ebba78735fa351ecdd14..09cf7a3e3407b4f12b176a7403747cf594e197d3 100644 --- a/Control/AthenaServices/src/AthenaOutputStream.cxx +++ b/Control/AthenaServices/src/AthenaOutputStream.cxx @@ -202,104 +202,50 @@ AthenaOutputStream::~AthenaOutputStream() { // initialize data writer StatusCode AthenaOutputStream::initialize() { - StatusCode status(StatusCode::FAILURE); - StatusCode baseStatus = this->FilteredAlgorithm::initialize(); + ATH_CHECK( this->FilteredAlgorithm::initialize() ); ATH_MSG_DEBUG("In initialize"); // Reset the number of events written m_events = 0; // set up the SG service: - status = m_dataStore.retrieve(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not locate default store"); - return(status); - } else { - ATH_MSG_DEBUG("Found " << m_dataStore.typeAndName() << " store."); - } + ATH_CHECK( m_dataStore.retrieve() ); + ATH_MSG_DEBUG("Found " << m_dataStore.typeAndName() << " store."); assert(static_cast<bool>(m_dataStore)); if (!m_metadataItemList.value().empty()) { - status = m_metadataStore.retrieve(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not locate metadata store"); - return(status); - } else { - ATH_MSG_DEBUG("Found " << m_metadataStore.typeAndName() << " store."); - } + ATH_CHECK( m_metadataStore.retrieve() ); + ATH_MSG_DEBUG("Found " << m_metadataStore.typeAndName() << " store."); assert(static_cast<bool>(m_metadataStore)); } // set up the CLID service: - status = m_pCLIDSvc.retrieve(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not locate default ClassIDSvc"); - return(status); - } + ATH_CHECK( m_pCLIDSvc.retrieve() ); // set up the ItemListSvc service: assert(static_cast<bool>(m_pCLIDSvc)); - status = m_itemSvc.retrieve(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not locate default ItemListSvc"); - return(status); - } + ATH_CHECK( m_itemSvc.retrieve() ); assert(static_cast<bool>(m_itemSvc)); // set up the OutputStreamSequencer service: - status = m_outSeqSvc.retrieve(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not locate OutputStreamSequencerSvc"); - return(status); - } + ATH_CHECK( m_outSeqSvc.retrieve() ); assert(static_cast<bool>(m_outSeqSvc)); // Get Output Stream tool for writing - status = m_streamer.retrieve(); - if (status.isFailure()) { - ATH_MSG_FATAL("Cannot find " << m_streamer); - return(status); - } - status = m_streamer->connectServices(m_dataStore.typeAndName(), m_persName, m_extendProvenanceRecord); - if (status.isFailure()) { - ATH_MSG_FATAL("Unable to connect services"); - return(status); - } + ATH_CHECK( m_streamer.retrieve() ); + ATH_CHECK( m_streamer->connectServices(m_dataStore.typeAndName(), m_persName, m_extendProvenanceRecord) ); - status = m_helperTools.retrieve(); - if (status.isFailure()) { - ATH_MSG_FATAL("Cannot find " << m_helperTools); - return(status); - } + ATH_CHECK( m_helperTools.retrieve() ); ATH_MSG_INFO("Found " << m_helperTools << endmsg << "Data output: " << m_outputName); - for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator iter = m_helperTools.begin(); - iter != m_helperTools.end(); iter++) { - if (!(*iter)->postInitialize().isSuccess()) { - status = StatusCode::FAILURE; - } + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + ATH_CHECK( tool->postInitialize() ); } // Register this algorithm for 'I/O' events ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name()); - status = iomgr.retrieve(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Cannot get the IoComponentMgr"); - return(status); - } - status = iomgr->io_register(this); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not register myself with the IoComponentMgr"); - return(status); - } - status = iomgr->io_register(this, IIoComponentMgr::IoMode::WRITE, m_outputName); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could not register [" << m_outputName << "] for output !"); - return(status); - } - status = this->io_reinit(); - if (!status.isSuccess()) { - ATH_MSG_FATAL("Could re-init I/O component"); - return(status); - } + ATH_CHECK( iomgr.retrieve() ); + ATH_CHECK( iomgr->io_register(this) ); + ATH_CHECK( iomgr->io_register(this, IIoComponentMgr::IoMode::WRITE, m_outputName) ); + ATH_CHECK( this->io_reinit() ); // Add an explicit input dependency for everything in our item list // that we know from the configuration is in the transient store. @@ -361,8 +307,7 @@ StatusCode AthenaOutputStream::initialize() { } ATH_MSG_DEBUG("End initialize"); - if (baseStatus == StatusCode::FAILURE) return StatusCode::FAILURE; - return(status); + return StatusCode::SUCCESS; } StatusCode AthenaOutputStream::stop() @@ -441,9 +386,8 @@ void AthenaOutputStream::writeMetaData(const std::string outputFN) // Moved preFinalize of helper tools to stop - want to optimize the // output file in finalize RDS 12/2009 - for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator iter = m_helperTools.begin(); - iter != m_helperTools.end(); iter++) { - if (!(*iter)->preFinalize().isSuccess()) { + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + if (!tool->preFinalize().isSuccess()) { throw GaudiException("Cannot finalize helper tool", name(), StatusCode::FAILURE); } } @@ -517,9 +461,8 @@ StatusCode AthenaOutputStream::finalize() { StatusCode AthenaOutputStream::execute() { bool failed = false; - for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator iter = m_helperTools.begin(); - iter != m_helperTools.end(); iter++) { - if (!(*iter)->preExecute().isSuccess()) { + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + if (!tool->preExecute().isSuccess()) { failed = true; } } @@ -529,9 +472,8 @@ StatusCode AthenaOutputStream::execute() { failed = true; } } - for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator iter = m_helperTools.begin(); - iter != m_helperTools.end(); iter++) { - if(!(*iter)->postExecute().isSuccess()) { + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + if(!tool->postExecute().isSuccess()) { failed = true; } } @@ -614,6 +556,10 @@ StatusCode AthenaOutputStream::write() { // prepare before releasing lock because m_outputAttributes change in metadataStop const std::string connectStr = outputFN + m_outputAttributes; + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + ATH_CHECK( tool->preStream() ); + } + // MN: would be nice to release the Stream lock here // lock.unlock(); @@ -1111,9 +1057,8 @@ StatusCode AthenaOutputStream::io_reinit() { return StatusCode::FAILURE; } incSvc->addListener(this, "MetaDataStop", 50); - for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator iter = m_helperTools.begin(); - iter != m_helperTools.end(); iter++) { - if (!(*iter)->postInitialize().isSuccess()) { + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + if (!tool->postInitialize().isSuccess()) { ATH_MSG_ERROR("Cannot initialize helper tool"); } } @@ -1123,9 +1068,8 @@ StatusCode AthenaOutputStream::io_reinit() { StatusCode AthenaOutputStream::io_finalize() { ATH_MSG_INFO("I/O finalization..."); - for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator iter = m_helperTools.begin(); - iter != m_helperTools.end(); iter++) { - if (!(*iter)->preFinalize().isSuccess()) { + for (ToolHandle<IAthenaOutputTool>& tool : m_helperTools) { + if (!tool->preFinalize().isSuccess()) { ATH_MSG_ERROR("Cannot finalize helper tool"); } } diff --git a/Control/AthenaServices/src/ThinningCacheTool.cxx b/Control/AthenaServices/src/ThinningCacheTool.cxx index a368b750302cb596c1672785d4da363ea5b1c4ef..ef17ecb19b2785beeaa669da023564fd89dec588 100644 --- a/Control/AthenaServices/src/ThinningCacheTool.cxx +++ b/Control/AthenaServices/src/ThinningCacheTool.cxx @@ -41,7 +41,21 @@ StatusCode ThinningCacheTool::postInitialize() } +/** + * @brief Called at the beginning of execute. A no-op for now. + */ StatusCode ThinningCacheTool::preExecute() +{ + return StatusCode::SUCCESS; +} + + +/** + * @brief Called before actually streaming objects. + * Find all thinning requests for this stream, build the @c ThinningCache, + * and install it in the current @c EventContext. + */ +StatusCode ThinningCacheTool::preStream() { m_cache.clear(); diff --git a/Control/AthenaServices/src/ThinningCacheTool.h b/Control/AthenaServices/src/ThinningCacheTool.h index 0208594700a353441dc8f5fa3be3c1dffa482387..8029a15d83beb5980a2d598825afd11cf0aa7ed8 100644 --- a/Control/AthenaServices/src/ThinningCacheTool.h +++ b/Control/AthenaServices/src/ThinningCacheTool.h @@ -52,11 +52,17 @@ public: /** - * @brief Called at the beginning of execute. + * @brief Called at the beginning of execute. A no-op for now. + */ + virtual StatusCode preExecute() override; + + + /** + * @brief Called before actually streaming objects. * Find all thinning requests for this stream, build the @c ThinningCache, * and install it in the current @c EventContext. */ - virtual StatusCode preExecute() override; + virtual StatusCode preStream() override; /** diff --git a/Control/AthenaServices/test/ThinningCacheTool_test.cxx b/Control/AthenaServices/test/ThinningCacheTool_test.cxx index 6f84c3cd1b856d4eb9628213b848b6c30bf3f88c..25af545c5d583efd25d1d51aaa9edf9cc488b6d5 100644 --- a/Control/AthenaServices/test/ThinningCacheTool_test.cxx +++ b/Control/AthenaServices/test/ThinningCacheTool_test.cxx @@ -81,7 +81,7 @@ void test1() ServiceHandle<StoreGateSvc> sg ("StoreGateSvc", "test"); assert (sg.retrieve().isSuccess()); - assert (tool->preExecute().isSuccess()); + assert (tool->preStream().isSuccess()); assert (SG::getThinningCache() == nullptr); assert (tool->postExecute().isSuccess()); assert (SG::getThinningCache() == nullptr); @@ -105,7 +105,7 @@ void test1() assert( sg->record (std::move (d2), "v2_THINNED_MyStream.a", false).isSuccess() ); assert( sg->record (std::move (d3), "v2_THINNED_MyStream.b", false).isSuccess() ); - assert (tool->preExecute().isSuccess()); + assert (tool->preStream().isSuccess()); assert (SG::getThinningCache() != nullptr); assert (SG::getThinningDecision ("v1") == d1p); @@ -137,7 +137,7 @@ void test2() ServiceHandle<ITrigNavigationThinningSvc> tsvc ("TestTNThinningSvc", "test"); assert (tsvc.retrieve().isSuccess()); - assert (tool->preExecute().isSuccess()); + assert (tool->preStream().isSuccess()); assert (SG::getThinningCache() != nullptr); assert (SG::getThinningCache()->trigNavigationThinningSvc() == tsvc.get()); assert (tool->postExecute().isSuccess()); diff --git a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx index 8b49f3e3ae13203315fd108dc7e33812616c297e..65699cc71c67d5b1df1352bdcaf02b4aabd618fd 100644 --- a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx +++ b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.cxx @@ -23,13 +23,10 @@ //___________________________________________________________________________ MakeEventStreamInfo::MakeEventStreamInfo(const std::string& type, const std::string& name, - const IInterface* parent) : ::AthAlgTool(type, name, parent), + const IInterface* parent) : base_class(type, name, parent), m_metaDataSvc("MetaDataSvc", name), m_eventStore("StoreGateSvc", name) { - // Declare IAthenaOutputStreamTool interface - declareInterface<IAthenaOutputTool>(this); - // Declare the properties declareProperty("Key", m_key = ""); declareProperty("EventInfoKey", m_eventInfoKey = "EventInfo"); @@ -68,6 +65,10 @@ StatusCode MakeEventStreamInfo::preExecute() { return(StatusCode::SUCCESS); } //___________________________________________________________________________ +StatusCode MakeEventStreamInfo::preStream() { + return(StatusCode::SUCCESS); +} +//___________________________________________________________________________ StatusCode MakeEventStreamInfo::postExecute() { const IAlgorithm* parentAlg = dynamic_cast<const IAlgorithm*>(this->parent()); if (parentAlg == nullptr) { diff --git a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h index d8dda11f4ae2b68bf780fe8aacf636cbb20dab96..fb4ffcef6a5bce945071313166d97d150d577b40 100644 --- a/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h +++ b/Database/AthenaPOOL/OutputStreamAthenaPool/src/MakeEventStreamInfo.h @@ -24,7 +24,7 @@ namespace xAODMaker { class IEventInfoCnvTool; } /** @class MakeEventStreamInfo * @brief This class provides an algorithm to make the EventStreamInfo object and update it. **/ -class MakeEventStreamInfo : public ::AthAlgTool, virtual public IAthenaOutputTool { +class MakeEventStreamInfo : public extends<::AthAlgTool, IAthenaOutputTool> { public: /// Standard AlgTool Constructor MakeEventStreamInfo(const std::string& type, const std::string& name, const IInterface* parent); @@ -32,17 +32,19 @@ public: virtual ~MakeEventStreamInfo(); /// Required of all IAthenaOutputTools: /// Called by AthenaOutputStream::initialize() (via ToolSvc retrieve()). - StatusCode initialize(); + virtual StatusCode initialize() override; /// Called at the end of AthenaOutputStream::initialize(). - StatusCode postInitialize(); + virtual StatusCode postInitialize() override; /// Called at the beginning of AthenaOutputStream::execute(). - StatusCode preExecute(); + virtual StatusCode preExecute() override; + /// Called before actually streaming objects. + virtual StatusCode preStream() override; /// Called at the end of AthenaOutputStream::execute(). - StatusCode postExecute(); + virtual StatusCode postExecute() override; /// Called at the beginning of AthenaOutputStream::finalize(). - StatusCode preFinalize(); + virtual StatusCode preFinalize() override; /// Called at the end of AthenaOutputStream::finalize() (via release()). - StatusCode finalize(); + virtual StatusCode finalize() override; private: /// Key, the StoreGate key for the EventStreamInfo object. diff --git a/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.cxx b/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.cxx index d2baa4b17aecab911caecc0341fe5c0286fa7225..28d83f1e276378c1030902422897bc90632c37cb 100755 --- a/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.cxx +++ b/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // RootNtupleOutputMetadataTool.cxx @@ -40,14 +40,12 @@ namespace Athena { RootNtupleOutputMetadataTool::RootNtupleOutputMetadataTool(const std::string& type, const std::string& name, const IInterface* parent) : - ::AthAlgTool(type, name, parent), + base_class(type, name, parent), m_imetaStore("InputMetaDataStore", name), m_ometaStore("MetaDataStore", name), m_clidSvc("ClassIDSvc", name), m_metaWritten(false) { - // Declare IAthenaOutputStreamTool interface - declareInterface<IAthenaOutputTool>(this); // Properties declareProperty("InputStore", m_imetaStore, @@ -149,6 +147,7 @@ RootNtupleOutputMetadataTool::finalize() StatusCode RootNtupleOutputMetadataTool::postInitialize() {return StatusCode::SUCCESS;} StatusCode RootNtupleOutputMetadataTool::preFinalize() {return StatusCode::SUCCESS;} StatusCode RootNtupleOutputMetadataTool::preExecute() {return StatusCode::SUCCESS;} +StatusCode RootNtupleOutputMetadataTool::preStream() {return StatusCode::SUCCESS;} StatusCode RootNtupleOutputMetadataTool::postExecute() {return StatusCode::SUCCESS;} void diff --git a/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.h b/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.h index d1784d76e18a258a83de60a296bcc58a9d997a40..f14103509adbb968ee4d245c9defb65adcde6a71 100755 --- a/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.h +++ b/Database/AthenaRoot/AthenaRootComps/src/RootNtupleOutputMetadataTool.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // RootNtupleOutputMetadataTool.h @@ -33,7 +33,7 @@ namespace Athena { * @brief This is the AthenaRoot version of AthenaServices/AthenaOutputStreamTool. **/ class RootNtupleOutputMetadataTool - : virtual public IIncidentListener, public ::IAthenaOutputTool, public ::AthAlgTool + : public extends<::AthAlgTool, IIncidentListener, ::IAthenaOutputTool> { public: @@ -46,16 +46,17 @@ public: virtual ~RootNtupleOutputMetadataTool(); /// Gaudi AlgTool Interface method implementations: - StatusCode initialize(); - StatusCode finalize(); - StatusCode stop(); + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; + virtual StatusCode stop() override; /// AthenaOutputTool Interface method implementations: - StatusCode postInitialize(); - StatusCode preFinalize(); - StatusCode preExecute(); - StatusCode postExecute(); + virtual StatusCode postInitialize() override; + virtual StatusCode preFinalize() override; + virtual StatusCode preExecute() override; + virtual StatusCode preStream() override; + virtual StatusCode postExecute() override; /// Incident service handle listening for Begin/End InputFile incidents - void handle(const Incident& incident); + virtual void handle(const Incident& incident) override; /// Connect to the output stream /// Must writeMetadata BEFORE streaming diff --git a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.cxx b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.cxx index 37dd0c9b9baf949f5ad46aceaab9b367c676a37b..4df951f99e2279eb86a4c9509100fbef7ddb4354 100644 --- a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.cxx +++ b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // $Id: FileMetaDataMarkUpTool.cxx 685407 2015-07-24 16:15:06Z cranshaw $ @@ -48,6 +48,10 @@ namespace xAODMaker { return(StatusCode::SUCCESS); } + StatusCode FileMetaDataMarkUpTool::preStream() { + return(StatusCode::SUCCESS); + } + StatusCode FileMetaDataMarkUpTool::postExecute() { return(StatusCode::SUCCESS); } diff --git a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.h b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.h index 6b863608eb521c37c1679ff5261bdb5e6ebde99d..d20cba2aa19b56fabc6e8b6c61dc2cf14d208f67 100644 --- a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.h +++ b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataMarkUpTool.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // $Id: FileMetaDataMarkUpTool.h 676522 2015-06-18 22:17:03Z cranshaw $ @@ -54,18 +54,20 @@ namespace xAODMaker { /// Required of all IAthenaOutputTools: /// Called by AthenaOutputStream::initialize() (via ToolSvc retrieve()). - StatusCode initialize(); + virtual StatusCode initialize() override; /// Called at the end of AthenaOutputStream::initialize(). - StatusCode postInitialize(); + virtual StatusCode postInitialize() override; /// Called at the beginning of AthenaOutputStream::execute(). - StatusCode preExecute(); + virtual StatusCode preExecute() override; + /// Called before actually streaming objects. + virtual StatusCode preStream() override; /// Called at the end of AthenaOutputStream::execute(). - StatusCode postExecute(); + virtual StatusCode postExecute() override; /// Called at the beginning of AthenaOutputStream::finalize(). - StatusCode preFinalize(); + virtual StatusCode preFinalize() override; /// Called at the end of AthenaOutputStream::finalize() (via release()). - StatusCode finalize(); - virtual StatusCode start(); + virtual StatusCode finalize() override; + virtual StatusCode start() override; protected: /// @name Functions called by the AsgMetadataTool base class