ATLAS Offline Software
Loading...
Searching...
No Matches
PpmByteStreamV1Cnv.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
12
15
17
18#include "GaudiKernel/DataObject.h"
19#include "GaudiKernel/IOpaqueAddress.h"
20#include "GaudiKernel/IRegistry.h"
21#include "GaudiKernel/ISvcLocator.h"
22#include "GaudiKernel/StatusCode.h"
23
27
29
30#include "PpmByteStreamV1Cnv.h"
31#include "PpmByteStreamV1Tool.h"
32
33namespace LVL1BS {
34
36 : AthConstConverter( storageType(), classID(), svcloc, "PpmByteStreamV1Cnv" ),
37 m_tool("LVL1BS::PpmByteStreamV1Tool/PpmByteStreamV1Tool"),
38 m_robDataProvider("ROBDataProviderSvc", name()),
39 m_ByteStreamEventAccess("ByteStreamCnvSvc", 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() );
66 ATH_CHECK( m_tool.retrieve() );
67
68 // Get ROBDataProvider
69 StatusCode sc = m_robDataProvider.retrieve();
70 if ( sc.isFailure() ) {
71 ATH_MSG_WARNING( "Failed to retrieve service " << m_robDataProvider );
72 // return is disabled for Write BS which does not require ROBDataProviderSvc
73 // return sc ;
74 }
75 return StatusCode::SUCCESS;
76}
77
78// createObj should create the RDO from bytestream.
79
80StatusCode PpmByteStreamV1Cnv::createObjConst ( IOpaqueAddress* pAddr,
81 DataObject*& pObj ) const
82{
83 ByteStreamAddress *pBS_Addr;
84 pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
85 if ( !pBS_Addr ) {
86 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
87 return StatusCode::FAILURE;
88 }
89
90 const std::string nm = *( pBS_Addr->par() );
91
92 ATH_MSG_DEBUG( " Creating Objects " << nm );
93
94 // get SourceIDs
95 const std::vector<uint32_t>& vID(m_tool->sourceIDs(nm));
96
97 // get ROB fragments
99 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags );
100
101 // size check
102 auto ttCollection = std::make_unique<DataVector<LVL1::TriggerTower> >(SG::VIEW_ELEMENTS);
103 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
104
105 if (robFrags.size() == 0) {
106 pObj = SG::asStorable(std::move(ttCollection)) ;
107 return StatusCode::SUCCESS;
108 }
109
110 ATH_CHECK( m_tool->convert(nm, robFrags, ttCollection.get()) );
111
112 pObj = SG::asStorable(std::move(ttCollection));
113
114 return StatusCode::SUCCESS;
115}
116
117// createRep should create the bytestream from RDOs.
118
119StatusCode PpmByteStreamV1Cnv::createRepConst ( DataObject* pObj,
120 IOpaqueAddress*& pAddr ) const
121{
122 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
123
124 DataVector<LVL1::TriggerTower>* ttCollection = 0;
125 if( !SG::fromStorable( pObj, ttCollection ) ) {
126 ATH_MSG_ERROR( " Cannot cast to DataVector<TriggerTower>" );
127 return StatusCode::FAILURE;
128 }
129
130 const std::string nm = pObj->registry()->name();
131
132 ByteStreamAddress* addr = new ByteStreamAddress( classID(), nm, "" );
133
134 pAddr = addr;
135
136 // Convert to ByteStream
137 return m_tool->convert( ttCollection, re );
138}
139
140} // end namespace
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(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.
static Double_t sc
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
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()
Derived DataVector<T>.
Definition DataVector.h:795
std::vector< const ROBF * > VROBFRAG
ToolHandle< LVL1BS::PpmByteStreamV1Tool > m_tool
Tool that does the actual work.
static const CLID & classID()
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Create ByteStream from TriggerTowers.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service for writing bytestream.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create TriggerTowers from ByteStream.
PpmByteStreamV1Cnv(ISvcLocator *svcloc)
virtual StatusCode initialize() override
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Default, invalid implementation of ClassID_traits.