18 unsigned countMatches(
const std::unordered_set<const xAOD::MuonSimHit*>& recoHits,
19 const std::unordered_set<const xAOD::MuonSimHit*>& truthHits){
20 return std::ranges::count_if(recoHits, [&truthHits](
const xAOD::MuonSimHit* recoHit){
21 return truthHits.count(recoHit);
36 ATH_MSG_FATAL(
"Please configure the input measurement container.");
37 return StatusCode::FAILURE;
44 return StatusCode::SUCCESS;
61 unsigned int bestCount{0};
63 <<
", eta: "<<matchMe.segment->etaIndex()<<
", sector: "<<matchMe.segment->sector());
65 unsigned int candCount = countMatches(matchMe.hits, truthCand.hits);
66 if (candCount > bestCount) {
67 ATH_MSG_VERBOSE(
"Found new candidate with better matches "<<bestCount<<
" vs. "<<candCount);
68 candCount = bestCount;
69 bestMatch = truthCand.segment;
76 ATH_MSG_DEBUG(
"Found a matching candidate with "<<bestCount<<
"/ "<<matchMe.hits.size()<<
" hits.");
77 dec_truthSegLink(*matchMe.segment) =
SegLink_t{truthSegments, bestMatch->
index()};
81 dec_truthLink(*matchMe.segment) =
TruthLink_t(truthCont, truthPart->
index());
84 return StatusCode::SUCCESS;
94 if (candidate.
hits.empty()) {
97 output.emplace_back(std::move(candidate));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
ElementLink implementation for ROOT usage.
std::vector< SegmentWithTruth > matchSimHits(const xAOD::MuonSegmentContainer &segments) const
Loops over the segment container and fetches the segments with truth matched hits.
virtual StatusCode initialize() override final
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_measKeys
Key to the prd containers in the event.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_truthSegKey
Key to the truth segment container.
std::vector< SegmentWithTruth > SegWithTruthVec_t
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_segTruthLinkKey
Output key to the associated truth particle decoration.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Key to the reconstructed segment container to truth match.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_segPrdLinkKey
Key to the associated uncalibrated measurement decoration.
Gaudi::Property< std::string > m_simLink
Decoration key of the prd -> simHit association.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_truthSegLinkKey
Key to the truth segment -> truth particle association.
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_prdLinkKeys
Dependency on the sim hit decoration.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_segTruthSegLinkKey
Output key to the associated truth segment link decoration.
virtual StatusCode execute(const EventContext &ctx) const override final
const SG::AuxVectorData * container() const
Return the container holding this element.
size_t index() const
Return the index of this element within its container.
SG::WriteDecorHandle< ContType, dType > makeHandle(const EventContext &ctx, const SG::WriteDecorHandleKey< ContType > &key, const dType &defValue=dType{})
This header ties the generic definitions in this package.
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
ElementLink< MuonR4::SegmentContainer > SegLink_t
Abrivation of the link to the reco segment container.
const std::string & chName(ChIndex index)
convert ChIndex into a string
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
TruthParticle_v1 TruthParticle
Typedef to implementation.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Helper struct of segments with simHits & associated spectrometer sector.
const xAOD::MuonSegment * segment
segment pointer of interest
std::unordered_set< const xAOD::MuonSimHit * > hits
list of associated sim hits