9#include <tracking/trackFindingCDC/collectors/selectors/SingleMatchSelector.h>
11#include <tracking/trackFindingCDC/numerics/WeightComperator.h>
13#include <gtest/gtest.h>
16using namespace TrackFindingCDC;
20 TEST(TrackFindingCDCTest, single_match_selector)
25 double c = 3, d = 4, e = 5;
27 std::vector<WeightedRelation<int, const double>> relations = {
34 std::sort(relations.begin(), relations.end());
35 selector.apply(relations);
37 std::sort(relations.begin(), relations.end(),
GreaterWeight());
39 ASSERT_EQ(relations.size(), 2);
40 ASSERT_EQ(relations[0].getWeight(), 1.0);
41 ASSERT_EQ(relations[0].getFrom(), &a);
42 ASSERT_EQ(relations[0].getTo(), &d);
43 ASSERT_EQ(relations[1].getWeight(), 0.6);
44 ASSERT_EQ(relations[1].getFrom(), &b);
45 ASSERT_EQ(relations[1].getTo(), &e);
50 TEST(TrackFindingCDCTest, single_best_match_selector)
53 selector.setUseOnlySingleBestCandidate(
false);
55 int a = 1, b = 2, c = 3;
56 double d = 4, e = 5, f = 6;
58 std::vector<WeightedRelation<int, const double>> relations = {
66 std::sort(relations.begin(), relations.end());
67 selector.apply(relations);
69 std::sort(relations.begin(), relations.end(),
GreaterWeight());
71 ASSERT_EQ(relations.size(), 3);
72 ASSERT_EQ(relations[0].getWeight(), 1.1);
73 ASSERT_EQ(relations[0].getFrom(), &a);
74 ASSERT_EQ(relations[0].getTo(), &d);
75 ASSERT_EQ(relations[1].getWeight(), 1.0);
76 ASSERT_EQ(relations[1].getFrom(), &a);
77 ASSERT_EQ(relations[1].getTo(), &e);
78 ASSERT_EQ(relations[2].getWeight(), 0.6);
79 ASSERT_EQ(relations[2].getFrom(), &b);
80 ASSERT_EQ(relations[2].getTo(), &f);
84 struct CustomComparer {
85 bool operator()(
const double* lhs,
const double* rhs)
const
87 return (
static_cast<int>(*lhs) % 2) < (
static_cast<int>(*rhs) % 2);
92 TEST(TrackFindingCDCTest, single_match_selector_with_comparer)
97 double c = 3, d = 4, e = 5;
99 std::vector<WeightedRelation<int, const double>> relations = {
106 std::sort(relations.begin(), relations.end());
107 selector.apply(relations);
109 std::sort(relations.begin(), relations.end(),
GreaterWeight());
111 ASSERT_EQ(relations.size(), 1);
112 ASSERT_EQ(relations[0].getWeight(), 1.0);
113 ASSERT_EQ(relations[0].getFrom(), &a);
114 ASSERT_EQ(relations[0].getTo(), &d);
Selector to remove all relations in the list, which share the same collection item - except one in ca...
Type for two related objects with a weight.
Abstract base class for different kinds of events.
Functor factory turning a binary functor and two functors into a new functor which executes the binar...