ATLAS Offline Software
Loading...
Searching...
No Matches
JepReadByteStreamV1V2Cnv.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
9#include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
10#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
11
12#include "ByteStreamData/RawEvent.h"
13#include "ByteStreamData/ROBData.h"
14
15#include "AthContainers/DataVector.h"
16
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"
22
23#include "AthenaKernel/ClassID_traits.h"
24#include "AthenaKernel/StorableConversions.h"
25#include "AthenaKernel/errorcheck.h"
26
27#include "JepByteStreamV1Tool.h"
28#include "JepByteStreamV2Tool.h"
29
30namespace LVL1BS {
31
32template <typename Container>
33JepReadByteStreamV1V2Cnv<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())
38{
39}
40
41template <typename Container>
42JepReadByteStreamV1V2Cnv<Container>::~JepReadByteStreamV1V2Cnv()
43{
44}
45
46// CLID
47
48template <typename Container>
49const CLID& JepReadByteStreamV1V2Cnv<Container>::classID()
50{
51 return ClassID_traits<Container>::ID();
52}
53
54template <typename Container>
55long JepReadByteStreamV1V2Cnv<Container>::storageType()
56{
57 return ByteStreamAddress::storageType();
58}
59
60// Init method gets all necessary services etc.
61
62
63template <typename Container>
64StatusCode JepReadByteStreamV1V2Cnv<Container>::initialize()
65{
66 ATH_CHECK( Converter::initialize() );
67 ATH_CHECK( m_tool1.retrieve() );
68 ATH_CHECK( m_tool2.retrieve() );
69 ATH_CHECK( m_robDataProvider.retrieve() );
70
71 return StatusCode::SUCCESS;
72}
73
74// createObj should create the RDO from bytestream.
75
76template <typename Container>
77StatusCode JepReadByteStreamV1V2Cnv<Container>::createObjConst ( IOpaqueAddress* pAddr,
78 DataObject*& pObj ) const
79{
80 ByteStreamAddress *pBS_Addr;
81 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
82 if ( !pBS_Addr ) {
83 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
84 return StatusCode::FAILURE;
85 }
86
87 const std::string nm = *( pBS_Addr->par() );
88
89 ATH_MSG_DEBUG( " Creating Objects " << nm );
90
91 // get SourceIDs
92 const std::vector<uint32_t>& vID1(m_tool1->sourceIDs());
93 const std::vector<uint32_t>& vID2(m_tool2->sourceIDs());
94
95 // get ROB fragments
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 );
100
101 // size check
102 auto collection = std::make_unique<Container>();
103 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags1.size()
104 << ", " << robFrags2.size() );
105
106 if (robFrags1.size() == 0 && robFrags2.size() == 0) {
107 pObj = SG::asStorable(std::move(collection)) ;
108 return StatusCode::SUCCESS;
109 }
110
111 // Pre-LS1 data
112 if (robFrags1.size() > 0) {
113 ATH_CHECK( m_tool1->convert(nm, robFrags1, collection.get()) );
114 }
115 // Post-LS1 data
116 if (robFrags2.size() > 0) {
117 ATH_CHECK( m_tool2->convert(nm, robFrags2, collection.get()) );
118 }
119
120 pObj = SG::asStorable(std::move(collection));
121
122 return StatusCode::SUCCESS;
123}
124
125} // end namespace