Belle II Software  release-05-01-25
LinearDivision.test.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost <oliver.frost@desy.de> *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/hough/baseelements/LinearDivision.h>
11 #include <tracking/trackFindingCDC/hough/boxes/Box.h>
12 #include <tracking/trackFindingCDC/numerics/Weight.h>
13 
14 #include <framework/logging/Logger.h>
15 
16 #include <gtest/gtest.h>
17 #include <cmath>
18 
19 
20 using namespace Belle2;
21 using namespace TrackFindingCDC;
22 
23 
24 TEST(TrackFindingCDCTest, SumInfinities)
25 {
26  EXPECT_EQ(INFINITY, INFINITY + INFINITY);
27 
28  std::array<Weight, 4> infinities{{INFINITY, INFINITY, INFINITY, INFINITY}};
29  Weight weightSum = std::accumulate(std::begin(infinities), std::end(infinities), Weight(0));
30  EXPECT_EQ(INFINITY, weightSum);
31 }
32 
33 
34 TEST(TrackFindingCDCTest, LinearDivision_createBoxes)
35 {
36  Box<float, float> box({{0, 3}}, {{0, 2}});
37 
38  size_t nSubNodes = LinearDivision<Box<float, float>, 3, 3>::s_nSubBoxes;
39  EXPECT_EQ(9, nSubNodes);
40 
41  //LinearDivision<Box<float, float>, 3, 2> subBoxFactory{Box<float, float>::Delta{0.0, 0.0}};
42  LinearDivision<Box<float, float>, 3, 2> subBoxFactory{};
43  std::array<Box<float, float>, 6 > subBoxes = subBoxFactory(box);
44 
45  size_t i = 0;
46  for (Box<float, float>& subBox : subBoxes) {
47  B2INFO("Lower bounds: " << subBox.getLowerBound<0>() << ", " << subBox.getLowerBound<1>());
48  B2INFO("Upper bounds: " << subBox.getUpperBound<0>() << ", " << subBox.getUpperBound<1>());
49 
50  EXPECT_EQ(i % 3 , subBox.getLowerBound<0>());
51  EXPECT_EQ(i / 3, subBox.getLowerBound<1>());
52 
53  EXPECT_EQ(i % 3 + 1, subBox.getUpperBound<0>());
54  EXPECT_EQ(i / 3 + 1, subBox.getUpperBound<1>());
55  ++i;
56  }
57 
59  EXPECT_EQ(6, i);
60 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TEST
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Definition: utilityFunctions.cc:18