Belle II Software development
MatcherInterface.test.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <tracking/trackFindingCDC/collectors/matchers/MatcherInterface.h>
10
11#include <tracking/trackFindingCDC/numerics/WeightComperator.h>
12
13#include <gtest/gtest.h>
14
15using namespace Belle2;
16using namespace TrackFindingCDC;
17
18namespace {
20 class SimpleMatcher : public MatcherInterface<int, double> {
21 Weight match(int& a, const double& b) override
22 {
23 return a + b;
24 }
25 };
27 TEST(TrackFindingCDCTest, matcher_interface)
28 {
29 SimpleMatcher matcher;
30
31 std::vector<WeightedRelation<int, const double>> relations;
32
33 std::vector<int> collectorItems = {1, 2};
34 std::vector<double> collectionItems = {2.1, 2.2, 2.3};
35
36 matcher.apply(collectorItems, collectionItems, relations);
37
38 std::sort(relations.begin(), relations.end(), GreaterWeight());
39
40 ASSERT_EQ(relations.size(), 6);
41 ASSERT_EQ(relations[5].getWeight(), 3.1);
42 ASSERT_EQ(relations[4].getWeight(), 3.2);
43 ASSERT_EQ(relations[3].getWeight(), 3.3);
44 ASSERT_EQ(relations[2].getWeight(), 4.1);
45 ASSERT_EQ(relations[1].getWeight(), 4.2);
46 ASSERT_EQ(relations[0].getWeight(), 4.3);
47 }
48}
Base class for a findlet, which outputs a list of weighted relations between elements in a list of Co...
Abstract base class for different kinds of events.