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
20 #include "fhiclcpp/types/Atom.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  */
52  public:
53  struct Config {
54 
55  using Name = fhicl::Name;
57 
59  Name("Emin"),
60  Comment("starting shower energy [GeV]"),
61  0.0 // default
62  };
63 
65  Name("Emax"),
66  Comment("last shower energy [GeV]"),
67  2.5 // default
68  };
69 
71  Name("Estep"),
72  Comment("shower energy step [GeV] (0 to have 10 steps)"),
73  0.0 // default
74  };
75 
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 
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 //------------------------------------------------------------------------------
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 
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Test functions for ShowerCalibrationGalore service providers.
ChannelGroupService::Name Name
std::vector< lar::example::ShowerCalibrationGalore::PDGID_t > PIDs
Definition: Run.h:17
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
Interface for a shower calibration art service.
ShowerCalibrationGaloreTest(art::EDAnalyzer::Table< Config > const &config)
#define Comment
Interface for a shower calibration service provider.
LArSoft-specific namespace.
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.