Belle II Software  release-08-01-10
LinearDivision.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 #include <tracking/trackFindingCDC/hough/baseelements/LinearDivision.h>
9 #include <tracking/trackFindingCDC/hough/boxes/Box.h>
10 #include <tracking/trackFindingCDC/numerics/Weight.h>
11 
12 #include <framework/logging/Logger.h>
13 
14 #include <gtest/gtest.h>
15 #include <cmath>
16 
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
21 
22 TEST(TrackFindingCDCTest, SumInfinities)
23 {
24  EXPECT_EQ(INFINITY, INFINITY + INFINITY);
25 
26  std::array<Weight, 4> infinities{{INFINITY, INFINITY, INFINITY, INFINITY}};
27  Weight weightSum = std::accumulate(std::begin(infinities), std::end(infinities), Weight(0));
28  EXPECT_EQ(INFINITY, weightSum);
29 }
30 
31 
32 TEST(TrackFindingCDCTest, LinearDivision_createBoxes)
33 {
34  Box<float, float> box({{0, 3}}, {{0, 2}});
35 
36  size_t nSubNodes = LinearDivision<Box<float, float>, 3, 3>::s_nSubBoxes;
37  EXPECT_EQ(9, nSubNodes);
38 
39  //LinearDivision<Box<float, float>, 3, 2> subBoxFactory{Box<float, float>::Delta{0.0, 0.0}};
40  LinearDivision<Box<float, float>, 3, 2> subBoxFactory{};
41  std::array<Box<float, float>, 6 > subBoxes = subBoxFactory(box);
42 
43  size_t i = 0;
44  for (Box<float, float>& subBox : subBoxes) {
45  B2INFO("Lower bounds: " << subBox.getLowerBound<0>() << ", " << subBox.getLowerBound<1>());
46  B2INFO("Upper bounds: " << subBox.getUpperBound<0>() << ", " << subBox.getUpperBound<1>());
47 
48  EXPECT_EQ(i % 3 , subBox.getLowerBound<0>());
49  EXPECT_EQ(i / 3, subBox.getLowerBound<1>());
50 
51  EXPECT_EQ(i % 3 + 1, subBox.getUpperBound<0>());
52  EXPECT_EQ(i / 3 + 1, subBox.getUpperBound<1>());
53  ++i;
54  }
55 
57  EXPECT_EQ(6, i);
58 }
The base class for all boxes.
Definition: Box.h:33
Factory object that constructs sub boxes from a given box with optional overlaps.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.