source: trunk/Mars/manalysis/MFiltercutsCalc.cc@ 10307

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