All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerCalibrationGalore.h
Go to the documentation of this file.
1 /**
2  * @file ShowerCalibrationGalore.h
3  * @brief Interface for a shower calibration service provider
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 27, 2016
6  * @ingroup ShowerCalibrationGalore
7  *
8  *
9  */
10 
11 
12 #ifndef LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALORE_H
13 #define LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALORE_H
14 
15 
16 /// LArSoft libraries
19 
20 // C/C++ standard libraries
21 #include <string>
22 
23 
24 namespace lar {
25  namespace example {
26 
27  /**
28  * @brief Interface for a shower calibration service provider.
29  * @ingroup ShowerCalibrationGalore
30  * @see @ref ShowerCalibrationGalore "ShowerCalibrationGalore example overview"
31  *
32  * The service provider computes a calibration factor for a reconstructed
33  * shower.
34  *
35  * It offers:
36  *
37  * * correction() to get the calibration factor with uncertainty
38  * * correctionFactor() to get just the calibration factor
39  *
40  * This is an abstract interface. The corresponding _art_ service
41  * interface is called `ShowerCalibrationGaloreService`.
42  *
43  */
46  {
47  public:
48 
49  //---------------------------------------------------------------------
50  /// A correction factor with global uncertainty
51  struct Correction_t {
52  float factor; ///< correction factor
53  float error; ///< correction factor uncertainty
54 
55  Correction_t(float val = 1., float err = 0.)
56  : factor(val), error(err)
57  {}
58 
59  bool operator== (Correction_t const& as) const
60  { return (factor == as.factor) && (error == as.error); }
61  bool operator!= (Correction_t const& as) const
62  { return (factor != as.factor) || (error != as.error); }
63  }; // Correction_t
64 
65  /// A type representing a particle ID in Particle Data Group convention
66  using PDGID_t = int;
67 
68  /// A mnemonic constant for unknown particle ID
69  static constexpr PDGID_t unknownID = 0;
70 
71 
72  //---------------------------------------------------------------------
73  // Virtual destructor
74  virtual ~ShowerCalibrationGalore() = default;
75 
76 
77  /// @{
78  /// @name Correction query
79 
80  //---------------------------------------------------------------------
81  /**
82  * @brief Returns a correction factor for a given reconstructed shower
83  * @param shower the shower to be calibrated
84  * @param PDGID hypothesis on type of particle originating the shower
85  * @return the correction factor
86  * @see correction()
87  *
88  * The returned value includes a correction factor to be applied to
89  * the shower energy to calibrate it, but no uncertainty.
90  *
91  * The particle type hypothesis argument is optional, and the invalid
92  * type `0` (`unknownID`) implies that no hypothesis is present.
93  *
94  */
95  virtual float correctionFactor
96  (recob::Shower const& shower, PDGID_t PDGID = unknownID) const = 0;
97 
98  /**
99  * @brief Returns the correction for a given reconstructed shower
100  * @param shower the shower to be calibrated
101  * @param PDGID hypothesis on type of particle originating the shower
102  * @return the correction with its uncertainty
103  * @see correctionFactor()
104  *
105  * The returned value includes a correction factor to be applied to
106  * the shower energy to calibrate it, with its global uncertainty.
107  *
108  * The particle type hypothesis argument is optional, and the invalid
109  * type `0` (`unknownID`) implies that no hypothesis is present.
110  *
111  */
112  virtual Correction_t correction
113  (recob::Shower const& shower, PDGID_t PDGID = unknownID) const = 0;
114 
115 
116  /// @}
117 
118 
119  /// Returns a string with a short report of the current corrections
120  virtual std::string report() const = 0;
121 
122  //---------------------------------------------------------------------
123 
124  }; // class ShowerCalibrationGalore
125 
126 
127  /// Output operator for the correction type
128  template <typename Stream>
129  Stream& operator<<
131  {
132  out << corr.factor << " +/- " << corr.error;
133  return out;
134  } // operator<< (Correction_t)
135 
136 
137  } // namespace example
138 } // namespace lar
139 
140 
141 #endif // LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALORE_H
142 
An empty class that can&#39;t be copied nor moved.
Defines classes that can&#39;t be copied nor moved.
EResult err(const char *call)
process_name shower
Definition: cheaterreco.fcl:51
A correction factor with global uncertainty.
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.
virtual float correctionFactor(recob::Shower const &shower, PDGID_t PDGID=unknownID) const =0
Returns a correction factor for a given reconstructed shower.
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.
virtual ~ShowerCalibrationGalore()=default
bnb BNB Stream
Interface for a shower calibration service provider.