source: trunk/MagicSoft/Mars/mfilter/MFDataChain.cc@ 1963

Last change on this file since 1963 was 1668, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.6 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/2002 <mailto:tbretz@astro.uni-wueruburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MFDataChain
28//
29// With this filter you can filter in all variables from Mars parameter
30// containers using rules (for more details see MDataChain).
31//
32// In the constructor you can give the filter variable, like
33// "sqrt(MHillas.fLength*MHillas.fLength)"
34// Where MHillas is the name of the parameter container in the parameter
35// list and fLength is the name of the data member which should be used
36// for the filter rule. If the name of the container is use specified
37// (MyHillas) the name to give would be:
38// "MyHillas.fLength"
39//
40// For example:
41// MFDataChain filter("sqr(MHillas.fLength)", '<', 150);
42//
43/////////////////////////////////////////////////////////////////////////////
44#include "MFDataChain.h"
45
46#include <fstream.h>
47
48#include <TMethodCall.h>
49
50#include "MParList.h"
51
52#include "MLog.h"
53#include "MLogManip.h"
54
55ClassImp(MFDataChain);
56
57// --------------------------------------------------------------------------
58//
59MFDataChain::MFDataChain(const char *member, const char type, const Double_t val,
60 const char *name, const char *title)
61 : fData(member), fValue(val)
62{
63 fName = name ? name : "MFDataChain";
64 fTitle = title ? title : "Filter using any data member of a class";
65
66 //AddToBranchList(member);
67
68 fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
69
70 if (type!='<' && type!='>')
71 *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
72}
73
74// --------------------------------------------------------------------------
75//
76Bool_t MFDataChain::PreProcess(MParList *plist)
77{
78 return fData.PreProcess(plist);
79}
80
81// --------------------------------------------------------------------------
82//
83Bool_t MFDataChain::Process()
84{
85 switch (fFilterType)
86 {
87 case kELowerThan:
88 fResult = (fData.GetValue() < fValue);
89 return kTRUE;
90 case kEGreaterThan:
91 fResult = (fData.GetValue() > fValue);
92 return kTRUE;
93 }
94
95 return kFALSE;
96}
97
98void MFDataChain::Print(Option_t *) const
99{
100 *fLog << GetRule() << flush;
101}
102
103void MFDataChain::StreamPrimitive(ofstream &out) const
104{
105 out << " MFDataChain " << GetUniqueName() << "(\"";
106 out << fData.GetRule() << "\", '";
107 out << (fFilterType==kELowerThan?"<":">");
108 out << "', " << fValue << ");" << endl;
109}
110
111TString MFDataChain::GetRule() const
112{
113 TString ret = "{";
114 ret += fData.GetRule();
115 ret += "}";
116 ret += fFilterType==kELowerThan?"<":">";
117
118 TString str;
119 str += fValue;
120
121 return ret+str.Strip(TString::kBoth);
122}
123
Note: See TracBrowser for help on using the repository browser.