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

Last change on this file since 7693 was 7693, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 3.1 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
20class TMatrix;
21class TVector;
22class TObjArray;
23
24class MArrayI;
25class MArrayF;
26
27class MRanTree;
28class MDataArray;
29class MHMatrix;
30class MParList;
31
32class MRanForest : public MParContainer
33{
34private:
35 Bool_t fClassify;
36
37 Int_t fNumTrees; // Number of trees
38 Int_t fNumTry; // Number of tries
39 Int_t fNdSize; // Size of node
40
41 Int_t fTreeNo; //! Number of tree
42
43 MRanTree *fRanTree; //! Pointer to some tree
44 MDataArray *fRules; //! Pointer to corresponding rules
45 TObjArray *fForest; // Array containing forest
46
47 // training data
48 TMatrix *fMatrix; //!
49
50 // true and estimated hadronness
51 TArrayI fClass; //!
52 TArrayD fGrid; //!
53 TArrayF fHadTrue; //!
54 TArrayF fHadEst; //!
55
56 // data sorted according to parameters
57 TArrayI fDataSort; //!
58 TArrayI fDataRang; //!
59 TArrayI fClassPop; //!
60
61 // weights
62 TArrayF fWeight; //!
63 TArrayI fNTimesOutBag; //!
64
65 // estimates for classification error of growing forest
66 TArrayD fTreeHad; //! Hadronness values (buffer for MHRanForest)
67
68 Double_t fUserVal; // A user value describing this tree (eg E-mc)
69
70protected:
71 // create and modify (->due to bagging) fDataSort
72 Bool_t CreateDataSort();
73 void ModifyDataSort(MArrayI &datsortinbag, const MArrayI &jinbag);
74
75public:
76 MRanForest(const char *name=NULL, const char *title=NULL);
77 MRanForest(const MRanForest &rf);
78 ~MRanForest();
79
80 void Print(Option_t *o="") const; //*MENU*
81
82 void SetGrid(const TArrayD &grid);
83 void SetWeights(const TArrayF &weights);
84 void SetNumTrees(Int_t n);
85
86 void SetNumTry(Int_t n);
87 void SetNdSize(Int_t n);
88
89 void SetClassify(Bool_t n){ fClassify=n; }
90 void PrepareClasses();
91
92 // tree growing
93 Bool_t SetupGrow(MHMatrix *mat,MParList *plist);
94 Bool_t GrowForest();
95 void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
96 Bool_t AddTree(MRanTree *rantree);
97 void SetUserVal(Double_t d) { fUserVal = d; }
98
99 // getter methods
100 TObjArray *GetForest() const { return fForest; }
101 MRanTree *GetCurTree() const { return fRanTree; }
102 MRanTree *GetTree(Int_t i) const;
103 MDataArray *GetRules() const { return fRules; }
104
105
106 Int_t GetNumTrees() const { return fNumTrees; }
107 Int_t GetNumData() const;
108 Int_t GetNumDim() const;
109 Int_t GetNdSize() const { return fNdSize; }
110 Int_t GetNclass() const;
111 Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
112 Double_t GetUserVal() const { return fUserVal; }
113 Bool_t IsClassify() const { return fClassify; }
114
115 // use forest to calculate hadronness of event
116 Double_t CalcHadroness(const TVector &event);
117 Double_t CalcHadroness();
118
119 Bool_t AsciiWrite(ostream &out) const;
120
121 ClassDef(MRanForest, 1) // Storage container for tree structure
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.