All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  typedef std::map<std::string, MvaFeature> MvaFeatureMap;
85 };
86 
87 //------------------------------------------------------------------------------------------------------------------------------------------
88 
89 /**
90  * @brief MvaInterface class
91  */
93 {
94 public:
95  /**
96  * @brief Classify the set of input features based on the trained model
97  *
98  * @param features the input features
99  *
100  * @return the classification
101  */
102  virtual bool Classify(const MvaTypes::MvaFeatureVector &features) const = 0;
103 
104  /**
105  * @brief Calculate the classification score for a set of input features, based on the trained model
106  *
107  * @param features the input features
108  *
109  * @return the classification score
110  */
111  virtual double CalculateClassificationScore(const MvaTypes::MvaFeatureVector &features) const = 0;
112 
113  /**
114  * @brief Calculate the classification probability for a set of input features, based on the trained model
115  *
116  * @param features the input features
117  *
118  * @return the classification probability
119  */
120  virtual double CalculateProbability(const MvaTypes::MvaFeatureVector &features) const = 0;
121 
122  /**
123  * @brief Destructor
124  */
125  virtual ~MvaInterface() = default;
126 };
127 
128 //------------------------------------------------------------------------------------------------------------------------------------------
129 //------------------------------------------------------------------------------------------------------------------------------------------
130 
131 inline MvaTypes::InitializedDouble::InitializedDouble() : m_number(0.), m_isInitialized(false)
132 {
133 }
134 
135 //------------------------------------------------------------------------------------------------------------------------------------------
136 
137 inline MvaTypes::InitializedDouble::InitializedDouble(const double number) : m_number(number), m_isInitialized(true)
138 {
139 }
140 
141 //------------------------------------------------------------------------------------------------------------------------------------------
142 
144  m_number(rhs.m_number),
145  m_isInitialized(rhs.m_isInitialized)
146 {
147 }
148 
149 //------------------------------------------------------------------------------------------------------------------------------------------
150 
152 {
153  m_number = number;
154  m_isInitialized = true;
155 
156  return *this;
157 }
158 
159 //------------------------------------------------------------------------------------------------------------------------------------------
160 
162 {
163  if (this != &rhs)
164  {
165  m_number = rhs.m_number;
166  m_isInitialized = rhs.m_isInitialized;
167  }
168 
169  return *this;
170 }
171 
172 //------------------------------------------------------------------------------------------------------------------------------------------
173 
174 inline double MvaTypes::InitializedDouble::Get() const
175 {
176  if (!m_isInitialized)
177  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
178 
179  return m_number;
180 }
181 
182 //------------------------------------------------------------------------------------------------------------------------------------------
183 
185 {
186  return m_isInitialized;
187 }
188 
189 } // namespace lar_content
190 
191 #endif // #ifndef LAR_MVA_INTERFACE_H
double Get() const
Get number held in class.
virtual ~MvaInterface()=default
Destructor.
bool IsInitialized() const
Check number has been initialized.
virtual bool Classify(const MvaTypes::MvaFeatureVector &features) const =0
Classify the set of input features based on the trained model.
MvaInterface class.
InitializedDouble class used to define mva features.
bool m_isInitialized
Whether the number has been initialized.
std::map< std::string, MvaFeature > MvaFeatureMap
double m_number
Number held by class.
MvaTypes class.
InitializedDouble MvaFeature
virtual double CalculateProbability(const MvaTypes::MvaFeatureVector &features) const =0
Calculate the classification probability for a set of input features, based on the trained model...
InitializedDouble & operator=(const double number)
Assignment operator.
virtual double CalculateClassificationScore(const MvaTypes::MvaFeatureVector &features) const =0
Calculate the classification score for a set of input features, based on the trained model...
std::vector< MvaFeature > MvaFeatureVector
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true