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

Last change on this file since 2273 was 2114, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.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 TVector;
18class TRandom;
19class MDataArray;
20
21class MRanTree : public MParContainer
22{
23private:
24 Int_t fNdSize;
25 Int_t fNumTry;
26
27 Int_t fNumNodes;
28 Int_t fNumEndNodes;
29 MDataArray *fData;
30
31 TArrayI fBestVar;
32 TArrayI fTreeMap1;
33 TArrayI fTreeMap2;
34 TArrayF fBestSplit;
35
36 TArrayF fGiniDec;
37
38public:
39 MRanTree(const char *name=NULL, const char *title=NULL);
40
41 void SetNdSize(Int_t n);
42 void SetNumTry(Int_t n);
43 void SetRules(MDataArray *rules);
44
45 MDataArray *GetRules() { return fData;}
46
47 Int_t GetNdSize() const { return fNdSize; }
48 Int_t GetNumTry() const { return fNumTry; }
49 Int_t GetNumNodes() const { return fNumNodes; }
50 Int_t GetNumEndNodes() const { return fNumEndNodes; }
51
52 Int_t GetBestVar(Int_t i) const { return fBestVar.At(i); }
53 Int_t GetTreeMap1(Int_t i) const { return fTreeMap1.At(i); }
54 Int_t GetTreeMap2(Int_t i) const { return fTreeMap2.At(i); }
55 Int_t GetNodeClass(Int_t i) const { return fBestVar.At(i)+2; }
56 Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
57 Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
58
59 Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); }
60
61 // functions used in tree growing process
62 void GrowTree(TMatrix &mhad,TMatrix &mgam,Int_t numdata, Int_t numdim,TArrayI &hadtrue,
63 TArrayI &datasort,TArrayI &datarang,TArrayF &tclasspop,TArrayI &jinbag,
64 TArrayF &winbag,TArrayF &weight);
65
66 Int_t FindBestSplit(TArrayI &datasort,TArrayI &datarang,TArrayI &hadtrue,Int_t mdim,
67 Int_t numdata,Int_t ndstart,Int_t ndend,TArrayF &tclasspop,
68 Int_t &msplit,Float_t &decsplit,Int_t &nbest,TArrayI &ncase,
69 TArrayI &jinbag,TArrayI &iv,TArrayF &winbag,TArrayF &wr,
70 TArrayF &wc,TArrayF &wl,Int_t kbuild);
71
72 void MoveData(TArrayI &datasort,Int_t mdim,Int_t numdata,Int_t ndstart,
73 Int_t ndend,TArrayI &idmove,TArrayI &ncase,Int_t msplit,
74 Int_t nbest,Int_t &ndendl);
75
76 void BuildTree(TArrayI &datasort,TArrayI &datarang,TArrayI &hadtrue,Int_t mdim,
77 Int_t numdata,TArrayI &bestsplit,TArrayI &bestsplitnext,
78 TArrayI &nodepop,TArrayI &nodestart,TArrayF &tclasspop,
79 Int_t nrnodes,TArrayI &idmove,TArrayI &ncase,TArrayI &parent,
80 TArrayI &jinbag,TArrayI &iv,TArrayF &winbag,TArrayF &wr,TArrayF &wc,
81 TArrayF &wl,Int_t ninbag);
82
83 Double_t TreeHad(const TVector &event);
84 Double_t TreeHad();
85
86 Bool_t AsciiWrite(ostream &out) const;
87
88 ClassDef(MRanTree, 1) // Storage container for tree structure
89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.