All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_iterator_loop_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_iterator_loop_test.cxx
3  * @brief Test for geometry iterator loops on a standard detector
4  * @date May 7th, 2015
5  * @author petrillo@fnal.gov
6  *
7  * Usage:
8  * geometry_iterator_loop_test [ConfigurationFile [GeometryTestParameterSet]]
9  *
10  * By default, an internal configuration is used or GeometryTestParameterSet is
11  * set to "physics.analysers.geotest".
12  *
13  * This unit test uses geometry_unit_test_base.h to build an environment with a
14  * geometry set up.
15  * For an example of use with Boost unit test module, see
16  * geometry_iterator_test.cxx .
17  */
18 
19 
20 // LArSoft libraries
25 
26 // utility libraries
27 #include "messagefacility/MessageLogger/MessageLogger.h"
28 
29 
30 //------------------------------------------------------------------------------
31 //--- The test environment
32 //---
33 
34 // we define here all the configuration that is needed;
35 // we use an existing class provided for this purpose, since our test
36 // environment allows us to tailor it at run time.
39 
40 /*
41  * GeometryTesterFixture, configured with the object above, is used in a
42  * non-Boost-unit-test context.
43  * It provides:
44  * - `geo::GeometryCore const* Geometry()`
45  * - `geo::GeometryCore const* GlobalGeometry()` (static member)
46  */
49 
50 
51 //------------------------------------------------------------------------------
52 //--- The tests
53 //---
54 
55 /** ****************************************************************************
56  * @brief Runs the test
57  * @param argc number of arguments in argv
58  * @param argv arguments to the function
59  * @return number of detected errors (0 on success)
60  * @throw cet::exception most of error situations throw
61  *
62  * The arguments in argv are:
63  * 0. name of the executable ("Geometry_test")
64  * 1. path to the FHiCL configuration file
65  * 2. FHiCL path to the configuration of the geometry test
66  * (default: physics.analysers.geotest)
67  * 3. FHiCL path to the configuration of the geometry
68  * (default: services.Geometry)
69  *
70  */
71 //------------------------------------------------------------------------------
72 int main(int argc, char const** argv) {
73 
74  StandardGeometryConfiguration config("geometry_iterator_loop_test");
75 
76  //
77  // parameter parsing
78  //
79  int iParam = 0;
80 
81  // first argument: configuration file (mandatory)
82  if (++iParam < argc) config.SetConfigurationPath(argv[iParam]);
83 
84  // second argument: path of the parameter set for geometry test configuration
85  // (optional; default: "physics.analysers.geotest")
86  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
87 
88  // third argument: path of the parameter set for geometry configuration
89  // (optional; default: "services.Geometry" from the inherited object)
90  if (++iParam < argc) config.SetGeometryParameterSetPath(argv[iParam]);
91 
92  //
93  // testing environment setup
94  //
96 
97  //
98  // run the test algorithm
99  //
100 
101  // 1. we initialize it from the configuration in the environment,
102  geo::GeometryIteratorLoopTestAlg Tester(TestEnvironment.TesterParameters());
103 
104  // 2. we set it up with the geometry from the environment
105  Tester.Setup(*(TestEnvironment.Provider<geo::GeometryCore>()));
106 
107  // 3. then we run it!
108  unsigned int nErrors = Tester.Run();
109 
110  // 4. And finally we cross fingers.
111  if (nErrors > 0) {
112  mf::LogError("geometry_iterator_loop_test")
113  << nErrors << " errors detected!";
114  }
115 
116  return nErrors;
117 } // main()
Base class for objects initializing a geometry.
Prov const * Provider() const
Return the specified provider (throws if not available)
fhicl::ParameterSet TesterParameters(std::string test_name) const
Returns the configuration of the specified test.
Access the description of detector geometry.
void SetGeometryParameterSetPath(std::string path)
Sets the FHiCL path for the geometry configuration.
virtual void Setup(geo::GeometryCore const &new_geo)
Algorithm set up.
Description of geometry of one entire detector.
void SetConfigurationPath(std::string path)
Sets the path to the configuration file.
testing::TesterEnvironment< testing::BasicEnvironmentConfiguration > TestEnvironment
Interface to algorithm class for a specific detector channel mapping.
Tests the correct iteration of the geo::Geometry iterators.
int main(int argc, char **argv)
void SetMainTesterParameterSetPath(std::string path)
Sets the FHiCL path for the configuration of the main test algorithm.