ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
20
21#include <cstdint>
22#include <vector>
23
32#include "GaudiKernel/DataObject.h"
33#include "GaudiKernel/IOpaqueAddress.h"
34#include "GaudiKernel/IRegistry.h"
35#include "GaudiKernel/ISvcLocator.h"
36#include "GaudiKernel/StatusCode.h"
37#include "GaudiKernel/MsgStream.h"
40
42#include "ZdcEvent/ZdcDigits.h"
47
48//L1Calo include
53
54//==================================================================================================
56 AthConstConverter(storageType(), classID(), svcloc, "ZdcByteStreamCnv"),
57 m_name("ZdcByteStreamCnv"),
58 //m_tool("ZdcByteStreamTool/ZdcByteStreamTool"), // old style
59 m_tool("ZdcByteStreamReadV1V2Tool/ZdcByteStreamReadV1V2Tool"), // new style
60 m_robDataProvider("ROBDataProviderSvc",m_name),
61 m_ByteStreamEventAccess("ByteStreamCnvSvc", m_name),
62 m_evtStore("StoreGateSvc", m_name)
63{
64}
65//==================================================================================================
66
67
68//==================================================================================================
72//==================================================================================================
73
74
75//==================================================================================================
80//==================================================================================================
81
82//==================================================================================================
87//==================================================================================================
88
89
90//==================================================================================================
92{
101
102 ATH_CHECK( Converter::initialize() );
104 ATH_CHECK( m_tool.retrieve() );
105 ATH_CHECK( m_evtStore.retrieve() );
106
107 StatusCode sc = m_robDataProvider.retrieve();
108 if (sc.isFailure())
109 {
110 ATH_MSG_WARNING( "ZDC: Failed to retrieve service " << m_robDataProvider );
111 }
112
113 return StatusCode::SUCCESS;
114}
115//==================================================================================================
116
117
118//==================================================================================================
119StatusCode ZdcByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
120{
122 ByteStreamAddress* pBS_Addr{};
123 ATH_CHECK( (pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
124
125 const EventContext& ctx = pBS_Addr->getEventContext();
126 const std::string nm = *(pBS_Addr->par());
127
128 ATH_MSG_DEBUG( "ZDC: Creating Objects " << nm );
129
130 // Get SourceIDs; This is NOT related to the ZDC Identifiers
131 //const std::vector<uint32_t>& vID(m_tool->sourceIDs()); // old style
132 const std::vector<uint32_t>& vID(m_tool->ppmSourceIDs("temp")); // new style
133
134 // get ROB fragments
136 m_robDataProvider->getROBData(ctx, vID, robFrags);
137
138 // size check
139 ATH_MSG_DEBUG( "ZDC: Number of ROB fragments is " << robFrags.size() );
140
141 //ZdcDigitsCollection* const ttCollection = new ZdcDigitsCollection;
142 auto TTCollection = std::make_unique<xAOD::TriggerTowerContainer>(); // new style
143 auto aux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
144 TTCollection->setStore(aux.get());
145
146 if (robFrags.empty())
147 {
148 pObj = SG::asStorable(std::move(TTCollection));
149 ATH_CHECK( m_evtStore->record (std::move(aux), nm + "Aux.") );
150 return StatusCode::SUCCESS;
151 }
152
153
154 ATH_CHECK( m_tool->convert(robFrags, TTCollection.get()) ); // new style
155
156 pObj = SG::asStorable(std::move(TTCollection)); // new style
157 ATH_CHECK( m_evtStore->record (std::move(aux), nm + "Aux.") );
158
159 return StatusCode::SUCCESS;
160}
161//==================================================================================================
162
163
164//==================================================================================================
166
167/*
168StatusCode ZdcByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
169{
170 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
171
172 ZdcDigitsCollection* ttCollection = 0;
173 if (!SG::fromStorable(pObj, ttCollection))
174 {
175 REPORT_ERROR (StatusCode::FAILURE) << "ZDC: Cannot cast to ZdcDigitsCollection";
176 return StatusCode::FAILURE;
177 }
178
179 const std::string nm = pObj->registry()->name();
180 ByteStreamAddress* addr = new ByteStreamAddress(classID(), nm, "");
181 pAddr = addr;
182
183 // Convert to ByteStream
184 return m_tool->convert(ttCollection, re);
185}
186*/
187
188//==================================================================================================
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
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...
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.
const EventContext & getEventContext() const
static constexpr long storageType()
std::vector< const ROBF * > VROBFRAG
static CLID classID()
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for READING bytestream.
ServiceHandle< StoreGateSvc > m_evtStore
virtual StatusCode initialize() override
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
static long storageType()
ZdcByteStreamCnv(ISvcLocator *svcloc)
ZdcByteStreamCnv.cxx.
std::string m_name
Converter name.
ToolHandle< ZdcByteStreamReadV1V2Tool > m_tool
Tool that does the actual work.
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service for WRITING bytestream.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)