Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
BDT.h
Go to the documentation of this file.
1 #ifndef BDT__HH
2 #define BDT__HH
3 #include <iostream>
4 #include <iomanip>
5 #include <fstream>
6 
7 #include "tmvaglob.h"
8 
9 #include "RQ_OBJECT.h"
10 
11 #include "TROOT.h"
12 #include "TStyle.h"
13 #include "TPad.h"
14 #include "TCanvas.h"
15 #include "TLine.h"
16 #include "TFile.h"
17 #include "TColor.h"
18 #include "TPaveText.h"
19 #include "TObjString.h"
20 #include "TControlBar.h"
21 
22 #include "TGWindow.h"
23 #include "TGButton.h"
24 #include "TGLabel.h"
25 #include "TGNumberEntry.h"
26 
27 #include "TMVA/DecisionTree.h"
28 #include "TMVA/Tools.h"
29 #include "TXMLEngine.h"
30 
31 // Uncomment this only if the link problem is solved. The include statement tends
32 // to use the ROOT classes rather than the local TMVA release
33 // #include "TMVA/DecisionTree.h"
34 // #include "TMVA/DecisionTreeNode.h"
35 namespace TMVA{
36 
37  // this macro displays a decision tree read in from the weight file
38 
39 
40  inline Int_t getSigColorF () {return TColor::GetColor( "#0000FF" );} // Pure Signal
41  inline Int_t getBkgColorF () {return TColor::GetColor( "#FF0000" );} // Pure Backgr.
42  inline Int_t getIntColorF () {return TColor::GetColor( "#33aa77" );} // novel green
43 
44 
45  inline Int_t getSigColorT () {return 10;}
46  inline Int_t getBkgColorT () {return 10;}
47  inline Int_t getIntColorT () {return 10;}
48 
49 
50 
51  class StatDialogBDT {
52 
53  RQ_OBJECT("StatDialogBDT")
54 
55  public:
56 
57  StatDialogBDT(TString dataset, const TGWindow* p, TString wfile,
58  TString methName = "BDT", Int_t itree = 0 );
59  virtual ~StatDialogBDT() {
60  TMVA::DecisionTreeNode::fgIsTraining=false;
61  fThis = 0;
62  fMain->CloseWindow();
63  fMain->Cleanup();
64  if(gROOT->GetListOfCanvases()->FindObject(fCanvas))
65  delete fCanvas;
66  }
67 
68  // draw method
69  void DrawTree(Int_t itree );
70 
71  void RaiseDialog() { if (fMain) { fMain->RaiseWindow(); fMain->Layout(); fMain->MapWindow(); } }
72 
73  private:
74 
75  TGMainFrame *fMain;
76  Int_t fItree;
77  Int_t fNtrees;
78  TCanvas* fCanvas;
79 
80 
81  TGNumberEntry* fInput;
82 
83  TGHorizontalFrame* fButtons;
84  TGTextButton* fDrawButton;
85  TGTextButton* fCloseButton;
86 
87  void UpdateCanvases();
88 
89  // draw methods
90  TMVA::DecisionTree* ReadTree( TString * &vars, Int_t itree );
91  void DrawNode( TMVA::DecisionTreeNode *n,
92  Double_t x, Double_t y, Double_t xscale, Double_t yscale, TString* vars );
93  void GetNtrees();
94 
95  TString fWfile;
96  TString fMethName;
97  TString fDataset;
98  Int_t fColorOffset;
99 
100  public:
101 
102  // static function for external deletion
103  static void Delete() { if (fThis != 0) { delete fThis; fThis = 0; } }
104 
105  // slots
106  void SetItree(); //*SIGNAL*
107  void Redraw(); //*SIGNAL*
108  void Close(); //*SIGNAL*
109 
110  private:
111 
112  static StatDialogBDT* fThis;
113 
114  };
115  // ========================================================================================
116 
117  extern std::vector<TControlBar*> BDT_Global__cbar;
118 
119  // intermediate GUI
120  void BDT(TString dataset, const TString& fin = "TMVA.root" );
121  void BDT_DeleteTBar(int i);
122  void BDT(TString dataset, Int_t itree, TString wfile , TString methName = "BDT", Bool_t useTMVAStyle = kTRUE ) ;
123 
124 }
125 #endif