Changeset 2710 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
12/18/03 12:05:36 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2709 r2710  
    2525     - added a first implementation to be able searching report
    2626       files for the run number
     27
     28   * mdata/MDataMember.[h,cc]:
     29     - implemented a way to determin whether the data member is
     30       a floating point value or an integer
     31
     32   * mfilter/MFDataMember.[h,cc]:
     33     - use the information to treat integer values more accuratly
    2734
    2835
  • trunk/MagicSoft/Mars/mdata/MDataMember.cc

    r2173 r2710  
    6363    fCall   = call;
    6464
     65    if (fCall->ReturnType()==TMethodCall::kLong)
     66        SetBit(kIsInt);
     67    else
     68        ResetBit(kIsInt);
     69
    6570    fDataMember = (TString)obj->GetName() + "." + call->GetName();
    6671}
     
    7782    fObject = obj;
    7883    fCall   = obj->GetterMethod(call);
     84
     85    if (fCall->ReturnType()==TMethodCall::kLong)
     86        SetBit(kIsInt);
     87    else
     88        ResetBit(kIsInt);
    7989
    8090    fDataMember = (TString)obj->GetName() + "." + call;
  • trunk/MagicSoft/Mars/mdata/MDataMember.h

    r1574 r2710  
    2020    TMethodCall   *fCall;
    2121
     22    enum { kIsInt = BIT(14) };
     23
    2224public:
    2325    MDataMember(const char *member=NULL) : fObject(NULL), fCall(NULL)
     
    3941    TString GetDataMember() const;
    4042
     43    Bool_t IsInt() const { return TestBit(kIsInt); }
     44
    4145    ClassDef(MDataMember, 1) // MData object corresponding to a single data member of a Mars container
    4246};
  • trunk/MagicSoft/Mars/merpp.cc

    r2709 r2710  
    2222#include "MRawCrateArray.h"
    2323
    24 #include "MFilterList.h"
    2524#include "MFDataMember.h"
    2625
     
    225224    // be created by MRawFileRead::PreProcess
    226225    //
    227     MTask       *read   = 0;
    228     MFilterList *filter = 0;
    229     MTask       *write  = 0;
     226    MTask   *read   = 0;
     227    MFilter *filter = 0;
     228    MTask   *write  = 0;
    230229
    231230    const TString option(kUpdate ? "UPDATE" : "RECREATE");
     
    278277            {
    279278                r->AddToList("MReportRun");
    280                 // FIXME: Too difficult!
    281                 filter = new MFilterList;
    282                 filter->SetOwner();
    283                 filter->AddToList(new MFDataMember("MReportRun.fRunNumber", '>', kRunNumber-0.5));
    284                 filter->AddToList(new MFDataMember("MReportRun.fRunNumber", '<', kRunNumber+0.5));
     279                filter = new MFDataMember("MReportRun.fRunNumber", '=', kRunNumber-0.5);
     280                filter->SetInverted();
    285281                w->SetFilter(filter);
    286282            }
  • trunk/MagicSoft/Mars/mfilter/MF.cc

    r2515 r2710  
    8585#include <ctype.h>        // isalnum, ...
    8686#include <stdlib.h>       // strtod, ...
    87 #include <fstream>      // ofstream, ...
     87#include <fstream>        // ofstream, ...
    8888
    8989#include <TMethodCall.h>
  • trunk/MagicSoft/Mars/mfilter/MFDataMember.cc

    r2206 r2710  
    4141//   MFDataMember filter("MHillas.fLength", '<', 150);
    4242//
     43// You can test '<', '>' and '='. Warning: Using '=' may give strange results
     44// in case you are comparing floating point values.
     45//
     46// In case the data member is detected to be an integer value, both
     47// the data member and the val given as argument in the constructor
     48// are castet to Long_t.
     49//
     50// To test != use the SetInverted() member function.
     51//
    4352/////////////////////////////////////////////////////////////////////////////
    4453#include "MFDataMember.h"
     
    6877    AddToBranchList(member);
    6978
    70     fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
     79    switch (type)
     80    {
     81    case '>': fFilterType = kEGreaterThan; break;
     82    case '<': fFilterType = kELowerThan;   break;
     83    case '=': fFilterType = kEEqual;       break;
     84    default:  fFilterType = kEGreaterThan; break;
     85    }
    7186
    72     if (type!='<' && type!='>')
    73         *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
     87    if (type!='<' && type!='=' && type!='>')
     88        *fLog << warn << dbginf << "Warning: Neither '<' nor '=' nor '>' specified... using '>'." << endl;
    7489}
    7590
     
    85100Int_t MFDataMember::Process()
    86101{
    87     switch (fFilterType)
     102    if (fData.IsInt())
    88103    {
    89     case kELowerThan:
    90         fResult = (fData.GetValue() < fValue);
    91         return kTRUE;
    92     case kEGreaterThan:
    93         fResult = (fData.GetValue() > fValue);
    94         return kTRUE;
     104        switch (fFilterType)
     105        {
     106        case kELowerThan:
     107            fResult = ((Long_t)fData.GetValue() < (Long_t)fValue);
     108            return kTRUE;
     109        case kEGreaterThan:
     110            fResult = ((Long_t)fData.GetValue() > (Long_t)fValue);
     111            return kTRUE;
     112        case kEEqual:
     113            fResult = ((Long_t)fData.GetValue() == (Long_t)fValue);
     114            return kTRUE;
     115        }
     116    }
     117    else
     118    {
     119        switch (fFilterType)
     120        {
     121        case kELowerThan:
     122            fResult = (fData.GetValue() < fValue);
     123            return kTRUE;
     124        case kEGreaterThan:
     125            fResult = (fData.GetValue() > fValue);
     126            return kTRUE;
     127        case kEEqual:
     128            fResult = (fData.GetValue() == fValue);
     129            return kTRUE;
     130        }
    95131    }
    96132
     
    107143    out << "   MFDataMember " << GetUniqueName() << "(\"";
    108144    out << fData.GetRule() << "\", '";
    109     out << (fFilterType==kELowerThan?"<":">");
     145    switch (fFilterType)
     146    {
     147    case kEGreaterThan: out << '>'; break;
     148    case kELowerThan:   out << '<'; break;
     149    case kEEqual:       out << '='; break;
     150    }
    110151    out << "', " << fValue << ");" << endl;
    111152}
     
    114155{
    115156    TString ret = fData.GetRule();
    116     ret += fFilterType==kELowerThan?"<":">";
     157    switch (fFilterType)
     158    {
     159    case kEGreaterThan: ret +='>'; break;
     160    case kELowerThan:   ret +='<'; break;
     161    case kEEqual:       ret +='='; break;
     162    }
    117163
    118164    TString str;
  • trunk/MagicSoft/Mars/mfilter/MFDataMember.h

    r2206 r2710  
    11#ifndef MARS_MFDataMember
    22#define MARS_MFDataMember
    3 
    4 /////////////////////////////////////////////////////////////////////////////
    5 //                                                                         //
    6 // MFDataMember                                                                 //
    7 //                                                                         //
    8 /////////////////////////////////////////////////////////////////////////////
    93
    104#ifndef MARS_MFilter
     
    2216    MDataMember fData;
    2317
    24     typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
     18    typedef enum { kELowerThan, kEGreaterThan, kEEqual } FilterType_t;
    2519    FilterType_t fFilterType;
    2620
     
    3428
    3529public:
     30    enum {
     31        kIsInt = BIT(14)
     32    };
    3633    MFDataMember(const char *member, const char type, const Double_t val,
    3734                 const char *name=NULL, const char *title=NULL);
Note: See TracChangeset for help on using the changeset viewer.