Belle II Software  release-05-01-25
FacetFitter.test.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - 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/fitting/FacetFitter.h>
11 
12 #include <tracking/trackFindingCDC/geometry/UncertainParameterLine2D.h>
13 #include <tracking/trackFindingCDC/geometry/LineParameters.h>
14 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
15 
16 #include <tracking/trackFindingCDC/numerics/Matrix.h>
17 
18 #include <framework/logging/Logger.h>
19 
20 #include <gtest/gtest.h>
21 
22 using namespace Belle2;
23 using namespace TrackFindingCDC;
24 
25 
26 TEST(TrackFindingCDCTest, fitting_FacetFitter_fitLine)
27 {
28  Matrix<double, 3, 1> weights = Matrix<double, 3, 1>::Constant(1.0 / 4.0);
29  Matrix<double, 3, 3> xyl = Matrix<double, 3, 3>::Zero();
30 
31  xyl(0, 0) = -1;
32  xyl(0, 1) = 1.1;
33  xyl(0, 2) = -0.05;
34 
35  xyl(1, 0) = 0;
36  xyl(1, 1) = 0.8;
37  xyl(1, 2) = 0.1;
38 
39  xyl(2, 0) = 1;
40  xyl(2, 1) = 1.1;
41  xyl(2, 2) = -0.05;
42 
43  for (int nSteps : {100, 1, 0}) {
44  UncertainParameterLine2D fittedLine = FacetFitter::fit(xyl, weights, nSteps);
45 
46  EXPECT_NEAR(1, fittedLine->tangential().x(), 1e-6);
47  EXPECT_NEAR(0, fittedLine->tangential().y(), 1e-6);
48  EXPECT_NEAR(0, fittedLine->support().x(), 1e-6);
49  EXPECT_NEAR(1, fittedLine->support().y(), 1e-6);
50  EXPECT_NEAR(0.015 * 1.0 / 4.0, fittedLine.chi2(), 1e-6);
51  B2INFO(fittedLine.lineCovariance());
52  }
53 }
54 
55 
56 TEST(TrackFindingCDCTest, fitting_FacetFitter_fitLine_alongYAxes)
57 {
58  Matrix<double, 3, 1> weights = Matrix<double, 3, 1>::Constant(1.0);
59  Matrix<double, 3, 3> xyl = Matrix<double, 3, 3>::Zero();
60 
61  xyl(0, 0) = 1.1;
62  xyl(0, 1) = -1;
63  xyl(0, 2) = 0.05;
64 
65  xyl(1, 0) = 0.8;
66  xyl(1, 1) = 0;
67  xyl(1, 2) = -0.1;
68 
69  xyl(2, 0) = 1.1;
70  xyl(2, 1) = 1;
71  xyl(2, 2) = 0.05;
72 
73  for (int nSteps : {100, 1, 0}) {
74  UncertainParameterLine2D fittedLine = FacetFitter::fit(xyl, weights, nSteps);
75 
76  EXPECT_NEAR(0, fittedLine->tangential().x(), 1e-6);
77  EXPECT_NEAR(1, fittedLine->tangential().y(), 1e-6);
78  EXPECT_NEAR(1, fittedLine->support().x(), 1e-6);
79  EXPECT_NEAR(0, fittedLine->support().y(), 1e-6);
80  EXPECT_NEAR(0.015, fittedLine.chi2(), 1e-6);
81  B2INFO(fittedLine.lineCovariance());
82  }
83 }
84 
85 
86 
87 TEST(TrackFindingCDCTest, fitting_FacetFitter_fitLine_sameSide)
88 {
89  Matrix<double, 3, 1> weights = Matrix<double, 3, 1>::Constant(1);
90  Matrix<double, 3, 3> xyl = Matrix<double, 3, 3>::Zero();
91 
92  xyl(0, 0) = 1;
93  xyl(0, 1) = 0.8;
94  xyl(0, 2) = -0.1;
95 
96  xyl(1, 0) = 0;
97  xyl(1, 1) = 0.8;
98  xyl(1, 2) = -0.4;
99 
100  xyl(2, 0) = -1;
101  xyl(2, 1) = 0.8;
102  xyl(2, 2) = -0.1;
103 
104  for (int nSteps : {100, 1, 0}) {
105  UncertainParameterLine2D fittedLine = FacetFitter::fit(xyl, weights, nSteps);
106 
107  EXPECT_NEAR(-1, fittedLine->tangential().x(), 1e-6);
108  EXPECT_NEAR(0, fittedLine->tangential().y(), 1e-6);
109  EXPECT_NEAR(0, fittedLine->support().x(), 1e-6);
110  EXPECT_NEAR(1, fittedLine->support().y(), 1e-6);
111  EXPECT_NEAR(0.06, fittedLine.chi2(), 1e-6);
112  B2INFO(fittedLine.lineCovariance());
113  }
114 }
Belle2::TrackFindingCDC::PlainMatrix::Zero
static PlainMatrix< T, M, N > Zero()
Construct a matrix initialized with zeros.
Definition: PlainMatrix.h:77
Belle2::TrackFindingCDC::FacetFitter::fit
static double fit(const CDCFacet &facet, int nSteps=100)
Fits a proper line to facet and returns the chi2.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::PlainMatrix::Constant
static PlainMatrix< T, M, N > Constant(T t)
Construct a matrix with all elements set to a constant.
Definition: PlainMatrix.h:93
Belle2::TEST
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Definition: utilityFunctions.cc:18