ATLAS Offline Software
Loading...
Searching...
No Matches
CpReadByteStreamV1V2Cnv.cxx
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
11
14
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
26
28
30#include "CpByteStreamV1Tool.h"
31#include "CpByteStreamV2Tool.h"
32
33namespace LVL1BS {
34
36 : AthConstConverter( storageType(), classID(), svcloc, "CpReadByteStreamV1V2Cnv" ),
37 m_tool1("LVL1BS::CpByteStreamV1Tool/CpByteStreamV1Tool"),
38 m_tool2("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool"),
39 m_robDataProvider("ROBDataProviderSvc", name())
40{
41}
42
46
47// CLID
48
53
58
59// Init method gets all necessary services etc.
60
61
63{
64 ATH_CHECK( Converter::initialize() );
65 ATH_CHECK( m_tool1.retrieve() );
66 ATH_CHECK( m_tool2.retrieve() );
67 ATH_CHECK( m_robDataProvider.retrieve() );
68
69 return StatusCode::SUCCESS;
70}
71
72// createObj should create the RDO from bytestream.
73
74StatusCode CpReadByteStreamV1V2Cnv::createObjConst( IOpaqueAddress* pAddr,
75 DataObject*& pObj ) const
76{
77 ByteStreamAddress *pBS_Addr;
78 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
79 if ( !pBS_Addr ) {
80 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
81 return StatusCode::FAILURE;
82 }
83
84 const std::string nm = *( pBS_Addr->par() );
85
86 ATH_MSG_DEBUG( " Creating Objects " << nm );
87
88 // get SourceIDs
89 const std::vector<uint32_t>& vID1(m_tool1->sourceIDs());
90 const std::vector<uint32_t>& vID2(m_tool2->sourceIDs());
91
92 // get ROB fragments
94 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID1, robFrags1 );
96 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID2, robFrags2 );
97
98 // size check
99 auto towerCollection = std::make_unique<DataVector<LVL1::CPMTower> >();
100 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags1.size()
101 << ", " << robFrags2.size() );
102
103 if (robFrags1.size() == 0 && robFrags2.size() == 0) {
104 pObj = SG::asStorable(std::move(towerCollection)) ;
105 return StatusCode::SUCCESS;
106 }
107
108 // Pre-LS1 data
109 if (robFrags1.size() > 0) {
110 ATH_CHECK( m_tool1->convert(nm, robFrags1, towerCollection.get()) );
111 }
112 // Post-LS1 data
113 if (robFrags2.size() > 0) {
114 ATH_CHECK( m_tool2->convert(nm, robFrags2, towerCollection.get()) );
115 }
116
117 pObj = SG::asStorable(std::move(towerCollection));
118
119 return StatusCode::SUCCESS;
120}
121
122} // end namespace
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::vector< Identifier > ID
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Helpers for checking error return status codes and reporting errors.
An STL vector of pointers that by default owns its pointed-to elements.
uint32_t CLID
The Class ID type.
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
convert to and from a SG storable
AthConstConverter(long storage_type, const CLID &class_type, ISvcLocator *svc, const std::string &name)
const std::string & name() const
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
static constexpr long storageType()
std::vector< const ROBF * > VROBFRAG
ToolHandle< LVL1BS::CpByteStreamV1Tool > m_tool1
Tool that does the actual work pre-LS1.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create CPM Towers from ByteStream.
virtual StatusCode initialize() override
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
ToolHandle< LVL1BS::CpByteStreamV2Tool > m_tool2
Tool that does the actual work post-LS1.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Default, invalid implementation of ClassID_traits.