| 1 | #ifndef MARS_MRanTree
 | 
|---|
| 2 | #define MARS_MRanTree
 | 
|---|
| 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 | class TMatrix;
 | 
|---|
| 17 | class TVector;
 | 
|---|
| 18 | class TRandom;
 | 
|---|
| 19 | class MDataArray;
 | 
|---|
| 20 | 
 | 
|---|
| 21 | class MRanTree : public MParContainer
 | 
|---|
| 22 | {
 | 
|---|
| 23 | private:
 | 
|---|
| 24 |     Int_t fNdSize;
 | 
|---|
| 25 |     Int_t fNumTry;
 | 
|---|
| 26 | 
 | 
|---|
| 27 |     Int_t fNumNodes;
 | 
|---|
| 28 |     Int_t fNumEndNodes;
 | 
|---|
| 29 |     MDataArray *fData;
 | 
|---|
| 30 | 
 | 
|---|
| 31 |     TArrayI fBestVar;
 | 
|---|
| 32 |     TArrayI fTreeMap1; 
 | 
|---|
| 33 |     TArrayI fTreeMap2; 
 | 
|---|
| 34 |     TArrayF fBestSplit;
 | 
|---|
| 35 | 
 | 
|---|
| 36 | public:
 | 
|---|
| 37 |     MRanTree(const char *name=NULL, const char *title=NULL);
 | 
|---|
| 38 | 
 | 
|---|
| 39 |     void SetNdSize(Int_t n);
 | 
|---|
| 40 |     void SetNumTry(Int_t n);
 | 
|---|
| 41 |     void SetRules(MDataArray *rules);
 | 
|---|
| 42 | 
 | 
|---|
| 43 |     MDataArray *GetData() { return fData;}
 | 
|---|
| 44 | 
 | 
|---|
| 45 |     Int_t GetNdSize() const { return fNdSize; }
 | 
|---|
| 46 |     Int_t GetNumTry() const { return fNumTry; }
 | 
|---|
| 47 |     Int_t GetNumNodes()          const { return fNumNodes; }
 | 
|---|
| 48 |     Int_t GetNumEndNodes()       const { return fNumEndNodes; }
 | 
|---|
| 49 | 
 | 
|---|
| 50 |     Int_t GetBestVar(Int_t i)    const { return fBestVar.At(i); }
 | 
|---|
| 51 |     Int_t GetTreeMap1(Int_t i)   const { return fTreeMap1.At(i); }
 | 
|---|
| 52 |     Int_t GetTreeMap2(Int_t i)   const { return fTreeMap2.At(i); }
 | 
|---|
| 53 |     Int_t GetNodeClass(Int_t i)  const { return fBestVar.At(i)+2; }
 | 
|---|
| 54 |     Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
 | 
|---|
| 55 |     Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
 | 
|---|
| 56 | 
 | 
|---|
| 57 |     // functions used in tree growing process
 | 
|---|
| 58 |     void GrowTree(TMatrix &mhad,TMatrix &mgam,Int_t numdata, Int_t numdim,TArrayI &hadtrue,
 | 
|---|
| 59 |                   TArrayI &datasort,TArrayI &datarang,TArrayF &ginidec,TArrayF &classpopw,
 | 
|---|
| 60 |                   TArrayI &jinbag,TArrayF &winbag,TArrayF &weight,TRandom &rand);
 | 
|---|
| 61 | 
 | 
|---|
| 62 |     Int_t FindBestSplit(TArrayI &datasort,TArrayI &datarang,TArrayI &hadtrue,Int_t mdim,
 | 
|---|
| 63 |                         Int_t numdata,Int_t ndstart,Int_t ndend,TArrayF &tclasspop,
 | 
|---|
| 64 |                         Int_t &msplit,Float_t &decsplit,Int_t &nbest,TArrayI &ncase,
 | 
|---|
| 65 |                         TArrayI &jinbag,TArrayI &iv,TArrayF &winbag,TArrayF &wr,
 | 
|---|
| 66 |                         TArrayF &wc,TArrayF &wl,Int_t kbuild,TRandom &rand);
 | 
|---|
| 67 | 
 | 
|---|
| 68 |     void MoveData(TArrayI &datasort,Int_t mdim,Int_t numdata,Int_t ndstart,
 | 
|---|
| 69 |                   Int_t ndend,TArrayI &idmove,TArrayI &ncase,Int_t msplit,
 | 
|---|
| 70 |                   Int_t nbest,Int_t &ndendl);
 | 
|---|
| 71 | 
 | 
|---|
| 72 |     void BuildTree(TArrayI &datasort,TArrayI &datarang,TArrayI &hadtrue,Int_t mdim,
 | 
|---|
| 73 |                    Int_t numdata,TArrayI &bestsplit,TArrayI &bestsplitnext,
 | 
|---|
| 74 |                    TArrayF &ginidec,TArrayI &nodepop,TArrayI &nodestart,TArrayF &tclasspop,
 | 
|---|
| 75 |                    Int_t nrnodes,TArrayI &idmove,TArrayI &ncase,TArrayI &parent,
 | 
|---|
| 76 |                    TArrayI &jinbag,TArrayI &iv,TArrayF &winbag,TArrayF &wr,TArrayF &wc,
 | 
|---|
| 77 |                    TArrayF &wl,Int_t ninbag,TRandom &rand);
 | 
|---|
| 78 | 
 | 
|---|
| 79 |     Double_t TreeHad(TVector &event);
 | 
|---|
| 80 |     Double_t TreeHad();
 | 
|---|
| 81 | 
 | 
|---|
| 82 |     Bool_t AsciiWrite(ostream &out) const;
 | 
|---|
| 83 | 
 | 
|---|
| 84 |     ClassDef(MRanTree, 1) // Storage container for tree structure
 | 
|---|
| 85 | };
 | 
|---|
| 86 | 
 | 
|---|
| 87 | #endif
 | 
|---|