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

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