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 "JepRoiByteStreamV1Tool.h"
29 template <typename Container>
30 JepRoiReadByteStreamV1Cnv<Container>::JepRoiReadByteStreamV1Cnv(
32 : AthConstConverter( storageType(), classID(), svcloc, "JepRoiReadByteStreamV1Cnv" ),
33 m_tool("LVL1BS::JepRoiByteStreamV1Tool/JepRoiByteStreamV1Tool"),
34 m_robDataProvider("ROBDataProviderSvc", name())
38 template <typename Container>
39 JepRoiReadByteStreamV1Cnv<Container>::~JepRoiReadByteStreamV1Cnv()
45 template <typename Container>
46 const CLID& JepRoiReadByteStreamV1Cnv<Container>::classID()
48 return ClassID_traits<Container>::ID();
51 template <typename Container>
52 long JepRoiReadByteStreamV1Cnv<Container>::storageType()
54 return ByteStreamAddress::storageType();
57 // Init method gets all necessary services etc.
60 template <typename Container>
61 StatusCode JepRoiReadByteStreamV1Cnv<Container>::initialize()
63 ATH_CHECK( Converter::initialize() );
64 ATH_CHECK( m_tool.retrieve() );
65 ATH_CHECK( m_robDataProvider.retrieve() );
67 return StatusCode::SUCCESS;
70 // createObj should create the RDO from bytestream.
72 template <typename Container>
73 StatusCode JepRoiReadByteStreamV1Cnv<Container>::createObjConst ( IOpaqueAddress* pAddr,
74 DataObject*& pObj ) const
76 ByteStreamAddress *pBS_Addr;
77 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
79 ATH_MSG_ERROR( " Cannot cast to ByteStreamAddress " );
80 return StatusCode::FAILURE;
83 const std::string nm = *( pBS_Addr->par() );
85 ATH_MSG_DEBUG( " Creating Objects " << nm );
88 const std::vector<uint32_t>& vID(m_tool->sourceIDs(nm));
91 IROBDataProviderSvc::VROBFRAG robFrags;
92 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags );
95 auto collection = std::make_unique<Container>();
96 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
98 if (robFrags.size() == 0) {
99 pObj = SG::asStorable(std::move(collection)) ;
100 return StatusCode::SUCCESS;
103 ATH_CHECK( m_tool->convert(robFrags, collection.get()) );
105 pObj = SG::asStorable(std::move(collection));
107 return StatusCode::SUCCESS;