Functions
ShowerCalibrationGaloreFromPID_test.cc File Reference

Tests ShowerCalibrationGaloreFromPID service provider. More...

#include "larexamples/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGaloreFromPID.h"
#include "larexamples/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGalore.h"
#include "larexamples/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGaloreFromPIDTestHelpers.h"
#include "larcorealg/TestUtils/unit_test_base.h"
#include "test/Services/ShowerCalibrationGalore/Providers/CreateTestShowerCalibrationFromPID.h"
#include "test/Services/ShowerCalibrationGalore/Providers/ShowerCalibrationGaloreTests.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Tests ShowerCalibrationGaloreFromPID service provider.

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

Runs a test that instantiates a ShowerCalibrationGaloreFromPID 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().

Definition in file ShowerCalibrationGaloreFromPID_test.cc.

Function Documentation

int main ( void  )

Definition at line 34 of file ShowerCalibrationGaloreFromPID_test.cc.

34  {
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");
49  config.AddDefaultServiceConfiguration
50  ("ShowerCalibrationGaloreService", R"(
51  service_provider: "ShowerCalibrationGaloreFromPIDService"
52  CalibrationFile: ")" + CalibrationFullPath + R"("
53  )");
54 
55  // set up a basic testing environment with that configuration
56  auto TesterEnv = testing::CreateTesterEnvironment(config);
57 
58  // set up a service provider
59  // (ShowerCalibrationGaloreFromPID explicitly supports this one-step setup)
60  TesterEnv.SimpleProviderSetup<lar::example::ShowerCalibrationGaloreFromPID>();
61 
62  //
63  // computation of expected values
64  //
65  unsigned int nErrors = 0; // error count
66 
67  // get the provider we just set up (but accessing it by the interface)ß
68  auto const* Calibration
69  = TesterEnv.Provider<lar::example::ShowerCalibrationGalore>();
70 
71  //
72  // run the test
73  //
75  mf::LogVerbatim("ShowerCalibrationGaloreFromPID_test"),
76  Calibration, 0.0, 2.5, 0.1,
77  { 11, 13, -11, -13, 211, 111, 2112, 2212, 22 }
78  );
79 
80  mf::LogInfo("ShowerCalibrationGaloreFromPID_test")
81  << Calibration->report() << std::endl;
82 
83  return nErrors;
84 } // main()
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Class holding a configuration for a test environment.
Shower calibration service provider correcting according to PID.
int CreateTestShowerCalibrationFromPID(std::string outputPath)
Creates a test calibration file for ShowerCalibrationGaloreFromPID.
static Config * config
Definition: config.cpp:1054
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.
QTextStream & endl(QTextStream &s)
Interface for a shower calibration service provider.