Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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());
13  return StatusCode::SUCCESS;
14 }
15 
16 StatusCode 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 
38 StatusCode 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 }
MM_RdoToDigit::decodeMM
StatusCode decodeMM(const EventContext &ctx, const Muon::MM_RawDataCollection &rdoCollection, DigitCollection &digitContainer) const
Definition: MM_RdoToDigit.cxx:38
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
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
MM_RdoToDigit::m_mmRdoKey
SG::ReadHandleKey< Muon::MM_RawDataContainer > m_mmRdoKey
Definition: MM_RdoToDigit.h:32
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
MM_RdoToDigit::DigitCollection
std::unordered_map< IdentifierHash, std::unique_ptr< MmDigitCollection > > DigitCollection
Definition: MM_RdoToDigit.h:24
MM_RdoToDigit::initialize
virtual StatusCode initialize() override final
Definition: MM_RdoToDigit.cxx:8
MM_RdoToDigit::m_mmRdoDecoderTool
ToolHandle< Muon::IMM_RDO_Decoder > m_mmRdoDecoderTool
Definition: MM_RdoToDigit.h:30
Muon::MM_RawDataCollection
Definition: MM_RawDataCollection.h:15
MM_RdoToDigit::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: MM_RdoToDigit.cxx:16
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MM_RdoToDigit::m_mmDigitKey
SG::WriteHandleKey< MmDigitContainer > m_mmDigitKey
Definition: MM_RdoToDigit.h:33
MM_RdoToDigit.h
Muon::MM_RawData
Temporary class to hold the MM RDO.
Definition: MM_RawData.h:20
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
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.
MM_RdoToDigit::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MM_RdoToDigit.h:31
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:109
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:400
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.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
Identifier
Definition: IdentifierFieldParser.cxx:14