All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | Functions
DetectorClocksStandard_test.cc File Reference

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

#include "larcorealg/TestUtils/unit_test_base.h"
#include "lardataalg/DetectorInfo/DetectorClocksStandard.h"
#include "lardataalg/DetectorInfo/DetectorClocksStandardTestHelpers.h"

Go to the source code of this file.

Typedefs

using TestEnvironment = testing::TesterEnvironment< testing::BasicEnvironmentConfiguration >
 

Functions

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

Detailed Description

Simple instantiation-only test for DetectorClocksStandard.

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

Definition in file DetectorClocksStandard_test.cc.

Typedef Documentation

Definition at line 23 of file DetectorClocksStandard_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 ("DetectorClocksStandard_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 DetectorClocks service (default: services.DetectorClocksService)

Definition at line 47 of file DetectorClocksStandard_test.cc.

48 {
49 
50  testing::BasicEnvironmentConfiguration config("clocks_test");
51 
52  //
53  // parameter parsing
54  //
55  int iParam = 0;
56 
57  // first argument: configuration file (mandatory)
58  if (++iParam < argc)
59  config.SetConfigurationPath(argv[iParam]);
60  else {
61  std::cerr << "FHiCL configuration file path required as first argument!" << std::endl;
62  return 1;
63  }
64 
65  // second argument: path of the parameter set for geometry test configuration
66  // (optional; default does not have any tester)
67  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
68 
69  // third argument: path of the parameter set for DetectorClocks configuration
70  // (optional; default: "services.DetectorClocks" from the inherited object)
71  if (++iParam < argc) config.SetServiceParameterSetPath("DetectorClocksService", argv[iParam]);
72 
73  unsigned int nErrors = 0 /* Tester.Run() */;
74 
75  //
76  // testing environment setup
77  //
78  TestEnvironment TestEnv(config);
79 
80  // DetectorClocksStandard supports the simple set up; so we invoke it
81  TestEnv.SimpleProviderSetup<detinfo::DetectorClocksStandard>();
82 
83  // Note that here we are querying the abstract DetectorClocks interface;
84  // this is the right way to go.
85  auto const* detClocks = TestEnv.Provider<detinfo::DetectorClocks>();
86  auto const& detClocksData = detClocks->DataForJob();
87  mf::LogVerbatim("clocks_test")
88  << "TPC clock frame: " << detClocksData.TPCClock().FramePeriod() << " us";
89 
90  detClocksData.debugReport(std::cout);
91 
92  // 4. And finally we cross fingers.
93  if (nErrors > 0) { mf::LogError("clocks_test") << nErrors << " errors detected!"; }
94 
95  return nErrors;
96 } // main()
BEGIN_PROLOG could also be cerr
Class holding a configuration for a test environment.
Class used for the conversion of times between different formats and references.
A test environment with some support for service providers.
DetectorClocksData DataForJob() const override
Returns a complete detinfo::DetectorClocksData object.
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.
BEGIN_PROLOG could also be cout