source: trunk/MagicSoft/Mars/mjoptim/MJOptimizeBase.cc@ 9146

Last change on this file since 9146 was 8643, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 3.5 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-2007
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MJOptimizeBase
28//
29// Base class for classes training a random forest
30//
31// The order when reading a file is:
32// 1) Execution of PreTasks (set by user)
33// 2) Execution of PreCuts (set by user)
34// 3) Selector (calculated from number of requested events)
35// 4) Splitter (if sample is split automatically in test/train)
36// 5) PostTasks (set by user)
37//
38// The split into Pre- and PostTasks is done for speed reason. So, if
39// you calculate a vlue which is not needed for your PreCuts, you can
40// calculate it afterwards, which will speed up execution.
41//
42/////////////////////////////////////////////////////////////////////////////
43#include "MJOptimizeBase.h"
44
45#include <TFile.h>
46
47#include "MLog.h"
48#include "MLogManip.h"
49
50#include "MFDataPhrase.h"
51#include "MParameterCalc.h"
52
53#include "MStatusDisplay.h"
54
55ClassImp(MJOptimizeBase);
56
57using namespace std;
58
59//------------------------------------------------------------------------
60//
61// Add a cut which is used to fill the matrix, eg "MMcEvt.fPartId<1.5"
62// (The rule is applied, not inverted: The matrix is filled with
63// the events fullfilling the condition)
64//
65void MJOptimizeBase::AddCut(TList &l, const char *rule)
66{
67 MFilter *f = new MFDataPhrase(rule);
68 f->SetBit(kCanDelete); //FIXME!!!! Why does not any other list delete it???
69 Add(l, f);
70}
71
72//------------------------------------------------------------------------
73//
74// Add an additional parameter (MParameterCalc), eg "0.5", "MWeight"
75// The default container name is "MWeight"
76//
77void MJOptimizeBase::AddPar(TList &l, const char *rule, const char *pname)
78{
79 TString tname(pname);
80 tname += "Calc";
81
82 MParameterCalc *par = new MParameterCalc(rule, tname);
83 par->SetNameParameter(pname);
84// par->SetBit(kCanDelete); //FIXME!!!! MTaskList is deleting it
85 Add(l, par);
86}
87
88//------------------------------------------------------------------------
89//
90// Add a task/cut which is used to fill the matrix. If kCanDelete is set
91// MJOptimize takes the ownership.
92//
93void MJOptimizeBase::Add(TList &l, MTask *f)
94{
95 l.Add(f);
96}
97
98//------------------------------------------------------------------------
99//
100// Add a parameter used in your filters (see AddFilter) The parameter
101// index is returned,
102//
103// Int_t idx = AddParameter("log10(MHillas.fSize)");
104//
105// The indices are starting with 0 always.
106//
107Int_t MJOptimizeBase::AddParameter(const char *rule)
108{
109 fRules.Add(new TNamed(rule, ""));
110 return fRules.GetSize()-1;
111}
Note: See TracBrowser for help on using the repository browser.