Belle II Software development
CDCTrajectory2D.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#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
9
10#include <tracking/trackFindingCDC/topology/WireLine.h>
11
12#include <framework/logging/Logger.h>
13
14#include <gtest/gtest.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18
19
20TEST(TrackFindingCDCTest, eventdata_trajectories_CDCTrajectory2D_constructorPosMomCharge)
21{
22 Vector2D newMom2D(1.0, 2.0);
23 Vector2D newPos2D(1.0, 2.0);
24 double newTime = 0.0;
25 ESign newChargeSign = ESign::c_Plus;
26 double bZ = 2.0;
27
28 CDCTrajectory2D trajectory(newPos2D, newTime, newMom2D, newChargeSign, bZ);
29
30 Vector2D mom2D = trajectory.getMom2DAtSupport(bZ);
31 Vector2D pos2D = trajectory.getSupport();
32 ESign chargeSign = trajectory.getChargeSign();
33
34 EXPECT_NEAR(newMom2D.x(), mom2D.x(), 10e-7);
35 EXPECT_NEAR(newMom2D.y(), mom2D.y(), 10e-7);
36
37 EXPECT_NEAR(newPos2D.x(), pos2D.x(), 10e-7);
38 EXPECT_NEAR(newPos2D.y(), pos2D.y(), 10e-7);
39
40 EXPECT_NEAR(newChargeSign, chargeSign, 10e-7);
41}
42
43
44TEST(TrackFindingCDCTest, eventdata_trajectories_CDCTrajectory2D_reconstruct)
45{
46 Vector3D forward(-1.0, 1.0, 10.0);
47 Vector3D backward(1.0, 1.0, -10.0);
48 WireLine wireLine(forward, backward, 0);
49
50 double localPhi0 = M_PI / 3;
51 double localCurv = -2.0;
52 double localImpact = 0.0;
53 UncertainPerigeeCircle localPerigeeCircle(localCurv, localPhi0, localImpact);
54 Vector3D localOrigin(0.5, 1, -5);
55
56 Vector3D positionOnWire = wireLine.nominalPos3DAtZ(localOrigin.z());
57 EXPECT_NEAR(localOrigin.x(), positionOnWire.x(), 10e-7);
58 EXPECT_NEAR(localOrigin.y(), positionOnWire.y(), 10e-7);
59 EXPECT_NEAR(localOrigin.z(), positionOnWire.z(), 10e-7);
60
61 CDCTrajectory2D trajectory2D(localOrigin.xy(), localPerigeeCircle);
62 double arcLength2D = trajectory2D.setLocalOrigin(Vector2D(0.0, 0.0));
63
64 // Check that the old origin is still on the line
65 double distance = trajectory2D.getDist2D(localOrigin.xy());
66 EXPECT_NEAR(0, distance, 10e-7);
67
68 // Extrapolate back to the local origin
69 Vector2D extrapolation2D = trajectory2D.getPos2DAtArcLength2D(-arcLength2D);
70 EXPECT_NEAR(localOrigin.x(), extrapolation2D.x(), 10e-7);
71 EXPECT_NEAR(localOrigin.y(), extrapolation2D.y(), 10e-7);
72
73 Vector3D recoPos3D = trajectory2D.reconstruct3D(wireLine);
74 B2INFO(trajectory2D);
75 B2INFO(recoPos3D);
76
77 EXPECT_NEAR(localOrigin.x(), recoPos3D.x(), 10e-7);
78 EXPECT_NEAR(localOrigin.y(), recoPos3D.y(), 10e-7);
79 EXPECT_NEAR(localOrigin.z(), recoPos3D.z(), 10e-7);
80}
Particle trajectory as it is seen in xy projection represented as a circle.
Adds an uncertainty matrix to the circle in perigee parameterisation.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:595
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:605
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
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
Abstract base class for different kinds of events.