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

Last change on this file since 7419 was 7396, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 2.9 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 Int_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
76 ~MRanForest();
77
78 void SetGrid(const TArrayD &grid);
79 void SetWeights(const TArrayF &weights);
80 void SetNumTrees(Int_t n);
81
82 void SetNumTry(Int_t n);
83 void SetNdSize(Int_t n);
84
85 void SetClassify(Int_t n){ fClassify=n; }
86 void PrepareClasses();
87
88 // tree growing
89 Bool_t SetupGrow(MHMatrix *mat,MParList *plist);
90 Bool_t GrowForest();
91 void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
92 Bool_t AddTree(MRanTree *rantree);
93 void SetUserVal(Double_t d) { fUserVal = d; }
94
95 // getter methods
96 TObjArray *GetForest() { return fForest; }
97 MRanTree *GetCurTree() { return fRanTree; }
98 MRanTree *GetTree(Int_t i);
99 MDataArray *GetRules() { return fRules; }
100
101
102 Int_t GetNumTrees() const { return fNumTrees; }
103 Int_t GetNumData() const;
104 Int_t GetNumDim() const;
105 Int_t GetNclass() const;
106 Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
107 Double_t GetUserVal() const { return fUserVal; }
108
109 // use forest to calculate hadronness of event
110 Double_t CalcHadroness(const TVector &event);
111 Double_t CalcHadroness();
112
113 Bool_t AsciiWrite(ostream &out) const;
114
115 ClassDef(MRanForest, 1) // Storage container for tree structure
116};
117
118#endif
Note: See TracBrowser for help on using the repository browser.