ATLAS Offline Software
Loading...
Searching...
No Matches
PpmByteStreamV1Cnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include <vector>
7#include <stdint.h>
8
12
15
17
18#include "GaudiKernel/DataObject.h"
19#include "GaudiKernel/IOpaqueAddress.h"
20#include "GaudiKernel/IRegistry.h"
21#include "GaudiKernel/ISvcLocator.h"
22#include "GaudiKernel/StatusCode.h"
23
27
29
30#include "PpmByteStreamV1Cnv.h"
31#include "PpmByteStreamV1Tool.h"
32
33namespace LVL1BS {
34
36 : AthConstConverter( storageType(), classID(), svcloc, "PpmByteStreamV1Cnv" ),
37 m_tool("LVL1BS::PpmByteStreamV1Tool/PpmByteStreamV1Tool"),
38 m_robDataProvider("ROBDataProviderSvc", name()),
39 m_ByteStreamEventAccess("ByteStreamCnvSvc", name())
40{
41}
42
46
47// CLID
48
53
58
59// Init method gets all necessary services etc.
60
61
63{
64 ATH_CHECK( Converter::initialize() );
66 ATH_CHECK( m_tool.retrieve() );
67
68 // Get ROBDataProvider
69 StatusCode sc = m_robDataProvider.retrieve();
70 if ( sc.isFailure() ) {
71 ATH_MSG_WARNING( "Failed to retrieve service " << m_robDataProvider );
72 // return is disabled for Write BS which does not require ROBDataProviderSvc
73 // return sc ;
74 }
75 return StatusCode::SUCCESS;
76}
77
78// createObj should create the RDO from bytestream.
79
80StatusCode PpmByteStreamV1Cnv::createObjConst ( IOpaqueAddress* pAddr,
81 DataObject*& pObj ) const
82{
83 ByteStreamAddress* pBS_Addr{};
84 ATH_CHECK( (pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
85
86 const EventContext& ctx = pBS_Addr->getEventContext();
87 const std::string nm = *( pBS_Addr->par() );
88
89 ATH_MSG_DEBUG( " Creating Objects " << nm );
90
91 // get SourceIDs
92 const std::vector<uint32_t>& vID(m_tool->sourceIDs(nm));
93
94 // get ROB fragments
96 m_robDataProvider->getROBData(ctx, vID, robFrags );
97
98 // size check
99 auto ttCollection = std::make_unique<DataVector<LVL1::TriggerTower> >(SG::VIEW_ELEMENTS);
100 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
101
102 if (robFrags.size() == 0) {
103 pObj = SG::asStorable(std::move(ttCollection)) ;
104 return StatusCode::SUCCESS;
105 }
106
107 ATH_CHECK( m_tool->convert(nm, robFrags, ttCollection.get()) );
108
109 pObj = SG::asStorable(std::move(ttCollection));
110
111 return StatusCode::SUCCESS;
112}
113
114// createRep should create the bytestream from RDOs.
115
116StatusCode PpmByteStreamV1Cnv::createRepConst ( DataObject* pObj,
117 IOpaqueAddress*& pAddr ) const
118{
119 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
120
121 DataVector<LVL1::TriggerTower>* ttCollection = 0;
122 if( !SG::fromStorable( pObj, ttCollection ) ) {
123 ATH_MSG_ERROR( " Cannot cast to DataVector<TriggerTower>" );
124 return StatusCode::FAILURE;
125 }
126
127 const std::string nm = pObj->registry()->name();
128
129 ByteStreamAddress* addr = new ByteStreamAddress( classID(), nm, "" );
130
131 pAddr = addr;
132
133 // Convert to ByteStream
134 return m_tool->convert( ttCollection, re );
135}
136
137} // end namespace
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Helpers for checking error return status codes and reporting errors.
An STL vector of pointers that by default owns its pointed-to elements.
uint32_t CLID
The Class ID type.
static Double_t sc
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
convert to and from a SG storable
AthConstConverter(long storage_type, const CLID &class_type, ISvcLocator *svc, const std::string &name)
const std::string & name() const
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
const EventContext & getEventContext() const
static constexpr long storageType()
Derived DataVector<T>.
Definition DataVector.h:795
std::vector< const ROBF * > VROBFRAG
ToolHandle< LVL1BS::PpmByteStreamV1Tool > m_tool
Tool that does the actual work.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Create ByteStream from TriggerTowers.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service for writing bytestream.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create TriggerTowers from ByteStream.
PpmByteStreamV1Cnv(ISvcLocator *svcloc)
virtual StatusCode initialize() override
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Default, invalid implementation of ClassID_traits.