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  const unsigned int hashMax = m_idHelperSvc->mdtIdHelper().module_hash_max();
29  ATH_CHECK(wh_mdtDigit.record(std::make_unique<MdtDigitContainer>(hashMax)));
30  ATH_MSG_DEBUG("Decoding MDT RDO into MDT Digit");
31 
32  // now decode RDO into digits
33  DigitCollection digitMap{};
34  digitMap.resize(hashMax);
35  for (const MdtCsm* csmColl : *rdoContainer) {
36  ATH_CHECK(decodeMdt(ctx, *csmColl, digitMap));
37  }
38 
39  for (std::unique_ptr<MdtDigitCollection>&collection: digitMap) {
40  if (!collection) continue;
41  const IdentifierHash hash = collection->identifierHash();
42  ATH_CHECK(wh_mdtDigit->addCollection(collection.release(), hash));
43  }
44  return StatusCode::SUCCESS;
45 }
46 
47 StatusCode MdtRdoToMdtDigit::decodeMdt(const EventContext& ctx, const MdtCsm& rdoColl, DigitCollection& digitMap) const {
48  if (rdoColl.empty()) {
49  return StatusCode::SUCCESS;
50  }
51  ATH_MSG_DEBUG(" Number of AmtHit in this Csm " << rdoColl.size());
52 
53  uint16_t subdetId = rdoColl.SubDetId();
54  uint16_t mrodId = rdoColl.MrodId();
55  uint16_t csmId = rdoColl.CsmId();
56 
57 
58  // for each Csm, loop over AmtHit, converter AmtHit to digit
59  // retrieve/create digit collection, and insert digit into collection
60  for (const MdtAmtHit* amtHit : rdoColl) {
61  std::unique_ptr<MdtDigit> newDigit{m_mdtRdoDecoderTool->getDigit(ctx, *amtHit, subdetId, mrodId, csmId)};
62 
63  if (!newDigit) {
64  ATH_MSG_WARNING("Digit rejected");
65  continue;
66  }
67 
68  // find here the Proper Digit Collection identifier, using the rdo-hit id
69  // (since RDO collections are not in a 1-to-1 relation with digit collections)
70  const IdentifierHash coll_hash = m_idHelperSvc->moduleHash(newDigit->identify());
71  std::unique_ptr<MdtDigitCollection>& outCollection = digitMap[coll_hash];
72  if(!outCollection) {
73  outCollection = std::make_unique<MdtDigitCollection>(m_idHelperSvc->chamberId(newDigit->identify()), coll_hash);
74  }
75  outCollection->push_back(std::move(newDigit));
76  }
77  return StatusCode::SUCCESS;
78 }
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
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MdtRdoToMdtDigit::DigitCollection
std::vector< std::unique_ptr< MdtDigitCollection > > DigitCollection
Definition: MdtRdoToMdtDigit.h:24
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
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
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:47
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:221
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
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.