source: trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc@ 7650

Last change on this file since 7650 was 7421, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 2.9 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 Bretz 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2005
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MJTrainRanForest
28//
29// Base class for classes training a random forest
30//
31/////////////////////////////////////////////////////////////////////////////
32#include "MJTrainRanForest.h"
33
34#include "MLog.h"
35#include "MLogManip.h"
36
37#include "MStatusDisplay.h"
38
39#include "MF.h"
40
41ClassImp(MJTrainRanForest);
42
43using namespace std;
44
45//------------------------------------------------------------------------
46//
47// Add a cut which is used to fill the matrix, eg "MMcEvt.fOartId<1.5"
48// (The rule is applied, nit inverted: The matrix is filled with
49// the events fullfilling the condition)
50//
51void MJTrainRanForest::AddCut(TList &l, const char *rule)
52{
53 MFilter *f = new MF(rule);
54 f->SetBit(kCanDelete);
55 AddCut(l, f);
56}
57
58//------------------------------------------------------------------------
59//
60// Add a cut which is used to fill the matrix. If kCanDelete is set
61// MJOptimize takes the ownership.
62//
63void MJTrainRanForest::AddCut(TList &l, MFilter *f)
64{
65 l.Add(f);
66}
67
68//------------------------------------------------------------------------
69//
70// Add a parameter used in your filters (see AddFilter) The parameter
71// index is returned,
72//
73// Int_t idx = AddParameter("log10(MHillas.fSize)");
74//
75// The indices area starting with 0 always.
76//
77Int_t MJTrainRanForest::AddParameter(const char *rule)
78{
79 fRules.Add(new TNamed(rule, ""));
80 return fRules.GetSize()-1;
81}
82
83Bool_t MJTrainRanForest::WriteDisplay(const char *fname) const
84{
85 TFile file(fname, "UPDATE");
86 if (!file.IsOpen())
87 {
88 *fLog << err << "ERROR - Couldn't open file " << fname << " for writing." << endl;
89 return kFALSE;
90 }
91
92 *fLog << inf << "Wrinting to " << fname << ":" << endl;
93 *fLog << " - MStatusDisplay..." << flush;
94 if (fDisplay && fDisplay->Write()<=0)
95 {
96 *fLog << err << "Unable to write MStatusDisplay to " << fname << endl;
97 return kFALSE;
98 }
99 *fLog << inf << "ok." << endl;
100
101 return kTRUE;
102}
Note: See TracBrowser for help on using the repository browser.