ATLAS Offline Software
Loading...
Searching...
No Matches
MuCTPIByteStreamCnv Class Reference

ByteStream converter for the MuCTPI_RDO object. More...

#include <MuCTPIByteStreamCnv.h>

Inheritance diagram for MuCTPIByteStreamCnv:
Collaboration diagram for MuCTPIByteStreamCnv:

Public Member Functions

 MuCTPIByteStreamCnv (ISvcLocator *svcloc)
 Standard constructor.
virtual StatusCode initialize () override
 Function connecting to all the needed services/tools.
virtual StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&pObj) override
 Function creating the MuCTPI_RDO object from a MuCTPI ROB fragment.
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&pAddr) override
 Function creating the MuCTPI ROB fragment from a MuCTPI_RDO object.
virtual long repSvcType () const override
 Function needed by the framework.

Static Public Member Functions

static long storageType ()
 Function needed by the framework.
static CLID classID ()
 Function needed by the framework.

Private Attributes

ToolHandle< MuCTPIByteStreamTool > m_tool
 Tool doing the actual conversion.
MuCTPISrcIdMap m_srcIdMap
 Object storing the various IDs of the MuCTPI fragment.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
 Service used when reading the BS data.
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
 Service used when writing the BS data.

Detailed Description

ByteStream converter for the MuCTPI_RDO object.

   This is a quite standard BS converter for the output sent from the
   "Muon to Central Trigger Processor Interface" to the DAQ. It uses
   an external tool (MuCTPIByteStreamTool) to do the actual work of
   the conversion, this converter is "only" supposed to communicate
   with the framework.
See also
MuCTPIByteStreamTool
Author
Tadashi Maeno
Attila Krasznahorkay

Definition at line 47 of file MuCTPIByteStreamCnv.h.

Constructor & Destructor Documentation

◆ MuCTPIByteStreamCnv()

MuCTPIByteStreamCnv::MuCTPIByteStreamCnv ( ISvcLocator * svcloc)

Standard constructor.

The constructor sets up all the ToolHandle and ServiceHandle objects and initialises the base class in the correct way.

Definition at line 33 of file MuCTPIByteStreamCnv.cxx.

34 : Converter( storageType(), classID(), svcloc ),
35 m_tool( "MuCTPIByteStreamTool" ),
36#ifdef CTP_MUCTPI_HAVE_SAME_ROS
37 m_ctp_tool( "CTPByteStreamTool" ),
38 m_ctp_rec_tool( "RecCTPByteStreamTool" ),
39 m_storeGate( "StoreGateSvc", "MuCTPIByteStreamCnv" ),
40#endif
41 m_robDataProvider( "ROBDataProviderSvc", "MuCTPIByteStreamCnv" ),
42 m_ByteStreamEventAccess( "ByteStreamCnvSvc", "MuCTPIByteStreamCnv" ) {
43
44}
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service used when writing the BS data.
ToolHandle< MuCTPIByteStreamTool > m_tool
Tool doing the actual conversion.
static long storageType()
Function needed by the framework.
static CLID classID()
Function needed by the framework.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service used when reading the BS data.

Member Function Documentation

◆ classID()

CLID MuCTPIByteStreamCnv::classID ( )
static

Function needed by the framework.

Function telling the framework the Class ID of the object that this converter is for (MuCTPI_RDO).

Definition at line 50 of file MuCTPIByteStreamCnv.cxx.

50 {
51
53
54}

◆ createObj()

StatusCode MuCTPIByteStreamCnv::createObj ( IOpaqueAddress * pAddr,
DataObject *& pObj )
overridevirtual

Function creating the MuCTPI_RDO object from a MuCTPI ROB fragment.

This function creates the MuCTPI_RDO object from the BS data.

It requests the ROB fragment with the ROB Id of the MuCTPI and gives this fragment to the MuCTPIByteStreamTool for conversion.

Definition at line 116 of file MuCTPIByteStreamCnv.cxx.

116 {
117
118 MsgStream log( msgSvc(), "MuCTPIByteStreamCnv" );
119 log << MSG::DEBUG << "createObj() called" << endmsg;
120
121 ByteStreamAddress* pBS_Addr{};
122 ATH_CHECK( (pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
123
124 const EventContext& ctx = pBS_Addr->getEventContext();
125
126 log << MSG::DEBUG << " Creating Objects " << *( pBS_Addr->par() ) << endmsg;
127
128 //
129 // Get SourceID:
130 //
131 const uint32_t robId = m_srcIdMap.getRobID( m_srcIdMap.getRodID() );
132
133 log << MSG::DEBUG << " expected ROB sub-detector ID: " << std::hex
134 << robId << std::dec << endmsg;
135
136 std::vector< uint32_t > vID;
137 vID.push_back( robId );
138
139 //
140 // Get ROB fragment:
141 //
143 m_robDataProvider->getROBData(ctx, vID, robFrags );
144
145 //
146 // Size check:
147 //
148 if( robFrags.size() == 0 ) {
149
150 // This is a hack - for some time CTP and MUCTPI were plugged in
151 // the same ROB of the same ROS PC ...
152 // 0x76000b : MUCTPI
153 // 0x76000a : CTP
154 // Note that the MUCTPI ROBID must come first, cos further down we
155 // just use the first element of robFrags to create the RDO
156 vID[0] = ( robId | 0x00000b );
157#ifdef CTP_MUCTPI_HAVE_SAME_ROS
158 vID.push_back( robId | 0x00000a );
159#endif
160 m_robDataProvider->getROBData(ctx, vID, robFrags );
161
162 if( robFrags.size() == 0 ) {
163 // yet another temporary hack!!! - for some time the ROB ID was 0!
164 vID[0] = 0x00000b;
165#ifdef CTP_MUCTPI_HAVE_SAME_ROS
166 vID[1] = 0x00000a;
167#endif
168 m_robDataProvider->getROBData(ctx, vID, robFrags );
169
170 if( robFrags.size() == 0 ) {
171 log << MSG::WARNING << "No MuCTPI ROB fragments found!" << endmsg;
172
173 MuCTPI_RDO* result = new MuCTPI_RDO;
174 pObj = SG::asStorable( result );
175 return StatusCode::SUCCESS;
176 }
177 }
178 }
179
180 IROBDataProviderSvc::VROBFRAG::const_iterator it = robFrags.begin();
181 MuCTPI_RDO* result = 0;
182 StatusCode sc = m_tool->convert( ROBData( *it ).getROBFragment(), result );
183 if( sc.isFailure() ) {
184 log << MSG::ERROR << " Failed to create Objects: " << *( pBS_Addr->par() ) << endmsg;
185 if (result!=0){
186 delete result;
187 result=0;
188 }
189 return sc;
190 }
191 pObj = SG::asStorable( result ) ;
192
193#ifdef CTP_MUCTPI_HAVE_SAME_ROS
194 // If CTP and MuCTPI send to the same ROS, the MuCTPI ROS, we get
195 // the CTP fragment in the MuCTPI ROS fragment. In order to be able
196 // to produce a CTP_RDO, we call the CTP ByteStream AlgTool from
197 // here whenever we think we have a CTP fragment.
198
199 if( robFrags.size() > 1 ) {
200
201 ++it;
202 if( it != robFrags.end() ) {
203
204 CTP_RDO* ctp_result = 0;
205 CTP_RIO* ctp_rio_result = 0;
206
207 ATH_CHECK( m_ctp_tool->convert( ROBData( *it ).getROBFragment(), ctp_result ) );
208
209 SG::asStorable( ctp_result ) ;
210 ATH_CHECK( m_storeGate->record( ctp_result, "CTP_RDO" ) );
211
212 ATH_CHECK( m_ctp_rec_tool->convert( ROBData( *it ).getROBFragment(), ctp_rio_result, log ) );
213
214 SG::asStorable( ctp_rio_result ) ;
215 ATH_CHECK( m_storeGate->record( ctp_rio_result, "CTP_RIO" ) );
216 }
217
218 }
219#endif
220
221 return sc;
222}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t sc
ROBData_T< OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment, OFFLINE_FRAGMENTS_NAMESPACE::PointerType > ROBData
Definition ROBData.h:225
const EventContext & getEventContext() const
std::vector< const ROBF * > VROBFRAG
MuCTPISrcIdMap m_srcIdMap
Object storing the various IDs of the MuCTPI fragment.
const ROBFragment * getROBFragment() const
Return the ROBFragment.
Definition ROBData.h:184
::StatusCode StatusCode
StatusCode definition for legacy code.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
setEventNumber uint32_t

◆ createRep()

StatusCode MuCTPIByteStreamCnv::createRep ( DataObject * pObj,
IOpaqueAddress *& pAddr )
overridevirtual

Function creating the MuCTPI ROB fragment from a MuCTPI_RDO object.

This function receives a MuCTPI_RDO object as input, and adds the ROB fragment of the MuCTPI to the current raw event using the IByteStreamEventAccess interface.

Definition at line 229 of file MuCTPIByteStreamCnv.cxx.

229 {
230
231 MsgStream log( msgSvc(), "MuCTPIByteStreamCnv" );
232 log << MSG::DEBUG << "createRep() called" << endmsg;
233
234 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
235
236 MuCTPI_RDO* result;
237 if( ! SG::fromStorable( pObj, result ) ) {
238 log << MSG::ERROR << " Cannot cast to MuCTPI_RDO" << endmsg;
239 return StatusCode::FAILURE;
240 }
241
242 ByteStreamAddress* addr = new ByteStreamAddress( classID(), pObj->registry()->name(), "" );
243
244 pAddr = addr;
245
246 // Convert to ByteStream
247 return m_tool->convert( result, re );
248}
const std::regex re(r_e)
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)

◆ initialize()

StatusCode MuCTPIByteStreamCnv::initialize ( )
overridevirtual

Function connecting to all the needed services/tools.

Init method gets all necessary services etc.

Definition at line 63 of file MuCTPIByteStreamCnv.cxx.

63 {
64
65 //
66 // Initialise the base class:
67 //
68 ATH_CHECK( Converter::initialize() );
69
70 MsgStream log( msgSvc(), "MuCTPIByteStreamCnv" );
71 log << MSG::DEBUG << "MuCTPIByteStreamCnv in initialize() " << endmsg;
72
73 //
74 // Get ByteStreamCnvSvc:
75 //
77
78 //
79 // Get MuCTPIByteStreamTool:
80 //
81 ATH_CHECK( m_tool.retrieve() );
82 log << MSG::DEBUG << "Connected to MuCTPIByteStreamTool" << endmsg;
83
84#ifdef CTP_MUCTPI_HAVE_SAME_ROS
85 //
86 // Get CTPByteStreamTool:
87 //
88 ATH_CHECK( m_ctp_tool.retrieve() );
89 log << MSG::DEBUG << "Connected to CTPByteStreamTool" << endmsg;
90
91 //
92 // Get RecCTPByteStreamTool:
93 //
94 ATH_CHECK( m_ctp_rec_tool.retrieve() );
95 log << MSG::DEBUG << "Connected to RecCTPByteStreamTool" << endmsg;
96#endif
97
98 //
99 // Get ROBDataProvider:
100 //
101 if( m_robDataProvider.retrieve().isFailure() ) {
102 log << MSG::WARNING << "Can't get ROBDataProviderSvc" << endmsg;
103 // return is disabled for Write BS which does not requre ROBDataProviderSvc
104 } else {
105 log << MSG::DEBUG << "Connected to ROBDataProviderSvc" << endmsg;
106 }
107
108 return StatusCode::SUCCESS;
109}

◆ repSvcType()

virtual long MuCTPIByteStreamCnv::repSvcType ( ) const
inlineoverridevirtual

Function needed by the framework.

Definition at line 61 of file MuCTPIByteStreamCnv.h.

61{ return i_repSvcType(); }

◆ storageType()

long MuCTPIByteStreamCnv::storageType ( )
static

Function needed by the framework.

Definition at line 56 of file MuCTPIByteStreamCnv.cxx.

56 {
58}
static constexpr long storageType()

Member Data Documentation

◆ m_ByteStreamEventAccess

ServiceHandle< IByteStreamEventAccess > MuCTPIByteStreamCnv::m_ByteStreamEventAccess
private

Service used when writing the BS data.

Definition at line 82 of file MuCTPIByteStreamCnv.h.

◆ m_robDataProvider

ServiceHandle< IROBDataProviderSvc > MuCTPIByteStreamCnv::m_robDataProvider
private

Service used when reading the BS data.

Definition at line 80 of file MuCTPIByteStreamCnv.h.

◆ m_srcIdMap

MuCTPISrcIdMap MuCTPIByteStreamCnv::m_srcIdMap
private

Object storing the various IDs of the MuCTPI fragment.

Definition at line 71 of file MuCTPIByteStreamCnv.h.

◆ m_tool

ToolHandle< MuCTPIByteStreamTool > MuCTPIByteStreamCnv::m_tool
private

Tool doing the actual conversion.

Definition at line 69 of file MuCTPIByteStreamCnv.h.


The documentation for this class was generated from the following files: