 |
ATLAS Offline Software
|
Go to the documentation of this file.
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);
34 return StatusCode::SUCCESS;
51 unsigned int bestCount{0};
53 <<
", eta: "<<matchMe.segment->etaIndex()<<
", sector: "<<matchMe.segment->sector());
55 unsigned int candCount = countMatches(matchMe.hits, truthCand.hits);
56 if (candCount > bestCount) {
57 ATH_MSG_VERBOSE(
"Found new candidate with better matches "<<bestCount<<
" vs. "<<candCount);
58 candCount = bestCount;
59 bestMatch = truthCand.segment;
66 ATH_MSG_DEBUG(
"Found a matching candidate with "<<bestCount<<
"/ "<<matchMe.hits.size()<<
" hits.");
67 dec_truthSegLink(*matchMe.segment) =
SegLink_t{truthSegments, bestMatch->
index()};
71 dec_truthLink(*matchMe.segment) =
TruthLink_t(truthCont, truthPart->
index());
74 return StatusCode::SUCCESS;
84 if (candidate.hits.empty()) {
87 output.emplace_back(std::move(candidate));
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_truthSegLinkKey
Key to the truth segment -> truth particle association.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_segTruthSegLinkKey
Output key to the associated truth segment link decoration.
Class describing a MuonSegment.
virtual StatusCode initialize() override final
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
Helper struct of segments with simHits & associated spectrometer sector.
#define ATH_MSG_VERBOSE(x)
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_segTruthLinkKey
Output key to the associated truth particle decoration.
std::vector< SegmentWithTruth > matchSimHits(const xAOD::MuonSegmentContainer &segments) const
Loops over the segment container and fetches the segments with truth matched hits.
std::vector< SegmentWithTruth > SegWithTruthVec_t
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_segPrdLinkKey
Key to the associated uncalibrated measurement decoration.
::StatusCode StatusCode
StatusCode definition for legacy code.
const std::string & chName(ChIndex index)
convert ChIndex into a string
Class describing a truth particle in the MC record.
const xAOD::MuonSegment * segment
segment pointer of interest
Handle class for adding a decoration to an object.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ElementLink< MuonR4::SegmentContainer > SegLink_t
size_t index() const
Return the index of this element within its container.
ElementLink implementation for ROOT usage.
This header ties the generic definitions in this package.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
index_type index() const
Get the index of the element inside of its container.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Key to the reconstructed segment container to truth match.
const SG::AuxVectorData * container() const
Return the container holding this element.
Handle class for reading from StoreGate.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_truthSegKey
Key to the truth segment container.
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment