LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArMvaInterface.h
Go to the documentation of this file.
1 
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 
21 class MvaTypes
22 {
23 public:
28  {
29  public:
34 
40  InitializedDouble(const double number);
41 
48 
54  InitializedDouble &operator=(const double number);
55 
62 
68  double Get() const;
69 
75  bool IsInitialized() const;
76 
77  private:
78  double m_number;
80  };
81 
83  typedef std::vector<MvaFeature> MvaFeatureVector;
84  typedef std::map<std::string, MvaFeature> MvaFeatureMap;
85 };
86 
87 //------------------------------------------------------------------------------------------------------------------------------------------
88 
93 {
94 public:
102  virtual bool Classify(const MvaTypes::MvaFeatureVector &features) const = 0;
103 
111  virtual double CalculateClassificationScore(const MvaTypes::MvaFeatureVector &features) const = 0;
112 
120  virtual double CalculateProbability(const MvaTypes::MvaFeatureVector &features) const = 0;
121 
125  virtual ~MvaInterface() = default;
126 };
127 
128 //------------------------------------------------------------------------------------------------------------------------------------------
129 //------------------------------------------------------------------------------------------------------------------------------------------
130 
132  m_number(0.),
133  m_isInitialized(false)
134 {
135 }
136 
137 //------------------------------------------------------------------------------------------------------------------------------------------
138 
140  m_number(number),
141  m_isInitialized(true)
142 {
143 }
144 
145 //------------------------------------------------------------------------------------------------------------------------------------------
146 
148  m_number(rhs.m_number),
150 {
151 }
152 
153 //------------------------------------------------------------------------------------------------------------------------------------------
154 
156 {
157  m_number = number;
158  m_isInitialized = true;
159 
160  return *this;
161 }
162 
163 //------------------------------------------------------------------------------------------------------------------------------------------
164 
166 {
167  if (this != &rhs)
168  {
169  m_number = rhs.m_number;
171  }
172 
173  return *this;
174 }
175 
176 //------------------------------------------------------------------------------------------------------------------------------------------
177 
178 inline double MvaTypes::InitializedDouble::Get() const
179 {
180  if (!m_isInitialized)
181  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
182 
183  return m_number;
184 }
185 
186 //------------------------------------------------------------------------------------------------------------------------------------------
187 
189 {
190  return m_isInitialized;
191 }
192 
193 } // namespace lar_content
194 
195 #endif // #ifndef LAR_MVA_INTERFACE_H
double Get() const
Get number held in class.
bool IsInitialized() const
Check number has been initialized.
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
InitializedDouble & operator=(const double number)
Assignment operator.
std::vector< MvaFeature > MvaFeatureVector