PandaRoot
PndMultiClassMlpClassify.h
Go to the documentation of this file.
1 /* ***************************************
2  * MultiClass MLP Classifier functions *
3  * Author: M.Babai@rug.nl *
4  * Version: *
5  * LICENSE: *
6  * ***************************************
7  */
8 /*
9  * Note: This is just an interface to the original TMVA
10  * implementation. To find out the available options, please read TMVA
11  * manuals. In case of errors or wrong outputs produced by TMVA
12  * classifiers, try to read their mailing list and send your questions
13  * to the same list.
14  ******* VERY IMORTANT ****
15  * You NEED TMVA version > 4.1.X before this works.
16  */
17 //#pragma once
18 #ifndef PND_MULTICLASS_MLP_CLASSIFY_H
19 #define PND_MULTICLASS_MLP_CLASSIFY_H
20 
21 // Local includes
22 #include "PndMvaClassifier.h"
23 
24 // Root && TMVA
25 #include "TMVA/Reader.h"
26 
27 // Interface definition for Multiclass MLP Classifier
29  //______________ Public ____________________
30  public:
37  explicit PndMultiClassMlpClassify(std::string const &inputFile, std::vector<std::string> const &classNames, std::vector<std::string> const &varNames);
41  virtual ~PndMultiClassMlpClassify();
42 
47  void GetMvaValues(std::vector<float> EvtData, std::map<std::string, float> &result);
52  std::string *Classify(std::vector<float> EvtData);
53 
57  void Initialize();
58 
59  //______________________________________________
60  //====== Getters and setters.
61  // Set the TMVA reader options
62  inline void SetReaderOptions(std::string const &opt);
63 
64  // Set the file name which contains the weights
65  inline void SetWeightsFileName(std::string const &name);
66 
67  // Get the TMVA reader options
68  inline std::string const &GetReaderOptions() const;
69 
70  // Get weights file name.
71  inline std::string const &GetWeightsFileName() const;
72 
73  //______________ Protected__________________
74  // protected:
75  //______________ Private ____________________
76  private:
77  // To avoid mistakes.
80 
81  //======================
82  TMVA::Reader *m_reader;
83 
84  std::string m_weightsFile;
85  std::string m_readerOptions;
86  std::vector<float> m_EventContainer;
87 }; // End of classifier interface definition.
88 
89 //=============== inline functions implementation. ========
90 //__________________________________________
91 inline void PndMultiClassMlpClassify::SetReaderOptions(std::string const &opt)
92 {
93  this->m_readerOptions = opt;
94 };
95 
96 inline std::string const &PndMultiClassMlpClassify::GetReaderOptions() const
97 {
98  return m_readerOptions;
99 };
100 
101 inline void PndMultiClassMlpClassify::SetWeightsFileName(std::string const &name)
102 {
103  this->m_weightsFile = name;
104 };
105 
106 inline std::string const &PndMultiClassMlpClassify::GetWeightsFileName() const
107 {
108  return m_weightsFile;
109 };
110 #endif
void GetMvaValues(std::vector< float > EvtData, std::map< std::string, float > &result)
std::string * Classify(std::vector< float > EvtData)
void SetWeightsFileName(std::string const &name)
PndMultiClassMlpClassify(std::string const &inputFile, std::vector< std::string > const &classNames, std::vector< std::string > const &varNames)
std::string const & GetReaderOptions() const
std::string const & GetWeightsFileName() const
virtual ~PndMultiClassMlpClassify()
void SetReaderOptions(std::string const &opt)