source: branches/Mars_MC/mranforest/MRanForest.h@ 17063

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