geometry_thirdplaneslope_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_thirdplaneslope_test.cxx
3  * @brief Simple unit test on a standard detector
4  * @date June 2nd, 2015
5  * @author petrillo@fnal.gov
6  *
7  * Usage: just run the executable.
8  * Boost unit testing environment keeps the arguments secret anyway.
9  */
10 
11 // Boost test libraries; we want to define this stuff as soon as possible
12 #define BOOST_TEST_MODULE GeometryThirdPlaneSlopeTest
13 
14 // LArSoft libraries
15 #include "test/Geometry/geometry_unit_test_base.h"
20 
21 // utility libraries
22 
23 // C/C++ standard libraries
24 
26 
27 //------------------------------------------------------------------------------
28 //--- The test environment
29 //---
30 
31 // we define here all the configuration that is needed;
32 // in the specific, the type of the channel mapping and a proper test name,
33 // used for output only; BasicGeometryEnvironmentConfiguration can read the
34 // configuration file name from command line, and
35 // BoostCommandLineConfiguration<> makes it initialize in time for Boost
36 // to catch it when instanciating the fixture.
39  testing::BasicGeometryEnvironmentConfiguration<geo::ChannelMapStandardAlg>
40  >
41 {
42  /// Constructor: overrides the application name
44  { SetApplicationName("GeometryThirdPlaneSlopeTest"); }
45 }; // class StandardGeometryConfiguration
46 
47 /*
48  * Our fixture is based on GeometryTesterFixture, configured with the object
49  * above.
50  */
53 
54 
55 
56 //------------------------------------------------------------------------------
57 //--- The tests
58 //---
59 //
60 // Note on Boost fixture options:
61 // - BOOST_FIXTURE_TEST_SUITE will provide the tester as a always-present data
62 // member in the environment, as "Tester()"; but a new fixture, with a new
63 // geometry and a new tester, is initialized on each test case
64 // - BOOST_GLOBAL_FIXTURE does not provide tester access, so one has to get it
65 // as GeometryIteratorTestFixture::GlobalTester(); on the other hand, the
66 // fixture is initialized only when a new global one is explicitly created.
67 //
68 
69 BOOST_FIXTURE_TEST_SUITE(GeometryIterators, SimpleGeometryTestFixture)
70 // BOOST_GLOBAL_FIXTURE(SimpleGeometryTestFixture)
71 
72 
74 {
75  geo::GeometryCore const& geom = *(Provider<geo::GeometryCore>());
76 
77  const double angle_u = 1. / 3. * util::pi<double>();
78  const double angle_v = 2. / 3. * util::pi<double>();
79  const double angle_w = 1. / 2. * util::pi<double>();
80 
81  BOOST_TEST_MESSAGE(
82  "Wire angles: u=" << angle_u << " v=" << angle_v << " => w=" << angle_w
83  );
84 
85  const double slope_u = 1. / std::sqrt(3);
86  const double slope_v = 1. / std::sqrt(3);
87 
88  const double expected_slope_w = 0.5;
89 
90  double slope_w = geom.ComputeThirdPlaneSlope
91  (angle_u, slope_u, angle_v, slope_v, angle_w);
92 
93  BOOST_TEST_MESSAGE(
94  "Slopes: s(u)=" << slope_u << " s(v)=" << slope_v << " => s(w)=" << slope_w
95  );
96 
97  BOOST_TEST(slope_w == expected_slope_w, 0.01% tolerance());
98 
99 } // BOOST_AUTO_TEST_CASE( AllTests )
100 
101 
102 BOOST_AUTO_TEST_SUITE_END()
testing::GeometryTesterEnvironment< StandardGeometryConfiguration > SimpleGeometryTestFixture
auto const tolerance
Class holding a configuration for a Boost test fixture.
StandardGeometryConfiguration()
Constructor: overrides the application name.
Environment for a geometry test.
Description of geometry of one entire detector.
static double ComputeThirdPlaneSlope(double angle1, double slope1, double angle2, double slope2, double angle_target)
Returns the slope on the third plane, given it in the other two.
BOOST_AUTO_TEST_CASE(AllTests)
Access the description of detector geometry.
Collection of Physical constants used in LArSoft.
void SetApplicationName(string const &applicationName)