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

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