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

Last change on this file since 7716 was 7697, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 3.9 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 Double_t TreeHad(const Float_t *evt);
48
49 int FindBestSplitGini(const MArrayI &datasort, const MArrayI &datarang,
50 const MArrayF &hadtrue, const MArrayI &idclass,
51 Int_t ndstart, Int_t ndend, const MArrayF &tclasspop,
52 const Float_t &mean, const Float_t &square, Int_t &msplit,
53 Float_t &decsplit, Int_t &nbest, const MArrayF &winbag,
54 const int nclass);
55
56 int FindBestSplitSigma(const MArrayI &datasort, const MArrayI &datarang,
57 const MArrayF &hadtrue, const MArrayI &idclass,
58 Int_t ndstart, Int_t ndend, const MArrayF &tclasspop,
59 const Float_t &mean, const Float_t &square, Int_t &msplit,
60 Float_t &decsplit, Int_t &nbest, const MArrayF &winbag,
61 const int nclass);
62
63 void MoveData(MArrayI &datasort, Int_t ndstart, Int_t ndend,
64 MArrayI &idmove, MArrayI &ncase, Int_t msplit,
65 Int_t nbest, Int_t &ndendl);
66
67 void BuildTree(MArrayI &datasort, const MArrayI &datarang, const MArrayF &hadtrue,
68 const MArrayI &idclass,MArrayI &bestsplit,MArrayI &bestsplitnext,
69 const MArrayF &tclasspop, const Float_t &tmean, const Float_t &tsquare, const MArrayF &winbag,
70 Int_t ninbag, const int nclass);
71
72public:
73 MRanTree(const char *name=NULL, const char *title=NULL);
74 MRanTree(const MRanTree &tree);
75
76 void SetNdSize(Int_t n);
77 void SetNumTry(Int_t n);
78 void SetError(Float_t f) { fError = f; }
79
80 Int_t GetNdSize() const { return fNdSize; }
81 Int_t GetNumTry() const { return fNumTry; }
82 Int_t GetNumNodes() const { return fNumNodes; }
83 Int_t GetNumEndNodes() const { return fNumEndNodes; }
84 Int_t IsClassify() const { return fClassify; }
85 Float_t GetError() const { return fError; }
86
87 Int_t GetBestVar(Int_t i) const { return fBestVar.At(i); }
88 Int_t GetTreeMap1(Int_t i) const { return fTreeMap1.At(i); }
89 Int_t GetTreeMap2(Int_t i) const { return fTreeMap2.At(i); }
90 Int_t GetNodeClass(Int_t i) const { return fBestVar.At(i)+2; }
91 Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
92 Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
93
94 Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); }
95
96 void SetClassify(Bool_t n){ fClassify=n; }
97
98 // functions used in tree growing process
99 void GrowTree(TMatrix *mat, const MArrayF &hadtrue, const MArrayI &idclass,
100 MArrayI &datasort, const MArrayI &datarang,const MArrayF &tclasspop,
101 const Float_t &mean, const Float_t &square, const MArrayI &jinbag, const MArrayF &winbag,
102 const int nclass);
103
104 Double_t TreeHad(const TVector &event);
105 Double_t TreeHad(const TMatrixRow &event);
106 Double_t TreeHad(const TMatrix &m, Int_t ievt);
107
108 Bool_t AsciiWrite(ostream &out) const;
109
110 ClassDef(MRanTree, 1) // Storage container for tree structure
111};
112
113#endif
Note: See TracBrowser for help on using the repository browser.