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

Last change on this file since 1915 was 1870, checked in by hengsteb, 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_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 Float_t fErr;
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 ~MRanForest();
77
78 // initialize forest
79 void SetPriors(Float_t prior_had, Float_t prior_gam);
80 void SetNumTrees(Int_t n);
81
82 // tree growing
83 //void SetupForest();
84 Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam);
85 Bool_t GrowForest();
86 void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
87 Bool_t AddTree(MRanTree *rantree);
88
89 // getter methods
90 TObjArray *GetForest() { return fForest; }
91 MRanTree *GetCurTree() { return fRanTree; }
92 Int_t GetNumTrees() const { return fNumTrees; }
93 Int_t GetNumData() const { return fNumData; }
94 Int_t GetNumDim() const { return fNumDim; }
95 Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
96
97 // use forest to calculate hadronness of event
98 Double_t CalcHadroness(TVector &event);
99
100 Bool_t AsciiWrite(ostream &out) const;
101
102 ClassDef(MRanForest, 1) // Storage container for tree structure
103};
104
105#endif
Note: See TracBrowser for help on using the repository browser.