diff --git a/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.cxx b/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.cxx index 5991520c7c5732446820db900207478623caa31e..81355fb6fe19d372fc4270ef5559a573635d749f 100644 --- a/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.cxx +++ b/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.cxx @@ -1,13 +1,9 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//==================================================================== -// EventSelectorByteStream.cxx -//==================================================================== -// -// Include files. +/* Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "EventSelectorByteStream.h" + +#include <vector> +#include <algorithm> + #include "EventContextByteStream.h" #include "ByteStreamCnvSvc/ByteStreamInputSvc.h" #include "ByteStreamCnvSvcBase/ByteStreamAddress.h" @@ -28,38 +24,61 @@ #include "PersistentDataModel/DataHeader.h" #include "eformat/StreamTag.h" -#include <vector> -#include <algorithm> // Constructor. -EventSelectorByteStream::EventSelectorByteStream(const std::string& name, ISvcLocator* svcloc) - : base_class(name, svcloc) -{ - declareProperty("HelperTools", m_helperTools); - - // RunNumber, OldRunNumber and OverrideRunNumberFromInput are used - // to override the run number coming in on the input stream - m_runNo.verifier().setLower(0); - // The following properties are only for compatibility with - // McEventSelector and are not really used anywhere - // TODO: validate if those are even used - m_eventsPerRun.verifier().setLower(0); - m_firstEventNo.verifier().setLower(0); - m_firstLBNo.verifier().setLower(0); - m_eventsPerLB.verifier().setLower(0); - m_initTimeStamp.verifier().setLower(0); - - m_inputCollectionsProp.declareUpdateHandler(&EventSelectorByteStream::inputCollectionsHandler, this); -} -//________________________________________________________________________________ +EventSelectorByteStream::EventSelectorByteStream( + const std::string& name, + ISvcLocator* svcloc) + : base_class(name, svcloc) + , m_activeStoreSvc("ActiveStoreSvc", name) { + declareProperty("HelperTools", m_helperTools); + + // RunNumber, OldRunNumber and OverrideRunNumberFromInput are used + // to override the run number coming in on the input stream + m_runNo.verifier().setLower(0); + // The following properties are only for compatibility with + // McEventSelector and are not really used anywhere + // TODO(berghaus): validate if those are even used + m_eventsPerRun.verifier().setLower(0); + m_firstEventNo.verifier().setLower(0); + m_firstLBNo.verifier().setLower(0); + m_eventsPerLB.verifier().setLower(0); + m_initTimeStamp.verifier().setLower(0); + + m_inputCollectionsProp.declareUpdateHandler( + &EventSelectorByteStream::inputCollectionsHandler, + this); +} + + +/******************************************************************************/ void EventSelectorByteStream::inputCollectionsHandler(Property&) { - if (this->FSMState() != Gaudi::StateMachine::OFFLINE) { - this->reinit().ignore(); - } + if (this->FSMState() != Gaudi::StateMachine::OFFLINE) { + this->reinit().ignore(); + } } -//________________________________________________________________________________ + + +/******************************************************************************/ EventSelectorByteStream::~EventSelectorByteStream() { } + + +/******************************************************************************/ +StoreGateSvc* +EventSelectorByteStream::eventStore() const { + if (m_activeStoreSvc == 0) { + if (!m_activeStoreSvc.retrieve().isSuccess()) { + ATH_MSG_ERROR("Cannot get ActiveStoreSvc"); + throw GaudiException( + "Cannot get ActiveStoreSvc", name(), StatusCode::FAILURE); + } + } + + return(m_activeStoreSvc->activeStore()); +} + + //________________________________________________________________________________ StatusCode EventSelectorByteStream::initialize() { if (m_isSecondary.value()) { @@ -92,11 +111,6 @@ StatusCode EventSelectorByteStream::initialize() { ATH_MSG_FATAL("Cannot cast ByteStreamInputSvc"); return(StatusCode::FAILURE); } - m_eventSource->addRef(); - if (!m_evtStore.retrieve().isSuccess()) { - ATH_MSG_FATAL("Cannot get StoreGateSvc"); - return(StatusCode::FAILURE); - } // Get CounterTool (if configured) if (!m_counterTool.empty()) { @@ -653,13 +667,13 @@ StatusCode EventSelectorByteStream::recordAttributeList() const { std::string listName("EventInfoAtts"); - if (m_evtStore->contains<AthenaAttributeList>(listName)) { + if (eventStore()->contains<AthenaAttributeList>(listName)) { const AthenaAttributeList* oldAttrList = nullptr; - if (!m_evtStore->retrieve(oldAttrList, listName).isSuccess()) { + if (!eventStore()->retrieve(oldAttrList, listName).isSuccess()) { ATH_MSG_ERROR("Cannot retrieve old AttributeList from StoreGate."); return(StatusCode::FAILURE); } - if (!m_evtStore->removeDataAndProxy(oldAttrList).isSuccess()) { + if (!eventStore()->removeDataAndProxy(oldAttrList).isSuccess()) { ATH_MSG_ERROR("Cannot remove old AttributeList from StoreGate."); return(StatusCode::FAILURE); } @@ -673,7 +687,7 @@ StatusCode EventSelectorByteStream::recordAttributeList() const ATH_CHECK(fillAttributeList(attrList.get(), "", false)); // put result in event store - if (m_evtStore->record(std::move(attrList), listName).isFailure()) { + if (eventStore()->record(std::move(attrList), listName).isFailure()) { return StatusCode::FAILURE; } @@ -900,7 +914,7 @@ StatusCode EventSelectorByteStream::readEvent(int maxevt) { //________________________________________________________________________________ StatusCode EventSelectorByteStream::createAddress(const IEvtSelector::Context& /*it*/, IOpaqueAddress*& iop) const { - SG::DataProxy* proxy = m_evtStore->proxy(ClassID_traits<DataHeader>::ID(),"ByteStreamDataHeader"); + SG::DataProxy* proxy = eventStore()->proxy(ClassID_traits<DataHeader>::ID(),"ByteStreamDataHeader"); if (proxy !=0) { iop = proxy->address(); return(StatusCode::SUCCESS); diff --git a/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.h b/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.h index b44112d5dafd78e879a0982bbd83dbd75694c43e..412414862e192bd2f91a7fc0778e3ba6b0ade890 100644 --- a/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.h +++ b/Event/ByteStreamCnvSvc/src/EventSelectorByteStream.h @@ -144,6 +144,7 @@ private: // internal member functions void nextFile() const; /// Search for event with number evtNum. int findEvent(int evtNum) const; + StoreGateSvc* eventStore() const; private: // properties /// IsSecondary, know if this is an instance of secondary event selector @@ -164,7 +165,7 @@ private: // properties mutable std::vector<std::string>::const_iterator m_inputCollectionsIterator; void inputCollectionsHandler(Property&); ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc", ""}; - ServiceHandle<StoreGateSvc> m_evtStore{this, "StoreGateSvc", "StoreGateSvc", ""}; + ServiceHandle<ActiveStoreSvc> m_activeStoreSvc; Gaudi::Property<long> m_skipEvents{this, "SkipEvents", 0, ""}; // Number of events to skip at the beginning Gaudi::Property<std::vector<long>> m_skipEventSequenceProp{this, "SkipEventSequence", {}, ""};