ATLAS Offline Software
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());
9  ATH_CHECK(m_mdtRdoDecoderTool.retrieve());
12  return StatusCode::SUCCESS;
13 }
14 
15 StatusCode 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 
41 StatusCode 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 }
MdtRdoToMdtDigit::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtRdoToMdtDigit.h:28
MdtCsm::CsmId
uint16_t CsmId() const
Returns the CSM online id (online identifier inside a MROD)
Definition: MdtCsm.h:61
MdtRdoToMdtDigit::m_mdtRdoDecoderTool
ToolHandle< Muon::IMDT_RDO_Decoder > m_mdtRdoDecoderTool
Definition: MdtRdoToMdtDigit.h:27
MdtRdoToMdtDigit::initialize
virtual StatusCode initialize() override final
Definition: MdtRdoToMdtDigit.cxx:7
MdtAmtHit
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition: MdtAmtHit.h:20
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition: IdentifiableContainerMT.h:297
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
MdtRdoToMdtDigit::DigitCollection
std::vector< std::unique_ptr< MdtDigitCollection > > DigitCollection
Definition: MdtRdoToMdtDigit.h:24
MdtCsm::SubDetId
uint16_t SubDetId() const
Returns the sub-detector Id.
Definition: MdtCsm.h:57
MdtCsm
MDT RDOs : Chamber Service Module, container of AmtHits of a single Mdt chamber.
Definition: MdtCsm.h:19
MdtRdoToMdtDigit::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: MdtRdoToMdtDigit.cxx:15
MdtCsm::MrodId
uint16_t MrodId() const
Returns the MROD id from the CSM header.
Definition: MdtCsm.h:59
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
MdtRdoToMdtDigit.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MdtRdoToMdtDigit::decodeMdt
StatusCode decodeMdt(const EventContext &ctx, const MdtCsm &rdoCollection, DigitCollection &digitContainer) const
Definition: MdtRdoToMdtDigit.cxx:41
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MdtRdoToMdtDigit::m_mdtDigitKey
SG::WriteHandleKey< MdtDigitContainer > m_mdtDigitKey
Definition: MdtRdoToMdtDigit.h:30
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MdtRdoToMdtDigit::m_mdtRdoKey
SG::ReadHandleKey< MdtCsmContainer > m_mdtRdoKey
Definition: MdtRdoToMdtDigit.h:29
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.