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

A tool to decode MM ROB fragments into MM RDO (based on the sTGC tool). More...

#include <MM_RawDataProviderTool.h>

Inheritance diagram for Muon::MM_RawDataProviderTool:
Collaboration diagram for Muon::MM_RawDataProviderTool:

Public Member Functions

virtual ~MM_RawDataProviderTool ()=default
 Default destructor.
virtual StatusCode initialize () override
 Standard AlgTool method.
virtual StatusCode convert (const EventContext &) const override
virtual StatusCode convert (const std::vector< IdentifierHash > &, const EventContext &) const override
virtual StatusCode convert (const std::vector< uint32_t > &, const EventContext &) const override

Protected Member Functions

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

Protected Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 The ID helper.
ToolHandle< IMM_ROD_Decoderm_decoder {this, "Decoder", "Muon::MmROD_Decoder/MmROD_Decoder"}
 Decoder for ROB fragment RDO conversion.
SG::WriteHandleKey< MM_RawDataContainerm_rdoContainerKey { this, "RdoLocation", "MMRDO", "Name of the MMRDO produced by RawDataProvider"}
 RDO container key.
unsigned int m_maxhashtoUse {0}
ServiceHandle< IROBDataProviderSvcm_robDataProvider {this, "ROBDataProviderSvc", "ROBDataProviderSvc"}
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< MM_RawDataCollection_Cachem_rdoContainerCacheKey

Detailed Description

A tool to decode MM ROB fragments into MM RDO (based on the sTGC tool).

Author
Leonidas Fountas leoni.nosp@m.das..nosp@m.fount.nosp@m.as@c.nosp@m.ern.c.nosp@m.h

Definition at line 29 of file MM_RawDataProviderTool.h.

Constructor & Destructor Documentation

◆ ~MM_RawDataProviderTool()

virtual Muon::MM_RawDataProviderTool::~MM_RawDataProviderTool ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ convert() [1/3]

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

Definition at line 154 of file MM_RawDataProviderTool.cxx.

155{
156 // method for unseeded mode. just decode everything.
157
158 MM_RawDataContainer* rdoContainer{nullptr};
159 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
160 if(m_skipDecoding) return StatusCode::SUCCESS;
161
162 ROBFragmentList vecRobf;
163 m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
164
165 // dummy hashID vector for the decoder (empty = unseeded mode)
166 const std::vector<IdentifierHash> rdoIdhVect;
167
168 return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
169}
#define ATH_CHECK
Evaluate an expression and check for errors.
std::vector< uint32_t > m_allRobIds
StatusCode initRdoContainer(const EventContext &, MM_RawDataContainer *&) const
Gaudi::Property< bool > m_skipDecoding
Flag to skip decoding and write empty container.
virtual StatusCode convertIntoContainer(const EventContext &ctx, const ROBFragmentList &, const std::vector< IdentifierHash > &, MM_RawDataContainer &) const
Method that converts the ROBFragments into the passed container.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider

◆ convert() [2/3]

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

Definition at line 137 of file MM_RawDataProviderTool.cxx.

138{
139 // method for RoI-seeded mode via hash IDs. we don't let empty hash containers reach the decoder,
140 // since an empty container means unseeded mode (decode everything).
141
142 MM_RawDataContainer* rdoContainer{nullptr};
143 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
144
145 if (rdoIdhVect.empty() || m_skipDecoding) return StatusCode::SUCCESS;
146
147 ROBFragmentList vecRobf;
148 m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
149
150 return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
151}

◆ convert() [3/3]

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

Definition at line 121 of file MM_RawDataProviderTool.cxx.

121 {
122 // method for RoI-seeded mode via ROB IDs
123 MM_RawDataContainer* rdoContainer{nullptr};
124 ATH_CHECK(initRdoContainer(ctx, rdoContainer));
125
126 if (robIds.empty() || m_skipDecoding) return StatusCode::SUCCESS;
127
128 ROBFragmentList vecRobf;
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 return convertIntoContainer(ctx, vecRobf, hashIDList, *rdoContainer);
134}

◆ convertIntoContainer()

StatusCode Muon::MM_RawDataProviderTool::convertIntoContainer ( const EventContext & ctx,
const ROBFragmentList & ,
const std::vector< IdentifierHash > & ,
MM_RawDataContainer &  ) const
protectedvirtual

Method that converts the ROBFragments into the passed container.

Definition at line 55 of file MM_RawDataProviderTool.cxx.

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

◆ initialize()

StatusCode Muon::MM_RawDataProviderTool::initialize ( )
overridevirtual

Standard AlgTool method.

Definition at line 18 of file MM_RawDataProviderTool.cxx.

19{
20 ATH_CHECK(m_idHelperSvc.retrieve());
21 ATH_CHECK(m_decoder.retrieve());
22 ATH_CHECK(m_robDataProvider.retrieve());
23 ATH_CHECK(m_rdoContainerKey.initialize());
24
25 m_maxhashtoUse = m_idHelperSvc->mmIdHelper().module_hash_max();
26
27 // generate all the Source Identifiers for MicroMegas to request the fragments.
28 // assume 16 RODs per side (one per sector) and that ROB ID = ROD ID.
29 for (uint32_t detID : {eformat::MUON_MMEGA_ENDCAP_A_SIDE, eformat::MUON_MMEGA_ENDCAP_C_SIDE}) { //0x6B, 0x6C
30 for (uint8_t sectorID(0); sectorID < 16; ++sectorID) {
31 // for now lets build all the possible ROB ids of all possible readout configurations
32 // 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
33
34 uint16_t moduleID = (0x0 << 8) | sectorID; // combined/single ROB
35 SourceIdentifier sid(static_cast<eformat::SubDetector>(detID), moduleID);
36 m_allRobIds.push_back(sid.simple_code());
37
38 moduleID = (0x1 << 8) | sectorID; // full device ROB (split configuration)
39 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
40 m_allRobIds.push_back(sid.simple_code());
41
42 moduleID = (0x2 << 8) | sectorID; // shared device ROB (split configuration)
43 sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
44 m_allRobIds.push_back(sid.simple_code());
45 }
46 }
47
49
50 return StatusCode::SUCCESS;
51}
SG::UpdateHandleKey< MM_RawDataCollection_Cache > m_rdoContainerCacheKey
SG::WriteHandleKey< MM_RawDataContainer > m_rdoContainerKey
RDO container key.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
The ID helper.
setWord1 uint16_t

◆ initRdoContainer()

StatusCode Muon::MM_RawDataProviderTool::initRdoContainer ( const EventContext & ctx,
MM_RawDataContainer *& rdoContainer ) const
protected

Definition at line 95 of file MM_RawDataProviderTool.cxx.

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

Member Data Documentation

◆ m_allRobIds

std::vector<uint32_t> Muon::MM_RawDataProviderTool::m_allRobIds
protected

Definition at line 71 of file MM_RawDataProviderTool.h.

◆ m_decoder

ToolHandle<IMM_ROD_Decoder> Muon::MM_RawDataProviderTool::m_decoder {this, "Decoder", "Muon::MmROD_Decoder/MmROD_Decoder"}
protected

Decoder for ROB fragment RDO conversion.

Definition at line 57 of file MM_RawDataProviderTool.h.

57{this, "Decoder", "Muon::MmROD_Decoder/MmROD_Decoder"};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MM_RawDataProviderTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
protected

The ID helper.

Definition at line 54 of file MM_RawDataProviderTool.h.

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

◆ m_maxhashtoUse

unsigned int Muon::MM_RawDataProviderTool::m_maxhashtoUse {0}
protected

Definition at line 62 of file MM_RawDataProviderTool.h.

62{0};

◆ m_rdoContainerCacheKey

SG::UpdateHandleKey<MM_RawDataCollection_Cache> Muon::MM_RawDataProviderTool::m_rdoContainerCacheKey
protected
Initial value:
{this, "MmContainerCacheKey",
"", "Optional external cache for the MM container"}

Definition at line 74 of file MM_RawDataProviderTool.h.

74 {this, "MmContainerCacheKey",
75 "", "Optional external cache for the MM container"};

◆ m_rdoContainerKey

SG::WriteHandleKey<MM_RawDataContainer> Muon::MM_RawDataProviderTool::m_rdoContainerKey { this, "RdoLocation", "MMRDO", "Name of the MMRDO produced by RawDataProvider"}
protected

RDO container key.

Definition at line 60 of file MM_RawDataProviderTool.h.

60{ this, "RdoLocation", "MMRDO", "Name of the MMRDO produced by RawDataProvider"};

◆ m_robDataProvider

ServiceHandle<IROBDataProviderSvc> Muon::MM_RawDataProviderTool::m_robDataProvider {this, "ROBDataProviderSvc", "ROBDataProviderSvc"}
protected

Definition at line 65 of file MM_RawDataProviderTool.h.

65{this, "ROBDataProviderSvc", "ROBDataProviderSvc"};

◆ m_skipDecoding

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

Flag to skip decoding and write empty container.

Definition at line 69 of file MM_RawDataProviderTool.h.

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

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