ATLAS Offline Software
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 
21 #include <cstdint>
22 #include <vector>
23 
28 #include "ByteStreamData/ROBData.h"
29 #include "StoreGate/StoreGateSvc.h"
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 //==================================================================================================
55 ZdcByteStreamCnv::ZdcByteStreamCnv(ISvcLocator* svcloc) :
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 //==================================================================================================
70 {
71 }
72 //==================================================================================================
73 
74 
75 //==================================================================================================
77 {
78  //std::cout << "In ZdcByteStreamCnv::classID()" << std::endl;
80  //return ClassID_traits<xAOD::TriggerTowerContainer>::ID();
81 }
82 //==================================================================================================
83 
84 //==================================================================================================
86 {
88 }
89 //==================================================================================================
90 
91 
92 //==================================================================================================
94 {
105  ATH_CHECK( m_ByteStreamEventAccess.retrieve() );
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 //==================================================================================================
121 StatusCode 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 /*
174 StatusCode 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 //==================================================================================================
ZdcByteStreamCnv::m_tool
ToolHandle< ZdcByteStreamReadV1V2Tool > m_tool
Tool that does the actual work.
Definition: ZdcByteStreamCnv.h:73
ZdcByteStreamCnv::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for READING bytestream.
Definition: ZdcByteStreamCnv.h:76
ZdcByteStreamCnv::ZdcByteStreamCnv
ZdcByteStreamCnv(ISvcLocator *svcloc)
ZdcByteStreamCnv.cxx.
Definition: ZdcByteStreamCnv.cxx:55
ZdcByteStreamTool.h
StorableConversions.h
convert to and from a SG storable
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
initialize
void initialize()
Definition: run_EoverP.cxx:894
ZdcByteStreamCnv::storageType
static long storageType()
Definition: ZdcByteStreamCnv.cxx:85
TriggerTowerContainer.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
ZdcDigitsCollection.h
IByteStreamEventAccess.h
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
ZdcByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: ZdcByteStreamCnv.cxx:121
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ZdcByteStreamCnv::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Definition: ZdcByteStreamCnv.h:81
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:27
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ZdcByteStreamCnv::classID
static const CLID & classID()
Definition: ZdcByteStreamCnv.cxx:76
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
errorcheck.h
Helpers for checking error return status codes and reporting errors.
ZdcDigits.h
TrigT1CaloDefs.h
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
ZdcByteStreamReadV1V2Tool.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TriggerTower.h
ZdcByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: ZdcByteStreamCnv.cxx:93
ZdcByteStreamCnv::m_ByteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service for WRITING bytestream.
Definition: ZdcByteStreamCnv.h:79
StoreGateSvc.h
IROBDataProviderSvc.h
ZdcByteStreamCnv.h
ZdcByteStreamCnv::~ZdcByteStreamCnv
virtual ~ZdcByteStreamCnv()
Definition: ZdcByteStreamCnv.cxx:69
TriggerTowerAuxContainer.h