ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::STGC_RawDataProviderTool Class Reference

A tool to decode STGC ROB fragments into STGC RDO (based on the TGC tool). More...

#include <STGC_RawDataProviderTool.h>

Inheritance diagram for Muon::STGC_RawDataProviderTool:
Collaboration diagram for Muon::STGC_RawDataProviderTool:

Public Member Functions

virtual ~STGC_RawDataProviderTool ()=default
 Default destructor.
virtual StatusCode initialize () override
 Standard AlgTool method.
virtual StatusCode convert (const EventContext &ctx) const override
virtual StatusCode convert (const std::vector< IdentifierHash > &chamberHashes, const EventContext &ctx) const override
virtual StatusCode convert (const std::vector< uint32_t > &robIDs, const EventContext &ctx) const override
virtual StatusCode convert (const ROBFragmentList &) const
virtual StatusCode convert (const ROBFragmentList &, const std::vector< IdentifierHash > &) const
virtual StatusCode convert () const
 the new ones
virtual StatusCode convert (const std::vector< IdentifierHash > &) const
 for a selection of rdo collections
virtual StatusCode convert (const std::vector< uint32_t > &) const
virtual StatusCode convert (const ROBFragmentList &, const EventContext &) const
virtual StatusCode convert (const ROBFragmentList &, const std::vector< IdentifierHash > &, const EventContext &) const

Private Member Functions

StatusCode convertIntoContainer (const EventContext &ctx, const ROBFragmentList &fragements, const std::vector< IdentifierHash > &chamberHashes, STGC_RawDataContainer &target) const
 Method that converts the ROBFragments into the passed container.
StatusCode initRdoContainer (const EventContext &, STGC_RawDataContainer *&) const

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 The ID helper.
ToolHandle< ISTGC_ROD_Decoderm_decoder {this, "Decoder", "Muon::STGC_ROD_Decoder/STGC_ROD_Decoder"}
 Decoder for ROB fragment RDO conversion.
SG::WriteHandleKey< STGC_RawDataContainerm_rdoContainerKey { this, "RdoLocation", "sTGCRDO", "Name of the sTGCRDO produced by RawDataProvider"}
 RDO container key.
unsigned int m_maxhashtoUse {0}
ServiceHandle< IROBDataProviderSvcm_robDataProvider {this, "RobProviderSvc", "ROBDataProviderSvc"}
 Rob Data Provider handle.
Gaudi::Property< bool > m_skipDecoding {this, "SkipDecoding", false, "Skip the decoding but still write the container"}
 Flag to skip decoding and write empty container.
std::vector< uint32_t > m_allRobIds
SG::UpdateHandleKey< STGC_RawDataCollection_Cachem_rdoContainerCacheKey

Detailed Description

A tool to decode STGC ROB fragments into STGC RDO (based on the TGC tool).

Author
Stelios Angelidakis sange.nosp@m.lid@.nosp@m.cern..nosp@m.ch

Definition at line 24 of file STGC_RawDataProviderTool.h.

Constructor & Destructor Documentation

◆ ~STGC_RawDataProviderTool()

virtual Muon::STGC_RawDataProviderTool::~STGC_RawDataProviderTool ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ convert() [1/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( ) const
inline

the new ones

for the entire event

Definition at line 31 of file IMuonRawDataProviderTool.h.

◆ convert() [2/10]

StatusCode Muon::STGC_RawDataProviderTool::convert ( const EventContext & ctx) const
overridevirtual

Definition at line 147 of file STGC_RawDataProviderTool.cxx.

147 {
148 // method for unseeded mode. just decode everything.
149
150 STGC_RawDataContainer* rdoContainer{nullptr};
151 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
152 if(m_skipDecoding) return StatusCode::SUCCESS;
153
154 ROBFragmentList vecRobf;
155 m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
156
157 // dummy hashID vector for the decoder (empty = unseeded mode)
158 const std::vector<IdentifierHash> rdoIdhVect;
159
160 return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
161}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode convertIntoContainer(const EventContext &ctx, const ROBFragmentList &fragements, const std::vector< IdentifierHash > &chamberHashes, STGC_RawDataContainer &target) const
Method that converts the ROBFragments into the passed container.
Gaudi::Property< bool > m_skipDecoding
Flag to skip decoding and write empty container.
StatusCode initRdoContainer(const EventContext &, STGC_RawDataContainer *&) const
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Rob Data Provider handle.

◆ convert() [3/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( const ROBFragmentList & ) const
inline

Definition at line 28 of file IMuonRawDataProviderTool.h.

28{ return StatusCode::FAILURE; }

◆ convert() [4/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( const ROBFragmentList & ,
const EventContext &  ) const
inline

Definition at line 36 of file IMuonRawDataProviderTool.h.

36{return StatusCode::FAILURE;}

◆ convert() [5/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( const ROBFragmentList & ,
const std::vector< IdentifierHash > &  ) const
inline

Definition at line 29 of file IMuonRawDataProviderTool.h.

29{ return StatusCode::FAILURE; }

◆ convert() [6/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( const ROBFragmentList & ,
const std::vector< IdentifierHash > & ,
const EventContext &  ) const
inline

Definition at line 37 of file IMuonRawDataProviderTool.h.

37{return StatusCode::FAILURE;}

◆ convert() [7/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( const std::vector< IdentifierHash > & ) const
inline

for a selection of rdo collections

Definition at line 32 of file IMuonRawDataProviderTool.h.

◆ convert() [8/10]

StatusCode Muon::STGC_RawDataProviderTool::convert ( const std::vector< IdentifierHash > & chamberHashes,
const EventContext & ctx ) const
overridevirtual

Definition at line 129 of file STGC_RawDataProviderTool.cxx.

130{
131 // method for RoI-seeded mode. we don't let empty hash containers reach the decoder,
132 // since an empty container means unseeded mode (decode everything).
133
134 STGC_RawDataContainer* rdoContainer{nullptr};
135 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
136
137 if (rdoIdhVect.empty() || m_skipDecoding) return StatusCode::SUCCESS;
138
139 ROBFragmentList vecRobf;
140 m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
141
142 return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
143}

◆ convert() [9/10]

virtual StatusCode Muon::IMuonRawDataProviderTool::convert ( const std::vector< uint32_t > & ) const
inline

Definition at line 33 of file IMuonRawDataProviderTool.h.

33{return StatusCode::FAILURE;}

◆ convert() [10/10]

StatusCode Muon::STGC_RawDataProviderTool::convert ( const std::vector< uint32_t > & robIDs,
const EventContext & ctx ) const
overridevirtual

Definition at line 163 of file STGC_RawDataProviderTool.cxx.

164{
165 STGC_RawDataContainer* rdoContainer{nullptr};
166 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
167
168 if (robIds.empty() || m_skipDecoding) return StatusCode::SUCCESS;
169
170 ROBFragmentList vecRobf;
171
172 m_robDataProvider->getROBData(ctx, robIds, vecRobf);
173
174 // pass empty list of ID hashes, every ROB ID in list will be decoded
175 const std::vector<IdentifierHash> hashIDList;
176
177 return convertIntoContainer(ctx, vecRobf, hashIDList, *rdoContainer);
178
179}

◆ convertIntoContainer()

StatusCode Muon::STGC_RawDataProviderTool::convertIntoContainer ( const EventContext & ctx,
const ROBFragmentList & fragements,
const std::vector< IdentifierHash > & chamberHashes,
STGC_RawDataContainer & target ) const
private

Method that converts the ROBFragments into the passed container.

Definition at line 56 of file STGC_RawDataProviderTool.cxx.

60{
61 // Since there can be multiple ROBFragments contributing to the same RDO collection a temporary cache is setup and passed to fillCollection by reference. Once all ROBFragments are processed the collections are added into the rdo container
62 std::unordered_map<IdentifierHash, std::unique_ptr<STGC_RawDataCollection>> rdo_map;
63
64
65 // Loop on the passed ROB fragments, and call the decoder for each one to fill the RDO container.
66 for (const ROBFragment* fragment : vecRobs)
67 ATH_CHECK( m_decoder->fillCollection(ctx, *fragment, rdoIdhVect, rdo_map) ); // always returns StatusCode::SUCCESS
68
69
70 // error counters
71 int nerr_duplicate{0}, nerr_rdo{0};
72
73 // add the RDO collections created from the data of this ROB into the identifiable container.
74 for (auto& [hash, collection]: rdo_map) {
75
76 if ((!collection) or collection->empty()) continue; // skip empty collections
77
78 STGC_RawDataContainer::IDC_WriteHandle lock = stgcRdoContainer.getWriteHandle(hash);
79
80 if (lock.alreadyPresent()) {
81 ++nerr_duplicate;
82 } else if (!lock.addOrDelete(std::move(collection)).isSuccess()) {
83 // since we prevent duplicates above, this error should never happen.
84 ++nerr_rdo;
85 }
86 }
87
88
89 // error summary (to reduce the number of messages)
90 if (nerr_duplicate) ATH_MSG_WARNING(nerr_duplicate << " elinks skipped since the same module hash has been added by a previous ROB fragment");
91 if (nerr_rdo) {
92 ATH_MSG_ERROR("Failed to add "<<nerr_rdo<<" RDOs into the identifiable container");
93 return StatusCode::FAILURE;
94 }
95
96 ATH_MSG_DEBUG("Size of sTgcRdoContainer is " << stgcRdoContainer.size());
97 return StatusCode::SUCCESS;
98}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
ToolHandle< ISTGC_ROD_Decoder > m_decoder
Decoder for ROB fragment RDO conversion.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27

◆ initialize()

StatusCode Muon::STGC_RawDataProviderTool::initialize ( )
overridevirtual

Standard AlgTool method.

Definition at line 15 of file STGC_RawDataProviderTool.cxx.

15 {
16
17
18 ATH_CHECK(m_idHelperSvc.retrieve());
19 ATH_CHECK(m_decoder.retrieve());
20 ATH_CHECK(m_robDataProvider.retrieve()); // ROBDataProviderSvc
21 ATH_CHECK(m_rdoContainerKey.initialize());
22
23 m_maxhashtoUse = m_idHelperSvc->stgcIdHelper().module_hash_max();
24 // generate all the Source Identifiers to request the fragments.
25 // assume 16 RODs per side (one per sector) and that ROB ID = ROD ID.
26 for (uint32_t detID : {eformat::MUON_STGC_ENDCAP_A_SIDE, eformat::MUON_STGC_ENDCAP_C_SIDE}) { //0x6D, 0x6E
27 for (uint8_t sectorID(0); sectorID < 16; ++sectorID) {
28 // for now lets build all the possible ROB ids of all possible readout configurations
29 // 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
30 // reference: slide 6 of https://indico.cern.ch/event/1260377/contributions/5294286/attachments/2603399/4495810/NSW-SwRod-Felix-v3.pdf
31
32 uint16_t moduleID = (0x0 << 8) | sectorID; // combined/single ROB
33 SourceIdentifier sid(static_cast<eformat::SubDetector>(detID), moduleID);
34 m_allRobIds.push_back(sid.simple_code());
35
36 moduleID = (0x1 << 8) | sectorID; // full device ROB (split configuration)
37 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
38 m_allRobIds.push_back(sid.simple_code());
39
40 moduleID = (0x2 << 8) | sectorID; // shared device ROB (split configuration)
41 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
42 m_allRobIds.push_back(sid.simple_code());
43
44 moduleID = (0x3 << 8) | sectorID; // spare device ROB (split configuration)
45 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
46 m_allRobIds.push_back(sid.simple_code());
47 }
48 }
49
51 return StatusCode::SUCCESS;
52}
SG::WriteHandleKey< STGC_RawDataContainer > m_rdoContainerKey
RDO container key.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
The ID helper.
SG::UpdateHandleKey< STGC_RawDataCollection_Cache > m_rdoContainerCacheKey
setWord1 uint16_t

◆ initRdoContainer()

StatusCode Muon::STGC_RawDataProviderTool::initRdoContainer ( const EventContext & ctx,
STGC_RawDataContainer *& rdoContainer ) const
private

Definition at line 102 of file STGC_RawDataProviderTool.cxx.

103{
104 // Create the identifiable RdoContainer in StoreGate to be filled with decoded fragment contents.
105 SG::WriteHandle rdoContainerHandle(m_rdoContainerKey, ctx);
106
107 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
108 if(!externalCacheRDO){
109 ATH_CHECK(rdoContainerHandle.record(std::make_unique<STGC_RawDataContainer>(m_maxhashtoUse)));
110 ATH_MSG_DEBUG("Created STGC RDO container");
111 } else {
112 SG::UpdateHandle<STGC_RawDataCollection_Cache> update(m_rdoContainerCacheKey, ctx);
113 ATH_CHECK(update.isValid());
114 ATH_CHECK(rdoContainerHandle.record(std::make_unique<STGC_RawDataContainer>(update.ptr())));
115 ATH_MSG_DEBUG("Created STGC RDO container using cache for " << m_rdoContainerCacheKey.key());
116 }
117
118 // this should never happen, but since we dereference the pointer, we should check
119 if (!(rdoContainer = rdoContainerHandle.ptr())) {
120 ATH_MSG_ERROR("The STGC RDO container is null, cannot decode STGC data");
121 return StatusCode::FAILURE;
122 }
123
124 return StatusCode::SUCCESS;
125}

Member Data Documentation

◆ m_allRobIds

std::vector<uint32_t> Muon::STGC_RawDataProviderTool::m_allRobIds
private

Definition at line 68 of file STGC_RawDataProviderTool.h.

◆ m_decoder

ToolHandle<ISTGC_ROD_Decoder> Muon::STGC_RawDataProviderTool::m_decoder {this, "Decoder", "Muon::STGC_ROD_Decoder/STGC_ROD_Decoder"}
private

Decoder for ROB fragment RDO conversion.

Definition at line 53 of file STGC_RawDataProviderTool.h.

53{this, "Decoder", "Muon::STGC_ROD_Decoder/STGC_ROD_Decoder"};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::STGC_RawDataProviderTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

The ID helper.

Definition at line 50 of file STGC_RawDataProviderTool.h.

50{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_maxhashtoUse

unsigned int Muon::STGC_RawDataProviderTool::m_maxhashtoUse {0}
private

Definition at line 58 of file STGC_RawDataProviderTool.h.

58{0}; //MT

◆ m_rdoContainerCacheKey

SG::UpdateHandleKey<STGC_RawDataCollection_Cache> Muon::STGC_RawDataProviderTool::m_rdoContainerCacheKey
private
Initial value:
{this, "sTgcContainerCacheKey", "" ,
"Optional external cache for the sTGC container"}

Definition at line 70 of file STGC_RawDataProviderTool.h.

70 {this, "sTgcContainerCacheKey", "" ,
71 "Optional external cache for the sTGC container"};

◆ m_rdoContainerKey

SG::WriteHandleKey<STGC_RawDataContainer> Muon::STGC_RawDataProviderTool::m_rdoContainerKey { this, "RdoLocation", "sTGCRDO", "Name of the sTGCRDO produced by RawDataProvider"}
private

RDO container key.

Definition at line 56 of file STGC_RawDataProviderTool.h.

56{ this, "RdoLocation", "sTGCRDO", "Name of the sTGCRDO produced by RawDataProvider"}; //MT

◆ m_robDataProvider

ServiceHandle<IROBDataProviderSvc> Muon::STGC_RawDataProviderTool::m_robDataProvider {this, "RobProviderSvc", "ROBDataProviderSvc"}
private

Rob Data Provider handle.

Definition at line 61 of file STGC_RawDataProviderTool.h.

61{this, "RobProviderSvc", "ROBDataProviderSvc"};

◆ m_skipDecoding

Gaudi::Property<bool> Muon::STGC_RawDataProviderTool::m_skipDecoding {this, "SkipDecoding", false, "Skip the decoding but still write the container"}
private

Flag to skip decoding and write empty container.

Definition at line 64 of file STGC_RawDataProviderTool.h.

64{this, "SkipDecoding", false, "Skip the decoding but still write the container"};

The documentation for this class was generated from the following files: