ATLAS Offline Software
Loading...
Searching...
No Matches
MdtRdoToMdtDigit.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 "MdtRdoToMdtDigit.h"
6
8 ATH_CHECK(m_idHelperSvc.retrieve());
10 ATH_CHECK(m_mdtRdoKey.initialize());
11 ATH_CHECK(m_mdtDigitKey.initialize());
12 return StatusCode::SUCCESS;
13}
14
15StatusCode MdtRdoToMdtDigit::execute(const EventContext& ctx) const {
16 ATH_MSG_DEBUG("in execute()");
17 SG::ReadHandle rdoContainer{m_mdtRdoKey, ctx};
18 ATH_CHECK(rdoContainer.isPresent());
19 ATH_MSG_DEBUG("Retrieved " << rdoContainer->size() << " MDT RDOs.");
20
22 const unsigned int hashMax = m_idHelperSvc->mdtIdHelper().module_hash_max();
23 ATH_CHECK(wh_mdtDigit.record(std::make_unique<MdtDigitContainer>(hashMax)));
24 ATH_MSG_DEBUG("Decoding MDT RDO into MDT Digit");
25
26 // now decode RDO into digits
27 DigitCollection digitMap{};
28 digitMap.resize(hashMax);
29 for (const MdtCsm* csmColl : *rdoContainer) {
30 ATH_CHECK(decodeMdt(ctx, *csmColl, digitMap));
31 }
32
33 for (std::unique_ptr<MdtDigitCollection>&collection: digitMap) {
34 if (!collection) continue;
35 const IdentifierHash hash = collection->identifierHash();
36 ATH_CHECK(wh_mdtDigit->addCollection(collection.release(), hash));
37 }
38 return StatusCode::SUCCESS;
39}
40
41StatusCode MdtRdoToMdtDigit::decodeMdt(const EventContext& ctx, const MdtCsm& rdoColl, DigitCollection& digitMap) const {
42 if (rdoColl.empty()) {
43 return StatusCode::SUCCESS;
44 }
45 ATH_MSG_DEBUG(" Number of AmtHit in this Csm " << rdoColl.size());
46
47 uint16_t subdetId = rdoColl.SubDetId();
48 uint16_t mrodId = rdoColl.MrodId();
49 uint16_t csmId = rdoColl.CsmId();
50
51
52 // for each Csm, loop over AmtHit, converter AmtHit to digit
53 // retrieve/create digit collection, and insert digit into collection
54 for (const MdtAmtHit* amtHit : rdoColl) {
55 std::unique_ptr<MdtDigit> newDigit{m_mdtRdoDecoderTool->getDigit(ctx, *amtHit, subdetId, mrodId, csmId)};
56
57 if (!newDigit) {
58 ATH_MSG_WARNING("Digit rejected");
59 continue;
60 }
61
62 // find here the Proper Digit Collection identifier, using the rdo-hit id
63 // (since RDO collections are not in a 1-to-1 relation with digit collections)
64 const IdentifierHash coll_hash = m_idHelperSvc->moduleHash(newDigit->identify());
65 std::unique_ptr<MdtDigitCollection>& outCollection = digitMap[coll_hash];
66 if(!outCollection) {
67 outCollection = std::make_unique<MdtDigitCollection>(m_idHelperSvc->chamberId(newDigit->identify()), coll_hash);
68 }
69 outCollection->push_back(std::move(newDigit));
70 }
71 return StatusCode::SUCCESS;
72}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
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.
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition MdtAmtHit.h:20
MDT RDOs : Chamber Service Module, container of AmtHits of a single Mdt chamber.
Definition MdtCsm.h:19
uint16_t CsmId() const
Returns the CSM online id (online identifier inside a MROD)
Definition MdtCsm.h:61
uint16_t MrodId() const
Returns the MROD id from the CSM header.
Definition MdtCsm.h:59
uint16_t SubDetId() const
Returns the sub-detector Id.
Definition MdtCsm.h:57
ToolHandle< Muon::IMDT_RDO_Decoder > m_mdtRdoDecoderTool
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< MdtDigitContainer > m_mdtDigitKey
SG::ReadHandleKey< MdtCsmContainer > m_mdtRdoKey
std::vector< std::unique_ptr< MdtDigitCollection > > DigitCollection
StatusCode decodeMdt(const EventContext &ctx, const MdtCsm &rdoCollection, DigitCollection &digitContainer) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.