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