2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
8 #include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
9 #include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h"
10 #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
12 #include "ByteStreamData/RawEvent.h"
13 #include "ByteStreamData/ROBData.h"
15 #include "AthenaKernel/errorcheck.h"
16 #include "GaudiKernel/DataObject.h"
17 #include "GaudiKernel/IOpaqueAddress.h"
18 #include "GaudiKernel/IRegistry.h"
19 #include "GaudiKernel/ISvcLocator.h"
20 #include "GaudiKernel/StatusCode.h"
22 #include "AthenaKernel/ClassID_traits.h"
23 #include "AthenaKernel/StorableConversions.h"
24 #include "StoreGate/StoreGateSvc.h"
27 #include "../ToString.h"
28 #include "L1CaloByteStreamReadTool.h"
32 template<typename ContainerT, typename AuxContainerT>
33 L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::L1CaloByteStreamAuxCnv(ISvcLocator* svcloc) :
34 Converter(storageType(), classID(), svcloc),
35 AthMessaging(svcloc != 0 ? msgSvc() : 0, "L1CaloByteStreamAuxCnv"),
36 m_name("L1CaloByteStreamAuxCnv"),
37 m_readTool("LVL1BS::L1CaloByteStreamReadTool/L1CaloByteStreamReadTool") {
42 template<typename ContainerT, typename AuxContainerT>
43 const CLID& L1CaloByteStreamAuxCnv<ContainerT,AuxContainerT>::classID() {
44 return ClassID_traits<ContainerT>::ID();
47 long L1CaloByteStreamAuxCnv<ContainerT,AuxContainerT>::storageType()
49 return ByteStreamAddress::storageType();
52 // Init method gets all necessary services etc.
55 template<typename ContainerT, typename AuxContainerT>
56 StatusCode L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::initialize() {
57 ATH_MSG_DEBUG("Initializing " << m_name);
59 CHECK(Converter::initialize());
60 CHECK(m_readTool.retrieve());
62 return StatusCode::SUCCESS;
65 // createObj should create the RDO from bytestream.
67 template<typename ContainerT, typename AuxContainerT>
68 StatusCode L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::createObj(IOpaqueAddress* pAddr,
70 ATH_MSG_DEBUG("createObj() called");
71 // -------------------------------------------------------------------------
72 ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
73 CHECK(pBS_Addr != nullptr);
74 // -------------------------------------------------------------------------
75 const std::string nm = *(pBS_Addr->par());
76 ATH_MSG_DEBUG("Creating Objects " << nm);
78 AuxContainerT* aux = new AuxContainerT();
79 ContainerT* const ttCollection = new ContainerT();
80 ttCollection->setStore(aux);
82 StatusCode sc = m_readTool->convert(ttCollection);
84 ATH_MSG_ERROR("Failed to create Objects");
88 ATH_MSG_VERBOSE(ToString(*ttCollection));
89 ATH_MSG_DEBUG("Number of readed objects: " << ttCollection->size());
92 pObj = SG::asStorable(aux);
94 return StatusCode::SUCCESS;
97 // createRep should create the bytestream from RDOs.
99 template<typename ContainerT, typename AuxContainerT>
100 StatusCode L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::createRep(DataObject* /*pObj*/,
101 IOpaqueAddress*& /*pAddr*/) {
102 return StatusCode::FAILURE;