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

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