From ab515f610231ee45cb2a17a2adc3397f8e45662e Mon Sep 17 00:00:00 2001 From: Peter Van Gemmeren <peter.van.gemmeren@cern.ch> Date: Tue, 9 Apr 2019 11:40:50 +0000 Subject: [PATCH] Use Read and WriteHandle for AttributeList in EventSelector. --- .../share/DoubleEventSelectorOverlayTest.ref | 4 +- .../DoubleEventSelectorOverlayTestMT.ref | 4 +- .../share/AthenaPoolExample_Copy.ref | 2 +- .../share/AthenaPoolExample_RCond.ref | 2 +- .../share/AthenaPoolExample_ReWrite.ref | 2 +- .../share/AthenaPoolExample_ReWriteAgain.ref | 2 +- .../share/AthenaPoolExample_ReWriteNext.ref | 2 +- .../share/AthenaPoolExample_WCond.ref | 2 +- .../src/AthenaPoolAddressProviderSvc.cxx | 35 ++++++------- .../src/EventSelectorAthenaPool.cxx | 52 ++++++++----------- 10 files changed, 47 insertions(+), 60 deletions(-) diff --git a/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTest.ref b/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTest.ref index 8a9fa649020..4919106c2a2 100644 --- a/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTest.ref +++ b/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTest.ref @@ -30,8 +30,8 @@ AddressRemappin... DEBUG Service base class initialized successfully ProxyProviderSvc DEBUG Property update for OutputLevel : new value = 2 ProxyProviderSvc DEBUG Service base class initialized successfully Stream1.Stream1... INFO Initializing Stream1.Stream1Tool - package version AthenaServices-00-00-00 -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. Stream1 INFO Found HelperTools = PrivateToolHandleArray([]) Stream1 INFO Data output: OutputRDO.root Stream1 INFO I/O reinitialization... diff --git a/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTestMT.ref b/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTestMT.ref index 20241bc9963..fb6f5d44703 100644 --- a/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTestMT.ref +++ b/AtlasTest/DatabaseTest/AthenaPoolTest/share/DoubleEventSelectorOverlayTestMT.ref @@ -32,8 +32,8 @@ AddressRemappingSvc DEBUG Service base class initi ProxyProviderSvc DEBUG Property update for OutputLevel : new value = 2 ProxyProviderSvc DEBUG Service base class initialized successfully Stream1.Stream1Tool 0 INFO Initializing Stream1.Stream1Tool - package version AthenaServices-00-00-00 -AthenaPoolAddressProviderSvcPrimary 0 DEBUG Cannot find DataHeader in DetectorStore. -AthenaPoolAddressProviderSvcSecondary 0 DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddressProviderSvcPrimary 0 DEBUG Cannot retrieve DataHeader from DetectorStore. +AthenaPoolAddressProviderSvcSecondary 0 DEBUG Cannot retrieve DataHeader from DetectorStore. Stream1 0 INFO Found HelperTools = PrivateToolHandleArray([]) Stream1 0 INFO Data output: OutputRDO.root Stream1 0 INFO I/O reinitialization... diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_Copy.ref b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_Copy.ref index 97beeaf0e3b..7a319d24ed6 100644 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_Copy.ref +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_Copy.ref @@ -134,7 +134,7 @@ Stream1 DEBUG Found MetaDataStore store. OutputStreamSeq... INFO Initializing OutputStreamSequencerSvc - package version AthenaServices-00-00-00 Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1Tool - package version AthenaServices-00-00-00 -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1_MakeEventStreamInfo - package version OutputStreamAthenaPool-00-00-00 Stream1 INFO Found HelperTools = PrivateToolHandleArray(['MakeEventStreamInfo/Stream1_MakeEventStreamInfo']) diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_RCond.ref b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_RCond.ref index 40d93c0bb44..acf58d9b217 100644 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_RCond.ref +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_RCond.ref @@ -238,7 +238,7 @@ AlgResourcePool INFO TopAlg list empty. Recovering the one of Application M AthenaEventLoopMgr INFO ===>>> start of run 1 <<<=== AthenaEventLoopMgr INFO ===>>> start processing event #0, run #1 0 events processed so far <<<=== ReadCond DEBUG in execute() -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. SimplePoolFile4... DEBUG --> Access DbContainer READ [ROOT_Tree] POOLContainer(DataHeader) POOLContainer(D... DEBUG Opening POOLContainer(D... DEBUG attributes# = 1 diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWrite.ref b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWrite.ref index a4dac0d493c..cdc35fcce07 100644 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWrite.ref +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWrite.ref @@ -156,7 +156,7 @@ Stream1 DEBUG Found MetaDataStore store. OutputStreamSeq... INFO Initializing OutputStreamSequencerSvc - package version AthenaServices-00-00-00 Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1Tool - package version AthenaServices-00-00-00 -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1_MakeEventStreamInfo - package version OutputStreamAthenaPool-00-00-00 Stream1 INFO Found HelperTools = PrivateToolHandleArray(['MakeEventStreamInfo/Stream1_MakeEventStreamInfo']) diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteAgain.ref b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteAgain.ref index 57c11355439..415d82fdd35 100644 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteAgain.ref +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteAgain.ref @@ -150,7 +150,7 @@ Stream1 DEBUG Found MetaDataStore store. OutputStreamSeq... INFO Initializing OutputStreamSequencerSvc - package version AthenaServices-00-00-00 Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1Tool - package version AthenaServices-00-00-00 -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1_MakeEventStreamInfo - package version OutputStreamAthenaPool-00-00-00 Stream1 INFO Found HelperTools = PrivateToolHandleArray(['MakeEventStreamInfo/Stream1_MakeEventStreamInfo']) diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteNext.ref b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteNext.ref index ca8f4d2eaf8..6ec1257ae95 100644 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteNext.ref +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_ReWriteNext.ref @@ -156,7 +156,7 @@ Stream1 DEBUG Found MetaDataStore store. OutputStreamSeq... INFO Initializing OutputStreamSequencerSvc - package version AthenaServices-00-00-00 Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1Tool - package version AthenaServices-00-00-00 -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. Stream1.Stream1... DEBUG Property update for OutputLevel : new value = 2 Stream1.Stream1... INFO Initializing Stream1.Stream1_MakeEventStreamInfo - package version OutputStreamAthenaPool-00-00-00 Stream1 INFO Found HelperTools = PrivateToolHandleArray(['MakeEventStreamInfo/Stream1_MakeEventStreamInfo']) diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_WCond.ref b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_WCond.ref index ea10d32939a..c57eee7b096 100644 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_WCond.ref +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/share/AthenaPoolExample_WCond.ref @@ -163,7 +163,7 @@ ReadData DEBUG Data Deps for ReadData + INPUT ( 'ExampleTrackContainer' , 'StoreGateSvc+MyTracks' ) WriteCond DEBUG Property update for OutputLevel : new value = 2 WriteCond INFO in initialize() -AthenaPoolAddre... DEBUG Cannot find DataHeader in DetectorStore. +AthenaPoolAddre... DEBUG Cannot retrieve DataHeader from DetectorStore. WriteCond DEBUG input handles: 1 WriteCond DEBUG output handles: 0 WriteCond DEBUG Data Deps for WriteCond diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/src/AthenaPoolAddressProviderSvc.cxx b/Database/AthenaPOOL/EventSelectorAthenaPool/src/AthenaPoolAddressProviderSvc.cxx index 868d8c7d35c..657501d0e32 100755 --- a/Database/AthenaPOOL/EventSelectorAthenaPool/src/AthenaPoolAddressProviderSvc.cxx +++ b/Database/AthenaPOOL/EventSelectorAthenaPool/src/AthenaPoolAddressProviderSvc.cxx @@ -20,6 +20,8 @@ #include "StoreGate/ActiveStoreSvc.h" #include "StoreGate/StoreGateSvc.h" +#include "StoreGate/ReadHandle.h" +#include "StoreGate/WriteHandle.h" #include "AthenaKernel/IClassIDSvc.h" #include <vector> @@ -93,12 +95,8 @@ StatusCode AthenaPoolAddressProviderSvc::preLoadAddresses(StoreID::type storeID, ATH_MSG_ERROR("Cannot get DetectorStore."); return(StatusCode::FAILURE); } - const DataHandle<DataHeader> dataHeader; - if (!detectorStoreSvc->contains<DataHeader>("CondProxyProvider")) { - ATH_MSG_DEBUG("Cannot find DataHeader in DetectorStore."); - return(StatusCode::SUCCESS); - } - if (!detectorStoreSvc->retrieve(dataHeader, "CondProxyProvider").isSuccess()) { + SG::ReadHandle<DataHeader> dataHeader("CondProxyProvider", detectorStoreSvc->name()); + if (!dataHeader.isValid()) { ATH_MSG_DEBUG("Cannot retrieve DataHeader from DetectorStore."); return(StatusCode::SUCCESS); } @@ -127,6 +125,7 @@ StatusCode AthenaPoolAddressProviderSvc::loadAddresses(StoreID::type storeID, Guid thisFile = Guid::null(); long int oid2 = 0L; + const DataHeader* dataHeader = nullptr; if (m_dataHeaderIterator) { // Get oid2 (event file entry number) from DataHeader proxy const SG::DataProxy* dhProxy = eventStore()->proxy(ClassID_traits<DataHeader>::ID(), m_dataHeaderKey.value()); if (dhProxy != nullptr && dhProxy->address() != nullptr) { @@ -135,27 +134,25 @@ StatusCode AthenaPoolAddressProviderSvc::loadAddresses(StoreID::type storeID, thisFile = token.dbID(); oid2 = token.oid().second; } + SG::ReadHandle<DataHeader> copiedDataHeader(thisFile.toString(), m_metaDataStore->name()); + if (copiedDataHeader.isValid()) { + dataHeader = copiedDataHeader.cptr(); + } } - const DataHandle<DataHeader> dataHeader; - if (thisFile == Guid::null() || oid2 == 0L || thisFile != m_guid) { // New file (or reading DataHeader) - if (!eventStore()->retrieve(dataHeader, m_dataHeaderKey.value()).isSuccess() || !dataHeader.isValid()) { + if (dataHeader == nullptr) { // New file (or reading DataHeader) + SG::ReadHandle<DataHeader> eventDataHeader(m_dataHeaderKey.value(), eventStore()->name()); + if (!eventDataHeader.isValid()) { ATH_MSG_ERROR("Cannot retrieve DataHeader from StoreGate: " << m_dataHeaderKey); return(StatusCode::FAILURE); } + dataHeader = eventDataHeader.cptr(); if (m_dataHeaderIterator) { - const DataHeader* dataHeaderCopy = new DataHeader(*dataHeader.cptr()); - if (m_metaDataStore->record(dataHeaderCopy, thisFile.toString()).isFailure()) { + std::unique_ptr<DataHeader> dataHeaderCopy(new DataHeader(*eventDataHeader.cptr())); + SG::WriteHandle<DataHeader> wh(thisFile.toString(), m_metaDataStore->name()); + if (!wh.record(std::move(dataHeaderCopy)).isSuccess()) { ATH_MSG_WARNING("Can't copy event DataHeader to MetaData store."); } } - } else { - if (m_metaDataStore->retrieve(dataHeader, thisFile.toString()).isFailure()) { - ATH_MSG_WARNING("Can't get event DataHeader from MetaData store."); - if (!eventStore()->retrieve(dataHeader, m_dataHeaderKey.value()).isSuccess() || !dataHeader.isValid()) { - ATH_MSG_ERROR("Cannot retrieve DataHeader from StoreGate: " << m_dataHeaderKey); - return(StatusCode::FAILURE); - } - } } // second data header if (m_attrListKey.value() != "") { diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/src/EventSelectorAthenaPool.cxx b/Database/AthenaPOOL/EventSelectorAthenaPool/src/EventSelectorAthenaPool.cxx index 46fb927a608..557f55ce494 100755 --- a/Database/AthenaPOOL/EventSelectorAthenaPool/src/EventSelectorAthenaPool.cxx +++ b/Database/AthenaPOOL/EventSelectorAthenaPool/src/EventSelectorAthenaPool.cxx @@ -20,6 +20,8 @@ #include "PoolSvc/IPoolSvc.h" #include "StoreGate/StoreGateSvc.h" #include "StoreGate/ActiveStoreSvc.h" +#include "StoreGate/ReadHandle.h" +#include "StoreGate/WriteHandle.h" #include "AthenaKernel/IAthenaIPCTool.h" #include "AthenaKernel/ICollectionSize.h" @@ -489,24 +491,18 @@ StatusCode EventSelectorAthenaPool::next(IEvtSelector::Context& ctxt) const { delete (char*)tokenStr; tokenStr = nullptr; return(StatusCode::FAILURE); } - // Remove any old AttributeList - if (const AthenaAttributeList* oldAttrList = - eventStore()->tryRetrieve<AthenaAttributeList> (m_attrListKey.value())) - { - if (!eventStore()->removeDataAndProxy(oldAttrList).isSuccess()) { - ATH_MSG_ERROR("Cannot remove old AttributeList from StoreGate."); - return(StatusCode::FAILURE); - } + if (!eventStore()->clearStore().isSuccess()) { + ATH_MSG_WARNING("Cannot clear Store"); } - AthenaAttributeList* athAttrList = new AthenaAttributeList(); - if (!eventStore()->record(athAttrList, m_attrListKey.value()).isSuccess()) { - ATH_MSG_ERROR("Cannot record AttributeList to StoreGate."); + std::unique_ptr<AthenaAttributeList> athAttrList(new AthenaAttributeList()); + athAttrList->extend("eventRef", "string"); + (*athAttrList)["eventRef"].data<std::string>() = std::string((char*)tokenStr); + SG::WriteHandle<AthenaAttributeList> wh(m_attrListKey.value(), eventStore()->name()); + if (!wh.record(std::move(athAttrList)).isSuccess()) { delete (char*)tokenStr; tokenStr = nullptr; - delete athAttrList; athAttrList = nullptr; + ATH_MSG_ERROR("Cannot record AttributeList to StoreGate " << StoreID::storeName(eventStore()->storeID())); return(StatusCode::FAILURE); } - athAttrList->extend("eventRef", "string"); - (*athAttrList)["eventRef"].data<std::string>() = std::string((char*)tokenStr); Token token; token.fromString(std::string((char*)tokenStr)); delete (char*)tokenStr; tokenStr = nullptr; @@ -627,6 +623,9 @@ StatusCode EventSelectorAthenaPool::next(IEvtSelector::Context& ctxt) const { return(StatusCode::FAILURE); } } else { + if (!eventStore()->clearStore().isSuccess()) { + ATH_MSG_WARNING("Cannot clear Store"); + } if (!recordAttributeList().isSuccess()) { ATH_MSG_ERROR("Failed to record AttributeList."); return(StatusCode::FAILURE); @@ -710,8 +709,8 @@ StatusCode EventSelectorAthenaPool::rewind(IEvtSelector::Context& /*ctxt*/) cons StatusCode EventSelectorAthenaPool::createAddress(const IEvtSelector::Context& /*ctxt*/, IOpaqueAddress*& iop) const { std::string tokenStr; - const DataHandle<AthenaAttributeList> attrList; - if (eventStore()->retrieve(attrList, m_attrListKey.value()).isSuccess()) { + SG::ReadHandle<AthenaAttributeList> attrList(m_attrListKey.value(), eventStore()->name()); + if (attrList.isValid()) { try { if (m_refName.value().empty()) { tokenStr = (*attrList)["eventRef"].data<std::string>(); @@ -1004,26 +1003,12 @@ PoolCollectionConverter* EventSelectorAthenaPool::getCollectionCnv(bool throwInc } //__________________________________________________________________________ StatusCode EventSelectorAthenaPool::recordAttributeList() const { - // Remove any old AttributeList - if (const AthenaAttributeList* oldAttrList = - eventStore()->tryRetrieve<AthenaAttributeList> (m_attrListKey.value())) - { - if (!eventStore()->removeDataAndProxy(oldAttrList).isSuccess()) { - ATH_MSG_ERROR("Cannot remove old AttributeList from StoreGate."); - return(StatusCode::FAILURE); - } - } // Get access to AttributeList ATH_MSG_DEBUG("Get AttributeList from the collection"); // MN: accessing only attribute list, ignoring token list const coral::AttributeList& attrList = m_headerIterator->currentRow().attributeList(); ATH_MSG_DEBUG("AttributeList size " << attrList.size()); - AthenaAttributeList* athAttrList = new AthenaAttributeList(attrList); - if (!eventStore()->record(athAttrList, m_attrListKey.value()).isSuccess()) { - ATH_MSG_ERROR("Cannot record AttributeList to StoreGate."); - delete athAttrList; athAttrList = nullptr; - return(StatusCode::FAILURE); - } + std::unique_ptr<AthenaAttributeList> athAttrList(new AthenaAttributeList(attrList)); const pool::TokenList& tokenList = m_headerIterator->currentRow().tokenList(); for (pool::TokenList::const_iterator iter = tokenList.begin(), last = tokenList.end(); iter != last; ++iter) { athAttrList->extend(iter.tokenName(), "string"); @@ -1033,6 +1018,11 @@ StatusCode EventSelectorAthenaPool::recordAttributeList() const { athAttrList->extend("eventRef", "string"); (*athAttrList)["eventRef"].data<std::string>() = m_headerIterator->eventRef().toString(); ATH_MSG_DEBUG("record AthenaAttribute, name = eventRef = " << m_headerIterator->eventRef().toString() << "."); + SG::WriteHandle<AthenaAttributeList> wh(m_attrListKey.value(), eventStore()->name()); + if (!wh.record(std::move(athAttrList)).isSuccess()) { + ATH_MSG_ERROR("Cannot record AttributeList to StoreGate " << StoreID::storeName(eventStore()->storeID())); + return(StatusCode::FAILURE); + } return(StatusCode::SUCCESS); } //__________________________________________________________________________ -- GitLab