Typedefs | Functions
driftvolumes_test.cxx File Reference

Test for neighbourhood discovery in simple geometries. More...

#include "test/Geometry/geometry_unit_test_base.h"
#include "larcorealg/Geometry/ChannelMapStandardAlg.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "larcorealg/Geometry/DriftPartitions.h"
#include "larcorealg/CoreUtils/DumpUtils.h"
#include "messagefacility/MessageLogger/MessageLogger.h"

Go to the source code of this file.

Typedefs

using StandardGeometryConfiguration = testing::BasicGeometryEnvironmentConfiguration< geo::ChannelMapStandardAlg >
 
using StandardGeometryTestEnvironment = testing::GeometryTesterEnvironment< StandardGeometryConfiguration >
 

Functions

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

Detailed Description

Test for neighbourhood discovery in simple geometries.

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

Usage:

driftvolumes_test configuration.fcl

The configuration file must contain a geometry service provider configuration under services.Geometry, That geometry configuration must use the standard channel mapping.

Definition in file driftvolumes_test.cxx.

Typedef Documentation

Definition at line 35 of file driftvolumes_test.cxx.

Definition at line 45 of file driftvolumes_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 (default: services.Geometry)

Definition at line 67 of file driftvolumes_test.cxx.

67  {
68 
69  StandardGeometryConfiguration config("driftvolumes_test");
70 
71  //
72  // parameter parsing
73  //
74  int iParam = 0;
75 
76  // first argument: configuration file (mandatory)
77  if (++iParam < argc) config.SetConfigurationPath(argv[iParam]);
78 
79  // second argument: path of the parameter set for geometry configuration
80  // (optional; default: "services.Geometry" from the inherited object)
81  if (++iParam < argc) config.SetGeometryParameterSetPath(argv[iParam]);
82 
83  //
84  // testing environment setup
85  //
87  auto const& geom = *(TestEnvironment.Provider<geo::GeometryCore>());
88 
89  //
90  // run the test algorithm
91  //
92 
93  unsigned int nErrors = 0;
94  for (auto const& cryo: geom.IterateCryostats()) {
95  auto partition = geo::buildDriftVolumes(cryo);
96  mf::LogVerbatim("driftvolumes_test")
97  << "Partition for cryostat " << cryo.ID() << ":";
98  partition.print(mf::LogVerbatim("driftvolumes_test"));
99 
100  //
101  // test that the partition topology is correct
102  //
103  for (geo::TPCGeo const& TPC: geom.IterateTPCs(cryo.ID())) {
104 
105  auto const& center = TPC.GetCenter<geo::Point_t>();
106 
107  auto where = partition.TPCat(center);
108  if (!where) {
109  mf::LogProblem("driftvolumes_test")
110  << "Center of TPC " << TPC.ID() << " " << lar::dump::vector3D(center)
111  << " not assigned to any TPC!";
112  ++nErrors;
113  }
114  else if (where->ID() != TPC.ID()) {
115  mf::LogProblem log("driftvolumes_test");
116  log
117  << "Center of TPC " << TPC.ID() << " " << lar::dump::vector3D(center)
118  << " assigned to TPC " << where->ID() << ":\n";
119  where->PrintTPCInfo(log, " ", /* verbosity */ 5);
120  ++nErrors;
121  }
122 
123  //
124  // test ownership of a uniform distribution of points inside the TPC
125  //
126  constexpr int nXsteps = 5, nYsteps = 5, nZsteps = 5;
127  const double xstep = TPC.HalfSizeX() / (nXsteps + 1);
128  const double ystep = TPC.HalfSizeY() / (nYsteps + 1);
129  const double zstep = TPC.HalfSizeZ() / (nZsteps + 1);
130  for (int xs = -nXsteps; xs <= nXsteps; ++xs) {
131  double const x = center.X() + xs * xstep;
132  for (int ys = -nYsteps; ys <= nYsteps; ++ys) {
133  double const y = center.Y() + ys * ystep;
134  for (int zs = -nZsteps; zs <= nZsteps; ++zs) {
135  double const z = center.Z() + zs * zstep;
136 
137  auto where = partition.TPCat({ x, y, z});
138  if (!where) {
139  mf::LogProblem("driftvolumes_test")
140  << "Point " << lar::dump::vector3D(center) << " within TPC "
141  << TPC.ID() << " (" << xs << "," << ys << "," << zs
142  << ") not assigned to any TPC!";
143  ++nErrors;
144  }
145  else if (where->ID() != TPC.ID()) {
146  mf::LogProblem log("driftvolumes_test");
147  log
148  << "Point " << lar::dump::vector3D(center) << " within TPC "
149  << TPC.ID() << " (" << xs << "," << ys << "," << zs
150  << ") assigned to TPC " << where->ID() << ":\n";
151  where->PrintTPCInfo(log, " ", /* verbosity */ 5);
152  ++nErrors;
153  }
154 
155  } // for zs
156  } // for ys
157  } // for xs
158 
159  } // for TPCs
160 
161  } // for
162 
163  // 4. And finally we cross fingers.
164  if (nErrors > 0) {
165  mf::LogError("geometry_test") << nErrors << " errors detected!";
166  }
167 
168  return nErrors;
169 } // main()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
auto vector3D(Vector3D const &v)
Returns a manipulator which will print the specified vector.
Definition: DumpUtils.h:301
Geometry information for a single TPC.
Definition: TPCGeo.h:38
DriftPartitions buildDriftVolumes(geo::CryostatGeo const &cryo)
Creates a DriftPartitions object from the TPCs in a cryostat.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
static Config * config
Definition: config.cpp:1054
Description of geometry of one entire detector.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
testing::TesterEnvironment< testing::BasicEnvironmentConfiguration > TestEnvironment
def center(depos, point)
Definition: depos.py:117
testing::GeometryTesterEnvironment< StandardGeometryConfiguration > StandardGeometryTestEnvironment
static constexpr double zs
Definition: Units.h:102
list x
Definition: train.py:276
static constexpr double ys
Definition: Units.h:103