source: trunk/MagicSoft/Mars/mranforest/MRanForest.h@ 2297

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