15 declareInterface<IMuonLayerAmbiguitySolverTool>(
this);
24 return StatusCode::SUCCESS;
28 std::vector<MuonCandidate>& resolvedCandidates)
const {
30 std::vector<std::vector<MuonLayerIntersection> > muonLayerDataHashVec;
34 unsigned int nseeds = 0;
35 std::set<const MuonSegment*> usedSegments;
42 if (!
getNextSeed(muonLayerDataHashVec, usedSegments, inverseSeedLayerOrder, layerIntersection)) {
48 std::vector<MuonLayerIntersection> layerIntersections = {layerIntersection};
55 msg(
MSG::VERBOSE) <<
" Candidate with layers " << candidate.layerIntersections.size();
56 for (
const auto&
entry : candidate.layerIntersections) {
65 for (
const auto&
layer : candidate.layerIntersections) { usedSegments.insert(
layer.segment.get()); }
67 resolvedCandidates.insert(resolvedCandidates.end(), std::make_move_iterator(
candidates.begin()),
73 ATH_MSG_DEBUG(
"Completed ambiguity solving using " << nseeds <<
" seeds, resulting in " << resolvedCandidates.size()
74 <<
" track candidates ");
78 const EventContext& ctx, std::vector<MuonCandidate>&
candidates,
79 const std::vector<std::vector<MuonLayerIntersection> >& muonLayerDataHashVec,
80 const std::vector<MuonStationIndex::StIndex>& inverseSeedLayerOrder)
const {
82 if (inverseSeedLayerOrder.empty())
return true;
88 const std::vector<MuonLayerIntersection>& layerIntersections = muonLayerDataHashVec[currentStIndex];
89 if (!layerIntersections.empty()) {
91 std::vector<MuonCandidate> newCandidates;
96 unsigned int selectedSegmentsInLayer = 0;
101 if (
match(ctx, candidate, layerIntersection)) {
103 if (selectedSegmentsInLayer == 0) {
104 candidate.layerIntersections.push_back(layerIntersection);
109 newCandidates.emplace_back(std::move(newCandidate));
111 ++selectedSegmentsInLayer;
116 if (!newCandidates.empty()) {
117 ATH_MSG_VERBOSE(
"Found multiple solutions, add new candidates " << newCandidates.size());
119 std::make_move_iterator(newCandidates.end()));
124 std::vector<MuonStationIndex::StIndex> newInverseSeedLayerOrder = inverseSeedLayerOrder;
125 newInverseSeedLayerOrder.pop_back();
139 std::set<const MuonSegment*>& usedSegments,
140 std::vector<MuonStationIndex::StIndex>& inverseSeedLayerOrder,
142 ATH_MSG_VERBOSE(
"getNextSeed, remaining layers " << inverseSeedLayerOrder.size());
144 std::vector<MuonStationIndex::StIndex>::const_reverse_iterator rit = inverseSeedLayerOrder.rbegin();
145 std::vector<MuonStationIndex::StIndex>::const_reverse_iterator rit_end = inverseSeedLayerOrder.rend();
146 for (; rit != rit_end; ++rit) {
153 if (usedSegments.count(
segment))
continue;
157 layerIntersection = muonLayerIntersection;
162 inverseSeedLayerOrder.pop_back();
168 std::vector<std::vector<MuonLayerIntersection> >& muonLayerDataHashVec)
const {
170 muonLayerDataHashVec.clear();
179 std::vector<MuonLayerIntersection> layerIntersections;
180 layerIntersections.reserve(
layer.segments.size());
181 for (
const std::shared_ptr<const MuonSegment>&
segment :
layer.segments) {
185 layerIntersections.emplace_back(
layer.intersection,
segment, quality);
189 if (muonLayerDataHashVec[stIndex].
empty()) {
190 muonLayerDataHashVec[stIndex] = std::move(layerIntersections);
198 muonLayerDataHashVec[stIndex].
begin(), muonLayerDataHashVec[stIndex].
end(),
204 for (
const auto&
vec : muonLayerDataHashVec) {
212 std::vector<MuonLayerIntersection>& existingLayerIntersections,
213 std::vector<MuonLayerIntersection>& newLayerIntersections)
const {
214 ATH_MSG_VERBOSE(
" resolveSmallLargeOverlaps: existing " << existingLayerIntersections.size() <<
" new "
215 << newLayerIntersections.size());
218 std::set<const MuonSegment*> combinedSegments;
219 std::vector<MuonLayerIntersection> combinedIntersections;
233 if (!
m_segmentMatchingTool->match(ctx, *layerIntersection1.segment, *layerIntersection2.segment))
continue;
237 std::shared_ptr<const MuonSegment> newseg{
238 m_muonTrackBuilder->combineToSegment(ctx, *layerIntersection1.segment, *layerIntersection2.segment, emptyVec)};
257 if (qualitynew < layerIntersection1.quality || qualitynew < layerIntersection2.quality) {
258 ATH_MSG_DEBUG(
"Quality got worse after combination: new " << qualitynew <<
" q1 " << layerIntersection1.quality
259 <<
" q2 " << layerIntersection2.quality);
271 double dist1 =
getDistance(layerIntersection1, direction);
272 double dist2 =
getDistance(layerIntersection2, direction);
274 combinedIntersections.emplace_back(layerIntersection1.intersection, newseg, qualitynew);
276 combinedIntersections.emplace_back(layerIntersection2.intersection, newseg, qualitynew);
279 <<
" first " <<
m_printer->print(*layerIntersection1.segment) << std::endl
280 <<
" second " <<
m_printer->print(*layerIntersection2.segment) << std::endl
281 <<
" combined " <<
m_printer->print(*newseg));
284 combinedSegments.insert(layerIntersection1.segment.get());
285 combinedSegments.insert(layerIntersection2.segment.get());
291 return !combinedSegments.count(inter_sect.segment.get());
294 combinedIntersections.reserve(existingLayerIntersections.size() + newLayerIntersections.size());
295 std::copy_if(std::make_move_iterator(existingLayerIntersections.begin()), std::make_move_iterator(existingLayerIntersections.end()),
296 std::back_inserter(combinedIntersections), insert_intersection);
297 std::copy_if(std::make_move_iterator(newLayerIntersections.begin()), std::make_move_iterator(newLayerIntersections.end()),
298 std::back_inserter(combinedIntersections), insert_intersection);
299 existingLayerIntersections = std::move(combinedIntersections);