20#include "Acts/Utilities/Helpers.hpp"
25 using ChVec_t = std::vector<std::uint16_t>;
26 using ChVec_t = std::vector<std::uint16_t>;
41 return StatusCode::SUCCESS;
43 template <
typename PrdType_t>
48 const auto* prd =
dynamic_cast<const PrdType_t*
>(measurement);
53 if (hitId == prd->identify()) {
56 if constexpr(!std::is_same_v<PrdType_t, xAOD::MdtDriftCircle>) {
57 if (prd->readoutElement()->layerHash(hitId) != prd->layerHash()) {
61 if constexpr(std::is_same_v<PrdType_t, xAOD::TgcStrip> ||
62 std::is_same_v<PrdType_t, xAOD::RpcMeasurement>) {
63 if (( prd->measuresPhi() && Acts::rangeContainsValue(acc_phiChannel(*
hit), prd->channelNumber())) ||
64 (!prd->measuresPhi() && Acts::rangeContainsValue(acc_etaChannel(*
hit), prd->channelNumber()))) {
67 }
else if constexpr (std::is_same_v<PrdType_t, xAOD::MMCluster> ||
68 std::is_same_v<PrdType_t, xAOD::sTgcStripCluster>) {
69 for (
auto ch : prd->stripNumbers()) {
70 if (Acts::rangeContainsValue(acc_etaChannel(*
hit), ch)) {
74 }
else if constexpr(std::is_same_v<PrdType_t, xAOD::sTgcWireHit>) {
75 if (Acts::rangeContainsValue(acc_phiChannel(*
hit), prd->channelNumber())){
78 }
else if constexpr(std::is_same_v<PrdType_t, xAOD::sTgcPadHit>) {
79 if (Acts::rangeContainsValue(acc_padChannel(*
hit), prd->channelNumber())){
93 if (measurements->
empty()){
94 return StatusCode::SUCCESS;
105 if ((simHitViewer.
size() == 0 ||
m_idHelperSvc->detElementHash(simHitViewer.
at(0)->identify()) > viewHash) &&
109 }
else if (
m_idHelperSvc->detElementHash(simHitViewer.
at(0)->identify()) < viewHash \
111 return m_idHelperSvc->detElementHash(hit->identify()) == viewHash;
116 <<
" view hash: "<<viewHash);
120 switch (measurement->type()) {
135 switch (prd->channelType()) {
153 return StatusCode::FAILURE;
160 decorHandle(*measurement) =
LinkType{*simHits, bestSimHit->index()};
162 }
while (prdViewer.
next());
164 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Handle class for adding a decoration to an object.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This is a "hash" representation of an Identifier.
xAOD::ChamberViewer< Cont_t > Viewer_t
Abrivate the chamber viewer type.
SG::ReadHandleKey< xAOD::MuonSimHitContainer > m_simHitsKey
Key to the associated simHit container.
SG::ReadHandleKey< xAOD::MuonMeasurementContainer > m_prdHitKey
Key to the uncalibrated measurements to decorate.
ElementLink< xAOD::MuonSimHitContainer > LinkType
Attached sim-hit link decoration to the measurement container.
StatusCode execute(const EventContext &ctx) const override final
const xAOD::MuonSimHit * truthMatchPrd(Viewer_t< xAOD::MuonSimHitContainer > &simHits, const xAOD::MuonMeasurement *measurement) const
Searches for the best matching sim hit to a measurement.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
StatusCode initialize() override final
SG::WriteDecorHandleKey< xAOD::MuonMeasurementContainer > m_decorKey
Helper class to provide constant type-safe access to aux data.
const_ref at(const std::size_t idx) const
Returns the i-the measurement from the current chamber.
std::size_t size() const noexcept
Returns how many hits are in the current chamber.
bool loadView(const Identifier &chamberId)
Loads the view matching the parsed identifier.
bool next()
Loads the hits from the next chamber.
Auxiliary class to instantiate WriteDecorHandles.The handles can be created in an empty state.
This header ties the generic definitions in this package.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
@ DetElement
View ends if the detElementHash changes.
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.
MuonMeasurement_v1 MuonMeasurement
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
sTgcMeasurement_v1 sTgcMeasurement
MuonMeasurementContainer_v1 MuonMeasurementContainer