Belle II Software  release-05-01-25
BeamSpotUT.cc
1 #include <mdst/dbobjects/BeamSpot.h>
2 #include <gtest/gtest.h>
3 
4 #include <limits>
5 #include <functional>
6 
7 namespace Belle2 {
13  class BeamSpotTest : public ::testing::Test {
14  protected:
15  };
16 
19  {
20  BeamSpot bs;
21  EXPECT_EQ(bs.getIPPosition().X() , 0.);
22  EXPECT_EQ(bs.getIPPosition().Y() , 0.);
23  EXPECT_EQ(bs.getIPPosition().Z() , 0.);
24 
25  std::function<float (int, int)> sizeElement = [ & sizeElement](int i, int j) {
26  return j >= i ? (i + 1) + 10 * (j + 1) : sizeElement(j, i) ;
27  };
28 
29  std::function<float (int, int)> errorElement = [& errorElement](int i, int j) {
30  return j >= i ? 100 + (i + 1) + 10 * (j + 1) : errorElement(j, i);
31  };
32 
33  TMatrixDSym size(3), positionError(3);
34  for (int i = 0; i < 3; i++)
35  for (int j = i; j < 3; j++) {
36  size(i, j) = size(j, i) = sizeElement(i, j);
37  positionError(i, j) = positionError(j, i) = errorElement(i, j);
38  }
39 
40  TVector3 position;
41  position.SetXYZ(1., 2., 3.);
42 
43  bs.setSizeCovMatrix(size);
44  bs.setIP(position, positionError);
45 
46  TVector3 testPosition = bs.getIPPosition();
47  EXPECT_EQ(testPosition.X() , 1.);
48  EXPECT_EQ(testPosition.Y() , 2.);
49  EXPECT_EQ(testPosition.Z() , 3.);
50 
51  TMatrixDSym testError = bs.getIPPositionCovMatrix();
52  for (int i = 0; i < 3; i++)
53  for (int j = 0; j < 3; j++)
54  EXPECT_EQ(testError(i, j) , errorElement(i, j));
55 
56  TMatrixDSym testSize = bs.getSizeCovMatrix();
57  for (int i = 0; i < 3; i++)
58  for (int j = 0; j < 3; j++)
59  EXPECT_EQ(testSize(i, j) , sizeElement(i, j));
60 
61 
62  TMatrixDSym testCovVertex = bs.getCovVertex();
63  for (int i = 0; i < 3; i++)
64  for (int j = 0; j < 3; j++)
65  EXPECT_EQ(testCovVertex(i, j) , (sizeElement(i, j) + errorElement(i, j)));
66 
67  EXPECT_EQ(bs.getGlobalUniqueID() , 1);
68  BeamSpot bs2(bs);
69  EXPECT_EQ(bs == bs2, true);
70 
71  BeamSpot bs3;
72  bs3 = bs;
73  EXPECT_EQ(bs == bs3, true);
74 
75  BeamSpot bs4;
76  bs4 = bs3;
77  size(2, 2) = 0.;
78 
79  bs3.setSizeCovMatrix(size);
80  size(2, 2) = std::numeric_limits<double>::min();
81  bs4.setSizeCovMatrix(size);
82 
83  EXPECT_EQ(bs4 == bs3, false);
84  }
85 
87 }
Belle2::BeamSpotTest
Definition: BeamSpotUT.cc:13
Belle2::BeamSpot::setSizeCovMatrix
void setSizeCovMatrix(const TMatrixDSym &size)
Set the covariance matrix of the size of the IP position.
Definition: BeamSpot.h:60
Belle2::BeamSpot::getCovVertex
TMatrixDSym getCovVertex() const
Get the total covariance matrix of theIP position (for compatibility with BeamParameters)
Definition: BeamSpot.h:95
Belle2::BeamSpot::getIPPosition
const TVector3 & getIPPosition() const
Get the IP position.
Definition: BeamSpot.h:76
Belle2::BeamSpot
This class contains the beam spot position and size modeled as a gaussian distribution in space.
Definition: BeamSpot.h:32
Belle2::BeamSpot::getSizeCovMatrix
const TMatrixDSym & getSizeCovMatrix() const
Get the covariance matrix of the size of the IP position modeled as a gaussian.
Definition: BeamSpot.h:88
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BeamSpot::setIP
void setIP(const TVector3 &ipPosition, const TMatrixDSym &covariance)
Set the IP position and its error matrix.
Definition: BeamSpot.h:69
Belle2::TEST_F
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Definition: globalLabel.cc:65
Belle2::BeamSpot::getIPPositionCovMatrix
const TMatrixDSym & getIPPositionCovMatrix() const
Get the covariance matrix of the measured IP position.
Definition: BeamSpot.h:82
Belle2::BeamSpot::getGlobalUniqueID
static unsigned short getGlobalUniqueID()
Return unique ID of BeamSpot in global Millepede calibration (1)
Definition: BeamSpot.h:101