2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
10 #include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
11 #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
13 #include "ByteStreamData/RawEvent.h"
14 #include "ByteStreamData/ROBData.h"
16 #include "GaudiKernel/DataObject.h"
17 #include "GaudiKernel/IOpaqueAddress.h"
18 #include "GaudiKernel/ISvcLocator.h"
19 #include "GaudiKernel/StatusCode.h"
21 #include "AthenaKernel/ClassID_traits.h"
22 #include "AthenaKernel/StorableConversions.h"
23 #include "AthenaKernel/errorcheck.h"
25 #include "CpByteStreamV1Tool.h"
29 template <typename Container>
30 CpReadByteStreamV1Cnv<Container>::CpReadByteStreamV1Cnv( ISvcLocator* svcloc )
31 : AthConstConverter( storageType(), classID(), svcloc, "CpReadByteStreamV1Cnv" ),
32 m_tool("LVL1BS::CpByteStreamV1Tool/CpByteStreamV1Tool"),
33 m_robDataProvider("ROBDataProviderSvc", name())
37 template <typename Container>
38 CpReadByteStreamV1Cnv<Container>::~CpReadByteStreamV1Cnv()
44 template <typename Container>
45 const CLID& CpReadByteStreamV1Cnv<Container>::classID()
47 return ClassID_traits<Container>::ID();
50 template <typename Container>
51 long CpReadByteStreamV1Cnv<Container>::storageType()
53 return ByteStreamAddress::storageType();
56 // Init method gets all necessary services etc.
59 template <typename Container>
60 StatusCode CpReadByteStreamV1Cnv<Container>::initialize()
62 ATH_CHECK( Converter::initialize() );
63 ATH_CHECK( m_tool.retrieve() );
64 ATH_CHECK( m_robDataProvider.retrieve() );
66 return StatusCode::SUCCESS;
69 // createObj should create the RDO from bytestream.
71 template <typename Container>
72 StatusCode CpReadByteStreamV1Cnv<Container>::createObjConst ( IOpaqueAddress* pAddr,
73 DataObject*& pObj ) const
75 ByteStreamAddress *pBS_Addr;
76 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
78 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
79 return StatusCode::FAILURE;
82 const std::string nm = *( pBS_Addr->par() );
84 ATH_MSG_DEBUG( " Creating Objects " << nm );
87 const std::vector<uint32_t>& vID(m_tool->sourceIDs());
90 IROBDataProviderSvc::VROBFRAG robFrags;
91 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags );
94 auto collection = std::make_unique<Container>();
95 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
97 if (robFrags.size() == 0) {
98 pObj = SG::asStorable(std::move(collection)) ;
99 return StatusCode::SUCCESS;
102 ATH_CHECK( m_tool->convert(nm, robFrags, collection.get()) );
104 pObj = SG::asStorable(std::move(collection));
106 return StatusCode::SUCCESS;