2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
9 #include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
10 #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
12 #include "ByteStreamData/RawEvent.h"
13 #include "ByteStreamData/ROBData.h"
15 #include "AthContainers/DataVector.h"
17 #include "GaudiKernel/DataObject.h"
18 #include "GaudiKernel/IOpaqueAddress.h"
19 #include "GaudiKernel/IRegistry.h"
20 #include "GaudiKernel/ISvcLocator.h"
21 #include "GaudiKernel/StatusCode.h"
23 #include "AthenaKernel/ClassID_traits.h"
24 #include "AthenaKernel/StorableConversions.h"
25 #include "AthenaKernel/errorcheck.h"
27 #include "JepByteStreamV1Tool.h"
28 #include "JepByteStreamV2Tool.h"
32 template <typename Container>
33 JepReadByteStreamV1V2Cnv<Container>::JepReadByteStreamV1V2Cnv( ISvcLocator* svcloc )
34 : AthConstConverter( storageType(), classID(), svcloc, "JepReadByteStreamV1V2Cnv" ),
35 m_tool1("LVL1BS::JepByteStreamV1Tool/JepByteStreamV1Tool"),
36 m_tool2("LVL1BS::JepByteStreamV2Tool/JepByteStreamV2Tool"),
37 m_robDataProvider("ROBDataProviderSvc", name())
41 template <typename Container>
42 JepReadByteStreamV1V2Cnv<Container>::~JepReadByteStreamV1V2Cnv()
48 template <typename Container>
49 const CLID& JepReadByteStreamV1V2Cnv<Container>::classID()
51 return ClassID_traits<Container>::ID();
54 template <typename Container>
55 long JepReadByteStreamV1V2Cnv<Container>::storageType()
57 return ByteStreamAddress::storageType();
60 // Init method gets all necessary services etc.
63 template <typename Container>
64 StatusCode JepReadByteStreamV1V2Cnv<Container>::initialize()
66 ATH_CHECK( Converter::initialize() );
67 ATH_CHECK( m_tool1.retrieve() );
68 ATH_CHECK( m_tool2.retrieve() );
69 ATH_CHECK( m_robDataProvider.retrieve() );
71 return StatusCode::SUCCESS;
74 // createObj should create the RDO from bytestream.
76 template <typename Container>
77 StatusCode JepReadByteStreamV1V2Cnv<Container>::createObjConst ( IOpaqueAddress* pAddr,
78 DataObject*& pObj ) const
80 ByteStreamAddress *pBS_Addr;
81 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
83 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
84 return StatusCode::FAILURE;
87 const std::string nm = *( pBS_Addr->par() );
89 ATH_MSG_DEBUG( " Creating Objects " << nm );
92 const std::vector<uint32_t>& vID1(m_tool1->sourceIDs());
93 const std::vector<uint32_t>& vID2(m_tool2->sourceIDs());
96 IROBDataProviderSvc::VROBFRAG robFrags1;
97 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID1, robFrags1 );
98 IROBDataProviderSvc::VROBFRAG robFrags2;
99 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID2, robFrags2 );
102 auto collection = std::make_unique<Container>();
103 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags1.size()
104 << ", " << robFrags2.size() );
106 if (robFrags1.size() == 0 && robFrags2.size() == 0) {
107 pObj = SG::asStorable(std::move(collection)) ;
108 return StatusCode::SUCCESS;
112 if (robFrags1.size() > 0) {
113 ATH_CHECK( m_tool1->convert(nm, robFrags1, collection.get()) );
116 if (robFrags2.size() > 0) {
117 ATH_CHECK( m_tool2->convert(nm, robFrags2, collection.get()) );
120 pObj = SG::asStorable(std::move(collection));
122 return StatusCode::SUCCESS;