ATLAS Offline Software
MM_RdoToDigit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MM_RdoToDigit.h"
6 
7 MM_RdoToDigit::MM_RdoToDigit(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
8 
10  ATH_CHECK(m_idHelperSvc.retrieve());
11  ATH_CHECK(m_mmRdoDecoderTool.retrieve());
14  return StatusCode::SUCCESS;
15 }
16 
17 StatusCode MM_RdoToDigit::execute(const EventContext& ctx) const {
18  ATH_MSG_DEBUG("in execute()");
20  if (!rdoContainer.isPresent()) {
21  ATH_MSG_ERROR("No MM RDO container found!");
22  return StatusCode::FAILURE;
23  }
25  ATH_CHECK(wh_mmDigit.record(std::make_unique<MmDigitContainer>(m_idHelperSvc->mmIdHelper().module_hash_max())));
26  ATH_MSG_DEBUG("Decoding MM RDO into MM Digit");
27  DigitCollection digitMap{};
28  for (const Muon::MM_RawDataCollection* coll : *rdoContainer) {
29  ATH_CHECK(decodeMM(ctx, *coll, digitMap));
30  }
31 
32  for (auto& [hash, collection]: digitMap) {
33  ATH_CHECK(wh_mmDigit->addCollection(collection.release(), hash));
34  }
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 StatusCode MM_RdoToDigit::decodeMM(const EventContext& ctx,
40  const Muon::MM_RawDataCollection& rdoColl,
41  DigitCollection& digitContainer) const {
42  if (rdoColl.empty()) {
43  return StatusCode::SUCCESS;
44  }
45 
46  ATH_MSG_DEBUG(" Number of RawData in this rdo " << rdoColl.size());
47 
48  // for each RDO, loop over RawData, converter RawData to digit
49  // retrieve/create digit collection, and insert digit into collection
50  for (const Muon::MM_RawData* data : rdoColl) {
51  std::unique_ptr<MmDigit> newDigit{m_mmRdoDecoderTool->getDigit(ctx, data)};
52  if (!newDigit) {
53  ATH_MSG_WARNING("Error in MM RDO decoder");
54  continue;
55  }
56 
57  // find here the Proper Digit Collection identifier, using the rdo-hit id
58  // (since RDO collections are not in a 1-to-1 relation with digit collections)
59  const Identifier elementId = m_idHelperSvc->mmIdHelper().elementID(newDigit->identify());
60  IdentifierHash coll_hash = m_idHelperSvc->moduleHash(elementId);
61  std::unique_ptr<MmDigitCollection>& outCollection = digitContainer[coll_hash];
62  if (!outCollection) {
63  outCollection = std::make_unique<MmDigitCollection>(elementId, coll_hash);
64  }
65  outCollection->push_back(std::move(newDigit));
66  }
67 
68  return StatusCode::SUCCESS;
69 }
MM_RdoToDigit::decodeMM
StatusCode decodeMM(const EventContext &ctx, const Muon::MM_RawDataCollection &rdoCollection, DigitCollection &digitContainer) const
Definition: MM_RdoToDigit.cxx:39
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:300
MM_RdoToDigit::m_mmRdoKey
SG::ReadHandleKey< Muon::MM_RawDataContainer > m_mmRdoKey
Definition: MM_RdoToDigit.h:32
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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:9
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:17
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:76
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:394
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
MM_RdoToDigit::MM_RdoToDigit
MM_RdoToDigit(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MM_RdoToDigit.cxx:7
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