ATLAS Offline Software
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"
10 #include "ByteStreamData/ROBData.h"
11 
13 
14 // Trigger include(s):
15 #include "TrigT1Result/CTP_RDO.h"
16 
17 // Local include(s):
18 #include "CTPByteStreamCnv.h"
19 
24 CTPByteStreamCnv::CTPByteStreamCnv( ISvcLocator* svcloc )
25  : Converter( storageType(), classID(), svcloc ),
26  m_tool( "CTPByteStreamTool" ),
27  m_robDataProvider( "ROBDataProviderSvc", "CTPByteStreamCnv" ),
28  m_ByteStreamEventAccess( "ByteStreamCnvSvc", "CTPByteStreamCnv" ) {
29 
30 }
31 
37 
39 
40 }
41 
44 }
45 
50 
51  //
52  // Initialise the base class:
53  //
55 
56  MsgStream log( msgSvc(), "CTPByteStreamCnv" );
57  log << MSG::DEBUG << "CTPByteStreamCnv in initialize() " << endmsg;
58 
59  //
60  // Get ByteStreamCnvSvc:
61  //
62  ATH_CHECK( m_ByteStreamEventAccess.retrieve() );
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 
89 StatusCode 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 
149 StatusCode 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 
156  CTP_RDO* result;
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 }
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
get_generator_info.result
result
Definition: get_generator_info.py:21
ROBData_T::getROBFragment
const ROBFragment * getROBFragment() const
Return the ROBFragment.
Definition: ROBData.h:184
CTPByteStreamCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Function creating the CTP_RDO object from a CTP ROB fragment.
Definition: CTPByteStreamCnv.cxx:89
CTP_RDO
CTP_RDO
Definition: TrigT1EventTPCnv.cxx:102
CTPByteStreamCnv::CTPByteStreamCnv
CTPByteStreamCnv(ISvcLocator *svcloc)
Standard constructor.
Definition: CTPByteStreamCnv.cxx:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
StorableConversions.h
convert to and from a SG storable
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
initialize
void initialize()
Definition: run_EoverP.cxx:894
ROBData_T
templete data class to wrap ROB fragment for accessing ROD data
Definition: ROBData.h:46
CTPByteStreamCnv::storageType
static long storageType()
Function needed by the framework.
Definition: CTPByteStreamCnv.cxx:42
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
CTPByteStreamCnv.h
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
RawEvent.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CTPByteStreamCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr) override
Function creating the CTP ROB fragment from a CTP_RDO object.
Definition: CTPByteStreamCnv.cxx:149
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:27
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
CTPByteStreamCnv::m_ByteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service used when writing the BS data.
Definition: CTPByteStreamCnv.h:65
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
CTPByteStreamCnv::m_tool
ToolHandle< CTPByteStreamTool > m_tool
Tool doing the actual conversion.
Definition: CTPByteStreamCnv.h:57
Converter
Definition: Converter.h:27
CTPByteStreamCnv::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service used when reading the BS data.
Definition: CTPByteStreamCnv.h:63
CTP_RDO.h
CTP_RDO
Definition: CTP_RDO.h:20
CTPSrcIdMap::getRodID
uint32_t getRodID() const
get a ROD Source ID
Definition: CTPSrcIdMap.cxx:13
re
const boost::regex re(r_e)
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CTPByteStreamCnv::initialize
virtual StatusCode initialize() override
Function connecting to all the needed services/tools.
Definition: CTPByteStreamCnv.cxx:49
CTPSrcIdMap::getRobID
uint32_t getRobID(uint32_t rod_id) const
Make a ROB Source ID from a ROD source ID.
Definition: CTPSrcIdMap.cxx:18
CTPByteStreamCnv::m_srcIdMap
CTPSrcIdMap m_srcIdMap
Object storing the various IDs of the CTP fragment.
Definition: CTPByteStreamCnv.h:60
CTPByteStreamCnv::classID
static const CLID & classID()
Function needed by the framework.
Definition: CTPByteStreamCnv.cxx:36