ATLAS Offline Software
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 
17 #include "ByteStreamData/RawEvent.h"
18 
20 #include "AthenaKernel/CLASS_DEF.h"
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 
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 
71 StatusCode 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) {
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 {
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 
146 StatusCode 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 }
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
TileDigitsContByteStreamCnv::m_decoder
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
Definition: TileDigitsContByteStreamCnv.h:73
TileDigitsCollection::ID
MyBase::ID ID
Definition: TileDigitsCollection.h:23
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
TileDigitsContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: TileDigitsContByteStreamCnv.cxx:146
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:167
StorableConversions.h
convert to and from a SG storable
TileDigitsContByteStreamTool.h
TileMutableDataContainer::status
StatusCode status() const
Return the error status from the constructors.
initialize
void initialize()
Definition: run_EoverP.cxx:894
TileDigitsContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: TileDigitsContByteStreamCnv.cxx:50
TileHid2RESrcID::getRobFromFragID
uint32_t getRobFromFragID(int frag_id) const
make a ROB SrcID for a fragment ID
Definition: TileHid2RESrcID.cxx:457
TileHid2RESrcID::getRobFromTileMuRcvFragID
uint32_t getRobFromTileMuRcvFragID(int frag_id) const
Definition: TileHid2RESrcID.cxx:579
TileDigitsContByteStreamCnv::m_hid2re
const TileHid2RESrcID * m_hid2re
Pointer to TileHid2RESrcID.
Definition: TileDigitsContByteStreamCnv.h:76
ROBDataProviderSvc.h
TileCalibUtils.h
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
TileDigitsContainer
Definition: TileDigitsContainer.h:13
TileDigitsContByteStreamCnv.h
TileDigitsContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: TileDigitsContByteStreamCnv.cxx:71
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
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
TileROD_Decoder.h
TileDigitsContainer.h
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TileMutableDataContainer
Helper for holding non-const raw data prior to recording in SG.
Definition: TileMutableDataContainer.h:52
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileDigitsContByteStreamCnv::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: TileDigitsContByteStreamCnv.h:67
TileDigitsContByteStreamCnv::m_tool
ToolHandle< TileDigitsContByteStreamTool > m_tool
Definition: TileDigitsContByteStreamCnv.h:65
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
TileROD_Decoder::NO_ROB
@ NO_ROB
Definition: TileROD_Decoder.h:226
TileDigitsCollection::clear
void clear()
Clear everything for next event.
Definition: TileDigitsCollection.cxx:79
TileRawDataCollection::identify
ID identify() const
Definition: TileRawDataCollection.h:71
TileHid2RESrcID.h
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
TileDigitsCollection
Definition: TileDigitsCollection.h:18
TileCalibUtils::FELIX_FRAGID_OFFSET
static const unsigned int FELIX_FRAGID_OFFSET
Offset for frag ID used for FELIX in frag ID to ROB ID map.
Definition: TileCalibUtils.h:157
TileMutableDataContainer::indexFindPtr
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AthConstConverter::name
const std::string & name() const
Definition: AthConstConverter.h:67
StoreClearedIncident.h
Incident sent after a store is cleared.
TileDigitsCollection::setFragBCID
void setFragBCID(uint32_t bcid)
Set BCID.
Definition: TileDigitsCollection.h:113
TileDigitsContByteStreamCnv::TileDigitsContByteStreamCnv
TileDigitsContByteStreamCnv(ISvcLocator *svcloc)
Definition: TileDigitsContByteStreamCnv.cxx:36
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ByteStreamCnvSvcBase.h
TileDigitsContByteStreamCnv::m_robSvc
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
Definition: TileDigitsContByteStreamCnv.h:70
merge.status
status
Definition: merge.py:17
TileDigitsContByteStreamCnv::classID
static const CLID & classID()
Definition: TileDigitsContByteStreamCnv.cxx:46
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
IByteStreamCnvSvc.h
CLASS_DEF.h
macros to associate a CLID to a type
TileDigitsContByteStreamCnv::finalize
virtual StatusCode finalize() override
Definition: TileDigitsContByteStreamCnv.cxx:179
TileDigitsContByteStreamCnv::storageType
static long storageType()
Definition: TileDigitsContByteStreamCnv.cxx:48
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37