source: trunk/Mars/mranforest/MRanForestFill.cc@ 19344

Last change on this file since 19344 was 2297, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.0 KB
Line 
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@alwa02.physik.uni-siegen.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MRanForestFill
28//
29// Calculates the hadroness of an event. It calculates a mean value of all
30// classifications by the trees in a previously grown random forest.
31//
32// To use only n trees for your calculation use:
33// MRanForestFill::SetUseNumTrees(n);
34//
35////////////////////////////////////////////////////////////////////////////
36#include "MRanForestFill.h"
37
38#include "MLog.h"
39#include "MLogManip.h"
40
41#include "MParList.h"
42
43#include "MRanForest.h"
44
45ClassImp(MRanForestFill);
46
47using namespace std;
48
49static const TString gsDefName = "MRanForestFill";
50static const TString gsDefTitle = "Tree Classification Loop";
51
52// --------------------------------------------------------------------------
53//
54//
55MRanForestFill::MRanForestFill(const char *name, const char *title):fNumTrees(-1)
56{
57 //
58 // set the name and title of this object
59 //
60 fName = name ? name : gsDefName.Data();
61 fTitle = title ? title : gsDefTitle.Data();
62}
63
64// --------------------------------------------------------------------------
65//
66// Delete the data chains
67//
68MRanForestFill::~MRanForestFill()
69{
70 // delete fData;
71}
72
73// --------------------------------------------------------------------------
74Int_t MRanForestFill::PreProcess(MParList *plist)
75{
76 fRanTree = (MRanTree*)plist->FindObject("MRanTree");
77 if (!fRanTree)
78 {
79 *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
80 return kFALSE;
81 }
82
83 fRanForest = (MRanForest*)plist->FindCreateObj("MRanForest");
84 if (!fRanForest)
85 {
86 *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
87 return kFALSE;
88 }
89
90 fNum=0;
91
92 return kTRUE;
93}
94
95// --------------------------------------------------------------------------
96//
97//
98Int_t MRanForestFill::Process()
99{
100 if (!(fRanForest->AddTree(fRanTree)))
101 return kFALSE;
102
103 fNum++;
104
105 return fNumTrees<0 ? kTRUE : fNum<fNumTrees;
106}
107
108Int_t MRanForestFill::PostProcess()
109{
110 fRanForest->SetNumTrees(fNum);
111 return kTRUE;
112}
113
Note: See TracBrowser for help on using the repository browser.