ATLAS Offline Software
Loading...
Searching...
No Matches
MM_RdoToDigit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MM_RdoToDigit.h"
6
7
9 ATH_CHECK(m_idHelperSvc.retrieve());
10 ATH_CHECK(m_mmRdoDecoderTool.retrieve());
11 ATH_CHECK(m_mmRdoKey.initialize());
12 ATH_CHECK(m_mmDigitKey.initialize());
13 return StatusCode::SUCCESS;
14}
15
16StatusCode MM_RdoToDigit::execute(const EventContext& ctx) const {
17 ATH_MSG_DEBUG("in execute()");
19 if (!rdoContainer.isPresent()) {
20 ATH_MSG_ERROR("No MM RDO container found!");
21 return StatusCode::FAILURE;
22 }
24 ATH_CHECK(wh_mmDigit.record(std::make_unique<MmDigitContainer>(m_idHelperSvc->mmIdHelper().module_hash_max())));
25 ATH_MSG_DEBUG("Decoding MM RDO into MM Digit");
26 DigitCollection digitMap{};
27 for (const Muon::MM_RawDataCollection* coll : *rdoContainer) {
28 ATH_CHECK(decodeMM(ctx, *coll, digitMap));
29 }
30
31 for (auto& [hash, collection]: digitMap) {
32 ATH_CHECK(wh_mmDigit->addCollection(collection.release(), hash));
33 }
34
35 return StatusCode::SUCCESS;
36}
37
38StatusCode MM_RdoToDigit::decodeMM(const EventContext& ctx,
39 const Muon::MM_RawDataCollection& rdoColl,
40 DigitCollection& digitContainer) const {
41 if (rdoColl.empty()) {
42 return StatusCode::SUCCESS;
43 }
44
45 ATH_MSG_DEBUG(" Number of RawData in this rdo " << rdoColl.size());
46
47 // for each RDO, loop over RawData, converter RawData to digit
48 // retrieve/create digit collection, and insert digit into collection
49 for (const Muon::MM_RawData* data : rdoColl) {
50 std::unique_ptr<MmDigit> newDigit{m_mmRdoDecoderTool->getDigit(ctx, data)};
51 if (!newDigit) {
52 ATH_MSG_WARNING("Error in MM RDO decoder");
53 continue;
54 }
55
56 // find here the Proper Digit Collection identifier, using the rdo-hit id
57 // (since RDO collections are not in a 1-to-1 relation with digit collections)
58 const Identifier elementId = m_idHelperSvc->mmIdHelper().elementID(newDigit->identify());
59 IdentifierHash coll_hash = m_idHelperSvc->moduleHash(elementId);
60 std::unique_ptr<MmDigitCollection>& outCollection = digitContainer[coll_hash];
61 if (!outCollection) {
62 outCollection = std::make_unique<MmDigitCollection>(elementId, coll_hash);
63 }
64 outCollection->push_back(std::move(newDigit));
65 }
66
67 return StatusCode::SUCCESS;
68}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This is a "hash" representation of an Identifier.
virtual StatusCode initialize() override final
SG::WriteHandleKey< MmDigitContainer > m_mmDigitKey
ToolHandle< Muon::IMM_RDO_Decoder > m_mmRdoDecoderTool
SG::ReadHandleKey< Muon::MM_RawDataContainer > m_mmRdoKey
StatusCode decodeMM(const EventContext &ctx, const Muon::MM_RawDataCollection &rdoCollection, DigitCollection &digitContainer) const
std::unordered_map< IdentifierHash, std::unique_ptr< MmDigitCollection > > DigitCollection
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode execute(const EventContext &ctx) const override final
Temporary class to hold the MM RDO.
Definition MM_RawData.h:20
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.