PandaRoot
PndPrzWindowClassify.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* ***************************************
14  * Parzen Window based classifier. *
15  * Author: M.Babai@rug.nl *
16  * Version: *
17  * license: *
18  * ***************************************
19  */
20 /*
21  * Based on the straight parzen window algorithm Using a linear search
22  * data structure.
23  */
24 //#pragma once
25 #ifndef PND_PRZ_WINDOW_CLASSIFY_H
26 #define PND_PRZ_WINDOW_CLASSIFY_H
27 
28 // Local includes
29 #include "PndMvaClassifier.h"
30 
31 /*
32  * Parzen Window based classification alg. implementation.
33  */
35  public:
36  /*
37  * @param inputFile: The name of the file that holds the weights
38  * @param classNames: The names of classes to which an event might be
39  * assigned to.
40  * @param varNames: Variable names from which the feature vector is
41  * built.
42  */
43  explicit PndPrzWindowClassify(std::string const &inputFile, std::vector<std::string> const &classNames, std::vector<std::string> const &varNames);
44 
46  virtual ~PndPrzWindowClassify();
47 
56  void GetMvaValues(std::vector<float> eventData, std::map<std::string, float> &result);
62  std::string *Classify(std::vector<float> EvtData);
63 
68  void setWindowSize(float wsize);
69 
74  inline void setWindowSize(std::map<std::string, float> const &wsize);
75 
79  inline float GetHyperCubeVolume() const;
80 
84  inline std::map<std::string, float> const &GetWindowSize() const;
85 
86  private:
87  // To avoid mistakes.
89  PndPrzWindowClassify &operator=(PndPrzWindowClassify const &other);
90 
91  /*
92  * A very simple implementation of a kernel function. It can be
93  * considerd as a multi-dimensional histogram with constant bin size
94  * in each dimension.
95  *@param evtDat Vector containing event data.
96  *@return 1 if the current test sample inside the window, else 0;
97  */
98  float histKernel(std::vector<float> const &evtDat, std::vector<float> const &trSample);
99 
100  // Compute the hypercube volume
101  float CompHyperCubeVolume();
102 
103  // Hypercube volume
104  float m_volumeN;
105 
106  // Window size in each dimension
107  std::map<std::string, float> m_Wsize;
108 };
109 
110 // ================================================================
111 inline void PndPrzWindowClassify::setWindowSize(std::map<std::string, float> const &wsize)
112 {
113  m_Wsize = std::map<std::string, float>(wsize);
114  // Set hypercube volume.
115  m_volumeN = CompHyperCubeVolume();
116 };
117 
119 {
120  return m_volumeN;
121 };
122 
123 inline std::map<std::string, float> const &PndPrzWindowClassify::GetWindowSize() const
124 {
125  return m_Wsize;
126 };
127 #endif // End of PndPrzWindowClassify interface.
void GetMvaValues(std::vector< float > eventData, std::map< std::string, float > &result)
PndPrzWindowClassify(std::string const &inputFile, std::vector< std::string > const &classNames, std::vector< std::string > const &varNames)
void setWindowSize(float wsize)
std::map< std::string, float > const & GetWindowSize() const
float GetHyperCubeVolume() const
std::string * Classify(std::vector< float > EvtData)
virtual ~PndPrzWindowClassify()
Destructor.