source: branches/Corsika7500Compatibility/mranforest/MRanTree.h@ 18527

Last change on this file since 18527 was 14447, checked in by tbretz, 12 years ago
Added some missing std::
File size: 4.0 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
16#ifndef ROOT_TVector
17#include <TVector.h>
18#endif
19
20#ifndef ROOT_TMatrix
21#include <TMatrix.h>
22#endif
23
24class TMatrixRow;
25class TRandom;
26
27class MArrayI;
28class MArrayF;
29
30class MRanTree : public MParContainer
31{
32private:
33 Bool_t fClassify;
34
35 Int_t fNdSize;
36 Int_t fNumTry;
37
38 Int_t fNumNodes;
39 Int_t fNumEndNodes;
40 Float_t fError;
41
42 TArrayI fBestVar;
43 TArrayI fTreeMap1;
44 TArrayI fTreeMap2;
45 TArrayF fBestSplit;
46 TArrayF fGiniDec;
47
48 int (MRanTree::*FindBestSplit)
49 (const MArrayI &, const MArrayI &, const MArrayF &, const MArrayI &,
50 Int_t, Int_t , const MArrayF &, const Float_t &, const Float_t &, Int_t &, Float_t &,
51 Int_t &, const MArrayF &, const int); //!
52
53 Double_t TreeHad(const Float_t *evt);
54
55 int FindBestSplitGini(const MArrayI &datasort, const MArrayI &datarang,
56 const MArrayF &hadtrue, const MArrayI &idclass,
57 Int_t ndstart, Int_t ndend, const MArrayF &tclasspop,
58 const Float_t &mean, const Float_t &square, Int_t &msplit,
59 Float_t &decsplit, Int_t &nbest, const MArrayF &winbag,
60 const int nclass);
61
62 int FindBestSplitSigma(const MArrayI &datasort, const MArrayI &datarang,
63 const MArrayF &hadtrue, const MArrayI &idclass,
64 Int_t ndstart, Int_t ndend, const MArrayF &tclasspop,
65 const Float_t &mean, const Float_t &square, Int_t &msplit,
66 Float_t &decsplit, Int_t &nbest, const MArrayF &winbag,
67 const int nclass);
68
69 void MoveData(MArrayI &datasort, Int_t ndstart, Int_t ndend,
70 MArrayI &idmove, MArrayI &ncase, Int_t msplit,
71 Int_t nbest, Int_t &ndendl);
72
73 void BuildTree(MArrayI &datasort, const MArrayI &datarang, const MArrayF &hadtrue,
74 const MArrayI &idclass,MArrayI &bestsplit,MArrayI &bestsplitnext,
75 const MArrayF &tclasspop, const Float_t &tmean, const Float_t &tsquare, const MArrayF &winbag,
76 Int_t ninbag, const int nclass);
77
78public:
79 MRanTree(const char *name=NULL, const char *title=NULL);
80 MRanTree(const MRanTree &tree);
81
82 void SetNdSize(Int_t n);
83 void SetNumTry(Int_t n);
84 void SetError(Float_t f) { fError = f; }
85
86 Int_t GetNdSize() const { return fNdSize; }
87 Int_t GetNumTry() const { return fNumTry; }
88 Int_t GetNumNodes() const { return fNumNodes; }
89 Int_t GetNumEndNodes() const { return fNumEndNodes; }
90 Int_t IsClassify() const { return fClassify; }
91 Float_t GetError() const { return fError; }
92
93 Int_t GetBestVar(Int_t i) const { return fBestVar.At(i); }
94 Int_t GetTreeMap1(Int_t i) const { return fTreeMap1.At(i); }
95 Int_t GetTreeMap2(Int_t i) const { return fTreeMap2.At(i); }
96 Int_t GetNodeClass(Int_t i) const { return fBestVar.At(i)+2; }
97 Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
98 Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
99
100 Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); }
101
102 void SetClassify(Bool_t n){ fClassify=n; }
103
104 // functions used in tree growing process
105 void GrowTree(TMatrix *mat, const MArrayF &hadtrue, const MArrayI &idclass,
106 MArrayI &datasort, const MArrayI &datarang,const MArrayF &tclasspop,
107 const Float_t &mean, const Float_t &square, const MArrayI &jinbag, const MArrayF &winbag,
108 const int nclass);
109
110 Double_t TreeHad(const TVector &event);
111 Double_t TreeHad(const TMatrixFRow_const &event);
112 Double_t TreeHad(const TMatrix &m, Int_t ievt);
113
114 Bool_t AsciiWrite(std::ostream &out) const;
115
116 ClassDef(MRanTree, 1) // Storage container for tree structure
117};
118
119#endif
Note: See TracBrowser for help on using the repository browser.