All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
SurfXYZTest.cc File Reference
#include "boost/test/unit_test.hpp"
#include <cmath>
#include "lardata/RecoObjects/SurfXYZPlane.h"
#include "lardata/RecoObjects/KalmanLinearAlgebra.h"
#include "cetlib_except/exception.h"

Go to the source code of this file.

Classes

struct  SurfXYZTestFixture
 

Macros

#define BOOST_TEST_MODULE   ( SurfXYZTest )
 

Functions

 BOOST_AUTO_TEST_CASE (Equality)
 
 BOOST_AUTO_TEST_CASE (Parallel)
 
 BOOST_AUTO_TEST_CASE (Transformation)
 
 BOOST_AUTO_TEST_CASE (Separation)
 
 BOOST_AUTO_TEST_CASE (NotParallel)
 
 BOOST_AUTO_TEST_CASE (TrackParameters)
 

Variables

auto const tol = 1.e-6% tolerance()
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( SurfXYZTest )

Definition at line 1 of file SurfXYZTest.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( Equality  )

Definition at line 35 of file SurfXYZTest.cc.

35  {
36  BOOST_TEST(surf1.isEqual(surf2));
37  BOOST_TEST(!surf1.isEqual(surf3));
38  BOOST_TEST(!surf1.isEqual(surf4));
39  BOOST_TEST(!surf2.isEqual(surf3));
40  BOOST_TEST(!surf2.isEqual(surf4));
41  BOOST_TEST(!surf3.isEqual(surf4));
42 }
BOOST_AUTO_TEST_CASE ( Parallel  )

Definition at line 46 of file SurfXYZTest.cc.

46  {
47  BOOST_TEST(surf1.isParallel(surf2));
48  BOOST_TEST(surf1.isParallel(surf3));
49  BOOST_TEST(!surf1.isParallel(surf4));
50  BOOST_TEST(surf2.isParallel(surf3));
51  BOOST_TEST(!surf2.isParallel(surf4));
52  BOOST_TEST(!surf3.isParallel(surf4));
53 }
BOOST_AUTO_TEST_CASE ( Transformation  )

Definition at line 57 of file SurfXYZTest.cc.

57  {
58  double xyz1[3] = {1., 2., 3.};
59  double xyz2[3];
60  double uvw[3];
61  surf4.toLocal(xyz1, uvw);
62  surf4.toGlobal(uvw, xyz2);
63  for(int i=0; i<3; ++i)
64  BOOST_TEST(xyz1[i] == xyz2[i], tol);
65 }
auto const tol
Definition: SurfXYZTest.cc:16
BOOST_AUTO_TEST_CASE ( Separation  )

Definition at line 69 of file SurfXYZTest.cc.

69  {
70  BOOST_TEST(surf1.distanceTo(surf2) == 0.);
71  BOOST_TEST(surf1.distanceTo(surf3) == 1.);
72  BOOST_TEST(surf3.distanceTo(surf1) == -1.);
73 }
BOOST_AUTO_TEST_CASE ( NotParallel  )

Definition at line 77 of file SurfXYZTest.cc.

77  {
78  BOOST_CHECK_EXCEPTION( surf1.distanceTo(surf4), cet::exception, \
79  [](cet::exception const & e) \
80  { \
81  return e.category() == "SurfXYZPlane"; \
82  } );
83 }
do i e
BOOST_AUTO_TEST_CASE ( TrackParameters  )

Definition at line 87 of file SurfXYZTest.cc.

87  {
88  trkf::TrackVector v(5);
89  v(0) = 0.1; // u.
90  v(1) = 0.2; // v.
91  v(2) = 2.; // du/dw.
92  v(3) = 3.; // dv/dw.
93  v(4) = 0.5; // p = 2 GeV.
94 
95  // For this vector, the direction cosines are.
96  // du/ds = 2./sqrt(14.);
97  // dv/ds = 3./sqrt(14.);
98  // dw/ds = 1./sqrt(14.);
99 
100  double xyz[3];
101  double mom[3];
102  surf1.getPosition(v, xyz);
103  BOOST_TEST(xyz[0] == 0.1, tol);
104  BOOST_TEST(xyz[1] == 0.2, tol);
105  BOOST_TEST(xyz[2] == 0.0, tol);
106  surf3.getPosition(v, xyz);
107  BOOST_TEST(xyz[0] == 1.1, tol);
108  BOOST_TEST(xyz[1] == 1.2, tol);
109  BOOST_TEST(xyz[2] == 1.0, tol);
110  surf1.getMomentum(v, mom, trkf::Surface::FORWARD);
111  BOOST_TEST(mom[0] == 4./std::sqrt(14.), tol);
112  BOOST_TEST(mom[1] == 6./std::sqrt(14.), tol);
113  BOOST_TEST(mom[2] == 2./std::sqrt(14.), tol);
114  surf1.getMomentum(v, mom, trkf::Surface::BACKWARD);
115  BOOST_TEST(mom[0] == -4./std::sqrt(14.), tol);
116  BOOST_TEST(mom[1] == -6./std::sqrt(14.), tol);
117  BOOST_TEST(mom[2] == -2./std::sqrt(14.), tol);
118  surf4.getMomentum(v, mom, trkf::Surface::FORWARD);
119  BOOST_TEST(mom[0] == (4.*std::cos(0.1) + 2.*std::sin(0.1))/std::sqrt(14.), tol);
120  BOOST_TEST(mom[1] == (4.*std::sin(0.1)*std::sin(1.) + 6.*std::cos(1.) - 2.*std::cos(0.1)*std::sin(1.))/std::sqrt(14.), tol);
121  BOOST_TEST(mom[2] == (-4.*std::sin(0.1)*std::cos(1.) + 6.*std::sin(1.) + 2.*std::cos(0.1)*std::cos(1.))/std::sqrt(14.), tol);
122 
123  // Should throw exception (no direction).
124 
125  BOOST_CHECK_EXCEPTION( surf1.getMomentum(v, mom), cet::exception, \
126  [](cet::exception const & e) \
127  { \
128  return e.category() == "SurfXYZPlane"; \
129  } );
130 }
auto const tol
Definition: SurfXYZTest.cc:16
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
do i e

Variable Documentation

auto const tol = 1.e-6% tolerance()

Definition at line 16 of file SurfXYZTest.cc.