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

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