1 | #ifndef MARS_MRanTree
|
---|
2 | #define MARS_MRanTree
|
---|
3 |
|
---|
4 | #ifndef MARS_MParContainer
|
---|
5 | #include "MParContainer.h"
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #ifndef MARS_MDataArray
|
---|
9 | #include "MDataArray.h"
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #ifndef ROOT_TRandom
|
---|
13 | #include <TRandom.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #ifndef ROOT_TArrayI
|
---|
17 | #include <TArrayI.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #ifndef ROOT_TArrayF
|
---|
21 | #include <TArrayF.h>
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #ifndef ROOT_TMatrix
|
---|
25 | #include <TMatrix.h>
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #ifndef ROOT_TVector
|
---|
29 | #include <TVector.h>
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | class MRanTree : public MParContainer
|
---|
33 | {
|
---|
34 | private:
|
---|
35 | Int_t fNdSize;
|
---|
36 | Int_t fNumTry;
|
---|
37 |
|
---|
38 | Int_t fNumNodes;
|
---|
39 | Int_t fNumEndNodes;
|
---|
40 | MDataArray *fData;
|
---|
41 |
|
---|
42 | TArrayI fBestVar;
|
---|
43 | TArrayI fTreeMap1;
|
---|
44 | TArrayI fTreeMap2;
|
---|
45 | TArrayF fBestSplit;
|
---|
46 |
|
---|
47 | public:
|
---|
48 | MRanTree(const char *name=NULL, const char *title=NULL);
|
---|
49 |
|
---|
50 | void SetNdSize(Int_t n);
|
---|
51 | void SetNumTry(Int_t n);
|
---|
52 | void SetRules(MDataArray *rules);
|
---|
53 |
|
---|
54 | MDataArray *GetData() { return fData;}
|
---|
55 |
|
---|
56 | Int_t GetNdSize() const { return fNdSize; }
|
---|
57 | Int_t GetNumTry() const { return fNumTry; }
|
---|
58 | Int_t GetNumNodes() const { return fNumNodes; }
|
---|
59 | Int_t GetNumEndNodes() const { return fNumEndNodes; }
|
---|
60 |
|
---|
61 | Int_t GetBestVar(Int_t i) const { return fBestVar.At(i); }
|
---|
62 | Int_t GetTreeMap1(Int_t i) const { return fTreeMap1.At(i); }
|
---|
63 | Int_t GetTreeMap2(Int_t i) const { return fTreeMap2.At(i); }
|
---|
64 | Int_t GetNodeClass(Int_t i) const { return fBestVar.At(i)+2; }
|
---|
65 | Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
|
---|
66 | Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
|
---|
67 |
|
---|
68 | // functions used in tree growing process
|
---|
69 | void GrowTree(TMatrix &mhad,TMatrix &mgam,Int_t numdata, Int_t numdim,TArrayI &hadtrue,
|
---|
70 | TArrayI &datasort,TArrayI &datarang,TArrayF &ginidec,TArrayF &classpopw,
|
---|
71 | TArrayI &jinbag,TArrayF &winbag,TArrayF &weight,TRandom &rand);
|
---|
72 |
|
---|
73 | Int_t FindBestSplit(TArrayI &datasort,TArrayI &datarang,TArrayI &hadtrue,Int_t mdim,
|
---|
74 | Int_t numdata,Int_t ndstart,Int_t ndend,TArrayF &tclasspop,
|
---|
75 | Int_t &msplit,Float_t &decsplit,Int_t &nbest,TArrayI &ncase,
|
---|
76 | TArrayI &jinbag,TArrayI &iv,TArrayF &winbag,TArrayF &wr,
|
---|
77 | TArrayF &wc,TArrayF &wl,Int_t kbuild,TRandom &rand);
|
---|
78 |
|
---|
79 | void MoveData(TArrayI &datasort,Int_t mdim,Int_t numdata,Int_t ndstart,
|
---|
80 | Int_t ndend,TArrayI &idmove,TArrayI &ncase,Int_t msplit,
|
---|
81 | Int_t nbest,Int_t &ndendl);
|
---|
82 |
|
---|
83 | void BuildTree(TArrayI &datasort,TArrayI &datarang,TArrayI &hadtrue,Int_t mdim,
|
---|
84 | Int_t numdata,TArrayI &bestsplit,TArrayI &bestsplitnext,
|
---|
85 | TArrayF &ginidec,TArrayI &nodepop,TArrayI &nodestart,TArrayF &tclasspop,
|
---|
86 | Int_t nrnodes,TArrayI &idmove,TArrayI &ncase,TArrayI &parent,
|
---|
87 | TArrayI &jinbag,TArrayI &iv,TArrayF &winbag,TArrayF &wr,TArrayF &wc,
|
---|
88 | TArrayF &wl,Int_t ninbag,TRandom &rand);
|
---|
89 |
|
---|
90 | Double_t TreeHad(TVector &event);
|
---|
91 | Double_t TreeHad();
|
---|
92 |
|
---|
93 | Bool_t AsciiWrite(ostream &out) const;
|
---|
94 |
|
---|
95 | ClassDef(MRanTree, 1) // Storage container for tree structure
|
---|
96 | };
|
---|
97 |
|
---|
98 | #endif
|
---|