ATLAS Offline Software
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 
17 #include "ByteStreamData/RawEvent.h"
18 
19 #include "AthenaKernel/CLASS_DEF.h"
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 
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();
59 
60  return StatusCode::SUCCESS;
61 }
62 
63 
64 StatusCode 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 
114 StatusCode 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 }
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
TileBeamElemCollection
Definition: TileBeamElemCollection.h:12
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
StorableConversions.h
convert to and from a SG storable
TileMutableDataContainer::status
StatusCode status() const
Return the error status from the constructors.
TileBeamElemContByteStreamCnv::m_hid2re
const TileHid2RESrcID * m_hid2re
Pointer to TileHid2RESrcID.
Definition: TileBeamElemContByteStreamCnv.h:85
initialize
void initialize()
Definition: run_EoverP.cxx:894
TileHid2RESrcID::getRobFromFragID
uint32_t getRobFromFragID(int frag_id) const
make a ROB SrcID for a fragment ID
Definition: TileHid2RESrcID.cxx:457
TileBeamElemContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: TileBeamElemContByteStreamCnv.cxx:114
DIGI_PAR_FRAG
#define DIGI_PAR_FRAG
Definition: TileTBFrag.h:41
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
ROBDataProviderSvc.h
TileBeamElemContByteStreamCnv::m_ROBID
std::vector< uint32_t > m_ROBID
Definition: TileBeamElemContByteStreamCnv.h:82
TileBeamElemContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: TileBeamElemContByteStreamCnv.cxx:44
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
TileBeamElemContByteStreamCnv::classID
static const CLID & classID()
Definition: TileBeamElemContByteStreamCnv.cxx:40
TileBeamElemCollection::ID
MyBase::ID ID
Definition: TileBeamElemCollection.h:17
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
IdentifiableContainerMT::GetAllCurrentHashes
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
Definition: IdentifiableContainerMT.h:231
TileROD_Decoder.h
TileRawDataCollection::clear
virtual void clear()
RawEvent.h
TileBeamElemContByteStreamCnv::storageType
static long storageType()
Definition: TileBeamElemContByteStreamCnv.cxx:42
TileBeamElemContByteStreamCnv::finalize
virtual StatusCode finalize() override
Definition: TileBeamElemContByteStreamCnv.cxx:123
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
TileBeamElemContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: TileBeamElemContByteStreamCnv.cxx:64
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamAddress.h
TileBeamElemContainer
Definition: TileBeamElemContainer.h:13
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
TileRawDataCollection::identify
ID identify() const
Definition: TileRawDataCollection.h:71
TileHid2RESrcID.h
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
TileBeamElemContByteStreamCnv::TileBeamElemContByteStreamCnv
TileBeamElemContByteStreamCnv(ISvcLocator *svcloc)
Definition: TileBeamElemContByteStreamCnv.cxx:31
TileMutableDataContainer::indexFindPtr
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LASER_OBJ_FRAG
#define LASER_OBJ_FRAG
Definition: TileTBFrag.h:49
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileTBFrag.h
TileMutableBeamElemContainer
Definition: TileMutableBeamElemContainer.h:25
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
TileBeamElemContByteStreamCnv.h
TileBeamElemContainer.h
ByteStreamCnvSvcBase.h
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
TileBeamElemContByteStreamCnv::m_robSvc
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
Definition: TileBeamElemContByteStreamCnv.h:71
TileBeamElemContByteStreamCnv::m_decoder
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
Definition: TileBeamElemContByteStreamCnv.h:74
CLASS_DEF.h
macros to associate a CLID to a type