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>
|
---|
47 |
|
---|
48 | #include <TMethodCall.h>
|
---|
49 |
|
---|
50 | #include "MParList.h"
|
---|
51 |
|
---|
52 | #include "MLog.h"
|
---|
53 | #include "MLogManip.h"
|
---|
54 |
|
---|
55 | ClassImp(MFDataChain);
|
---|
56 |
|
---|
57 | using namespace std;
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | MFDataChain::MFDataChain(const char *member, const char type, const Double_t val,
|
---|
62 | const char *name, const char *title)
|
---|
63 | : fData(member), fValue(val)
|
---|
64 | {
|
---|
65 | fName = name ? name : "MFDataChain";
|
---|
66 | fTitle = title ? title : "Filter using any data member of a class";
|
---|
67 |
|
---|
68 | //AddToBranchList(member);
|
---|
69 |
|
---|
70 | fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
|
---|
71 |
|
---|
72 | if (type!='<' && type!='>')
|
---|
73 | *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
|
---|
74 | }
|
---|
75 |
|
---|
76 | // --------------------------------------------------------------------------
|
---|
77 | //
|
---|
78 | Int_t MFDataChain::PreProcess(MParList *plist)
|
---|
79 | {
|
---|
80 | return fData.PreProcess(plist);
|
---|
81 | }
|
---|
82 |
|
---|
83 | // --------------------------------------------------------------------------
|
---|
84 | //
|
---|
85 | Int_t MFDataChain::Process()
|
---|
86 | {
|
---|
87 | switch (fFilterType)
|
---|
88 | {
|
---|
89 | case kELowerThan:
|
---|
90 | fResult = (fData.GetValue() < fValue);
|
---|
91 | return kTRUE;
|
---|
92 | case kEGreaterThan:
|
---|
93 | fResult = (fData.GetValue() > fValue);
|
---|
94 | return kTRUE;
|
---|
95 | }
|
---|
96 |
|
---|
97 | return kFALSE;
|
---|
98 | }
|
---|
99 |
|
---|
100 | void MFDataChain::Print(Option_t *) const
|
---|
101 | {
|
---|
102 | *fLog << GetRule() << flush;
|
---|
103 | }
|
---|
104 |
|
---|
105 | void MFDataChain::StreamPrimitive(ofstream &out) const
|
---|
106 | {
|
---|
107 | out << " MFDataChain " << GetUniqueName() << "(\"";
|
---|
108 | out << fData.GetRule() << "\", '";
|
---|
109 | out << (fFilterType==kELowerThan?"<":">");
|
---|
110 | out << "', " << fValue << ");" << endl;
|
---|
111 | }
|
---|
112 |
|
---|
113 | TString MFDataChain::GetRule() const
|
---|
114 | {
|
---|
115 | TString ret = "{";
|
---|
116 | ret += fData.GetRule();
|
---|
117 | ret += "}";
|
---|
118 | ret += fFilterType==kELowerThan?"<":">";
|
---|
119 |
|
---|
120 | TString str;
|
---|
121 | str += fValue;
|
---|
122 |
|
---|
123 | ret += str.Strip(TString::kBoth);
|
---|
124 | return ret;
|
---|
125 | }
|
---|
126 |
|
---|