All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerCalibrationGaloreTest_module.cc
Go to the documentation of this file.
1 /**
2  * @file ShowerCalibrationGaloreTest_module.cc
3  * @brief A simple test for ShowerCalibrationGaloreService example services
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date May 4, 2016
6  * @see ShowerCalibrationGaloreService.h
7  *
8  */
9 
10 // LArSoft libraries
14 
15 // framework and support libraries
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Core/EDAnalyzer.h"
18 #include "canvas/Utilities/Exception.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "fhiclcpp/types/Atom.h"
21 #include "fhiclcpp/types/Sequence.h"
22 
23 // C++ standard libraries
24 
25 
26 namespace lar {
27  namespace example {
28  namespace tests {
29 
30  /**
31  * @brief Tests ShowerCalibrationGaloreService
32  *
33  *
34  * Prints the available corrections from the configured shower
35  * calibration service.
36  *
37  *
38  * Configuration parameters
39  * -------------------------
40  *
41  * * *Emin* (real, default: 0), *Emax* (real, default: 2.5):
42  * lower and upper shower energy for printout, in GeV.
43  * * *Estep* (real, default: 0): shower energy step size for the
44  * printout, in GeV. The special value of 0 directs the module to
45  * arrange 10 steps in the full range.
46  * * *PID* (list of integers, default: { 11, 13, 111, 2212, 22 }):
47  * print the correction for particles with type from this list;
48  * each number is the PDG particle ID.
49  *
50  */
51  class ShowerCalibrationGaloreTest: public art::EDAnalyzer {
52  public:
53  struct Config {
54 
55  using Name = fhicl::Name;
56  using Comment = fhicl::Comment;
57 
58  fhicl::Atom<float> Emin {
59  Name("Emin"),
60  Comment("starting shower energy [GeV]"),
61  0.0 // default
62  };
63 
64  fhicl::Atom<float> Emax {
65  Name("Emax"),
66  Comment("last shower energy [GeV]"),
67  2.5 // default
68  };
69 
70  fhicl::Atom<float> Estep {
71  Name("Estep"),
72  Comment("shower energy step [GeV] (0 to have 10 steps)"),
73  0.0 // default
74  };
75 
76  fhicl::Sequence<int> PID {
77  Name("PID"),
78  Comment
79  ("list of ID of particles to test shower calibration of"),
80  { 11, 13, 111, 2212, 22 } // default
81  };
82 
83  }; // Config
84 
86  (art::EDAnalyzer::Table<Config> const& config);
87 
88  // correction printout is repeated for each event
89  virtual void analyze(art::Event const&) override;
90 
91  virtual void beginRun(art::Run const&) override;
92 
93  private:
94  float Emin = 0.0;
95  float Emax = 1.0;
96  float Estep = 0.0;
97  std::vector<lar::example::ShowerCalibrationGalore::PDGID_t> PIDs;
98 
99  }; // class ShowerCalibrationGaloreTest
100 
101  } // namespace tests
102  } // namespace example
103 } // namespace lar
104 
105 
106 
107 //------------------------------------------------------------------------------
109  (art::EDAnalyzer::Table<Config> const& config)
110  : art::EDAnalyzer(config)
111  , Emin(config().Emin())
112  , Emax(config().Emax())
113  , Estep(config().Estep())
114  , PIDs(config().PID())
115 {}
116 
117 
118 //------------------------------------------------------------------------------
120 {
121 
122  auto const* calib
123  = lar::providerFrom<lar::example::ShowerCalibrationGaloreService>();
124 
125  mf::LogInfo("ShowerCalibrationGaloreTest") << calib->report();
126 
127 } // lar::example::tests::ShowerCalibrationGaloreTest::beginRun()
128 
129 
130 //------------------------------------------------------------------------------
132  (art::Event const&)
133 {
134  auto const* calib
135  = lar::providerFrom<lar::example::ShowerCalibrationGaloreService>();
136 
138  mf::LogVerbatim("ShowerCalibrationGaloreTest"),
139  calib,
140  Emin, Emax, Estep, PIDs
141  );
142 
143 } // lar::example::tests::ShowerCalibrationGaloreTest::beginRun()
144 
145 
146 //------------------------------------------------------------------------------
147 
148 
149 
Test functions for ShowerCalibrationGalore service providers.
std::vector< lar::example::ShowerCalibrationGalore::PDGID_t > PIDs
BEGIN_PROLOG vertical distance to the surface Name
static const std::vector< int > PIDs
Interface for a shower calibration art service.
ShowerCalibrationGaloreTest(art::EDAnalyzer::Table< Config > const &config)
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.