ATLAS Offline Software
Loading...
Searching...
No Matches
TileBeamElemContByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 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 pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
70 if(!pRE_Addr) {
71 ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
72 return StatusCode::FAILURE;
73 }
74
75 std::vector<uint32_t> robid(1);
76 robid[0] = 0;
77 std::vector<const ROBDataProviderSvc::ROBF*> robf;
78
79 // keep pointer to whole event and to CIS PAR frag internally
80 m_event = m_robSvc->getEvent(Gaudi::Hive::currentContext());
81 m_robSvc->getROBData(Gaudi::Hive::currentContext(), m_ROBID, robf);
82 m_robFrag = (robf.size() > 0 ) ? robf[0] : 0;
83
84 TileMutableBeamElemContainer* cont = m_queue.get (true);
85 ATH_CHECK( cont->status() );
86
87 // iterate over all collections in a container and fill them
88 for (IdentifierHash hash : cont->GetAllCurrentHashes()) {
89 TileBeamElemCollection* beamCollection = cont->indexFindPtr (hash);
90 beamCollection->clear();
91 TileBeamElemCollection::ID collID = beamCollection->identify();
92
93 // find ROB
94 uint32_t newrob = m_hid2re->getRobFromFragID(collID);
95 if (newrob != robid[0]) {
96 robid[0] = newrob;
97 robf.clear();
98 m_robSvc->getROBData(Gaudi::Hive::currentContext(), robid, robf);
99 }
100
101 // unpack ROB data
102 if (robf.size() > 0 ) {
103 m_decoder->fillCollection(robf[0], *beamCollection);
104 }
105 }
106
107 ATH_MSG_DEBUG( " Creating Container " << *(pRE_Addr->par()) );
108
109 TileBeamElemContainer* basecont = cont;
110 pObj = SG::asStorable( basecont ) ;
111 return StatusCode::SUCCESS;
112}
113
114StatusCode TileBeamElemContByteStreamCnv::createRepConst(DataObject* /* pObj */, IOpaqueAddress*& /* pAddr */) const
115{
116 // No conversion from TileBeamElem to BS
117
118 ATH_MSG_ERROR( " Can not create BS from TileBeamElem " );
119
120 return StatusCode::FAILURE ;
121}
122
124{
125 return Converter::finalize();
126}
#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.
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)