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

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