Belle II Software  release-08-01-10
CDCTrajectory3D.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 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
10 
11 #include <genfit/TrackCand.h>
12 
13 #include <TMatrixDSym.h>
14 
15 #include <gtest/gtest.h>
16 
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
21 TEST(TrackFindingCDCTest, eventdata_trajectories_CDCTrajectory3D_constructorPosMomCharge)
22 {
23  Vector3D newMom3D(1.0, 2.0, 1.0);
24  Vector3D newPos3D(1.0, 2.0, 1.0);
25  double newTime = 0.0;
26  ESign newChargeSign = ESign::c_Plus;
27  double bZ = 2.0;
28 
29  CDCTrajectory3D trajectory(newPos3D, newTime, newMom3D, newChargeSign, bZ);;
30 
31  Vector3D mom3D = trajectory.getMom3DAtSupport(bZ);
32  Vector3D pos3D = trajectory.getSupport();
33  ESign chargeSign = trajectory.getChargeSign();
34 
35 
36  EXPECT_NEAR(newMom3D.x(), mom3D.x(), 10e-7);
37  EXPECT_NEAR(newMom3D.y(), mom3D.y(), 10e-7);
38  EXPECT_NEAR(newMom3D.z(), mom3D.z(), 10e-7);
39 
40  EXPECT_NEAR(newPos3D.x(), pos3D.x(), 10e-7);
41  EXPECT_NEAR(newPos3D.y(), pos3D.y(), 10e-7);
42  EXPECT_NEAR(newPos3D.z(), pos3D.z(), 10e-7);
43 
44  EXPECT_NEAR(newChargeSign, chargeSign, 10e-7);
45 }
46 
47 
48 
49 TEST(TrackFindingCDCTest, CDCTrajectory3D_clear)
50 {
51  Vector3D newMom3D(1.0, 2.0, 1.0);
52  Vector3D newPos3D(1.0, 2.0, 1.0);
53  double newTime = 0.0;
54  ESign newChargeSign = ESign::c_Plus;
55 
56  CDCTrajectory3D trajectory3D(newPos3D, newTime, newMom3D, newChargeSign);
57  UncertainHelix uncertainHelix = trajectory3D.getLocalHelix();
58  Helix helix = uncertainHelix;
59 
60  PerigeeCircle perigeeCircle = helix.circleXY();
61  SZLine szLine = helix.szLine();
62 
63  trajectory3D.clear();
64  EXPECT_TRUE(trajectory3D.isInvalid());
65  EXPECT_FALSE(trajectory3D.isFitted());
66 
67  uncertainHelix.invalidate();
68  EXPECT_TRUE(uncertainHelix->isInvalid());
69 
70  helix.invalidate();
71  EXPECT_TRUE(helix.isInvalid());
72 
73  perigeeCircle.invalidate();
74  EXPECT_TRUE(perigeeCircle.isInvalid());
75 
76  szLine.invalidate();
77  EXPECT_TRUE(szLine.isInvalid());
78 }
79 
80 
81 TEST(TrackFindingCDCTest, CDCTrajectory3D_GFTrackRoundTrip)
82 {
83  Vector3D expectedMomentum(1.0, 0.0, 0.0);
84  Vector3D expectedPosition(0.0, 1.0, 0.0);
85  ESign expectedCharge = ESign::c_Plus;
86  double bZ = 2;
87 
88  genfit::TrackCand expectedGFTrackCand;
89  expectedGFTrackCand.setPosMomSeed(expectedPosition,
90  expectedMomentum,
91  expectedCharge);
92 
93  TMatrixDSym expectedCov6(6);
94  expectedCov6.Zero();
95  expectedCov6(0, 0) = 0; // There cannot be a covariance in the x direction since the direction along the track has no constraint.
96  expectedCov6(1, 1) = 2;
97  expectedCov6(2, 2) = 3;
98  expectedCov6(3, 3) = 4;
99  expectedCov6(4, 4) = 5;
100  expectedCov6(5, 5) = 6;
101  expectedGFTrackCand.setCovSeed(expectedCov6);
102 
103 
104  CDCTrajectory3D trajectory3D(expectedGFTrackCand, bZ);
105 
106  genfit::TrackCand gfTrackCand;
107  trajectory3D.fillInto(gfTrackCand, bZ);
108 
109  Vector3D position(gfTrackCand.getPosSeed());
110  Vector3D momentum(gfTrackCand.getMomSeed());
111  ESign charge = sign(gfTrackCand.getChargeSeed());
112  TMatrixDSym cov6 = gfTrackCand.getCovSeed();
113 
114 
115  EXPECT_NEAR(expectedPosition.x(), position.x(), 10e-7);
116  EXPECT_NEAR(expectedPosition.y(), position.y(), 10e-7);
117  EXPECT_NEAR(expectedPosition.z(), position.z(), 10e-7);
118 
119  EXPECT_NEAR(expectedMomentum.x(), momentum.x(), 10e-7);
120  EXPECT_NEAR(expectedMomentum.y(), momentum.y(), 10e-7);
121  EXPECT_NEAR(expectedMomentum.z(), momentum.z(), 10e-7);
122 
123  EXPECT_EQ(expectedCharge, charge);
124  for (int i = 0; i < 6; ++i) {
125  for (int j = 0; j < 6; ++j) {
126  EXPECT_NEAR(expectedCov6(i, j), cov6(i, j), 10e-7);
127  }
128  }
129 
130 }
Helix parameter class.
Definition: Helix.h:48
Particle full three dimensional trajectory.
Extension of the generalized circle also caching the perigee coordinates.
Definition: PerigeeCircle.h:36
bool isInvalid() const
Indicates if all circle parameters are zero.
void invalidate()
Sets all circle parameters to zero.
A line in the sz space.
Definition: SZLine.h:26
bool isInvalid() const
Indicates if the line parameters do not represent a valid line.
Definition: SZLine.h:142
void invalidate()
Sets the parameters to a invalid representation.
Definition: SZLine.h:135
A three dimensional vector.
Definition: Vector3D.h:33
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:472
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:484
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
This class represents an ideal helix in perigee parameterization including the covariance matrix of t...
Track candidate – seed values and indices.
Definition: TrackCand.h:69
TVector3 getMomSeed() const
get the seed value for track: mom.
Definition: TrackCand.h:128
void setPosMomSeed(const TVector3 &pos, const TVector3 &mom, const double charge)
sets the state to seed the track fitting.
Definition: TrackCand.cc:258
TVector3 getPosSeed() const
get the seed value for track: pos.
Definition: TrackCand.h:125
void setCovSeed(const TMatrixDSym &cov6D)
set the covariance matrix seed (6D).
Definition: TrackCand.h:175
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
Definition: TrackCand.h:131
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:44
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
Abstract base class for different kinds of events.