LArMvaInterface.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArObjects/LArMvaInterface.h
3  *
4  * @brief Header file for the lar multivariate analysis interface class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_MVA_INTERFACE_H
9 #define LAR_MVA_INTERFACE_H 1
10 
11 #include "Pandora/PandoraInputTypes.h"
12 
13 #include <vector>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief MvaTypes class
20  */
21 class MvaTypes
22 {
23 public:
24  /**
25  * @brief InitializedDouble class used to define mva features
26  */
28  {
29  public:
30  /**
31  * @brief Default constructor.
32  */
34 
35  /**
36  * @brief Constructor.
37  *
38  * @param number to hold in class
39  */
40  InitializedDouble(const double number);
41 
42  /**
43  * @brief Copy constructor
44  *
45  * @param rhs the initialized double to copy
46  */
48 
49  /**
50  * @brief Assignment operator
51  *
52  * @param number the double to assign
53  */
54  InitializedDouble &operator=(const double number);
55 
56  /**
57  * @brief Assignment operator
58  *
59  * @param rhs the initialized double to assign
60  */
62 
63  /**
64  * @brief Get number held in class
65  *
66  * @return number held in class
67  */
68  double Get() const;
69 
70  /**
71  * @brief Check number has been initialized
72  *
73  * @return whether number has been initialized
74  */
75  bool IsInitialized() const;
76 
77  private:
78  double m_number; ///< Number held by class
79  bool m_isInitialized; ///< Whether the number has been initialized
80  };
81 
83  typedef std::vector<MvaFeature> MvaFeatureVector;
84 };
85 
86 //------------------------------------------------------------------------------------------------------------------------------------------
87 
88 /**
89  * @brief MvaInterface class
90  */
92 {
93 public:
94  /**
95  * @brief Classify the set of input features based on the trained model
96  *
97  * @param features the input features
98  *
99  * @return the classification
100  */
101  virtual bool Classify(const MvaTypes::MvaFeatureVector &features) const = 0;
102 
103  /**
104  * @brief Calculate the classification score for a set of input features, based on the trained model
105  *
106  * @param features the input features
107  *
108  * @return the classification score
109  */
110  virtual double CalculateClassificationScore(const MvaTypes::MvaFeatureVector &features) const = 0;
111 
112  /**
113  * @brief Calculate the classification probability for a set of input features, based on the trained model
114  *
115  * @param features the input features
116  *
117  * @return the classification probability
118  */
119  virtual double CalculateProbability(const MvaTypes::MvaFeatureVector &features) const = 0;
120 
121  /**
122  * @brief Destructor
123  */
124  virtual ~MvaInterface() = default;
125 };
126 
127 //------------------------------------------------------------------------------------------------------------------------------------------
128 //------------------------------------------------------------------------------------------------------------------------------------------
129 
131 {
132 }
133 
134 //------------------------------------------------------------------------------------------------------------------------------------------
135 
136 inline MvaTypes::InitializedDouble::InitializedDouble(const double number) : m_number(number), m_isInitialized(true)
137 {
138 }
139 
140 //------------------------------------------------------------------------------------------------------------------------------------------
141 
143  m_number(rhs.m_number),
145 {
146 }
147 
148 //------------------------------------------------------------------------------------------------------------------------------------------
149 
151 {
152  m_number = number;
153  m_isInitialized = true;
154 
155  return *this;
156 }
157 
158 //------------------------------------------------------------------------------------------------------------------------------------------
159 
161 {
162  if (this != &rhs)
163  {
164  m_number = rhs.m_number;
166  }
167 
168  return *this;
169 }
170 
171 //------------------------------------------------------------------------------------------------------------------------------------------
172 
173 inline double MvaTypes::InitializedDouble::Get() const
174 {
175  if (!m_isInitialized)
176  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
177 
178  return m_number;
179 }
180 
181 //------------------------------------------------------------------------------------------------------------------------------------------
182 
184 {
185  return m_isInitialized;
186 }
187 
188 } // namespace lar_content
189 
190 #endif // #ifndef LAR_MVA_INTERFACE_H
double Get() const
Get number held in class.
bool IsInitialized() const
Check number has been initialized.
MvaInterface class.
const char features[]
Definition: feature_tests.c:2
InitializedDouble class used to define mva features.
bool m_isInitialized
Whether the number has been initialized.
double m_number
Number held by class.
MvaTypes class.
InitializedDouble MvaFeature
InitializedDouble & operator=(const double number)
Assignment operator.
std::vector< MvaFeature > MvaFeatureVector