ATLAS Offline Software
Loading...
Searching...
No Matches
CTPByteStreamCnv.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// 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 pBS_Addr = dynamic_cast< ByteStreamAddress* >( pAddr );
96 if( ! pBS_Addr ) {
97 log << MSG::ERROR << "Can not cast input to ByteStreamAddress" << endmsg ;
98 return StatusCode::FAILURE;
99 }
100
101 log << MSG::DEBUG << "Creating Objects: " << *( pBS_Addr->par() ) << endmsg;
102
103 //
104 // Get the SourceID:
105 //
106 const uint32_t robId = m_srcIdMap.getRobID( m_srcIdMap.getRodID() );
107
108 log << MSG::DEBUG << "expected ROB sub-detector ID: " << std::hex
109 << robId << std::dec << endmsg;
110
111 std::vector< uint32_t > vID;
112 vID.push_back( robId );
113
114 //
115 // Get the ROB fragment:
116 //
118 m_robDataProvider->getROBData( Gaudi::Hive::currentContext(), vID, robFrags );
119
120 //
121 // Size check:
122 //
123 if( robFrags.size() != 1 ) {
124 log << MSG::WARNING << "Number of ROB fragments is " << robFrags.size() << endmsg;
125 log << MSG::WARNING << "Creating empty CTP_RDO object" << endmsg;
126
127 CTP_RDO* result = new CTP_RDO(3,0,0);
128 pObj = SG::asStorable( result );
129 return StatusCode::SUCCESS;
130 }
131
132 //
133 // Do the actual conversion:
134 //
135 IROBDataProviderSvc::VROBFRAG::const_iterator it = robFrags.begin();
136 CTP_RDO* result = 0;
137
138 ATH_CHECK( m_tool->convert( ROBData( *it ).getROBFragment(), result ) );
139 pObj = SG::asStorable( result ) ;
140
141 return StatusCode::SUCCESS;
142}
143
149StatusCode CTPByteStreamCnv::createRep( DataObject* pObj, IOpaqueAddress*& pAddr ) {
150
151 MsgStream log( msgSvc(), "CTPByteStreamCnv" );
152 log << MSG::DEBUG << "createRep() called" << endmsg;
153
154 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
155
157 if( ! SG::fromStorable( pObj, result ) ) {
158 log << MSG::ERROR << " Cannot cast to CTP_RDO" << endmsg;
159 return StatusCode::FAILURE;
160 }
161
162 ByteStreamAddress* addr = new ByteStreamAddress( classID(), pObj->registry()->name(), "" );
163
164 pAddr = addr;
165
166 // Convert to ByteStream
167 return m_tool->convert( result, re );
168}
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.
static constexpr long storageType()
static const CLID & classID()
Function needed by the framework.
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.
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)