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

Tests ShowerCalibrationGaloreScale service provider. More...

#include "larexamples/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGaloreScale.h"
#include "larexamples/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGalore.h"
#include "larexamples/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGaloreScaleTestHelpers.h"
#include "larcorealg/TestUtils/unit_test_base.h"
#include "test/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGaloreTests.h"
#include <iostream>

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Tests ShowerCalibrationGaloreScale service provider.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
April 28, 2016
See Also
ShowerCalibrationGaloreScale.h

Runs a test that instantiates a ShowerCalibrationGaloreScale provider with a known configuration and verifies that the same factor is returned for a nominal reconstructed shower. It also prints on screen a "standard" table of corrections, as printed by ShowerCalibrationTableTest().

Command line arguments: none.

Definition in file ShowerCalibrationGaloreScale_test.cc.

Function Documentation

int main ( )

Definition at line 31 of file ShowerCalibrationGaloreScale_test.cc.

31  {
32 
33  //
34  // prepare the test environment
35  //
37 
38  // provide a test name and a push a configuration for
39  // "ShowerCalibrationGaloreService" ("service_provider" is inconsequential)
41  ("ShowerCalibrationGaloreScale_test");
42  config.AddDefaultServiceConfiguration
43  ("ShowerCalibrationGaloreService", R"( service_provider: "ShowerCalibrationGaloreScaleService" factor: )" + std::to_string(expected.factor) + R"( error: )" + std::to_string(expected.error) + R"( )");
44 
45  // set up a basic testing environment with that configuration
46  auto TesterEnv = testing::CreateTesterEnvironment(config);
47 
48  // set up a service provider
49  // (ShowerCalibrationGaloreScale explicitly supports this one-step setup)
50  TesterEnv.SimpleProviderSetup<lar::example::ShowerCalibrationGaloreScale>();
51 
52  //
53  // computation of expected values
54  //
55  unsigned int nErrors = 0; // error count
56 
57  // get the provider we just set up (but accessing it by the interface)
58  auto const* Calibration
59  = TesterEnv.Provider<lar::example::ShowerCalibrationGalore>();
60 
61  //
62  // run the test
63  //
65  std::cout, Calibration, 0.0, 2.5, 0.1,
66  { 11, 13, -11, -13, 211, 111, 2112, 2212, 22 }
67  );
68 
69  std::cout << Calibration->report() << std::endl;
70 
71  auto shower = lar::example::tests::MakeShower(1.0); // shower with 1 GeV
72  auto corr = Calibration->correction(shower);
73  if (corr != expected) {
74  std::cerr << "Correction for a shower of energy "
75  << shower.Energy().at(shower.best_plane()) << " GeV is " << corr
76  << ", expected " << expected << std::endl;
77  ++nErrors;
78  }
79  auto corr_factor = Calibration->correctionFactor(shower);
80  if (corr_factor != expected.factor) {
81  std::cerr << "Correction factor for a shower of energy "
82  << shower.Energy().at(shower.best_plane()) << " GeV is " << corr_factor
83  << ", expected " << expected.factor << std::endl;
84  ++nErrors;
85  }
86 
87  return nErrors;
88 } // main()
89 
BEGIN_PROLOG could also be cerr
A shower calibration service provider applying a uniform scale.
Class holding a configuration for a test environment.
recob::Shower MakeShower(float E, int bestPlane=2, int ID=1)
process_name shower
Definition: cheaterreco.fcl:51
A correction factor with global uncertainty.
TESTENV CreateTesterEnvironment(CONFIG &&config, ARGS...other_args)
Constructs and returns a TesterEnvironment object.
unsigned int ShowerCalibrationTableTest(Stream &&out, lar::example::ShowerCalibrationGalore const *calibration, float Emin=0.0, float Emax=2.5, float Estep=0.1, std::vector< lar::example::ShowerCalibrationGalore::PDGID_t > const &pids={11, 13, 111, 2212, 22})
Synthetic test: prints corrections for showers in a energy range.
std::string to_string(WindowPattern const &pattern)
BEGIN_PROLOG could also be cout
Interface for a shower calibration service provider.