All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerCalibrationGaloreScale.h
Go to the documentation of this file.
1 /**
2  * @file ShowerCalibrationGaloreScale.h
3  * @brief Shower calibration service provider applying a uniform energy scale
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 28, 2016
6  * @see ShowerCalibrationGalore.h
7  * @ingroup ShowerCalibrationGalore
8  *
9  *
10  */
11 
12 
13 #ifndef LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALORESCALE_H
14 #define LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALORESCALE_H
15 
16 
17 // LArSoft libraries
19 
20 // framework libraries
21 #include "fhiclcpp/ParameterSet.h"
22 #include "fhiclcpp/types/Atom.h"
23 #include "fhiclcpp/types/Comment.h"
24 #include "fhiclcpp/types/Name.h"
25 #include "fhiclcpp/types/Table.h"
26 
27 // C/C++ standard libraries
28 #include <sstream>
29 #include <string>
30 
31 
32 namespace lar {
33  namespace example {
34 
35  /**
36  * @brief A shower calibration service provider applying a uniform scale.
37  * @ingroup ShowerCalibrationGalore
38  * @see @ref ShowerCalibrationGalore "ShowerCalibrationGalore example overview"
39  *
40  * The service provider computes a calibration factor for a reconstructed
41  * shower. The calibration factor is a single number for the whole
42  * detector and for the entire data sample.
43  *
44  * Configuration parameters
45  * -------------------------
46  *
47  * * *factor* (real, _mandatory_): the scale factor to apply
48  * * *error* (real, _mandatory_): the total uncertainty on the correction
49  * factor
50  *
51  */
53  public:
54 
55  //---------------------------------------------------------------------
56  /// Collection of configuration parameters for the service
57  struct Config {
58  using Name = fhicl::Name;
59  using Comment = fhicl::Comment;
60 
61  fhicl::Atom<float> factor {
62  Name("factor"),
63  Comment("correction factor to be applied to all particles")
64  };
65 
66  fhicl::Atom<float> error {
67  Name("error"),
68  Comment("uncertainty on the correction factor")
69  };
70 
71  }; // struct Config
72 
73  /// Type describing all the parameters
74  using parameters_type = fhicl::Table<Config>;
75 
76 
77  //---------------------------------------------------------------------
78  /// Constructor from the complete configuration object
80  : corr(config.factor(), config.error())
81  {}
82 
83  //---------------------------------------------------------------------
84  /// Constructor from a parameter set
85  ShowerCalibrationGaloreScale(fhicl::ParameterSet const& pset)
87  (parameters_type(pset, { "service_type", "service_provider" })())
88  {}
89 
90 
91  /// @{
92  /// @name Correction query
93 
94  //---------------------------------------------------------------------
95  /**
96  * @brief Returns a correction factor for a given reconstructed shower
97  * @return the uniform energy correction factor
98  * @see correction()
99  *
100  * The returned value includes a correction factor to be applied to
101  * the shower energy to calibrate it, but no uncertainty.
102  *
103  */
104  virtual float correctionFactor
105  (recob::Shower const&, PDGID_t = unknownID) const override
106  { return corr.factor; }
107 
108  /**
109  * @brief Returns the correction for a given reconstructed shower
110  * @return the correction with its uncertainty
111  * @see correctionFactor()
112  *
113  * The returned value includes a correction factor to be applied to
114  * any shower energy to calibrate it, with its global uncertainty.
115  *
116  */
117  virtual Correction_t correction
118  (recob::Shower const&, PDGID_t = unknownID) const override
119  { return corr; }
120 
121  /// @}
122 
123 
124  /// Returns a string with a short report of the current correctionß
125  virtual std::string report() const override
126  {
127  std::ostringstream sstr;
128  sstr << "Uniform correction: " << corr;
129  return sstr.str();
130  }
131 
132 
133  //---------------------------------------------------------------------
134  private:
135  Correction_t corr;
136 
137  }; // class ShowerCalibrationGaloreScale
138 
139 
140  } // namespace example
141 } // namespace lar
142 
143 
144 #endif // LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALORESCALE_H
145 
fhicl::Table< Config > parameters_type
Type describing all the parameters.
A shower calibration service provider applying a uniform scale.
virtual Correction_t correction(recob::Shower const &shower, PDGID_t PDGID=unknownID) const =0
Returns the correction for a given reconstructed shower.
virtual std::string report() const =0
Returns a string with a short report of the current corrections.
ShowerCalibrationGaloreScale(fhicl::ParameterSet const &pset)
Constructor from a parameter set.
virtual float correctionFactor(recob::Shower const &shower, PDGID_t PDGID=unknownID) const =0
Returns a correction factor for a given reconstructed shower.
BEGIN_PROLOG vertical distance to the surface Name
ShowerCalibrationGaloreScale(Config const &config)
Constructor from the complete configuration object.
static constexpr PDGID_t unknownID
A mnemonic constant for unknown particle ID.
int PDGID_t
A type representing a particle ID in Particle Data Group convention.
Interface for a shower calibration service provider.
Collection of configuration parameters for the service.
Interface for a shower calibration service provider.