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

Last change on this file since 6593 was 6479, checked in by hengsteb, 20 years ago
*** empty log message ***
File size: 2.5 KB
Line 
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
36class MHMatrix;
37class MRanTree;
38class TVector;
39class TMatrix;
40
41class MRanForest : public MParContainer
42{
43private:
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 void InitHadEst(Int_t from, Int_t to, const TMatrix &m, TArrayI &jinbag);
73
74protected:
75 // create and modify (->due to bagging) fDataSort
76 void CreateDataSort();
77 void ModifyDataSort(TArrayI &datsortinbag, Int_t ninbag, const TArrayI &jinbag);
78
79public:
80 MRanForest(const char *name=NULL, const char *title=NULL);
81 ~MRanForest();
82
83 // initialize forest
84 void SetPriors(Float_t prior_had, Float_t prior_gam);
85 void SetNumTrees(Int_t n);
86
87 // tree growing
88 //void SetupForest();
89 Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam);
90 Bool_t GrowForest();
91 void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
92 Bool_t AddTree(MRanTree *rantree);
93
94 // getter methods
95 TObjArray *GetForest() { return fForest; }
96 MRanTree *GetCurTree() { return fRanTree; }
97 MRanTree *GetTree(Int_t i) { return (MRanTree*)(fForest->At(i)); }
98 MDataArray *GetRules() { return ((MRanTree*)(fForest->At(0)))->GetRules(); }
99
100
101 Int_t GetNumTrees() const { return fNumTrees; }
102 Int_t GetNumData() const;
103 Int_t GetNumDim() const;
104 Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
105
106 // use forest to calculate hadronness of event
107 Double_t CalcHadroness(const TVector &event);
108
109 Bool_t AsciiWrite(ostream &out) const;
110
111 ClassDef(MRanForest, 1) // Storage container for tree structure
112};
113
114#endif
Note: See TracBrowser for help on using the repository browser.