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

Last change on this file since 2302 was 2297, checked in by tbretz, 22 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
39public:
40 MRanTree(const char *name=NULL, const char *title=NULL);
41
42 void SetNdSize(Int_t n);
43 void SetNumTry(Int_t n);
44 void SetRules(MDataArray *rules);
45
46 MDataArray *GetRules() { return fData;}
47
48 Int_t GetNdSize() const { return fNdSize; }
49 Int_t GetNumTry() const { return fNumTry; }
50 Int_t GetNumNodes() const { return fNumNodes; }
51 Int_t GetNumEndNodes() const { return fNumEndNodes; }
52
53 Int_t GetBestVar(Int_t i) const { return fBestVar.At(i); }
54 Int_t GetTreeMap1(Int_t i) const { return fTreeMap1.At(i); }
55 Int_t GetTreeMap2(Int_t i) const { return fTreeMap2.At(i); }
56 Int_t GetNodeClass(Int_t i) const { return fBestVar.At(i)+2; }
57 Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
58 Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
59
60 Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); }
61
62 // functions used in tree growing process
63 void GrowTree(const TMatrix &mhad, const TMatrix &mgam,
64 const TArrayI &hadtrue, TArrayI &datasort,
65 const TArrayI &datarang,
66 TArrayF &tclasspop, TArrayI &jinbag, const TArrayF &winbag);
67
68 Int_t FindBestSplit(const TArrayI &datasort, const TArrayI &datarang,
69 const TArrayI &hadtrue,
70 Int_t ndstart, Int_t ndend, TArrayF &tclasspop,
71 Int_t &msplit, Float_t &decsplit, Int_t &nbest,
72 const TArrayF &winbag);
73
74 void MoveData(TArrayI &datasort, Int_t ndstart, Int_t ndend,
75 TArrayI &idmove, TArrayI &ncase, Int_t msplit,
76 Int_t nbest, Int_t &ndendl);
77
78 void BuildTree(TArrayI &datasort, const TArrayI &datarang,
79 const TArrayI &hadtrue,
80 TArrayI &bestsplit,TArrayI &bestsplitnext,
81 TArrayF &tclasspop,
82 const TArrayF &winbag,
83 Int_t ninbag);
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.