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