| 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>
|
|---|
| 47 |
|
|---|
| 48 | #include <TMethodCall.h>
|
|---|
| 49 |
|
|---|
| 50 | #include "MParList.h"
|
|---|
| 51 |
|
|---|
| 52 | #include "MLog.h"
|
|---|
| 53 | #include "MLogManip.h"
|
|---|
| 54 |
|
|---|
| 55 | ClassImp(MFDataMember);
|
|---|
| 56 |
|
|---|
| 57 | using namespace std;
|
|---|
| 58 |
|
|---|
| 59 | // --------------------------------------------------------------------------
|
|---|
| 60 | //
|
|---|
| 61 | MFDataMember::MFDataMember(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 : "MFDataMember";
|
|---|
| 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 MFDataMember::PreProcess(MParList *plist)
|
|---|
| 79 | {
|
|---|
| 80 | return fData.PreProcess(plist);
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | Int_t MFDataMember::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 MFDataMember::Print(Option_t *) const
|
|---|
| 101 | {
|
|---|
| 102 | *fLog << GetRule() << flush;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | void MFDataMember::StreamPrimitive(ofstream &out) const
|
|---|
| 106 | {
|
|---|
| 107 | out << " MFDataMember " << GetUniqueName() << "(\"";
|
|---|
| 108 | out << fData.GetRule() << "\", '";
|
|---|
| 109 | out << (fFilterType==kELowerThan?"<":">");
|
|---|
| 110 | out << "', " << fValue << ");" << endl;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | TString MFDataMember::GetRule() const
|
|---|
| 114 | {
|
|---|
| 115 | TString ret = fData.GetRule();
|
|---|
| 116 | ret += fFilterType==kELowerThan?"<":">";
|
|---|
| 117 |
|
|---|
| 118 | TString str;
|
|---|
| 119 | str += fValue;
|
|---|
| 120 |
|
|---|
| 121 | return ret+str.Strip(TString::kBoth);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|