ATLAS Offline Software
Loading...
Searching...
No Matches
TileBeamElemContByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Gaudi includes
6#include "GaudiKernel/StatusCode.h"
7#include "GaudiKernel/DataObject.h"
8#include "GaudiKernel/IRegistry.h"
9
10// Athena includes
13
18
20
21
22// Tile includes
28
29
30
32 : AthConstConverter(storageType(), classID(), svcloc, "TileBeamElemContByteStreamCnv")
33 , m_robSvc("ROBDataProviderSvc", name())
34 , m_decoder("TileROD_Decoder")
35 , m_ROBID()
36 , m_hid2re(nullptr)
37{
38}
39
41
43
45
46 ATH_CHECK( Converter::initialize() );
47
48 ATH_MSG_DEBUG( " initialize " );
49
50 // retrieve Tool
51 ATH_CHECK( m_decoder.retrieve() );
52 m_hid2re = m_decoder->getHid2re();
53
54 ATH_CHECK( m_robSvc.retrieve() );
55
56 m_ROBID.clear();
57 m_ROBID.push_back( m_hid2re->getRobFromFragID(DIGI_PAR_FRAG) );
58 m_ROBID.push_back( m_hid2re->getRobFromFragID(LASER_OBJ_FRAG) );
59
60 return StatusCode::SUCCESS;
61}
62
63
64StatusCode TileBeamElemContByteStreamCnv::createObjConst (IOpaqueAddress* pAddr, DataObject*& pObj) const
65{
66 ATH_MSG_DEBUG( " Executing createObj method" );
67
68 ByteStreamAddress* pRE_Addr{};
69 ATH_CHECK( (pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
70
71 const EventContext& ctx = pRE_Addr->getEventContext();
72
73 std::vector<uint32_t> robid(1);
74 robid[0] = 0;
75 std::vector<const ROBDataProviderSvc::ROBF*> robf;
76
77 // keep pointer to whole event and to CIS PAR frag internally
78 m_event = m_robSvc->getEvent(ctx);
79 m_robSvc->getROBData(ctx, m_ROBID, robf);
80 m_robFrag = (robf.size() > 0 ) ? robf[0] : 0;
81
82 TileMutableBeamElemContainer* cont = m_queue.get (true);
83 ATH_CHECK( cont->status() );
84
85 // iterate over all collections in a container and fill them
86 for (IdentifierHash hash : cont->GetAllCurrentHashes()) {
87 TileBeamElemCollection* beamCollection = cont->indexFindPtr (hash);
88 beamCollection->clear();
89 TileBeamElemCollection::ID collID = beamCollection->identify();
90
91 // find ROB
92 uint32_t newrob = m_hid2re->getRobFromFragID(collID);
93 if (newrob != robid[0]) {
94 robid[0] = newrob;
95 robf.clear();
96 m_robSvc->getROBData(ctx, robid, robf);
97 }
98
99 // unpack ROB data
100 if (robf.size() > 0 ) {
101 m_decoder->fillCollection(robf[0], *beamCollection);
102 }
103 }
104
105 ATH_MSG_DEBUG( " Creating Container " << *(pRE_Addr->par()) );
106
107 TileBeamElemContainer* basecont = cont;
108 pObj = SG::asStorable( basecont ) ;
109 return StatusCode::SUCCESS;
110}
111
112StatusCode TileBeamElemContByteStreamCnv::createRepConst(DataObject* /* pObj */, IOpaqueAddress*& /* pAddr */) const
113{
114 // No conversion from TileBeamElem to BS
115
116 ATH_MSG_ERROR( " Can not create BS from TileBeamElem " );
117
118 return StatusCode::FAILURE ;
119}
120
122{
123 return Converter::finalize();
124}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
macros to associate a CLID to a type
Helpers for checking error return status codes and reporting errors.
uint32_t CLID
The Class ID type.
convert to and from a SG storable
#define LASER_OBJ_FRAG
Definition TileTBFrag.h:49
#define DIGI_PAR_FRAG
Definition TileTBFrag.h:41
AthConstConverter(long storage_type, const CLID &class_type, ISvcLocator *svc, const std::string &name)
const std::string & name() const
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
const EventContext & getEventContext() const
static constexpr long storageType()
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
This is a "hash" representation of an Identifier.
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
const TileHid2RESrcID * m_hid2re
Pointer to TileHid2RESrcID.
StatusCode status() const
Return the error status from the constructors.
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
virtual void clear()
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)