ATLAS Offline Software
Loading...
Searching...
No Matches
JepReadByteStreamV2Cnv.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 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 "JepByteStreamV2Tool.h"
26
27namespace LVL1BS {
28
29template <typename Container>
30JepReadByteStreamV2Cnv<Container>::JepReadByteStreamV2Cnv( ISvcLocator* svcloc )
31 : AthConstConverter( storageType(), classID(), svcloc, "JepReadByteStreamV2Cnv" ),
32 m_tool("LVL1BS::JepByteStreamV2Tool/JepByteStreamV2Tool"),
33 m_robDataProvider("ROBDataProviderSvc", name())
34{
35}
36
37template <typename Container>
38JepReadByteStreamV2Cnv<Container>::~JepReadByteStreamV2Cnv()
39{
40}
41
42// CLID
43
44template <typename Container>
45const CLID& JepReadByteStreamV2Cnv<Container>::classID()
46{
47 return ClassID_traits<Container>::ID();
48}
49
50long JepReadByteStreamV2Cnv<Container>::storageType()
51{
52 return ByteStreamAddress::storageType();
53}
54
55// Init method gets all necessary services etc.
56
57
58template <typename Container>
59StatusCode JepReadByteStreamV2Cnv<Container>::initialize()
60{
61 ATH_CHECK( Converter::initialize() );
62 ATH_CHECK( m_tool.retrieve() );
63 ATH_CHECK( m_robDataProvider.retrieve() );
64
65 return StatusCode::SUCCESS;
66}
67
68// createObj should create the RDO from bytestream.
69
70template <typename Container>
71StatusCode JepReadByteStreamV2Cnv<Container>::createObjConst( IOpaqueAddress* pAddr,
72 DataObject*& pObj ) const
73{
74 ByteStreamAddress *pBS_Addr;
75 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
76 if ( !pBS_Addr ) {
77 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
78 return StatusCode::FAILURE;
79 }
80
81 const std::string nm = *( pBS_Addr->par() );
82
83 ATH_MSG_DEBUG( " Creating Objects " << nm );
84
85 // get SourceIDs
86 const std::vector<uint32_t>& vID(m_tool->sourceIDs(nm));
87
88 // get ROB fragments
89 IROBDataProviderSvc::VROBFRAG robFrags;
90 m_robDataProvider->getROBData( vID, robFrags );
91
92 // size check
93 auto collection = std::make_unique<Container>();
94 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
95
96 if (robFrags.size() == 0) {
97 pObj = SG::asStorable(std::move(collection)) ;
98 return StatusCode::SUCCESS;
99 }
100
101 ATH_CHECK( m_tool->convert(robFrags, collection.get()) );
102
103 pObj = SG::asStorable(std::move(collection));
104
105 return sc;
106}
107
108} // end namespace