ATLAS Offline Software
Loading...
Searching...
No Matches
STGC_RawDataProviderToolMT.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// STGC_RawDataProviderToolMT.cxx, (c) ATLAS Detector software
8
11#include "eformat/SourceIdentifier.h"
12using eformat::helper::SourceIdentifier;
13
14//==============================================================================
15Muon::STGC_RawDataProviderToolMT::STGC_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p)
17{
18 declareInterface<IMuonRawDataProviderTool>(this);
19}
20
21
22//==============================================================================
24{
25 // generate all the Source Identifiers to request the fragments.
26 // assume 16 RODs per side (one per sector) and that ROB ID = ROD ID.
27 for (uint32_t detID : {eformat::MUON_STGC_ENDCAP_A_SIDE, eformat::MUON_STGC_ENDCAP_C_SIDE}) { //0x6D, 0x6E
28 for (uint8_t sectorID(0); sectorID < 16; ++sectorID) {
29 // for now lets build all the possible ROB ids of all possible readout configurations
30 // maybe later we can come up with a smart way to detect which readout sheme is running and only request the relevant ROB ids from the ROBDataProviderSvc
31 // reference: slide 6 of https://indico.cern.ch/event/1260377/contributions/5294286/attachments/2603399/4495810/NSW-SwRod-Felix-v3.pdf
32
33 uint16_t moduleID = (0x0 << 8) | sectorID; // combined/single ROB
34 SourceIdentifier sid(static_cast<eformat::SubDetector>(detID), moduleID);
35 m_allRobIds.push_back(sid.simple_code());
36
37 moduleID = (0x1 << 8) | sectorID; // full device ROB (split configuration)
38 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
39 m_allRobIds.push_back(sid.simple_code());
40
41 moduleID = (0x2 << 8) | sectorID; // shared device ROB (split configuration)
42 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
43 m_allRobIds.push_back(sid.simple_code());
44
45 moduleID = (0x3 << 8) | sectorID; // spare device ROB (split configuration)
46 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
47 m_allRobIds.push_back(sid.simple_code());
48 }
49 }
50
53 return StatusCode::SUCCESS;
54}
55
56
57//==============================================================================
58StatusCode Muon::STGC_RawDataProviderToolMT::initRdoContainer(const EventContext& ctx, STGC_RawDataContainer*& rdoContainer) const
59{
60 // Create the identifiable RdoContainer in StoreGate to be filled with decoded fragment contents.
62
63 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
64 if(!externalCacheRDO){
65 ATH_CHECK(rdoContainerHandle.record(std::make_unique<STGC_RawDataContainer>(m_maxhashtoUse)));
66 ATH_MSG_DEBUG("Created STGC RDO container");
67 } else {
69 ATH_CHECK(update.isValid());
70 ATH_CHECK(rdoContainerHandle.record(std::make_unique<STGC_RawDataContainer>(update.ptr())));
71 ATH_MSG_DEBUG("Created STGC RDO container using cache for " << m_rdoContainerCacheKey.key());
72 }
73
74 // this should never happen, but since we dereference the pointer, we should check
75 if (!(rdoContainer = rdoContainerHandle.ptr())) {
76 ATH_MSG_ERROR("The STGC RDO container is null, cannot decode STGC data");
77 return StatusCode::FAILURE;
78 }
79
80 return StatusCode::SUCCESS;
81}
82
83
84//==============================================================================
85StatusCode Muon::STGC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect, const EventContext& ctx) const
86{
87 // method for RoI-seeded mode. we don't let empty hash containers reach the decoder,
88 // since an empty container means unseeded mode (decode everything).
89
90 STGC_RawDataContainer* rdoContainer{nullptr};
91 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
92
93 if (rdoIdhVect.empty() || m_skipDecoding) return StatusCode::SUCCESS;
94
95 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecRobf;
96 m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
97
98 return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
99}
100
101
102//==============================================================================
103StatusCode Muon::STGC_RawDataProviderToolMT::convert(const EventContext& ctx) const
104{
105 // method for unseeded mode. just decode everything.
106
107 STGC_RawDataContainer* rdoContainer{nullptr};
108 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
109 if(m_skipDecoding) return StatusCode::SUCCESS;
110
111 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecRobf;
112 m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
113
114 // dummy hashID vector for the decoder (empty = unseeded mode)
115 const std::vector<IdentifierHash> rdoIdhVect;
116
117 return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
118}
119
120StatusCode Muon::STGC_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds, const EventContext& ctx) const
121{
122 STGC_RawDataContainer* rdoContainer{nullptr};
123 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
124
125 if (robIds.empty() || m_skipDecoding) return StatusCode::SUCCESS;
126
127 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecRobf;
128
129 m_robDataProvider->getROBData(ctx, robIds, vecRobf);
130
131 // pass empty list of ID hashes, every ROB ID in list will be decoded
132 const std::vector<IdentifierHash> hashIDList;
133
134 return convertIntoContainer(ctx, vecRobf, hashIDList, *rdoContainer);
135
136}
137
138//===============================================================================
140{
141 ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert() Not implemented.");
142 return StatusCode::FAILURE;
143}
144
146{
147 ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs) Not implemented.");
148 return StatusCode::FAILURE;
149}
150
151StatusCode Muon::STGC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& ) const
152{
153 ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect) Not implemented.");
154 return StatusCode::FAILURE;
155}
156
157StatusCode Muon::STGC_RawDataProviderToolMT::convert(const ROBFragmentList&, const std::vector<IdentifierHash>&) const
158{
159 ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>&) Not implemented.");
160 return StatusCode::FAILURE;
161}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > ROBFragmentList
Decoding method.
Gaudi::Property< bool > m_skipDecoding
Flag to skip decoding and write empty container.
virtual StatusCode convertIntoContainer(const EventContext &ctx, const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &, const std::vector< IdentifierHash > &, STGC_RawDataContainer &) const
Method that converts the ROBFragments into the passed container.
STGC_RawDataProviderToolCore(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
SG::WriteHandleKey< STGC_RawDataContainer > m_rdoContainerKey
RDO container key.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Rob Data Provider handle.
virtual StatusCode initialize() override
Standard AlgTool method.
virtual StatusCode convert() const override
the new ones
virtual StatusCode initialize() override
Standard AlgTool method.
StatusCode initRdoContainer(const EventContext &, STGC_RawDataContainer *&) const
STGC_RawDataProviderToolMT(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
SG::UpdateHandleKey< STGC_RawDataCollection_Cache > m_rdoContainerCacheKey
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.