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

Last change on this file since 2196 was 2173, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.8 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}
65
66// --------------------------------------------------------------------------
67//
68// Delete the filter list.
69//
70MFiltercutsCalc::~MFiltercutsCalc()
71{
72 delete fList;
73}
74
75// --------------------------------------------------------------------------
76//
77// Add the filter to the list. Set the rule as its name.
78//
79void MFiltercutsCalc::AddToList(MFilter *f)
80{
81 f->SetName(f->GetRule());
82 fList->AddToList(f);
83}
84
85// --------------------------------------------------------------------------
86//
87// Print the rule of the list.
88//
89void MFiltercutsCalc::Print(Option_t *opt) const
90{
91 *fLog << all << underline << GetDescriptor() << ":" << endl;
92 fList->Print();
93 *fLog << endl;
94}
95
96// --------------------------------------------------------------------------
97//
98// There is MUCH space for speed improvement!
99// Add MF(lo<name && name<up) to the filter list (&&),
100// for more details see MF::MF(), too.
101//
102void MFiltercutsCalc::AddCut(const char *name, Double_t lo, Double_t up)
103{
104 AddToList(new MFDataChain(name, '>', lo));
105 AddToList(new MFDataChain(name, '<', up));
106}
107
108// --------------------------------------------------------------------------
109//
110// There is MUCH space for speed improvement!
111// Add MF(fabs(name)<val) to the filter list (&&),
112// for more details see MF::MF(), too.
113//
114void MFiltercutsCalc::AddCut(const char *name, Double_t val)
115{
116 AddToList(new MFDataChain(Form("fabs(%s)", name), '<', val));
117}
118
119// --------------------------------------------------------------------------
120//
121// There is MUCH space for speed improvement!
122// Add 'cut' as MF(cut) to the filter list (&&),
123// for more details see MF::MF(), too.
124//
125void MFiltercutsCalc::AddCut(const char *cut)
126{
127 AddToList(new MF(cut));
128}
129
130// --------------------------------------------------------------------------
131//
132// There is MUCH space for speed improvement!
133// Add cut to filter list (&&), for more details see MF::MF(), too.
134//
135void MFiltercutsCalc::AddCut(MFilter *f)
136{
137 AddToList(f);
138}
139
140// --------------------------------------------------------------------------
141//
142// Search for fHadronnessName [MHadronness] to store the hadronness in
143// there. PreProcess the filter list.
144//
145Bool_t MFiltercutsCalc::PreProcess(MParList *pList)
146{
147 if (!fList->PreProcess(pList))
148 return kFALSE;
149
150 fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
151 if (!fHadronness)
152 return kFALSE;
153
154 return kTRUE;
155}
156
157// --------------------------------------------------------------------------
158//
159// Evaluate the filter list. if the Expression is true set hadronness to
160// 0.25, otherwise to 0.75.
161//
162Bool_t MFiltercutsCalc::Process()
163{
164 if (!fList->Process())
165 return kFALSE;
166
167 if (fList->IsExpressionTrue())
168 fHadronness->SetHadronness(0.25);
169 else
170 fHadronness->SetHadronness(0.75);
171
172 fHadronness->SetReadyToSave();
173
174 return kTRUE;
175}
Note: See TracBrowser for help on using the repository browser.