#ifndef MARS_MRanForest #define MARS_MRanForest #ifndef MARS_MParContainer #include "MParContainer.h" #endif #ifndef ROOT_TArrayI #include #endif #ifndef ROOT_TArrayF #include #endif #ifndef ROOT_TArrayD #include #endif #ifndef ROOT_TObjArray #include #endif #ifndef ROOT_TRandom #include #endif #ifndef ROOT_TMatrix #include #endif #ifndef MARS_MHMatrix #include "MHMatrix.h" #endif #ifndef MARS_MRanTree #include "MRanTree.h" #endif class MRanForest : public MParContainer { private: Int_t fNumTrees; Int_t fTreeNo; TRandom fRand; MRanTree *fRanTree; TObjArray *fForest; // training data MHMatrix *fGammas; MHMatrix *fHadrons; Int_t fNumGam; Int_t fNumHad; Int_t fNumData; Int_t fNumDim; // true and estimated hadronness TArrayI fHadTrue; TArrayF fHadEst; // data sorted according to parameters TArrayI fDataSort; TArrayI fDataRang; TArrayI fClassPop; // weights Bool_t fUsePriors; TArrayF fPrior; TArrayF fWeight; TArrayI fNTimesOutBag; // estimates for classification error of growing forest TArrayD fTreeHad; Float_t fErr; // decrease in Gini-index TArrayF fGiniDec; protected: // create and modify (->due to bagging) fDataSort void CreateDataSort(); void ModifyDataSort(TArrayI &datsortinbag,Int_t ninbag,TArrayI &jinbag); public: MRanForest(const char *name=NULL, const char *title=NULL); // initialize forest void SetPriors(Float_t prior_had, Float_t prior_gam); void SetNumTrees(Int_t n); // tree growing void SetupForest(); void SetTree(MRanTree *rantree); Bool_t AddTree(); Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam); Bool_t GrowForest(); // getter methods TObjArray *GetForest() { return fForest; } Int_t GetNumTrees() const { return fNumTrees; } Int_t GetNumData() const { return fNumData; } Int_t GetNumDim() const { return fNumDim; } Double_t GetTreeHad(Int_t i) const { return fTreeHad.At(i); } Float_t GetGiniDec(Int_t i) const { return fGiniDec.At(i); } // use forest to calculate hadronness of event Double_t CalcHadroness(TVector &event); Bool_t AsciiWrite(ostream &out) const; ClassDef(MRanForest, 1) // Storage container for tree structure }; #endif