ATLAS Offline Software
Loading...
Searching...
No Matches
TileDigitsContByteStreamCnv.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
9// Athena includes
12
18
21
22
23// Tile includes
30
31#include <vector>
32#include <string>
33#include <stdint.h>
34
35
37 : AthConstConverter(storageType(), classID(), svcloc, "TileDigitsContByteStreamCnv")
38 , m_tool("TileDigitsContByteStreamTool")
39 , m_byteStreamCnvSvc("ByteStreamCnvSvc", name())
40 , m_robSvc("ROBDataProviderSvc", name())
41 , m_decoder("TileROD_Decoder")
42 , m_hid2re(0)
43{
44}
45
47
49
51
52 ATH_CHECK(Converter::initialize());
53
54 ATH_MSG_DEBUG(" initialize ");
55
56 // Get ByteStreamCnvSvc
57 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
58
59 // retrieve Tool
60 ATH_CHECK( m_decoder.retrieve() );
61 m_hid2re = m_decoder->getHid2re();
62
63 ATH_CHECK( m_tool.retrieve() );
64
65 ATH_CHECK( m_robSvc.retrieve() );
66
67
68 return StatusCode::SUCCESS;
69}
70
71StatusCode TileDigitsContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
72{
73 ATH_MSG_DEBUG(" Executing createObj method ");
74
75 ByteStreamAddress* pRE_Addr{};
76 ATH_CHECK( (pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
77
78 const EventContext& ctx = pRE_Addr->getEventContext();
79
80 const std::string containerName(*(pRE_Addr->par()));
81 bool isTMDB(containerName == std::string("MuRcvDigitsCnt"));
82 bool isFELIX(containerName == std::string("TileDigitsFlxCnt"));
83 uint32_t newrob = 0x0;
84
85
86 std::vector<uint32_t> robid(1);
87 robid[0] = 0;
88 std::vector<const ROBDataProviderSvc::ROBF*> robf;
89
90 TileMutableDigitsContainer* cont = m_queue.get (true);
91 ATH_CHECK( cont->status() );
92
93 // iterate over all collections in a container and fill them
94 //
95 for (IdentifierHash hash : cont->GetAllCurrentHashes()) {
96 TileDigitsCollection* digitsCollection = cont->indexFindPtr (hash);
97 digitsCollection->clear();
98 TileDigitsCollection::ID collID = digitsCollection->identify();
99
100 // find ROB
101 if (isTMDB) {
102 newrob = m_hid2re->getRobFromTileMuRcvFragID(collID);
103 } else if (isFELIX) {
104 newrob = m_hid2re->getRobFromFragID(collID + TileCalibUtils::FELIX_FRAGID_OFFSET);
105 } else {
106 newrob = m_hid2re->getRobFromFragID(collID);
107 }
108
109 if (newrob != robid[0]) {
110 robid[0] = newrob;
111 robf.clear();
112 m_robSvc->getROBData(ctx, robid, robf);
113 }
114
115 if (robf.size() > 0 ) {
116 if (isTMDB) {// reid for TMDB 0x5x010x
117 ATH_MSG_DEBUG(" Decoding TMDB digits in ROD fragment ");
118 m_decoder->fillCollection_TileMuRcv_Digi(robf[0], *digitsCollection);
119 }else if (isFELIX) {
120 ATH_MSG_DEBUG(" Decoding FELIX digits in ROD fragment ");
121 m_decoder->fillCollection_FELIX_Digi(robf[0], *digitsCollection);
122 } else {
123 m_decoder->fillCollection(robf[0], *digitsCollection);
124 }
125 } else {
126 uint32_t status = TileROD_Decoder::NO_ROB;
127 digitsCollection->setFragBCID(0xDEAD | (status<<16));
128 ATH_MSG_DEBUG( "Status for " << ((isTMDB)?"TMDB ":"") << "drawer 0x" << MSG::hex << collID << " in Digi frag is 0x" << status << MSG::dec);
129 }
130
131
132 }
133
134 ATH_MSG_DEBUG( "Creating digits container: " << containerName );
135
136 TileDigitsContainer* basecont = cont;
137 pObj = SG::asStorable( basecont ) ;
138
139
140 return StatusCode::SUCCESS;
141}
142
143
144StatusCode TileDigitsContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
145{
146 // convert TileDigitsContainer in the container into ByteStream
147
148 ATH_MSG_DEBUG(" Executing createRep method ");
149
150 // uint32_t runnum = re->header()->specific_part()->run_no();
151
152 // get Full Event Assembler
154 std::string key("Tile");
155 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea, key) );
156
157 // create TileDigitsContainer
158 TileDigitsContainer* digicont(0) ;
159 SG::fromStorable(pObj, digicont );
160
161 if(!digicont){
162 ATH_MSG_ERROR(" Can not cast to TileDigitsContainer ");
163 return StatusCode::FAILURE;
164 }
165
166 std::string name = pObj->registry()->name();
167
168 ByteStreamAddress* addr = new ByteStreamAddress(classID(), name, "");
169
170 pAddr = addr;
171
172 // call TileDigitsContByteStreamTool
173
174 return m_tool->convert(digicont, fea);
175}
176
178{
179 return Converter::finalize();
180}
#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
Incident sent after a store is cleared.
TileMutableDataContainer< TileDigitsContainer > TileMutableDigitsContainer
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()
Template class for assembling a full atlas raw event from subfragments.
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.
static const unsigned int FELIX_FRAGID_OFFSET
Offset for frag ID used for FELIX in frag ID to ROB ID map.
void clear()
Clear everything for next event.
void setFragBCID(uint32_t bcid)
Set BCID.
virtual StatusCode finalize() override
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
virtual StatusCode initialize() override
const TileHid2RESrcID * m_hid2re
Pointer to TileHid2RESrcID.
ToolHandle< TileDigitsContByteStreamTool > m_tool
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
StatusCode status() const
Return the error status from the constructors.
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)