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

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