All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_iterator_loop_sbnd_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_iterator_loop_sbnd_test.cxx
3  * @brief Test for geometry iterator loops on SBND detector
4  * @date May 11th, 2015
5  * @author petrillo@fnal.gov
6  *
7  * Usage:
8  * `geometry_iterator_loop_sbnd_test [ConfigurationFile [GeometryTestParameterSet]]`
9  *
10  * By default, an internal configuration is used or GeometryTestParameterSet is
11  * set to "physics.analyzers.geotest".
12  *
13  */
14 
15 
16 // SBND libraries
18 
19 // LArSoft libraries
23 
24 // utility libraries
25 #include "messagefacility/MessageLogger/MessageLogger.h"
26 
27 
28 //------------------------------------------------------------------------------
29 //--- The test environment
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 
74  ("geometry_iterator_loop_test_SBND");
75  config.SetMainTesterParameterSetName("geotest");
76 
77  //
78  // parameter parsing
79  //
80  int iParam = 0;
81 
82  // first argument: configuration file (mandatory)
83  if (++iParam < argc) config.SetConfigurationPath(argv[iParam]);
84 
85  // second argument: path of the parameter set for geometry test configuration
86  // (optional; default: "physics.analyzers.geotest");
87  // if no path is provided, we have a empty default configuration;
88  // if path is provided, we don't have any default configuration
89  // and if the configuration is missing there will be an error
90  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
91  else config.AddDefaultTesterConfiguration("");
92 
93  // third argument: path of the parameter set for geometry configuration
94  // (optional; default: "services.Geometry" from the inherited object)
95  if (++iParam < argc) config.SetGeometryParameterSetPath(argv[iParam]);
96 
97  //
98  // testing environment setup
99  //
101 
102  //
103  // run the test algorithm
104  //
105 
106  // 1. we initialize it from the configuration in the environment,
107  geo::GeometryIteratorLoopTestAlg Tester(TestEnvironment.TesterParameters());
108 
109  // 2. we set it up with the geometry from the environment
110  Tester.Setup(*TestEnvironment.Geometry());
111 
112  // 3. then we run it!
113  unsigned int nErrors = Tester.Run();
114 
115  // 4. And finally we cross fingers.
116  if (nErrors > 0) {
117  mf::LogError("geometry_iterator_loop_test_SBND")
118  << nErrors << " errors detected!";
119  }
120 
121  return nErrors;
122 } // main()
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.
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 SBND fixture.
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)
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.