ATLAS Offline Software
TileMuRcvContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Gaudi includes
6 #include "GaudiKernel/MsgStream.h"
7 #include "GaudiKernel/StatusCode.h"
8 #include "GaudiKernel/DataObject.h"
9 #include "GaudiKernel/IRegistry.h"
10 #include "GaudiKernel/IToolSvc.h"
11 
12 // Athena includes
14 
20 
22 #include "AthenaKernel/CLASS_DEF.h"
23 
24 // Tile includes
28 
29 
30 #include <string>
31 
32 
34  : AthConstConverter(storageType(), classID(),svcloc, "TileMuRcvContByteStreamCnv")
35  , m_tool("TileMuRcvContByteStreamTool")
36  , m_byteStreamCnvSvc("ByteStreamCnvSvc", name())
37  , m_storeGate("StoreGateSvc", name())
38  , m_robSvc("ROBDataProviderSvc", name())
39  , m_decoder("TileROD_Decoder")
40 {
41 }
42 
45 }
46 
49 }
50 
52 {
54 
55  ATH_MSG_DEBUG(" initialize ");
56 
57  // Get ByteStreamCnvSvc
58  ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
59 
60  // retrieve Tool
61  ATH_CHECK( m_decoder.retrieve() );
62 
63  ATH_CHECK( m_tool.retrieve() );
64 
65  ATH_CHECK( m_robSvc.retrieve() );
66 
67  ATH_CHECK( m_storeGate.retrieve() );
68 
69  return StatusCode::SUCCESS ;
70 }
71 
72 
73 StatusCode TileMuRcvContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
74 {
75 
76  ATH_MSG_DEBUG( " Executing createObj method" );
77 
78  ByteStreamAddress* pRE_Addr;
79  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
80  if(!pRE_Addr) {
81  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
82  return StatusCode::FAILURE;
83  }
84 
85  const RawEvent* re = m_robSvc->getEvent(Gaudi::Hive::currentContext());
86  if (!re) {
87  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
88  return StatusCode::FAILURE;
89  }
90 
91  auto cont = std::make_unique<TileMuonReceiverContainer>();
92 
93  StatusCode sc=m_decoder->convertTMDBDecision(re,cont.get());
94  if (sc!=StatusCode::SUCCESS) {
95  ATH_MSG_WARNING( "Conversion tool returned an error. TileMuonReceiverContainer might be empty." );
96  }
97 
98  pObj = SG::asStorable( std::move(cont) );
99 
100  return StatusCode::SUCCESS;
101 }
102 
103 StatusCode TileMuRcvContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
104 {
105  ATH_MSG_DEBUG( " Executing createRep method" );
106 
107  // get Full Event Assembler
109  std::string key("Tile");
110 
111  ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea, key) );
112 
113  // create TileMuonReceiverContainer
114  //
115  TileMuonReceiverContainer* muRcvCont(0);
116  SG::fromStorable(pObj, muRcvCont);
117  if(!muRcvCont){
118  ATH_MSG_ERROR( " Can not cast to TileMuonReceiverContainer " );
119  return StatusCode::FAILURE;
120  }
121 
122  std::string name = pObj->registry()->name();
123  ByteStreamAddress* addr = new ByteStreamAddress(classID(), name, "");
124 
125  pAddr = addr;
126 
127  // call TileMuRcvContByteStreamTool
128  ATH_CHECK( m_tool->convert(muRcvCont,fea) );
129 
130  return StatusCode::SUCCESS;
131 }
132 
134 {
135  return Converter::finalize();
136 }
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
TileMuRcvContByteStreamCnv::finalize
virtual StatusCode finalize() override
Definition: TileMuRcvContByteStreamCnv.cxx:133
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
initialize
void initialize()
Definition: run_EoverP.cxx:894
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
TileMuRcvContByteStreamCnv::storageType
static long storageType()
Definition: TileMuRcvContByteStreamCnv.cxx:47
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TileMuRcvContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Pointer to TileMuRcvContByteStreamTool.
Definition: TileMuRcvContByteStreamCnv.h:54
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileROD_Decoder.h
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
ByteStreamAddress.h
TileMuRcvContByteStreamCnv::TileMuRcvContByteStreamCnv
TileMuRcvContByteStreamCnv(ISvcLocator *svcloc)
Definition: TileMuRcvContByteStreamCnv.cxx:33
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
TileMuRcvContByteStreamCnv::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGateSvc.
Definition: TileMuRcvContByteStreamCnv.h:59
TileMuRcvContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: TileMuRcvContByteStreamCnv.cxx:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileMuRcvContByteStreamCnv::classID
static const CLID & classID()
Definition: TileMuRcvContByteStreamCnv.cxx:43
AthConstConverter::name
const std::string & name() const
Definition: AthConstConverter.h:67
TileMuRcvContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: TileMuRcvContByteStreamCnv.cxx:73
TileMuRcvContByteStreamCnv::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: TileMuRcvContByteStreamCnv.h:56
StoreClearedIncident.h
Incident sent after a store is cleared.
TileMuRcvContByteStreamCnv::m_decoder
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
Definition: TileMuRcvContByteStreamCnv.h:65
TileMuRcvContByteStreamCnv::m_robSvc
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
Definition: TileMuRcvContByteStreamCnv.h:62
TileMuRcvContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: TileMuRcvContByteStreamCnv.cxx:103
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
TileMuRcvContByteStreamCnv.h
ByteStreamCnvSvcBase.h
IByteStreamCnvSvc.h
TileMuRcvContByteStreamTool.h
TileContainer
Definition: TileContainer.h:38
CLASS_DEF.h
macros to associate a CLID to a type
IROBDataProviderSvc.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37