ATLAS Offline Software
Loading...
Searching...
No Matches
CpReadByteStreamV1Cnv.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include <vector>
7#include <stdint.h>
8#include <typeinfo>
9
10#include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
11#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
12
13#include "ByteStreamData/RawEvent.h"
14#include "ByteStreamData/ROBData.h"
15
16#include "GaudiKernel/DataObject.h"
17#include "GaudiKernel/IOpaqueAddress.h"
18#include "GaudiKernel/ISvcLocator.h"
19#include "GaudiKernel/StatusCode.h"
20
21#include "AthenaKernel/ClassID_traits.h"
22#include "AthenaKernel/StorableConversions.h"
23#include "AthenaKernel/errorcheck.h"
24
25#include "CpByteStreamV1Tool.h"
26
27namespace LVL1BS {
28
29template <typename Container>
30CpReadByteStreamV1Cnv<Container>::CpReadByteStreamV1Cnv( ISvcLocator* svcloc )
31 : AthConstConverter( storageType(), classID(), svcloc, "CpReadByteStreamV1Cnv" ),
32 m_tool("LVL1BS::CpByteStreamV1Tool/CpByteStreamV1Tool"),
33 m_robDataProvider("ROBDataProviderSvc", name())
34{
35}
36
37template <typename Container>
38CpReadByteStreamV1Cnv<Container>::~CpReadByteStreamV1Cnv()
39{
40}
41
42// CLID
43
44template <typename Container>
45CLID CpReadByteStreamV1Cnv<Container>::classID()
46{
47 return ClassID_traits<Container>::ID();
48}
49
50template <typename Container>
51long CpReadByteStreamV1Cnv<Container>::storageType()
52{
53 return ByteStreamAddress::storageType();
54}
55
56// Init method gets all necessary services etc.
57
58
59template <typename Container>
60StatusCode CpReadByteStreamV1Cnv<Container>::initialize()
61{
62 ATH_CHECK( Converter::initialize() );
63 ATH_CHECK( m_tool.retrieve() );
64 ATH_CHECK( m_robDataProvider.retrieve() );
65
66 return StatusCode::SUCCESS;
67}
68
69// createObj should create the RDO from bytestream.
70
71template <typename Container>
72StatusCode CpReadByteStreamV1Cnv<Container>::createObjConst ( IOpaqueAddress* pAddr,
73 DataObject*& pObj ) const
74{
75
76 ByteStreamAddress* pBS_Addr{};
77 ATH_CHECK( (pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
78
79 const EventContext& ctx = pBS_Addr->getEventContext();
80 const std::string nm = *( pBS_Addr->par() );
81
82 ATH_MSG_DEBUG( " Creating Objects " << nm );
83
84 // get SourceIDs
85 const std::vector<uint32_t>& vID(m_tool->sourceIDs());
86
87 // get ROB fragments
88 IROBDataProviderSvc::VROBFRAG robFrags;
89 m_robDataProvider->getROBData(ctx, vID, robFrags );
90
91 // size check
92 auto collection = std::make_unique<Container>();
93 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
94
95 if (robFrags.size() == 0) {
96 pObj = SG::asStorable(std::move(collection)) ;
97 return StatusCode::SUCCESS;
98 }
99
100 ATH_CHECK( m_tool->convert(nm, robFrags, collection.get()) );
101
102 pObj = SG::asStorable(std::move(collection));
103
104 return StatusCode::SUCCESS;
105}
106
107} // end namespace