source: trunk/MagicSoft/Mars/mfilter/MFDataMember.cc@ 2157

Last change on this file since 2157 was 1661, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.5 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 01/2002 <mailto:tbretz@astro.uni-wueruburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MFDataMember
28//
29// With this filter you can filter in all variables from Mars parameter
30// containers.
31//
32// In the constructor you can give the filter variable, like
33// "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// MFDataMember filter("MHillas.fLength", '<', 150);
42//
43/////////////////////////////////////////////////////////////////////////////
44#include "MFDataMember.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(MFDataMember);
56
57// --------------------------------------------------------------------------
58//
59MFDataMember::MFDataMember(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 : "MFDataMember";
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 MFDataMember::PreProcess(MParList *plist)
77{
78 return fData.PreProcess(plist);
79}
80
81// --------------------------------------------------------------------------
82//
83Bool_t MFDataMember::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 MFDataMember::Print(Option_t *) const
99{
100 *fLog << GetRule() << flush;
101}
102
103void MFDataMember::StreamPrimitive(ofstream &out) const
104{
105 out << " MFDataMember " << GetUniqueName() << "(\"";
106 out << fData.GetRule() << "\", '";
107 out << (fFilterType==kELowerThan?"<":">");
108 out << "', " << fValue << ");" << endl;
109}
110
111TString MFDataMember::GetRule() const
112{
113 TString ret = fData.GetRule();
114 ret += fFilterType==kELowerThan?"<":">";
115
116 TString str;
117 str += fValue;
118
119 return ret+str.Strip(TString::kBoth);
120}
121
Note: See TracBrowser for help on using the repository browser.