source: trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.cc@ 7238

Last change on this file since 7238 was 2206, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.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, 05/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MFiltercutsCalc
28//
29// This class sets the hadronness to 0.25 if the evaluttion of the cuts
30// is true, otherwise 0.75.
31//
32// The cuts can be set by AddCut (see there for mor information)
33//
34// All single cuts are linked with a logical and ('&&')
35//
36/////////////////////////////////////////////////////////////////////////////
37#include "MFiltercutsCalc.h"
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42#include "MF.h"
43#include "MFDataChain.h"
44#include "MParList.h"
45#include "MFilterList.h"
46#include "MHadronness.h"
47
48ClassImp(MFiltercutsCalc);
49
50using namespace std;
51
52// --------------------------------------------------------------------------
53//
54// Default constructor. Creates the filter list.
55//
56MFiltercutsCalc::MFiltercutsCalc(const char *name, const char *title)
57 : fHadronnessName("MHadronness")
58{
59 fName = name ? name : "MFiltercutsCalc";
60 fTitle = title ? title : "Class to evaluate the Supercuts";
61
62 fList = new MFilterList;
63 fList->SetOwner();
64 fList->SetBit(kMustCleanup);
65
66 gROOT->GetListOfCleanups()->Add(fList);
67}
68
69// --------------------------------------------------------------------------
70//
71// Delete the filter list.
72//
73MFiltercutsCalc::~MFiltercutsCalc()
74{
75 delete fList;
76}
77
78// --------------------------------------------------------------------------
79//
80// Add the filter to the list. Set the rule as its name.
81//
82void MFiltercutsCalc::AddToList(MFilter *f)
83{
84 f->SetName(f->GetRule());
85 f->SetBit(kMustCleanup);
86 fList->AddToList(f);
87}
88
89// --------------------------------------------------------------------------
90//
91// Print the rule of the list.
92//
93void MFiltercutsCalc::Print(Option_t *opt) const
94{
95 *fLog << all << underline << GetDescriptor() << ":" << endl;
96 fList->Print();
97 *fLog << endl;
98}
99
100// --------------------------------------------------------------------------
101//
102// There is MUCH space for speed improvement!
103// Add MF(lo<name && name<up) to the filter list (&&),
104// for more details see MF::MF(), too.
105//
106void MFiltercutsCalc::AddCut(const char *name, Double_t lo, Double_t up)
107{
108 AddToList(new MFDataChain(name, '>', lo));
109 AddToList(new MFDataChain(name, '<', up));
110}
111
112// --------------------------------------------------------------------------
113//
114// There is MUCH space for speed improvement!
115// Add MF(fabs(name)<val) to the filter list (&&),
116// for more details see MF::MF(), too.
117//
118void MFiltercutsCalc::AddCut(const char *name, Double_t val)
119{
120 AddToList(new MFDataChain(Form("fabs(%s)", name), '<', val));
121}
122
123// --------------------------------------------------------------------------
124//
125// There is MUCH space for speed improvement!
126// Add 'cut' as MF(cut) to the filter list (&&),
127// for more details see MF::MF(), too.
128//
129void MFiltercutsCalc::AddCut(const char *cut)
130{
131 AddToList(new MF(cut));
132}
133
134// --------------------------------------------------------------------------
135//
136// There is MUCH space for speed improvement!
137// Add cut to filter list (&&), for more details see MF::MF(), too.
138//
139void MFiltercutsCalc::AddCut(MFilter *f)
140{
141 AddToList(f);
142}
143
144// --------------------------------------------------------------------------
145//
146// Search for fHadronnessName [MHadronness] to store the hadronness in
147// there. PreProcess the filter list.
148//
149Int_t MFiltercutsCalc::PreProcess(MParList *pList)
150{
151 if (!fList->PreProcess(pList))
152 return kFALSE;
153
154 fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
155 if (!fHadronness)
156 return kFALSE;
157
158 return kTRUE;
159}
160
161// --------------------------------------------------------------------------
162//
163// Evaluate the filter list. if the Expression is true set hadronness to
164// 0.25, otherwise to 0.75.
165//
166Int_t MFiltercutsCalc::Process()
167{
168 if (!fList->Process())
169 return kFALSE;
170
171 if (fList->IsExpressionTrue())
172 fHadronness->SetHadronness(0.25);
173 else
174 fHadronness->SetHadronness(0.75);
175
176 fHadronness->SetReadyToSave();
177
178 return kTRUE;
179}
Note: See TracBrowser for help on using the repository browser.