Belle II Software  release-08-01-10
root.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 /*
10 This file contains test to check the behaviour of ROOT.
11 Its purpose is mainly to asure the programmer that his assumptions about run time behaviour are correct.
12 */
13 
14 #include <TMatrixD.h>
15 #include <TMatrixDSym.h>
16 
17 #include <gtest/gtest.h>
18 
19 TEST(TrackFindingCDCTest, root_TMatrixD)
20 {
21  TMatrixD jacobian(2, 2);
22  jacobian(0, 0) = 0;
23  jacobian(0, 1) = 1;
24 
25  jacobian(1, 0) = -1;
26  jacobian(1, 1) = 0;
27 
28 
29  TMatrixD covariance(2, 2);
30  covariance(0, 0) = 1;
31  covariance(0, 1) = 1;
32 
33  covariance(1, 0) = 1;
34  covariance(1, 1) = 0;
35 
36  //result = J * V * J^T
37  TMatrixD left(2, 2);
38  left.Mult(jacobian, covariance);
39 
40  TMatrixD result(2, 2);
41  result.MultT(left, jacobian);
42 
43  EXPECT_EQ(0, result(0, 0));
44  EXPECT_EQ(-1, result(0, 1));
45  EXPECT_EQ(-1, result(1, 0));
46  EXPECT_EQ(1, result(1, 1));
47 }
48 
49 
50 TEST(TrackFindingCDCTest, root_TMatrixDSym_Similarity_differing_rows_columns)
51 {
52  // Test if the number of rows gets augmented correctly,
53  // when transformed with a on square jacobian matrix.
54 
55  TMatrixDSym cov2(2);
56  cov2.Zero();
57 
58  cov2(0, 0) = 1;
59  cov2(1, 1) = 1;
60 
61  EXPECT_EQ(2, cov2.GetNrows());
62  EXPECT_EQ(2, cov2.GetNcols());
63 
64 
65  TMatrixD jacobianInflate(3, 2);
66  jacobianInflate.Zero();
67 
68  jacobianInflate(0, 0) = 1;
69  jacobianInflate(1, 1) = 1;
70  jacobianInflate(2, 0) = 1;
71  jacobianInflate(2, 1) = 1;
72 
73 
74  cov2.Similarity(jacobianInflate);
75 
76  EXPECT_EQ(3, cov2.GetNrows());
77  EXPECT_EQ(3, cov2.GetNcols());
78 
79  EXPECT_EQ(1, cov2(0, 0));
80  EXPECT_EQ(0, cov2(0, 1));
81  EXPECT_EQ(1, cov2(0, 2));
82 
83  EXPECT_EQ(0, cov2(1, 0));
84  EXPECT_EQ(1, cov2(1, 1));
85  EXPECT_EQ(1, cov2(1, 2));
86 
87  EXPECT_EQ(1, cov2(2, 0));
88  EXPECT_EQ(1, cov2(2, 1));
89  EXPECT_EQ(2, cov2(2, 2));
90 
91 }
92 
93 
94 // // Transform
95 // TMatrixDSym cov6(6);
96 // if (true){
97 // TMatrixD jacobianInflateT(5, 6);
98 // jacobianInflateT.Transpose(jacobianInflate);
99 // TMatrixD cov6workaroud = jacobianInflate * cov5 * jacobianInflateT;
100 
101 // for (unsigned int i = 0; i < 6; ++i) {
102 // for (unsigned int j = 0; j < 6; ++j) {
103 // cov6(i, j) = cov6workaroud(i, j);
104 // }
105 // }
106 // } else {
107 // cov6 = cov5; //copy
108 // cov6.Similarity(jacobianInflate);
109 // gfTrackCand.setCovSeed(cov6);
110 // }
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.