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

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