PandaRoot
PndMultiClassMlpClassify.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  * MultiClass MLP Classifier functions *
15  * Author: M.Babai@rug.nl *
16  * Version: *
17  * LICENSE: *
18  * ***************************************
19  */
20 /*
21  * Note: This is just an interface to the original TMVA
22  * implementation. To find out the available options, please read TMVA
23  * manuals. In case of errors or wrong outputs produced by TMVA
24  * classifiers, try to read their mailing list and send your questions
25  * to the same list.
26  ******* VERY IMORTANT ****
27  * You NEED TMVA version > 4.1.X before this works.
28  */
29 //#pragma once
30 #ifndef PND_MULTICLASS_MLP_CLASSIFY_H
31 #define PND_MULTICLASS_MLP_CLASSIFY_H
32 
33 // Local includes
34 #include "PndMvaClassifier.h"
35 
36 // Root && TMVA
37 #include "TMVA/Reader.h"
38 
39 // Interface definition for Multiclass MLP Classifier
41  //______________ Public ____________________
42  public:
49  explicit PndMultiClassMlpClassify(std::string const &inputFile, std::vector<std::string> const &classNames, std::vector<std::string> const &varNames);
53  virtual ~PndMultiClassMlpClassify();
54 
59  void GetMvaValues(std::vector<float> EvtData, std::map<std::string, float> &result);
64  std::string *Classify(std::vector<float> EvtData);
65 
69  void Initialize();
70 
71  //______________________________________________
72  //====== Getters and setters.
73  // Set the TMVA reader options
74  inline void SetReaderOptions(std::string const &opt);
75 
76  // Set the file name which contains the weights
77  inline void SetWeightsFileName(std::string const &name);
78 
79  // Get the TMVA reader options
80  inline std::string const &GetReaderOptions() const;
81 
82  // Get weights file name.
83  inline std::string const &GetWeightsFileName() const;
84 
85  //______________ Protected__________________
86  // protected:
87  //______________ Private ____________________
88  private:
89  // To avoid mistakes.
92 
93  //======================
94  TMVA::Reader *m_reader;
95 
96  std::string m_weightsFile;
97  std::string m_readerOptions;
98  std::vector<float> m_EventContainer;
99 }; // End of classifier interface definition.
100 
101 //=============== inline functions implementation. ========
102 //__________________________________________
103 inline void PndMultiClassMlpClassify::SetReaderOptions(std::string const &opt)
104 {
105  this->m_readerOptions = opt;
106 };
107 
108 inline std::string const &PndMultiClassMlpClassify::GetReaderOptions() const
109 {
110  return m_readerOptions;
111 };
112 
113 inline void PndMultiClassMlpClassify::SetWeightsFileName(std::string const &name)
114 {
115  this->m_weightsFile = name;
116 };
117 
118 inline std::string const &PndMultiClassMlpClassify::GetWeightsFileName() const
119 {
120  return m_weightsFile;
121 };
122 #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)