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

Last change on this file since 2296 was 2296, 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;
31
32class MRanForest : public MParContainer
33{
34private:
35 Int_t fNumTrees;
36 Int_t fTreeNo;
37
38 MRanTree *fRanTree;
39 TObjArray *fForest;
40
41 // training data
42 MHMatrix *fGammas;
43 MHMatrix *fHadrons;
44
45 Int_t fNumGam;
46 Int_t fNumHad;
47 Int_t fNumData;
48 Int_t fNumDim;
49
50 // true and estimated hadronness
51 TArrayI fHadTrue;
52 TArrayF fHadEst;
53
54 // data sorted according to parameters
55 TArrayI fDataSort;
56 TArrayI fDataRang;
57 TArrayI fClassPop;
58
59 // weights
60 Bool_t fUsePriors;
61 TArrayF fPrior;
62 TArrayF fWeight;
63 TArrayI fNTimesOutBag;
64
65 // estimates for classification error of growing forest
66 TArrayD fTreeHad;
67
68protected:
69 // create and modify (->due to bagging) fDataSort
70 void CreateDataSort();
71 void ModifyDataSort(TArrayI &datsortinbag, Int_t ninbag, const TArrayI &jinbag);
72
73public:
74 MRanForest(const char *name=NULL, const char *title=NULL);
75 ~MRanForest();
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 Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam);
84 Bool_t GrowForest();
85 void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
86 Bool_t AddTree(MRanTree *rantree);
87
88 // getter methods
89 TObjArray *GetForest() { return fForest; }
90 MRanTree *GetCurTree() { return fRanTree; }
91 Int_t GetNumTrees() const { return fNumTrees; }
92 Int_t GetNumData() const { return fNumData; }
93 Int_t GetNumDim() const { return fNumDim; }
94 Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
95
96 // use forest to calculate hadronness of event
97 Double_t CalcHadroness(const 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.