Typedefs | Functions
DetectorPropertiesStandard_test.cc File Reference

Simple instantiation-only test for DetectorPropertiesStandard. More...

#include "larcorealg/CoreUtils/RealComparisons.h"
#include "larcorealg/Geometry/ChannelMapStandardAlg.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "lardataalg/DetectorInfo/DetectorClocksStandardTestHelpers.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandardTestHelpers.h"
#include "lardataalg/DetectorInfo/LArPropertiesStandardTestHelpers.h"
#include "test/Geometry/geometry_unit_test_base.h"
#include <array>
#include <iomanip>

Go to the source code of this file.

Typedefs

using TesterConfiguration = testing::BasicGeometryEnvironmentConfiguration< geo::ChannelMapStandardAlg >
 
using TestEnvironment = testing::GeometryTesterEnvironment< TesterConfiguration >
 

Functions

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

Detailed Description

Simple instantiation-only test for DetectorPropertiesStandard.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
May 6th, 2016

Definition in file DetectorPropertiesStandard_test.cc.

Typedef Documentation

Definition at line 34 of file DetectorPropertiesStandard_test.cc.

Definition at line 33 of file DetectorPropertiesStandard_test.cc.

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 ("DetectorPropertiesStandard_test")

  1. (mandatory) path to the FHiCL configuration file
  2. FHiCL path to the configuration of the test (default: physics.analyzers.larptest)
  3. FHiCL path to the configuration of DetectorProperties service (default: services.DetectorPropertiesService)

Definition at line 58 of file DetectorPropertiesStandard_test.cc.

59 {
60 
61  TesterConfiguration config("detp_test");
62 
63  //
64  // parameter parsing
65  //
66  int iParam = 0;
67 
68  // first argument: configuration file (mandatory)
69  if (++iParam < argc)
70  config.SetConfigurationPath(argv[iParam]);
71  else {
72  std::cerr << "FHiCL configuration file path required as first argument!" << std::endl;
73  return 1;
74  }
75 
76  // second argument: path of the parameter set for geometry test configuration
77  // (optional; default does not have any tester)
78  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
79 
80  // third argument: path of the parameter set for DetectorProperties confi
81  // (optional; default: "services.DetectorProperties" from inherited object)
82  if (++iParam < argc) {
83  config.SetServiceParameterSetPath("DetectorPropertiesService", argv[iParam]);
84  }
85 
86  unsigned int nErrors = 0 /* Tester.Run() */;
87 
88  //
89  // testing environment setup
90  //
91  TestEnvironment TestEnv(config);
92 
93  // DetectorPropertiesStandard and all its dependencies support the simple set
94  // up (see testing::TesterEnvironment::SimpleProviderSetup()), except for
95  // Geometry, that has been configured already in the geometry-aware
96  // environment. So we invoke a simple set up for each of the dependencies:
97  TestEnv.SimpleProviderSetup<detinfo::LArPropertiesStandard>();
98  TestEnv.SimpleProviderSetup<detinfo::DetectorClocksStandard>();
99  TestEnv.SimpleProviderSetup<detinfo::DetectorPropertiesStandard>();
100 
101  //
102  // run the test algorithm
103  // (I leave it here for reference -- there is no test algorithm here)
104  //
105 
106  // 1. we initialize it from the configuration in the environment,
107  // MyTestAlgo Tester(TestEnv.TesterParameters());
108 
109  // 2. we set it up with the geometry from the environment
110  // Tester.Setup(*(TestEnv.Provider<detinfo::DetectorProperties>()));
111 
112  // 3. then we run it!
113  auto const& geom = *TestEnv.Provider<geo::GeometryCore>();
114  auto const clock_data = TestEnv.Provider<detinfo::DetectorClocks>()->DataForJob();
115  auto const& detp = *TestEnv.Provider<detinfo::DetectorProperties>();
116 
117  auto const driftVelocity = detp.DriftVelocity();
118  auto const TDCtick = sampling_rate(clock_data);
119  unsigned int const nWaveformTicks = detp.NumberTimeSamples();
120  unsigned int const nReadoutWindowTicks = detp.ReadOutWindowSize();
121 
122  mf::LogVerbatim("detp_test") << "Electric field in the active volume: " << detp.Efield()
123  << " kV/cm"
124  << "\nSampling rate: " << TDCtick << " ns"
125  << "\nArgon temperature: " << detp.Temperature() << " K"
126  << "\nArgon density: " << detp.Density() << " kg/dm^3 (at " << detp.Temperature() << " K)"
127  << "\nArgon density: " << detp.Density(87.0) << " kg/dm^3 (at 87 K)"
128  << "\nDrift velocity: " << driftVelocity << " cm/us"
129  << "\nReadout window: " << nReadoutWindowTicks << " ticks ("
130  << (nReadoutWindowTicks * TDCtick / 1000) << " us)"
131  << "\nTPC waveform length: " << nWaveformTicks << " ticks ("
132  << (nWaveformTicks * TDCtick / 1000) << " us)";
133 
134  // accumulate the plane IDs; needed just for table formatting
135  unsigned int headerColWidth = 0U;
136  for (auto planeID : geom.IteratePlaneIDs()) {
137  auto const l = std::string(planeID).length();
138  if (headerColWidth < l) headerColWidth = l;
139  }
140 
141  // print drift distances
142  // collect all drift distances, and check whether they are all equal
143  bool allSameDrift = true;
144  lar::util::RealComparisons<double> check(1.0); // 1 cm tolerance
145  auto driftDistances = geom.makeTPCData<double>();
146  for (auto const& TPC : geom.IterateTPCs()) {
147  auto const driftDistance = TPC.DriftDistance();
148  driftDistances[TPC.ID()] = driftDistance;
149  allSameDrift = allSameDrift & check.equal(driftDistance, driftDistances.first());
150  } // for
151 
152  if (allSameDrift) {
153  // print drift distance
154  auto const driftDistance = driftDistances.first();
155  auto const driftTime = driftDistance / driftVelocity;
156  mf::LogVerbatim("detp_test") << "Drift distance: " << driftDistance << " cm"
157  << "\nDrift time: " << driftTime << " us, "
158  << (driftTime / (TDCtick / 1000.)) << " ticks";
159  }
160  else {
161  // print drift distance table header
162  mf::LogVerbatim log("detp_test");
163  std::array<unsigned int, 4U> const columnSizes = {{headerColWidth, 9U, 13U, 7U}};
164  log << std::setw(columnSizes[0]) << "Drift:"
165  << " | " << std::setw(columnSizes[1]) << "time [us]"
166  << " | " << std::setw(columnSizes[2]) << "distance [cm]"
167  << " | " << std::setw(columnSizes[3]) << "ticks";
168 
169  // print drift distances by TPC
170  for (auto const& TPCID : geom.IterateTPCIDs()) {
171  auto const driftDistance = driftDistances[TPCID];
172  auto const driftTime = driftDistance / driftVelocity;
173  log << "\n"
174  << std::setw(columnSizes[0]) << TPCID << " | " << std::setw(columnSizes[1]) << driftTime
175  << " | " << std::setw(columnSizes[2]) << driftDistance << " | "
176  << std::setw(columnSizes[3]) << (driftTime / (TDCtick / 1000.));
177  } // for TPC
178  }
179 
180  // 4. And finally we cross fingers.
181  if (nErrors > 0) { mf::LogError("detp_test") << nErrors << " errors detected!"; }
182 
183  return nErrors;
184 } // main()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string string
Definition: nybbler.cc:12
Provides simple real number checks.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
static QStrList * l
Definition: config.cpp:1044
bool check(const std::vector< std::vector< float > > &outputs)
testing::BasicGeometryEnvironmentConfiguration< geo::ChannelMapStandardAlg > TesterConfiguration
static Config * config
Definition: config.cpp:1054
Description of geometry of one entire detector.
Class used for the conversion of times between different formats and references.
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
testing::TesterEnvironment< testing::BasicEnvironmentConfiguration > TestEnvironment
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
Properties related to liquid argon environment in the detector.
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
QTextStream & endl(QTextStream &s)