ATLAS Offline Software
Loading...
Searching...
No Matches
L1TopoByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// Gaudi/Athena include(s):
7#include "GaudiKernel/IRegistry.h"
8
12
14
15// Trigger include(s):
17#include "L1TopoRDO/Helpers.h"
18
19// Local include(s):
20#include "L1TopoByteStreamCnv.h"
21#include "L1TopoSrcIdMap.h"
22
29 : AthConstConverter(storageType(), classID(), svcloc, "L1TopoByteStreamCnv"),
30 m_tool("L1TopoByteStreamTool"),
31 m_srcIdMap(0),
32 m_robDataProvider("ROBDataProviderSvc", "L1TopoByteStreamCnv"),
33 m_ByteStreamEventAccess("ByteStreamCnvSvc", "L1TopoByteStreamCnv") {}
34
45
53
57
62 //
63 // Initialise the base class:
64 //
65 StatusCode sc = Converter::initialize();
66 if (sc.isFailure()) {
67 return sc;
68 }
69
70 ATH_MSG_DEBUG("L1TopoByteStreamCnv in initialize() ");
71
72 //
73 // Get ByteStreamCnvSvc:
74 //
75 sc = m_ByteStreamEventAccess.retrieve();
76 if (sc.isFailure()) {
77 ATH_MSG_FATAL("Can't get ByteStreamEventAccess interface");
78 return sc;
79 } else {
80 ATH_MSG_DEBUG("Connected to ByteStreamEventAccess interface");
81 }
82
83 //
84 // Get L1TopoByteStreamTool:
85 //
86 sc = m_tool.retrieve();
87 if (sc.isFailure()) {
88 ATH_MSG_FATAL("Can't get L1TopoByteStreamTool");
89 return sc;
90 } else {
91 ATH_MSG_DEBUG("Connected to L1TopoByteStreamTool");
92 }
93
94 //
95 // Get ROBDataProvider:
96 //
97 sc = m_robDataProvider.retrieve();
98 if (sc.isFailure()) {
99 ATH_MSG_WARNING("Can't get ROBDataProviderSvc");
100 // return is disabled for Write BS which does not requre ROBDataProviderSvc
101 } else {
102 ATH_MSG_DEBUG("Connected to ROBDataProviderSvc");
103 }
104
105 //
106 // Create L1TopoSrcIdMap:
107 //
109
110 return StatusCode::SUCCESS;
111}
112
118StatusCode L1TopoByteStreamCnv::createObjConst(IOpaqueAddress* pAddr,
119 DataObject*& pObj) const {
120 ATH_MSG_DEBUG("createObj() called");
121 // -------------------------------------------------------------------------
122 ByteStreamAddress* pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
123 CHECK(pBS_Addr != nullptr);
124 // -------------------------------------------------------------------------
125 const std::string nm = *(pBS_Addr->par());
126 ATH_MSG_DEBUG("Creating Objects " << nm);
127
128 // Create an empty collection. This is a DataVector<L1TopoRDO> which is like a
129 // vector of pointers to L1TopoRDO and it owns the L1TopoRDOs from a memory
130 // cleanup point of view
132 StatusCode sc = m_tool->convert(nm, result);
133 if (sc.isFailure()) {
134 return sc;
135 }
136 ATH_MSG_DEBUG("Converted " << result->size() << " ROBs");
137 pObj = SG::asStorable(result);
138
139 return StatusCode::SUCCESS;
140}
141
147StatusCode L1TopoByteStreamCnv::createRepConst(DataObject* pObj,
148 IOpaqueAddress*& pAddr) const {
149 ATH_MSG_DEBUG("createRep() called");
150
151 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
152
154 if (!SG::fromStorable(pObj, result)) {
155 ATH_MSG_ERROR(" Cannot cast to L1TopoRDOCollection");
156 return StatusCode::FAILURE;
157 } else {
158 ATH_MSG_DEBUG(" Found " << result->size() << " L1TopoRDOs to convert to ROBs");
159 }
160
161 ByteStreamAddress* addr =
162 new ByteStreamAddress(classID(), pObj->registry()->name(), "");
163
164 pAddr = addr;
165
166 // Convert to ByteStream
168 it != result->end(); ++it) {
169 StatusCode sc = m_tool->convert(*it, re);
170 if (sc.isFailure()) {
171 ATH_MSG_ERROR(" Failed to create ROB for L1TopoRDO: " << **it);
172 return sc;
173 }
174 }
175 return StatusCode::SUCCESS;
176}
const boost::regex re(r_e)
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
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)
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
static constexpr long storageType()
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
L1TopoByteStreamCnv(ISvcLocator *svcloc)
Standard constructor.
virtual StatusCode initialize()
Function connecting to all the needed services/tools.
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service used when writing the BS data.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service used when reading the BS data.
static long storageType()
Function needed by the framework.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const
Function creating the L1Topo ROB fragment from a L1TopoRDOCollection object.
L1TopoSrcIdMap * m_srcIdMap
Object storing the various IDs of the CTP fragment.
~L1TopoByteStreamCnv()
Standard destructor.
static const CLID & classID()
Function needed by the framework.
ToolHandle< L1TopoByteStreamTool > m_tool
Tool doing the actual conversion.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const
Function creating the L1TopoRDOCollection object from a L1Topo ROB fragment.
Container of L1TopoRDOs (standard Athena boilerplate)
This class provides conversion between Lower level Source ID to higher level source ID for L1Topo Byt...
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)