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 pBS_Addr = dynamic_cast<ByteStreamAddress *> (pAddr);
124 if (!pBS_Addr)
125 {
126 ATH_MSG_ERROR( "ZDC: Can not cast to ByteStreamAddress " );
127 return StatusCode::FAILURE;
128 }
129
130 const std::string nm = *(pBS_Addr->par());
131
132 ATH_MSG_DEBUG( "ZDC: Creating Objects " << nm );
133
134 // Get SourceIDs; This is NOT related to the ZDC Identifiers
135 //const std::vector<uint32_t>& vID(m_tool->sourceIDs()); // old style
136 const std::vector<uint32_t>& vID(m_tool->ppmSourceIDs("temp")); // new style
137
138 // get ROB fragments
140 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags);
141
142 // size check
143 ATH_MSG_DEBUG( "ZDC: Number of ROB fragments is " << robFrags.size() );
144
145 //ZdcDigitsCollection* const ttCollection = new ZdcDigitsCollection;
146 auto TTCollection = std::make_unique<xAOD::TriggerTowerContainer>(); // new style
147 auto aux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
148 TTCollection->setStore(aux.get());
149
150 if (robFrags.empty())
151 {
152 pObj = SG::asStorable(std::move(TTCollection));
153 ATH_CHECK( m_evtStore->record (std::move(aux), nm + "Aux.") );
154 return StatusCode::SUCCESS;
155 }
156
157
158 ATH_CHECK( m_tool->convert(robFrags, TTCollection.get()) ); // new style
159
160 pObj = SG::asStorable(std::move(TTCollection)); // new style
161 ATH_CHECK( m_evtStore->record (std::move(aux), nm + "Aux.") );
162
163 return StatusCode::SUCCESS;
164}
165//==================================================================================================
166
167
168//==================================================================================================
170
171/*
172StatusCode ZdcByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
173{
174 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
175
176 ZdcDigitsCollection* ttCollection = 0;
177 if (!SG::fromStorable(pObj, ttCollection))
178 {
179 REPORT_ERROR (StatusCode::FAILURE) << "ZDC: Cannot cast to ZdcDigitsCollection";
180 return StatusCode::FAILURE;
181 }
182
183 const std::string nm = pObj->registry()->name();
184 ByteStreamAddress* addr = new ByteStreamAddress(classID(), nm, "");
185 pAddr = addr;
186
187 // Convert to ByteStream
188 return m_tool->convert(ttCollection, re);
189}
190*/
191
192//==================================================================================================
#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)
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.
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)