ATLAS Offline Software
Loading...
Searching...
No Matches
TileDigitsContByteStreamCnv.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/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 pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
77 if(!pRE_Addr) {
78 ATH_MSG_ERROR(" Can not cast to ByteStreamAddress ");
79 return StatusCode::FAILURE;
80 }
81
82 const std::string containerName(*(pRE_Addr->par()));
83 bool isTMDB(containerName == std::string("MuRcvDigitsCnt"));
84 bool isFELIX(containerName == std::string("TileDigitsFlxCnt"));
85 uint32_t newrob = 0x0;
86
87
88 std::vector<uint32_t> robid(1);
89 robid[0] = 0;
90 std::vector<const ROBDataProviderSvc::ROBF*> robf;
91
92 TileMutableDigitsContainer* cont = m_queue.get (true);
93 ATH_CHECK( cont->status() );
94
95 // iterate over all collections in a container and fill them
96 //
97 for (IdentifierHash hash : cont->GetAllCurrentHashes()) {
98 TileDigitsCollection* digitsCollection = cont->indexFindPtr (hash);
99 digitsCollection->clear();
100 TileDigitsCollection::ID collID = digitsCollection->identify();
101
102 // find ROB
103 if (isTMDB) {
104 newrob = m_hid2re->getRobFromTileMuRcvFragID(collID);
105 } else if (isFELIX) {
106 newrob = m_hid2re->getRobFromFragID(collID + TileCalibUtils::FELIX_FRAGID_OFFSET);
107 } else {
108 newrob = m_hid2re->getRobFromFragID(collID);
109 }
110
111 if (newrob != robid[0]) {
112 robid[0] = newrob;
113 robf.clear();
114 m_robSvc->getROBData(Gaudi::Hive::currentContext(), robid, robf);
115 }
116
117 if (robf.size() > 0 ) {
118 if (isTMDB) {// reid for TMDB 0x5x010x
119 ATH_MSG_DEBUG(" Decoding TMDB digits in ROD fragment ");
120 m_decoder->fillCollection_TileMuRcv_Digi(robf[0], *digitsCollection);
121 }else if (isFELIX) {
122 ATH_MSG_DEBUG(" Decoding FELIX digits in ROD fragment ");
123 m_decoder->fillCollection_FELIX_Digi(robf[0], *digitsCollection);
124 } else {
125 m_decoder->fillCollection(robf[0], *digitsCollection);
126 }
127 } else {
128 uint32_t status = TileROD_Decoder::NO_ROB;
129 digitsCollection->setFragBCID(0xDEAD | (status<<16));
130 ATH_MSG_DEBUG( "Status for " << ((isTMDB)?"TMDB ":"") << "drawer 0x" << MSG::hex << collID << " in Digi frag is 0x" << status << MSG::dec);
131 }
132
133
134 }
135
136 ATH_MSG_DEBUG( "Creating digits container: " << containerName );
137
138 TileDigitsContainer* basecont = cont;
139 pObj = SG::asStorable( basecont ) ;
140
141
142 return StatusCode::SUCCESS;
143}
144
145
146StatusCode TileDigitsContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
147{
148 // convert TileDigitsContainer in the container into ByteStream
149
150 ATH_MSG_DEBUG(" Executing createRep method ");
151
152 // uint32_t runnum = re->header()->specific_part()->run_no();
153
154 // get Full Event Assembler
156 std::string key("Tile");
157 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea, key) );
158
159 // create TileDigitsContainer
160 TileDigitsContainer* digicont(0) ;
161 SG::fromStorable(pObj, digicont );
162
163 if(!digicont){
164 ATH_MSG_ERROR(" Can not cast to TileDigitsContainer ");
165 return StatusCode::FAILURE;
166 }
167
168 std::string name = pObj->registry()->name();
169
170 ByteStreamAddress* addr = new ByteStreamAddress(classID(), name, "");
171
172 pAddr = addr;
173
174 // call TileDigitsContByteStreamTool
175
176 return m_tool->convert(digicont, fea);
177}
178
180{
181 return Converter::finalize();
182}
#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.
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)