Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RMethodBase.h
Go to the documentation of this file.
1 // @(#)root/tmva/rmva $Id$
2 // Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : RMethodBase *
8  * *
9  * Description: *
10  * Virtual base class for all MVA method based on ROOTR *
11  * *
12  **********************************************************************************/
13 
14 #ifndef ROOT_TMVA_RMethodBase
15 #define ROOT_TMVA_RMethodBase
16 
17 //////////////////////////////////////////////////////////////////////////
18 // //
19 // RMethodBase //
20 // //
21 // Virtual base class for all TMVA method based on ROOTR //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "TMVA/MethodBase.h"
26 
27 #include <TRInterface.h>
28 
29 class TGraph;
30 class TTree;
31 class TDirectory;
32 class TSpline;
33 class TH1F;
34 class TH1D;
35 
36 namespace TMVA {
37 
38  class Ranking;
39  class PDF;
40  class TSpline1;
41  class MethodCuts;
42  class MethodBoost;
43  class DataSetInfo;
44 
45  class RMethodBase : public MethodBase {
46 
47  friend class Factory;
48  protected:
49  ROOT::R::TRInterface &r;
50  public:
51 
52  // default constructur
53  RMethodBase(const TString &jobName,
54  Types::EMVA methodType,
55  const TString &methodTitle,
56  DataSetInfo &dsi,
57  const TString &theOption = "", ROOT::R::TRInterface &_r = ROOT::R::TRInterface::Instance());
58 
59  // constructor used for Testing + Application of the MVA, only (no training),
60  // using given weight file
61  RMethodBase(Types::EMVA methodType,
62  DataSetInfo &dsi,
63  const TString &weightFile, ROOT::R::TRInterface &_r = ROOT::R::TRInterface::Instance());
64 
65  // default destructur
66  virtual ~RMethodBase() {};
67  virtual void Train() = 0;
68  // options treatment
69  virtual void Init() = 0;
70  virtual void DeclareOptions() = 0;
71  virtual void ProcessOptions() = 0;
72  // create ranking
73  virtual const Ranking *CreateRanking() = 0;
74 
75  virtual Double_t GetMvaValue(Double_t *errLower = 0, Double_t *errUpper = 0) = 0;
76 
77  Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) = 0;
78  protected:
79  // the actual "weights"
80  virtual void AddWeightsXMLTo(void *parent) const = 0;
81  virtual void ReadWeightsFromXML(void *wghtnode) = 0;
82  virtual void ReadWeightsFromStream(std::istream &) = 0; // backward compatibility
83  virtual void ReadWeightsFromStream(TFile &) {} // backward compatibility
84 
85 
86  void LoadData();//Read data from Data() Aand DataInfo() to Dataframes and Vectors
87  protected:
88  ROOT::R::TRDataFrame fDfTrain;//signal and backgrd
89  ROOT::R::TRDataFrame fDfTest;
90  TVectorD fWeightTrain;
91  TVectorD fWeightTest;
92  std::vector<std::string> fFactorTrain;
93  std::vector<std::string> fFactorTest;
94  ROOT::R::TRDataFrame fDfSpectators;
95 
96  private:
97  ClassDef(RMethodBase, 0) // Virtual base class for all TMVA method
98 
99  };
100 } // namespace TMVA
101 
102 #endif
103 
104