ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 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//==================================================================================================
77{
78 //std::cout << "In ZdcByteStreamCnv::classID()" << std::endl;
80 //return ClassID_traits<xAOD::TriggerTowerContainer>::ID();
81}
82//==================================================================================================
83
84//==================================================================================================
89//==================================================================================================
90
91
92//==================================================================================================
94{
103
104 ATH_CHECK( Converter::initialize() );
106 ATH_CHECK( m_tool.retrieve() );
107 ATH_CHECK( m_evtStore.retrieve() );
108
109 StatusCode sc = m_robDataProvider.retrieve();
110 if (sc.isFailure())
111 {
112 ATH_MSG_WARNING( "ZDC: Failed to retrieve service " << m_robDataProvider );
113 }
114
115 return StatusCode::SUCCESS;
116}
117//==================================================================================================
118
119
120//==================================================================================================
121StatusCode ZdcByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
122{
124 ByteStreamAddress *pBS_Addr;
125 pBS_Addr = dynamic_cast<ByteStreamAddress *> (pAddr);
126 if (!pBS_Addr)
127 {
128 ATH_MSG_ERROR( "ZDC: Can not cast to ByteStreamAddress " );
129 return StatusCode::FAILURE;
130 }
131
132 const std::string nm = *(pBS_Addr->par());
133
134 ATH_MSG_DEBUG( "ZDC: Creating Objects " << nm );
135
136 // Get SourceIDs; This is NOT related to the ZDC Identifiers
137 //const std::vector<uint32_t>& vID(m_tool->sourceIDs()); // old style
138 const std::vector<uint32_t>& vID(m_tool->ppmSourceIDs("temp")); // new style
139
140 // get ROB fragments
142 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags);
143
144 // size check
145 ATH_MSG_DEBUG( "ZDC: Number of ROB fragments is " << robFrags.size() );
146
147 //ZdcDigitsCollection* const ttCollection = new ZdcDigitsCollection;
148 auto TTCollection = std::make_unique<xAOD::TriggerTowerContainer>(); // new style
149 auto aux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
150 TTCollection->setStore(aux.get());
151
152 if (robFrags.empty())
153 {
154 pObj = SG::asStorable(std::move(TTCollection));
155 ATH_CHECK( m_evtStore->record (std::move(aux), nm + "Aux.") );
156 return StatusCode::SUCCESS;
157 }
158
159
160 ATH_CHECK( m_tool->convert(robFrags, TTCollection.get()) ); // new style
161
162 pObj = SG::asStorable(std::move(TTCollection)); // new style
163 ATH_CHECK( m_evtStore->record (std::move(aux), nm + "Aux.") );
164
165 return StatusCode::SUCCESS;
166}
167//==================================================================================================
168
169
170//==================================================================================================
172
173/*
174StatusCode ZdcByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
175{
176 RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
177
178 ZdcDigitsCollection* ttCollection = 0;
179 if (!SG::fromStorable(pObj, ttCollection))
180 {
181 REPORT_ERROR (StatusCode::FAILURE) << "ZDC: Cannot cast to ZdcDigitsCollection";
182 return StatusCode::FAILURE;
183 }
184
185 const std::string nm = pObj->registry()->name();
186 ByteStreamAddress* addr = new ByteStreamAddress(classID(), nm, "");
187 pAddr = addr;
188
189 // Convert to ByteStream
190 return m_tool->convert(ttCollection, re);
191}
192*/
193
194//==================================================================================================
#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
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.
static const CLID & classID()
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)