| 1 | /* ======================================================================== *\
 | 
|---|
| 2 | !
 | 
|---|
| 3 | ! *
 | 
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
 | 
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
 | 
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
 | 
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
 | 
|---|
| 8 | ! *
 | 
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
 | 
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
 | 
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
 | 
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
 | 
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
 | 
|---|
| 14 | ! * or implied warranty.
 | 
|---|
| 15 | ! *
 | 
|---|
| 16 | !
 | 
|---|
| 17 | !
 | 
|---|
| 18 | !   Author(s): Thomas Hengstebeck 3/2003 <mailto:hengsteb@physik.hu-berlin.de>
 | 
|---|
| 19 | !
 | 
|---|
| 20 | !   Copyright: MAGIC Software Development, 2000-2005
 | 
|---|
| 21 | !
 | 
|---|
| 22 | !
 | 
|---|
| 23 | \* ======================================================================== */
 | 
|---|
| 24 | 
 | 
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 26 | //
 | 
|---|
| 27 | //  MRanForestGrow
 | 
|---|
| 28 | //
 | 
|---|
| 29 | //  Grows a random forest.
 | 
|---|
| 30 | //
 | 
|---|
| 31 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 32 | #include "MRanForestGrow.h"
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #include "MHMatrix.h" // must be before MLogManip.h
 | 
|---|
| 35 | 
 | 
|---|
| 36 | #include "MLog.h"
 | 
|---|
| 37 | #include "MLogManip.h"
 | 
|---|
| 38 | 
 | 
|---|
| 39 | #include "MParList.h"
 | 
|---|
| 40 | #include "MRanForest.h"
 | 
|---|
| 41 | 
 | 
|---|
| 42 | ClassImp(MRanForestGrow);
 | 
|---|
| 43 | 
 | 
|---|
| 44 | using namespace std;
 | 
|---|
| 45 | 
 | 
|---|
| 46 | const TString MRanForestGrow::gsDefName  = "MRead";
 | 
|---|
| 47 | const TString MRanForestGrow::gsDefTitle = "Task to train a random forst";
 | 
|---|
| 48 | 
 | 
|---|
| 49 | MRanForestGrow::MRanForestGrow(const char *name, const char *title)
 | 
|---|
| 50 | {
 | 
|---|
| 51 |     //   set the name and title of this object
 | 
|---|
| 52 | 
 | 
|---|
| 53 |     fName  = name  ? name  : gsDefName.Data();
 | 
|---|
| 54 |     fTitle = title ? title : gsDefTitle.Data();
 | 
|---|
| 55 | 
 | 
|---|
| 56 |     //     SetNumTrees();
 | 
|---|
| 57 |     //     SetNumTry();
 | 
|---|
| 58 |     //     SetNdSize();
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | Int_t MRanForestGrow::PreProcess(MParList *plist)
 | 
|---|
| 62 | {
 | 
|---|
| 63 |     fMatrix = (MHMatrix*)plist->FindObject("MatrixTrain", "MHMatrix");
 | 
|---|
| 64 |     if (!fMatrix)
 | 
|---|
| 65 |     {
 | 
|---|
| 66 |         *fLog << err << dbginf << "MatrixTrain [MHMatrix] not found... aborting." << endl;
 | 
|---|
| 67 |         return kFALSE;
 | 
|---|
| 68 |     }
 | 
|---|
| 69 | 
 | 
|---|
| 70 |     fRanForest = (MRanForest*)plist->FindCreateObj("MRanForest");
 | 
|---|
| 71 |     if (!fRanForest)
 | 
|---|
| 72 |     {
 | 
|---|
| 73 |         *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
 | 
|---|
| 74 |         return kFALSE;
 | 
|---|
| 75 |     }
 | 
|---|
| 76 | 
 | 
|---|
| 77 |     //     fRanForest->SetNumTry(fNumTry);
 | 
|---|
| 78 |     //     fRanForest->SetNdSize(fNdSize);
 | 
|---|
| 79 |     //     fRanForest->SetNumTrees(fNumTrees);
 | 
|---|
| 80 | 
 | 
|---|
| 81 |     return fRanForest->SetupGrow(fMatrix,plist);
 | 
|---|
| 82 | }
 | 
|---|
| 83 | 
 | 
|---|
| 84 | Int_t MRanForestGrow::Process()
 | 
|---|
| 85 | {
 | 
|---|
| 86 |     return fRanForest->GrowForest();
 | 
|---|
| 87 | }
 | 
|---|
| 88 | 
 | 
|---|
| 89 | Int_t MRanForestGrow::PostProcess()
 | 
|---|
| 90 | {
 | 
|---|
| 91 |     fRanForest->SetReadyToSave();
 | 
|---|
| 92 | 
 | 
|---|
| 93 |     return kTRUE;
 | 
|---|
| 94 | }
 | 
|---|