1 | #ifndef MARS_MRanForest
|
---|
2 | #define MARS_MRanForest
|
---|
3 |
|
---|
4 | #ifndef MARS_MParContainer
|
---|
5 | #include "MParContainer.h"
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #ifndef MARS_MRanTree
|
---|
9 | #include "MRanTree.h"
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #ifndef MARS_MDataArray
|
---|
13 | #include "MDataArray.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_TArrayD
|
---|
25 | #include <TArrayD.h>
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #ifndef ROOT_TObjArray
|
---|
29 | #include <TObjArray.h>
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #ifndef ROOT_TRandom
|
---|
33 | #include <TRandom.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | class MHMatrix;
|
---|
37 | class MRanTree;
|
---|
38 | class TVector;
|
---|
39 | class TMatrix;
|
---|
40 |
|
---|
41 | class MRanForest : public MParContainer
|
---|
42 | {
|
---|
43 | private:
|
---|
44 | Int_t fNumTrees;
|
---|
45 | Int_t fTreeNo; //!
|
---|
46 |
|
---|
47 | MRanTree *fRanTree; //!
|
---|
48 | TObjArray *fForest;
|
---|
49 |
|
---|
50 | // training data
|
---|
51 | MHMatrix *fGammas; //!
|
---|
52 | MHMatrix *fHadrons; //!
|
---|
53 |
|
---|
54 | // true and estimated hadronness
|
---|
55 | TArrayI fHadTrue; //!
|
---|
56 | TArrayF fHadEst; //!
|
---|
57 |
|
---|
58 | // data sorted according to parameters
|
---|
59 | TArrayI fDataSort; //!
|
---|
60 | TArrayI fDataRang; //!
|
---|
61 | TArrayI fClassPop; //!
|
---|
62 |
|
---|
63 | // weights
|
---|
64 | Bool_t fUsePriors; //!
|
---|
65 | TArrayF fPrior; //!
|
---|
66 | TArrayF fWeight; //!
|
---|
67 | TArrayI fNTimesOutBag;//!
|
---|
68 |
|
---|
69 | // estimates for classification error of growing forest
|
---|
70 | TArrayD fTreeHad; //
|
---|
71 |
|
---|
72 | Double_t fUserVal;
|
---|
73 |
|
---|
74 | void InitHadEst(Int_t from, Int_t to, const TMatrix &m, TArrayI &jinbag);
|
---|
75 |
|
---|
76 | protected:
|
---|
77 | // create and modify (->due to bagging) fDataSort
|
---|
78 | void CreateDataSort();
|
---|
79 | void ModifyDataSort(TArrayI &datsortinbag, Int_t ninbag, const TArrayI &jinbag);
|
---|
80 |
|
---|
81 | public:
|
---|
82 | MRanForest(const char *name=NULL, const char *title=NULL);
|
---|
83 | ~MRanForest();
|
---|
84 |
|
---|
85 | // initialize forest
|
---|
86 | void SetPriors(Float_t prior_had, Float_t prior_gam);
|
---|
87 | void SetNumTrees(Int_t n);
|
---|
88 |
|
---|
89 | // tree growing
|
---|
90 | //void SetupForest();
|
---|
91 | Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam);
|
---|
92 | Bool_t GrowForest();
|
---|
93 | void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
|
---|
94 | Bool_t AddTree(MRanTree *rantree);
|
---|
95 | void SetUserVal(Double_t d) { fUserVal = d; }
|
---|
96 |
|
---|
97 | // getter methods
|
---|
98 | TObjArray *GetForest() { return fForest; }
|
---|
99 | MRanTree *GetCurTree() { return fRanTree; }
|
---|
100 | MRanTree *GetTree(Int_t i) { return (MRanTree*)(fForest->At(i)); }
|
---|
101 | MDataArray *GetRules() { return ((MRanTree*)(fForest->At(0)))->GetRules(); }
|
---|
102 |
|
---|
103 | Int_t GetNumTrees() const { return fNumTrees; }
|
---|
104 | Int_t GetNumData() const;
|
---|
105 | Int_t GetNumDim() const;
|
---|
106 | Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
|
---|
107 | Double_t GetUserVal() const { return fUserVal; }
|
---|
108 |
|
---|
109 | // use forest to calculate hadronness of event
|
---|
110 | Double_t CalcHadroness(const TVector &event);
|
---|
111 |
|
---|
112 | Bool_t AsciiWrite(ostream &out) const;
|
---|
113 |
|
---|
114 | ClassDef(MRanForest, 2) // Storage container for tree structure
|
---|
115 | };
|
---|
116 |
|
---|
117 | #endif
|
---|