All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_icarus_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_icarus_test.cxx
3  * @brief Unit test for geometry on ICARUS detector.
4  * @date October 10, 2017
5  * @author Gianluca Petrillo (petrillo@fnal.gov)
6  *
7  * Usage:
8  *
9  * geometry_icarus_test [ConfigurationFile [GeometryTestParameterSet]]
10  *
11  * By default, `GeometryTestParameterSet` is set to `"physics.analyzers.geotest"`.
12  *
13  */
14 
15 // ICARUS libraries
18 
19 // LArSoft libraries
22 
23 // utility libraries
24 #include "messagefacility/MessageLogger/MessageLogger.h"
25 
26 
27 //------------------------------------------------------------------------------
28 //--- The test environment
29 //---
30 
31 
32 // we define here all the configuration that is needed;
33 // we use an existing class provided for this purpose, since our test
34 // environment allows us to tailor it at run time.
38 
39 /*
40  * GeometryTesterFixture, configured with the object above, is used in a
41  * non-Boost-unit-test context.
42  * It provides:
43  * - `geo::GeometryCore const* Geometry()`
44  * - `geo::GeometryCore const* GlobalGeometry()` (static member)
45  */
48 
49 
50 //------------------------------------------------------------------------------
51 //--- The tests
52 //---
53 
54 /** ****************************************************************************
55  * @brief Runs the test
56  * @param argc number of arguments in argv
57  * @param argv arguments to the function
58  * @return number of detected errors (0 on success)
59  * @throw cet::exception most of error situations throw
60  *
61  * The arguments in argv are:
62  * 0. name of the executable ("Geometry_test")
63  * 1. path to the FHiCL configuration file
64  * 2. FHiCL path to the configuration of the geometry test
65  * (default: physics.analysers.geotest)
66  * 3. FHiCL path to the configuration of the geometry
67  * (default: services.Geometry)
68  *
69  */
70 //------------------------------------------------------------------------------
71 int main(int argc, char const** argv) {
72 
73  IcarusGeometryConfiguration config("geometry_test_ICARUS");
74  config.SetMainTesterParameterSetName("geotest");
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 no path is provided, we have a empty default configuration;
87  // if path is provided, we don't have any default configuration
88  // and if the configuration is missing there will be an error
89  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
90  else config.AddDefaultTesterConfiguration("");
91 
92  // third argument: path of the parameter set for geometry configuration
93  // (optional; default: "services.Geometry" from the inherited object)
94  if (++iParam < argc) config.SetGeometryParameterSetPath(argv[iParam]);
95 
96  //
97  // testing environment setup
98  //
100 
101  //
102  // run the test algorithm
103  //
104 
105  // 1. we initialize it from the configuration in the environment,
106  geo::GeometryTestAlg Tester(TestEnvironment.TesterParameters());
107 
108  // 2. we set it up with the geometry from the environment
109  Tester.Setup(*TestEnvironment.Geometry());
110 
111  // 3. then we run it!
112  unsigned int nErrors = Tester.Run();
113 
114  // 4. And finally we cross fingers.
115  if (nErrors > 0) {
116  mf::LogError("geometry_test_ICARUS") << nErrors << " errors detected!";
117  }
118 
119  return nErrors;
120 } // main()
121 
Unit test for geometry functionalities.
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.
Performs tests on the geometry as seen by Geometry service.
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)
Runs the test.
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.
int main(int argc, char **argv)
void SetMainTesterParameterSetPath(std::string path)
Sets the FHiCL path for the configuration of the main test algorithm.