All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_iterator_loop_icarus_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_iterator_loop_icarus_test.cxx
3  * @brief Test for geometry iterator loops on ICARUS detector.
4  * @date October 10, 2017
5  * @author Gianluca Petrillo (petrillo@fnal.gov)
6  *
7  * Usage:
8  *
9  * geometry_iterator_loop_icarus_test [ConfigurationFile [GeometryTestParameterSet]]
10  *
11  *
12  * By default, an internal configuration is used or `GeometryTestParameterSet` is
13  * set to `"physics.analyzers.geotest"`.
14  *
15  */
16 
17 
18 // ICARUS libraries
20 
21 // 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.
40 
41 /*
42  * GeometryTesterFixture, configured with the object above, is used in a
43  * non-Boost-unit-test context.
44  * It provides:
45  * - `geo::GeometryCore const* Geometry()`
46  * - `geo::GeometryCore const* GlobalGeometry()` (static member)
47  */
50 
51 
52 //------------------------------------------------------------------------------
53 //--- The tests
54 //---
55 
56 /** ****************************************************************************
57  * @brief Runs the test
58  * @param argc number of arguments in argv
59  * @param argv arguments to the function
60  * @return number of detected errors (0 on success)
61  * @throw cet::exception most of error situations throw
62  *
63  * The arguments in argv are:
64  * 0. name of the executable ("Geometry_test")
65  * 1. path to the FHiCL configuration file
66  * 2. FHiCL path to the configuration of the geometry test
67  * (default: physics.analysers.geotest)
68  * 3. FHiCL path to the configuration of the geometry
69  * (default: services.Geometry)
70  *
71  */
72 //------------------------------------------------------------------------------
73 int main(int argc, char const** argv) {
74 
76  ("geometry_iterator_loop_test_ICARUS");
77  config.SetMainTesterParameterSetName("geoitertest");
78 
79  //
80  // parameter parsing
81  //
82  int iParam = 0;
83 
84  // first argument: configuration file (mandatory)
85  if (++iParam < argc) config.SetConfigurationPath(argv[iParam]);
86 
87  // second argument: path of the parameter set for geometry test configuration
88  // (optional; default: "physics.analyzers.geotest");
89  // if no path is provided, we have a empty default configuration;
90  // if path is provided, we don't have any default configuration
91  // and if the configuration is missing there will be an error
92  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
93  else config.AddDefaultTesterConfiguration("");
94 
95  // third argument: path of the parameter set for geometry configuration
96  // (optional; default: "services.Geometry" from the inherited object)
97  if (++iParam < argc) config.SetGeometryParameterSetPath(argv[iParam]);
98 
99  //
100  // testing environment setup
101  //
103 
104  //
105  // run the test algorithm
106  //
107 
108  // 1. we initialize it from the configuration in the environment,
109  geo::GeometryIteratorLoopTestAlg Tester(TestEnvironment.TesterParameters());
110 
111  // 2. we set it up with the geometry from the environment
112  Tester.Setup(*TestEnvironment.Geometry());
113 
114  // 3. then we run it!
115  unsigned int nErrors = Tester.Run();
116 
117  // 4. And finally we cross fingers.
118  if (nErrors > 0) {
119  mf::LogError("geometry_iterator_loop_test_ICARUS")
120  << nErrors << " errors detected!";
121  }
122 
123  return nErrors;
124 } // main()
125 
Channel mapping algorithms for ICARUS detector.
Class for objects initializing ICARUS geometry.
fhicl::ParameterSet TesterParameters(std::string test_name) const
Returns the configuration of the specified test.
void SetMainTesterParameterSetName(std::string name)
Sets the FHiCL name for the configuration of the test algorithm.
Access the description of detector geometry.
void SetGeometryParameterSetPath(std::string path)
Sets the FHiCL path for the geometry configuration.
void AddDefaultTesterConfiguration(std::string tester_name, std::string tester_cfg)
Adds a default configuration for the specified tester.
virtual void Setup(geo::GeometryCore const &new_geo)
Algorithm set up.
void SetConfigurationPath(std::string path)
Sets the path to the configuration file.
testing::TesterEnvironment< testing::BasicEnvironmentConfiguration > TestEnvironment
Class holding the configuration for a ICARUS fixture.
Channel mapping for ICARUS detector with split wires.
geo::GeometryCore const * Geometry() const
Returns a pointer to the geometry.
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.