All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerCalibrationGaloreFromPID_test.cc
Go to the documentation of this file.
1 /**
2  * @file ShowerCalibrationGaloreFromPID_test.cc
3  * @brief Tests ShowerCalibrationGaloreFromPID service provider
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 28, 2016
6  * @see ShowerCalibrationGaloreFromPID.h
7  *
8  * Runs a test that instantiates a ShowerCalibrationGaloreFromPID provider with
9  * a known configuration and verifies that the same factor is returned for
10  * a nominal reconstructed shower.
11  * It also prints on screen a "standard" table of corrections, as printed by
12  * ShowerCalibrationTableTest().
13  *
14  */
15 
16 
17 // LArSoft libraries
24 
25 // utility libraries
26 #include "messagefacility/MessageLogger/MessageLogger.h"
27 
28 // C/C++ standard libraries
29 #include <string>
30 #include <vector>
31 
32 
33 //------------------------------------------------------------------------------
34 int main() {
35 
36  //
37  // prepare the test environment
38  //
39 
40  // create a test calibration file on the spot
41  std::string const CalibrationFullPath = "TestCalibration.root:Showers";
43  (CalibrationFullPath);
44 
45  // provide a test name and a push a configuration for
46  // "ShowerCalibrationGaloreService" ("service_provider" is inconsequential)
48  ("ShowerCalibrationGaloreFromPID_test");
50  ("ShowerCalibrationGaloreService", R"( service_provider: "ShowerCalibrationGaloreFromPIDService" CalibrationFile: ")" + CalibrationFullPath + R"(" )");
51 
52  // set up a basic testing environment with that configuration
53  auto TesterEnv = testing::CreateTesterEnvironment(config);
54 
55  // set up a service provider
56  // (ShowerCalibrationGaloreFromPID explicitly supports this one-step setup)
57  TesterEnv.SimpleProviderSetup<lar::example::ShowerCalibrationGaloreFromPID>();
58 
59  //
60  // computation of expected values
61  //
62  unsigned int nErrors = 0; // error count
63 
64  // get the provider we just set up (but accessing it by the interface)ß
65  auto const* Calibration
66  = TesterEnv.Provider<lar::example::ShowerCalibrationGalore>();
67 
68  //
69  // run the test
70  //
72  mf::LogVerbatim("ShowerCalibrationGaloreFromPID_test"),
73  Calibration, 0.0, 2.5, 0.1,
74  { 11, 13, -11, -13, 211, 111, 2112, 2212, 22 }
75  );
76 
77  mf::LogInfo("ShowerCalibrationGaloreFromPID_test")
78  << Calibration->report() << std::endl;
79 
80  return nErrors;
81 } // main()
82 
Test functions for ShowerCalibrationGalore service providers.
Class holding a configuration for a test environment.
Shower calibration service provider correcting according to PID.
void AddDefaultServiceConfiguration(std::string service_name, std::string service_cfg)
Adds a default configuration for the specified service.
int CreateTestShowerCalibrationFromPID(std::string outputPath)
Creates a test calibration file for ShowerCalibrationGaloreFromPID.
TESTENV CreateTesterEnvironment(CONFIG &&config, ARGS...other_args)
Constructs and returns a TesterEnvironment object.
Creates a test calibration file for ShowerCalibrationGaloreFromPID.
Specialization of helper classes for LArSoft tests.
Interface for a shower calibration service provider.
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.
Shower energy calibration according to particle type.
int main(int argc, char **argv)
Base class for unit tests using FHiCL configuration.
Interface for a shower calibration service provider.