source: trunk/MagicSoft/Mars/mranforest/MRanTree.h@ 7693

Last change on this file since 7693 was 7693, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 3.8 KB
Line 
1#ifndef MARS_MRanTree
2#define MARS_MRanTree
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8#ifndef ROOT_TArrayI
9#include <TArrayI.h>
10#endif
11
12#ifndef ROOT_TArrayF
13#include <TArrayF.h>
14#endif
15
16class TMatrix;
17class TMatrixRow;
18class TVector;
19class TRandom;
20
21class MArrayI;
22class MArrayF;
23
24class MRanTree : public MParContainer
25{
26private:
27 Bool_t fClassify;
28
29 Int_t fNdSize;
30 Int_t fNumTry;
31
32 Int_t fNumNodes;
33 Int_t fNumEndNodes;
34 Float_t fError;
35
36 TArrayI fBestVar;
37 TArrayI fTreeMap1;
38 TArrayI fTreeMap2;
39 TArrayF fBestSplit;
40 TArrayF fGiniDec;
41
42 int (MRanTree::*FindBestSplit)
43 (const MArrayI &, const MArrayI &, const MArrayF &, const MArrayI &,
44 Int_t, Int_t , const MArrayF &, const Float_t &, const Float_t &, Int_t &, Float_t &,
45 Int_t &, const MArrayF &, const int); //!
46
47
48 int FindBestSplitGini(const MArrayI &datasort, const MArrayI &datarang,
49 const MArrayF &hadtrue, const MArrayI &idclass,
50 Int_t ndstart, Int_t ndend, const MArrayF &tclasspop,
51 const Float_t &mean, const Float_t &square, Int_t &msplit,
52 Float_t &decsplit, Int_t &nbest, const MArrayF &winbag,
53 const int nclass);
54
55 int FindBestSplitSigma(const MArrayI &datasort, const MArrayI &datarang,
56 const MArrayF &hadtrue, const MArrayI &idclass,
57 Int_t ndstart, Int_t ndend, const MArrayF &tclasspop,
58 const Float_t &mean, const Float_t &square, Int_t &msplit,
59 Float_t &decsplit, Int_t &nbest, const MArrayF &winbag,
60 const int nclass);
61
62 void MoveData(MArrayI &datasort, Int_t ndstart, Int_t ndend,
63 MArrayI &idmove, MArrayI &ncase, Int_t msplit,
64 Int_t nbest, Int_t &ndendl);
65
66 void BuildTree(MArrayI &datasort, const MArrayI &datarang, const MArrayF &hadtrue,
67 const MArrayI &idclass,MArrayI &bestsplit,MArrayI &bestsplitnext,
68 MArrayF &tclasspop, const Float_t &tmean, const Float_t &tsquare, const MArrayF &winbag,
69 Int_t ninbag, const int nclass);
70
71public:
72 MRanTree(const char *name=NULL, const char *title=NULL);
73 MRanTree(const MRanTree &tree);
74
75 void SetNdSize(Int_t n);
76 void SetNumTry(Int_t n);
77 void SetError(Float_t f) { fError = f; }
78
79 Int_t GetNdSize() const { return fNdSize; }
80 Int_t GetNumTry() const { return fNumTry; }
81 Int_t GetNumNodes() const { return fNumNodes; }
82 Int_t GetNumEndNodes() const { return fNumEndNodes; }
83 Int_t IsClassify() const { return fClassify; }
84 Float_t GetError() const { return fError; }
85
86 Int_t GetBestVar(Int_t i) const { return fBestVar.At(i); }
87 Int_t GetTreeMap1(Int_t i) const { return fTreeMap1.At(i); }
88 Int_t GetTreeMap2(Int_t i) const { return fTreeMap2.At(i); }
89 Int_t GetNodeClass(Int_t i) const { return fBestVar.At(i)+2; }
90 Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
91 Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
92
93 Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); }
94
95 void SetClassify(Bool_t n){ fClassify=n; }
96
97 // functions used in tree growing process
98 void GrowTree(TMatrix *mat, const MArrayF &hadtrue, const MArrayI &idclass,
99 MArrayI &datasort, const MArrayI &datarang,MArrayF &tclasspop,
100 const Float_t &mean, const Float_t &square, const MArrayI &jinbag, const MArrayF &winbag,
101 const int nclass);
102
103 Double_t TreeHad(const TVector &event);
104 Double_t TreeHad(const TMatrixRow &event);
105 Double_t TreeHad(const TMatrix &m, Int_t ievt);
106
107 Bool_t AsciiWrite(ostream &out) const;
108
109 ClassDef(MRanTree, 1) // Storage container for tree structure
110};
111
112#endif
Note: See TracBrowser for help on using the repository browser.