Functions
geometry_loader_test.cxx File Reference

Unit test for geometry functionalities on a standard detector. More...

#include "test/Geometry/GeometryTestAlg.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "larcorealg/Geometry/StandaloneGeometrySetup.h"
#include "larcorealg/Geometry/StandaloneBasicSetup.h"
#include "larcorealg/Geometry/ChannelMapStandardAlg.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <string>
#include <stdexcept>

Go to the source code of this file.

Functions

int main (int argc, char const **argv)
 Runs the test. More...
 

Detailed Description

Unit test for geometry functionalities on a standard detector.

Date
June 22, 2017
Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)

Usage:

geometry_loader_test  ConfigurationFile [test configuration FHiCL path]

The configuration file path must be complete, i.e. it must point directly to the configuration file. By default, the test configuration is expected in "physics.analysis.geotest".

This unit test uses StaticLoadGeometry() to set up the geometry.

Definition in file geometry_loader_test.cxx.

Function Documentation

int main ( int  argc,
char const **  argv 
)

Runs the test.


Parameters
argcnumber of arguments in argv
argvarguments to the function
Returns
number of detected errors (0 on success)
Exceptions
cet::exceptionmost of error situations throw

The arguments in argv are: 0. name of the executable ("Geometry_test")

  1. path to the FHiCL configuration file
  2. FHiCL path to the configuration of the geometry test (default: physics.analysers.geotest)
  3. FHiCL path to the configuration of the geometry (default: services.Geometry)

Definition at line 58 of file geometry_loader_test.cxx.

58  {
59 
60  //
61  // parameter parsing
62  //
63  std::string configPath;
64  std::string geoTestConfigPath = "physics.analyzers.geotest";
65 
66  int iParam = 0;
67 
68  // first argument: configuration file (mandatory)
69  if (++iParam < argc) configPath = argv[iParam];
70  else
71  throw std::runtime_error("No configuration file specified.");
72 
73  // second argument: test configuration path
74  if (++iParam < argc) geoTestConfigPath = argv[iParam];
75 
76 
77  //
78  // 1. testing environment setup
79  //
80 
81  using namespace lar::standalone;
82 
83  // parse a configuration file
84  fhicl::ParameterSet pset = ParseConfiguration(configPath);
85 
86  // set up message facility
87  SetupMessageFacility(pset, "geometry_loader_test");
88  mf::SetContextIteration("setup");
89 
90  // set up geometry
91  auto geom = SetupGeometry<geo::ChannelMapStandardAlg>
92  (pset.get<fhicl::ParameterSet>("services.Geometry"));
93 
94  // update the context string for the messages
96 
97  //
98  // 2. prepare the test algorithm
99  //
100 
101  geo::GeometryTestAlg Tester(pset.get<fhicl::ParameterSet>(geoTestConfigPath));
102  Tester.Setup(*geom);
103 
104  //
105  // 3. then we run it!
106  //
107  unsigned int nErrors = Tester.Run();
108 
109  //
110  // 4. And finally we cross fingers.
111  //
113  if (nErrors > 0) {
114  mf::LogError("geometry_test") << nErrors << " errors detected!";
115  }
116 
117  return nErrors;
118 } // main()
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void SetContextIteration(string const &val)
void SetupMessageFacility(fhicl::ParameterSet const &pset, std::string applName="standalone")
Sets up the message facility service.
Performs tests on the geometry as seen by Geometry service.
T get(std::string const &key) const
Definition: ParameterSet.h:271
Utilities for use in an environment without art.
fhicl::ParameterSet ParseConfiguration(std::string configPath, cet::filepath_maker &lookupPolicy)
Parses a FHiCL configuration file.