ATLAS Offline Software
ByteStreamRDP_OutputSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //===================================================================
6 // Implementation of ByteStreamRDP_OutputSvc
7 // Initial implementation Jan 10, 2003
8 //
9 //===================================================================
10 //
11 
12 // Include files.
15 
16 // Constructor.
17 ByteStreamRDP_OutputSvc::ByteStreamRDP_OutputSvc(const std::string& name, ISvcLocator* svcloc)
18  : ByteStreamOutputSvc(name, svcloc) {
20 }
21 
22 // Open the first input file and read the first event.
24  ATH_MSG_INFO("Initializing");
25  if (!ByteStreamOutputSvc::initialize().isSuccess()) {
26  ATH_MSG_FATAL("Cannot initialize ByteStreamOutputSvc base class.");
27  return(StatusCode::FAILURE);
28  }
29 
30  // Retrieve ROBDataProviderSvc
31  if (!m_robProvider.retrieve().isSuccess()) {
32  ATH_MSG_FATAL("Cannot get ROBDataProviderSvc");
33  return(StatusCode::FAILURE);
34  }
35  return(StatusCode::SUCCESS);
36 }
37 
38 // Receive the next event without explicit context
40  return putEvent(re, Gaudi::Hive::currentContext());
41 }
42 
43 // Receive the next event
44 bool ByteStreamRDP_OutputSvc::putEvent(const RawEvent* re, const EventContext& ctx) {
45  EventCache* cache = m_eventsCache.get(ctx);
46  cache->releaseEvent();
47  const uint32_t reSize = re->fragment_size_word();
48  const uint32_t* reStart = re->start();
49  cache->dataBuffer = std::make_unique<uint32_t[]>(reSize);
50  std::copy(reStart, reStart+reSize, cache->dataBuffer.get());
51 
52  // Create a cached RawEvent object from the cached data buffer
53  cache->rawEvent = std::make_unique<RawEvent>(cache->dataBuffer.get());
54 
55  // Give the RawEvent to ROBDataProvider
56  m_robProvider->setNextEvent(ctx, cache->rawEvent.get());
57 
58  return true;
59 }
60 
61 StatusCode ByteStreamRDP_OutputSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) {
62  if (ByteStreamOutputSvc::interfaceID().versionMatch(riid)) {
63  *ppvInterface = dynamic_cast<ByteStreamOutputSvc*>(this);
64  } else {
65  // Interface is not directly available: try out a base class
66  return(::AthService::queryInterface(riid, ppvInterface));
67  }
68  addRef();
69  return(StatusCode::SUCCESS);
70 }
ByteStreamRDP_OutputSvc::putEvent
virtual bool putEvent(const RawEvent *re) override
Implementation of the ByteStreamOutputSvc interface methods.
Definition: ByteStreamRDP_OutputSvc.cxx:39
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ByteStreamRDP_OutputSvc::EventCache::releaseEvent
void releaseEvent()
Definition: ByteStreamRDP_OutputSvc.h:42
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ByteStreamRDP_OutputSvc::EventCache
Definition: ByteStreamRDP_OutputSvc.h:41
initialize
void initialize()
Definition: run_EoverP.cxx:894
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
ROBDataProviderSvc.h
ByteStreamRDP_OutputSvc::m_bsOutputStreamName
Gaudi::Property< std::string > m_bsOutputStreamName
Definition: ByteStreamRDP_OutputSvc.h:53
ByteStreamRDP_OutputSvc::EventCache::rawEvent
std::unique_ptr< RawEvent > rawEvent
Current event fragment.
Definition: ByteStreamRDP_OutputSvc.h:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamRDP_OutputSvc::m_robProvider
ServiceHandle< IROBDataProviderSvc > m_robProvider
Definition: ByteStreamRDP_OutputSvc.h:51
ByteStreamOutputSvc::interfaceID
static const InterfaceID & interfaceID()
Retrieve interface ID.
Definition: ByteStreamOutputSvc.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ByteStreamRDP_OutputSvc::ByteStreamRDP_OutputSvc
ByteStreamRDP_OutputSvc(const std::string &name, ISvcLocator *svcloc)
Constructors:
Definition: ByteStreamRDP_OutputSvc.cxx:17
ByteStreamRDP_OutputSvc.h
ByteStreamRDP_OutputSvc::EventCache::dataBuffer
std::unique_ptr< uint32_t[]> dataBuffer
Underlying data structure.
Definition: ByteStreamRDP_OutputSvc.h:47
re
const boost::regex re(r_e)
ByteStreamRDP_OutputSvc::m_eventsCache
SG::SlotSpecificObj< EventCache > m_eventsCache
Cache of event data for each slot.
Definition: ByteStreamRDP_OutputSvc.h:49
ByteStreamOutputSvc
This class provides the base class to services to write bytestream data. The concrete class can provi...
Definition: ByteStreamOutputSvc.h:25
ByteStreamRDP_OutputSvc::initialize
virtual StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamRDP_OutputSvc.cxx:23
calibdata.copy
bool copy
Definition: calibdata.py:27
ByteStreamRDP_OutputSvc::queryInterface
StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Required of all Gaudi services: see Gaudi documentation for details.
Definition: ByteStreamRDP_OutputSvc.cxx:61