source: trunk/MagicSoft/Mars/manalysis/MRanForestFill.cc@ 1869

Last change on this file since 1869 was 1864, checked in by tbretz, 22 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
47static const TString gsDefName = "MRanForestFill";
48static const TString gsDefTitle = "Tree Classification Loop 1/2";
49
50// --------------------------------------------------------------------------
51//
52//
53MRanForestFill::MRanForestFill(const char *name, const char *title):fNumTrees(100)
54{
55 //
56 // set the name and title of this object
57 //
58 fName = name ? name : gsDefName.Data();
59 fTitle = title ? title : gsDefTitle.Data();
60}
61
62// --------------------------------------------------------------------------
63//
64// Delete the data chains
65//
66MRanForestFill::~MRanForestFill()
67{
68 // delete fData;
69}
70
71// --------------------------------------------------------------------------
72Bool_t MRanForestFill::PreProcess(MParList *plist)
73{
74 fRanTree = (MRanTree*)plist->FindObject("MRanTree");
75 if (!fRanTree)
76 {
77 *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
78 return kFALSE;
79 }
80
81 fRanForest = (MRanForest*)plist->FindCreateObj("MRanForest");
82 if (!fRanForest)
83 {
84 *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
85 return kFALSE;
86 }
87
88 fRanForest->SetupForest();
89 fNum=0;
90
91 return kTRUE;
92}
93
94// --------------------------------------------------------------------------
95//
96//
97Bool_t MRanForestFill::Process()
98{
99 fNum++;
100 fRanForest->SetTree(fRanTree);
101 if(!(fRanForest->AddTree()))
102 return kFALSE;
103
104 return fNum<fNumTrees;
105}
106
107Bool_t MRanForestFill::PostProcess()
108{
109 fRanForest->SetNumTrees(fNum);
110
111 return kTRUE;
112}
113
Note: See TracBrowser for help on using the repository browser.