ATLAS Offline Software
MdtRdoToMdtDigit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MdtRdoToMdtDigit.h"
6 
7 MdtRdoToMdtDigit::MdtRdoToMdtDigit(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
8 
10  ATH_CHECK(m_idHelperSvc.retrieve());
11  ATH_CHECK(m_mdtRdoDecoderTool.retrieve());
14  return StatusCode::SUCCESS;
15 }
16 
17 StatusCode MdtRdoToMdtDigit::execute(const EventContext& ctx) const {
18  ATH_MSG_DEBUG("in execute()");
20  if (!rdoRH.isValid()) {
21  ATH_MSG_WARNING("No MDT RDO container found!");
22  return StatusCode::SUCCESS;
23  }
24  const MdtCsmContainer* rdoContainer = rdoRH.cptr();
25  ATH_MSG_DEBUG("Retrieved " << rdoContainer->size() << " MDT RDOs.");
26 
28  ATH_CHECK(wh_mdtDigit.record(std::make_unique<MdtDigitContainer>(m_idHelperSvc->mdtIdHelper().module_hash_max())));
29  ATH_MSG_DEBUG("Decoding MDT RDO into MDT Digit");
30 
31  // now decode RDO into digits
32  std::unordered_map<IdentifierHash, std::unique_ptr<MdtDigitCollection>> digitMap{};
33  for (const MdtCsm* csmColl : *rdoContainer) {
34  ATH_CHECK(decodeMdt(*csmColl, digitMap));
35  }
36 
37  for (auto& [hash, collection]: digitMap) {
38  ATH_CHECK(wh_mdtDigit->addCollection(collection.release(), hash));
39  }
40  return StatusCode::SUCCESS;
41 }
42 
44  if (rdoColl.empty()) {
45  return StatusCode::SUCCESS;
46  }
47  ATH_MSG_DEBUG(" Number of AmtHit in this Csm " << rdoColl.size());
48 
49  uint16_t subdetId = rdoColl.SubDetId();
50  uint16_t mrodId = rdoColl.MrodId();
51  uint16_t csmId = rdoColl.CsmId();
52 
53 
54  // for each Csm, loop over AmtHit, converter AmtHit to digit
55  // retrieve/create digit collection, and insert digit into collection
56  for (const MdtAmtHit* amtHit : rdoColl) {
57  std::unique_ptr<MdtDigit> newDigit{m_mdtRdoDecoderTool->getDigit(amtHit, subdetId, mrodId, csmId)};
58 
59  if (!newDigit) {
60  ATH_MSG_WARNING("Error in MDT RDO decoder");
61  continue;
62  }
63 
64  // find here the Proper Digit Collection identifier, using the rdo-hit id
65  // (since RDO collections are not in a 1-to-1 relation with digit collections)
66  const Identifier elementId = m_idHelperSvc->mdtIdHelper().elementID(newDigit->identify());
67  const IdentifierHash coll_hash = m_idHelperSvc->moduleHash(newDigit->identify());
68  std::unique_ptr<MdtDigitCollection>& outCollection = digitMap[coll_hash];
69  if(!outCollection) {
70  outCollection = std::make_unique<MdtDigitCollection>(elementId, coll_hash);
71  }
72  outCollection->push_back(std::move(newDigit));
73  }
74  return StatusCode::SUCCESS;
75 }
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:9
MdtAmtHit
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition: MdtAmtHit.h:20
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
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
MdtRdoToMdtDigit::decodeMdt
StatusCode decodeMdt(const MdtCsm &rdoCollection, DigitCollection &digitContainer) const
Definition: MdtRdoToMdtDigit.cxx:43
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
MdtCsm::SubDetId
uint16_t SubDetId() const
Returns the sub-detector Id.
Definition: MdtCsm.h:57
MdtCsmContainer
This container provides acces to the MDT RDOs.
Definition: MdtCsmContainer.h:22
MdtCsm
MDT RDOs : Chamber Service Module, container of AmtHits of a single Mdt chamber.
Definition: MdtCsm.h:19
MdtRdoToMdtDigit::MdtRdoToMdtDigit
MdtRdoToMdtDigit(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MdtRdoToMdtDigit.cxx:7
MdtRdoToMdtDigit::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: MdtRdoToMdtDigit.cxx:17
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MdtCsm::MrodId
uint16_t MrodId() const
Returns the MROD id from the CSM header.
Definition: MdtCsm.h:59
MdtRdoToMdtDigit::DigitCollection
std::unordered_map< IdentifierHash, std::unique_ptr< MdtDigitCollection > > DigitCollection
Definition: MdtRdoToMdtDigit.h:24
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
MdtRdoToMdtDigit.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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: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
MdtRdoToMdtDigit::m_mdtDigitKey
SG::WriteHandleKey< MdtDigitContainer > m_mdtDigitKey
Definition: MdtRdoToMdtDigit.h:30
IdentifierHash
Definition: IdentifierHash.h:38
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.