Classes | Macros | Functions | Variables
SurfYZLineTest.cc File Reference
#include "boost/test/unit_test.hpp"
#include <cmath>
#include "lardata/RecoObjects/SurfYZLine.h"
#include "lardata/RecoObjects/KalmanLinearAlgebra.h"
#include "cetlib_except/exception.h"

Go to the source code of this file.

Classes

struct  SurfYZLineTestFixture
 

Macros

#define BOOST_TEST_MODULE   ( SurfYZTest )
 

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   ( SurfYZTest )

Definition at line 1 of file SurfYZLineTest.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( Equality  )

Definition at line 35 of file SurfYZLineTest.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 SurfYZLineTest.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 SurfYZLineTest.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
BOOST_AUTO_TEST_CASE ( Separation  )

Definition at line 69 of file SurfYZLineTest.cc.

69  {
70  BOOST_TEST(surf1.distanceTo(surf2) == 0.);
71  BOOST_TEST(surf1.distanceTo(surf3) == sqrt(2.), tol);
72  BOOST_TEST(surf3.distanceTo(surf1) == sqrt(2.), tol);
73 }
auto const tol
BOOST_AUTO_TEST_CASE ( NotParallel  )

Definition at line 77 of file SurfYZLineTest.cc.

77  {
78  BOOST_CHECK_EXCEPTION( surf1.distanceTo(surf4), cet::exception,
79  [](cet::exception const & e)
80  {
81  return e.category() == "SurfYZLine";
82  } );
83 }
const double e
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
BOOST_AUTO_TEST_CASE ( TrackParameters  )

Definition at line 87 of file SurfYZLineTest.cc.

87  {
88  trkf::TrackVector v(5);
89  v(0) = 0.1; // r.
90  v(1) = 0.2; // v.
91  v(2) = 2.; // phi.
92  v(3) = 1.; // eta.
93  v(4) = 0.5; // p = 2 GeV.
94 
95  double xyz[3];
96  double mom[3];
97  surf1.getPosition(v, xyz);
98  BOOST_TEST(xyz[0] == -0.1*std::sin(2.), tol);
99  BOOST_TEST(xyz[1] == 0.2, tol);
100  BOOST_TEST(xyz[2] == 0.1*std::cos(2.), tol);
101  surf3.getPosition(v, xyz);
102  BOOST_TEST(xyz[0] == 1. - 0.1*std::sin(2.), tol);
103  BOOST_TEST(xyz[1] == 1.2, tol);
104  BOOST_TEST(xyz[2] == 1. + 0.1*std::cos(2.), tol);
105  surf1.getMomentum(v, mom, trkf::Surface::FORWARD);
106  BOOST_TEST(mom[0] == 2. * std::cos(2.) / std::cosh(1.), tol);
107  BOOST_TEST(mom[1] == 2. * std::tanh(1.), tol);
108  BOOST_TEST(mom[2] == 2. * std::sin(2.) / cosh(1.), tol);
109  surf1.getMomentum(v, mom, trkf::Surface::BACKWARD);
110  BOOST_TEST(mom[0] == 2. * std::cos(2.) / std::cosh(1.), tol);
111  BOOST_TEST(mom[1] == 2. * std::tanh(1.), tol);
112  BOOST_TEST(mom[2] == 2. * std::sin(2.) / cosh(1.), tol);
113  surf1.getMomentum(v, mom);
114  BOOST_TEST(mom[0] == 2. * std::cos(2.) / std::cosh(1.), tol);
115  BOOST_TEST(mom[1] == 2. * std::tanh(1.), tol);
116  BOOST_TEST(mom[2] == 2. * std::sin(2.) / cosh(1.), tol);
117 }
auto const tol
KVector< 5 >::type TrackVector
Track state vector, dimension 5.

Variable Documentation

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

Definition at line 16 of file SurfYZLineTest.cc.