ATLAS Offline Software
L1CaloByteStreamAuxCnv.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <vector>
6 #include <stdint.h>
7 
8 #include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
9 #include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h"
10 #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
11 
12 #include "ByteStreamData/RawEvent.h"
13 #include "ByteStreamData/ROBData.h"
14 
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"
21 
22 #include "AthenaKernel/ClassID_traits.h"
23 #include "AthenaKernel/StorableConversions.h"
24 #include "StoreGate/StoreGateSvc.h"
25 
26 
27 #include "../ToString.h"
28 #include "L1CaloByteStreamReadTool.h"
29 
30 namespace LVL1BS {
31 
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") {
38 
39 }
40 
41 // CLID
42 template<typename ContainerT, typename AuxContainerT>
43 const CLID& L1CaloByteStreamAuxCnv<ContainerT,AuxContainerT>::classID() {
44  return ClassID_traits<ContainerT>::ID();
45 }
46 
47 long L1CaloByteStreamAuxCnv<ContainerT,AuxContainerT>::storageType()
48 {
49  return ByteStreamAddress::storageType();
50 }
51 
52 // Init method gets all necessary services etc.
53 
54 
55 template<typename ContainerT, typename AuxContainerT>
56 StatusCode L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::initialize() {
57  ATH_MSG_DEBUG("Initializing " << m_name);
58 
59  CHECK(Converter::initialize());
60  CHECK(m_readTool.retrieve());
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 // createObj should create the RDO from bytestream.
66 
67 template<typename ContainerT, typename AuxContainerT>
68 StatusCode L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::createObj(IOpaqueAddress* pAddr,
69  DataObject*& pObj) {
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);
77 
78  AuxContainerT* aux = new AuxContainerT();
79  ContainerT* const ttCollection = new ContainerT();
80  ttCollection->setStore(aux);
81 
82  StatusCode sc = m_readTool->convert(ttCollection);
83  if (sc.isFailure()) {
84  ATH_MSG_ERROR("Failed to create Objects");
85  delete ttCollection;
86  return sc;
87  }
88  ATH_MSG_VERBOSE(ToString(*ttCollection));
89  ATH_MSG_DEBUG("Number of readed objects: " << ttCollection->size());
90 
91 
92  pObj = SG::asStorable(aux);
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 // createRep should create the bytestream from RDOs.
98 
99 template<typename ContainerT, typename AuxContainerT>
100 StatusCode L1CaloByteStreamAuxCnv<ContainerT, AuxContainerT>::createRep(DataObject* /*pObj*/,
101  IOpaqueAddress*& /*pAddr*/) {
102  return StatusCode::FAILURE;
103 }
104 
105 } // end namespace