ATLAS Offline Software
Loading...
Searching...
No Matches
CTPByteStreamCnv.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// Gaudi/Athena include(s):
7#include "GaudiKernel/MsgStream.h"
11
13
14// Trigger include(s):
16
17// Local include(s):
18#include "CTPByteStreamCnv.h"
19
25 : Converter( storageType(), classID(), svcloc ),
26 m_tool( "CTPByteStreamTool" ),
27 m_robDataProvider( "ROBDataProviderSvc", "CTPByteStreamCnv" ),
28 m_ByteStreamEventAccess( "ByteStreamCnvSvc", "CTPByteStreamCnv" ) {
29
30}
31
41
45
50
51 //
52 // Initialise the base class:
53 //
54 ATH_CHECK( Converter::initialize() );
55
56 MsgStream log( msgSvc(), "CTPByteStreamCnv" );
57 log << MSG::DEBUG << "CTPByteStreamCnv in initialize() " << endmsg;
58
59 //
60 // Get ByteStreamCnvSvc:
61 //
63 log << MSG::DEBUG << "Connected to ByteStreamEventAccess interface" << endmsg;
64
65 //
66 // Get CTPByteStreamTool:
67 //
68 ATH_CHECK( m_tool.retrieve() );
69 log << MSG::DEBUG << "Connected to CTPByteStreamTool" << endmsg;
70
71 //
72 // Get ROBDataProvider:
73 //
74 if( m_robDataProvider.retrieve().isFailure() ) {
75 log << MSG::WARNING << "Can't get ROBDataProviderSvc" << endmsg;
76 // return is disabled for Write BS which does not requre ROBDataProviderSvc
77 } else {
78 log << MSG::DEBUG << "Connected to ROBDataProviderSvc" << endmsg;
79 }
80
81 return StatusCode::SUCCESS;
82}
83
89StatusCode CTPByteStreamCnv::createObj( IOpaqueAddress* pAddr, DataObject*& pObj ) {
90
91 MsgStream log( msgSvc(), "CTPByteStreamCnv" );
92 log << MSG::DEBUG << "createObj() called" << endmsg;
93
94 ByteStreamAddress* pBS_Addr{};
95 ATH_CHECK( (pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
96
97 const EventContext& ctx = pBS_Addr->getEventContext();
98
99 log << MSG::DEBUG << "Creating Objects: " << *( pBS_Addr->par() ) << endmsg;
100
101 //
102 // Get the SourceID:
103 //
104 const uint32_t robId = m_srcIdMap.getRobID( m_srcIdMap.getRodID() );
105
106 log << MSG::DEBUG << "expected ROB sub-detector ID: " << std::hex
107 << robId << std::dec << endmsg;
108
109 std::vector< uint32_t > vID;
110 vID.push_back( robId );
111
112 //
113 // Get the ROB fragment:
114 //
116 m_robDataProvider->getROBData( ctx, vID, robFrags );
117
118 //
119 // Size check:
120 //
121 if( robFrags.size() != 1 ) {
122 log << MSG::WARNING << "Number of ROB fragments is " << robFrags.size() << endmsg;
123 log << MSG::WARNING << "Creating empty CTP_RDO object" << endmsg;
124
125 CTP_RDO* result = new CTP_RDO(3,0,0);
126 pObj = SG::asStorable( result );
127 return StatusCode::SUCCESS;
128 }
129
130 //
131 // Do the actual conversion:
132 //
133 IROBDataProviderSvc::VROBFRAG::const_iterator it = robFrags.begin();
134 CTP_RDO* result = 0;
135
136 ATH_CHECK( m_tool->convert( ROBData( *it ).getROBFragment(), result ) );
137 pObj = SG::asStorable( result ) ;
138
139 return StatusCode::SUCCESS;
140}
141
147StatusCode CTPByteStreamCnv::createRep( DataObject* pObj, IOpaqueAddress*& pAddr ) {
148
149 MsgStream log( msgSvc(), "CTPByteStreamCnv" );
150 log << MSG::DEBUG << "createRep() called" << endmsg;
151
152 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
153
154 CTP_RDO* result;
155 if( ! SG::fromStorable( pObj, result ) ) {
156 log << MSG::ERROR << " Cannot cast to CTP_RDO" << endmsg;
157 return StatusCode::FAILURE;
158 }
159
160 ByteStreamAddress* addr = new ByteStreamAddress( classID(), pObj->registry()->name(), "" );
161
162 pAddr = addr;
163
164 // Convert to ByteStream
165 return m_tool->convert( result, re );
166}
const boost::regex re(r_e)
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
uint32_t CLID
The Class ID type.
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
ROBData_T< OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment, OFFLINE_FRAGMENTS_NAMESPACE::PointerType > ROBData
Definition ROBData.h:225
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
convert to and from a SG storable
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
const EventContext & getEventContext() const
static constexpr long storageType()
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr) override
Function creating the CTP ROB fragment from a CTP_RDO object.
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Function creating the CTP_RDO object from a CTP ROB fragment.
ToolHandle< CTPByteStreamTool > m_tool
Tool doing the actual conversion.
static CLID classID()
Function needed by the framework.
CTPByteStreamCnv(ISvcLocator *svcloc)
Standard constructor.
virtual StatusCode initialize() override
Function connecting to all the needed services/tools.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service used when reading the BS data.
CTPSrcIdMap m_srcIdMap
Object storing the various IDs of the CTP fragment.
static long storageType()
Function needed by the framework.
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service used when writing the BS data.
std::vector< const ROBF * > VROBFRAG
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)