source: trunk/MagicSoft/Mars/manalysis/MRanForest.h@ 1859

Last change on this file since 1859 was 1859, checked in by hengsteb, 22 years ago
*** empty log message ***
File size: 2.4 KB
Line 
1#ifndef MARS_MRanForest
2#define MARS_MRanForest
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_TArrayD
17#include <TArrayD.h>
18#endif
19
20#ifndef ROOT_TObjArray
21#include <TObjArray.h>
22#endif
23
24#ifndef ROOT_TRandom
25#include <TRandom.h>
26#endif
27
28#ifndef ROOT_TMatrix
29#include <TMatrix.h>
30#endif
31
32#ifndef MARS_MHMatrix
33#include "MHMatrix.h"
34#endif
35
36#ifndef MARS_MRanTree
37#include "MRanTree.h"
38#endif
39
40class MRanForest : public MParContainer
41{
42private:
43 Int_t fNumTrees;
44 Int_t fTreeNo;
45
46 TRandom fRand;
47 MRanTree *fRanTree;
48 TObjArray *fForest;
49
50 // training data
51 MHMatrix *fGammas;
52 MHMatrix *fHadrons;
53
54 Int_t fNumGam;
55 Int_t fNumHad;
56 Int_t fNumData;
57 Int_t fNumDim;
58
59 // true and estimated hadronness
60 TArrayI fHadTrue;
61 TArrayF fHadEst;
62
63 // data sorted according to parameters
64 TArrayI fDataSort;
65 TArrayI fDataRang;
66 TArrayI fClassPop;
67
68 // weights
69 Bool_t fUsePriors;
70 TArrayF fPrior;
71 TArrayF fWeight;
72 TArrayI fNTimesOutBag;
73
74 // estimates for classification error of growing forest
75 TArrayD fTreeHad;
76 Float_t fErr;
77
78 // decrease in Gini-index
79 TArrayF fGiniDec;
80
81protected:
82 // create and modify (->due to bagging) fDataSort
83 void CreateDataSort();
84 void ModifyDataSort(TArrayI &datsortinbag,Int_t ninbag,TArrayI &jinbag);
85
86public:
87 MRanForest(const char *name=NULL, const char *title=NULL);
88
89 // initialize forest
90 void SetPriors(Float_t prior_had, Float_t prior_gam);
91 void SetNumTrees(Int_t n);
92
93 // tree growing
94 void SetupForest();
95 void SetTree(MRanTree *rantree);
96 Bool_t AddTree();
97 Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam);
98 Bool_t GrowForest();
99
100 // getter methods
101 TObjArray *GetForest() { return fForest; }
102 Int_t GetNumTrees() const { return fNumTrees; }
103 Int_t GetNumData() const { return fNumData; }
104 Int_t GetNumDim() const { return fNumDim; }
105 Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
106 Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); }
107
108 // use forest to calculate hadronness of event
109 Double_t CalcHadroness(TVector &event);
110
111 Bool_t AsciiWrite(ostream &out) const;
112
113 ClassDef(MRanForest, 1) // Storage container for tree structure
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.