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

Last change on this file since 1884 was 1870, checked in by hengsteb, 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";
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 fNum=0;
89
90 return kTRUE;
91}
92
93// --------------------------------------------------------------------------
94//
95//
96Bool_t MRanForestFill::Process()
97{
98 fNum++;
99 if(!(fRanForest->AddTree(fRanTree)))
100 return kFALSE;
101
102 return fNum<fNumTrees;
103}
104
105Bool_t MRanForestFill::PostProcess()
106{
107 fRanForest->SetNumTrees(fNum);
108
109 return kTRUE;
110}
111
Note: See TracBrowser for help on using the repository browser.