FairRoot/PandaRoot
PndPrzWindowClassify.h
Go to the documentation of this file.
1 /* ***************************************
2  * Parzen Window based classifier. *
3  * Author: M.Babai@rug.nl *
4  * Version: *
5  * license: *
6  * ***************************************
7  */
8 /*
9  * Based on the straight parzen window algorithm Using a linear search
10  * data structure.
11  */
12 //#pragma once
13 #ifndef PND_PRZ_WINDOW_CLASSIFY_H
14 #define PND_PRZ_WINDOW_CLASSIFY_H
15 
16 // Local includes
17 #include "PndMvaClassifier.h"
18 
19 /*
20  * Parzen Window based classification alg. implementation.
21  */
23 {
24  public:
25  /*
26  * @param inputFile: The name of the file that holds the weights
27  * @param classNames: The names of classes to which an event might be
28  * assigned to.
29  * @param varNames: Variable names from which the feature vector is
30  * built.
31  */
32  explicit PndPrzWindowClassify(std::string const& inputFile,
33  std::vector<std::string> const& classNames,
34  std::vector<std::string> const& varNames);
35 
37  virtual ~PndPrzWindowClassify();
38 
47  void GetMvaValues(std::vector<float> eventData,
48  std::map<std::string,float>& result);
54  std::string* Classify(std::vector<float> EvtData);
55 
60  void setWindowSize(float wsize);
61 
66  inline void setWindowSize(std::map<std::string, float> const& wsize);
67 
71  inline float GetHyperCubeVolume() const;
72 
76  inline std::map<std::string, float> const& GetWindowSize() const;
77 
78  private:
79  // To avoid mistakes.
82 
83  /*
84  * A very simple implementation of a kernel function. It can be
85  * considerd as a multi-dimensional histogram with constant bin size
86  * in each dimension.
87  *@param evtDat Vector containing event data.
88  *@return 1 if the current test sample inside the window, else 0;
89  */
90  float histKernel(std::vector<float> const& evtDat, std::vector<float> const& trSample);
91 
92  // Compute the hypercube volume
93  float CompHyperCubeVolume();
94 
95  // Hypercube volume
96  float m_volumeN;
97 
98  // Window size in each dimension
99  std::map<std::string, float> m_Wsize;
100 };
101 
102 // ================================================================
103 inline void PndPrzWindowClassify::setWindowSize(std::map<std::string, float> const& wsize)
104 {
105  m_Wsize = std::map<std::string, float>(wsize);
106  // Set hypercube volume.
108 };
109 
111 {
112  return m_volumeN;
113 };
114 
115 inline std::map<std::string, float> const& PndPrzWindowClassify::GetWindowSize() const
116 {
117  return m_Wsize;
118 };
119 #endif //End of PndPrzWindowClassify interface.
std::map< std::string, float > m_Wsize
void GetMvaValues(std::vector< float > eventData, std::map< std::string, float > &result)
std::map< std::string, float > const & GetWindowSize() const
PndPrzWindowClassify(std::string const &inputFile, std::vector< std::string > const &classNames, std::vector< std::string > const &varNames)
float histKernel(std::vector< float > const &evtDat, std::vector< float > const &trSample)
PndPrzWindowClassify & operator=(PndPrzWindowClassify const &other)
void setWindowSize(float wsize)
float GetHyperCubeVolume() const
std::string * Classify(std::vector< float > EvtData)
virtual ~PndPrzWindowClassify()
Destructor.