6 #include "GaudiKernel/SystemOfUnits.h"
14 #include "GaudiKernel/PhysicalConstants.h"
19 using simHitSet = std::unordered_set<const xAOD::MuonSimHit*>;
39 return StatusCode::SUCCESS;
51 for (
unsigned int s = 0 ;
s < truthSigns.size(); ++
s) {
52 same += (truthSigns[
s] != 0) && truthSigns[
s] == recoSigns[
s];
56 std::vector<MuonValR4::ObjectMatching>
61 std::vector<ObjectMatching> allAssociations{};
62 std::unordered_set<const SegmentSeed*> usedSeeds{};
63 std::unordered_set<const Segment*> usedSegs{};
70 std::vector<simHitSet> truthHitsVec{}, seedSimHitVec{}, segmentSimHitVec{};
82 ObjectMatching & matchedWithTruth = allAssociations.emplace_back();
86 std::vector<std::pair<const SegmentSeed*, unsigned>> matchedSeeds{};
93 if (seed->msSector() != matchedWithTruth.
chamber) {
96 const simHitSet& seedHits{seedSimHitVec[seedIdx]};
97 unsigned int matchedHits =
countMatched(truthHits, seedHits);
101 matchedSeeds.emplace_back(std::make_pair(seed, matchedHits));
105 std::vector<std::pair<const Segment*, unsigned>> matchedSegs{};
111 const simHitSet& segmentHits{segmentSimHitVec[segmentIdx]};
112 unsigned int matchedHits =
countMatched(truthHits, segmentHits);
116 matchedSegs.emplace_back(std::make_pair(
segment,matchedHits));
122 std::ranges::sort(matchedSegs,
123 [
this, &truth, &gctx](
const std::pair<const Segment*, unsigned>& segA,
124 const std::pair<const Segment*, unsigned>& segB){
125 if (segA.second != segB.second)
return segA.second > segB.second;
129 std::ranges::sort(matchedSeeds, [](
const std::pair<const SegmentSeed*, unsigned>& seedA,
130 const std::pair<const SegmentSeed*, unsigned>& seedB) {
131 return seedA.second > seedB.second;
138 for (
const auto& [
matched, nMatchedHits] : matchedSegs) {
143 usedSeeds.insert(
matched->parent());
148 for (
const auto& [seed , nHits] : matchedSeeds) {
153 usedSeeds.insert(seed);
163 for (
const Segment* seg: *segmentContainer) {
165 if (usedSegs.count(seg)) {
169 match.chamber = seg->msSector();
170 match.matchedSegments = {seg};
171 match.matchedSeeds = {seg->parent()};
173 usedSeeds.insert(seg->parent());
177 if (usedSeeds.count(seed)) {
181 match.chamber = seed->msSector();
182 match.matchedSeeds = {seed};
184 return allAssociations;
187 template <
class ContainerType>
190 const ContainerType*& contToPush)
const {
191 contToPush =
nullptr;
194 return StatusCode::SUCCESS;
198 contToPush = readHandle.cptr();
199 return StatusCode::SUCCESS;
204 return StatusCode::SUCCESS;
208 const EventContext & ctx = Gaudi::Hive::currentContext();
227 std::vector<ObjectMatching>
objects =
matchWithTruth(gctx, readTruthSegments, readSegmentSeeds, readMuonSegments);
236 return StatusCode::SUCCESS;