Changeset 1661 for trunk/MagicSoft


Ignore:
Timestamp:
11/21/02 15:04:04 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1660 r1661  
    1                                                                   -*-*- END -*-*-
     1                       #                                           -*-*- END -*-*-
    22 2002/11/21: Thomas Bretz
    33
     
    55     - introduced kERROR to stop an eventloop with an error
    66
     7   * mbase/MTask.h:
     8     - made SetFilter virtual
     9
     10   * mbase/MTaskList.[h,cc]:
     11     - added new member function AddToListBefore/After
     12     - split the code of the AddToList function into CheckAddToList
     13
    714   * manalysis/MMultiDimDistCalc.cc:
    815     - introduced usage of kERROR in case the matrix is not posdef.
     
    1017   * macros/collarea.C:
    1118     - some simplifications
     19
     20   * mdata/MDataChain.[h,cc]:
     21     - added 'sqr'
     22
     23   * mfilter/MF.[h,cc]:
     24     - added support for MFDataChain
     25
     26   * mfilter/MFDataChain.[h,cc]:
     27     - added
     28
     29   * mfilter/Makefile, mfilter/FilterLinkDef.h:
     30     - added MFDataChain
    1231
    1332
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r1574 r1661  
    6565    virtual ~MTask();
    6666
    67     void SetFilter(MFilter *filter) { fFilter=filter; }
     67    virtual void SetFilter(MFilter *filter) { fFilter=filter; }
    6868    const MFilter *GetFilter() const      { return fFilter; }
     69    MFilter *GetFilter()  { return fFilter; } // for MContinue only
    6970    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
    7071
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1657 r1661  
    135135}
    136136
    137 
    138 // --------------------------------------------------------------------------
    139 //
    140 // schedule task for execution, whether as first task, or after
    141 // 'where'. 'tType' is the event type which should be processed
    142 //
    143 Bool_t MTaskList::AddToList(MTask *task, const char *type, MTask *where)
    144 {
    145     // FIXME: We agreed to put the task into list in an ordered way.
    146 
     137Bool_t MTaskList::CheckAddToList(MTask *task, const char *type, const MTask *where) const
     138{
    147139    //
    148140    // Sanity check
     
    182174    }
    183175
    184     if (where)
    185     {
    186         if (!fTasks->FindObject(where))
    187         {
    188             *fLog << err << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl;
    189             return kFALSE;
    190         }
    191     }
    192 
    193     *fLog << inf << "Adding " << name << " to " << GetName() << " for " << type << "... " << flush;
    194 
     176    if (!where)
     177        return kTRUE;
     178
     179    if (fTasks->FindObject(where))
     180        return kTRUE;
     181
     182    *fLog << err << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl;
     183    return kFALSE;
     184}
     185
     186
     187// --------------------------------------------------------------------------
     188//
     189// schedule task for execution, before 'where'.
     190// 'type' is the event type which should be processed
     191//
     192Bool_t MTaskList::AddToListBefore(MTask *task, const MTask *where, const char *type)
     193{
     194    // FIXME: We agreed to put the task into list in an ordered way.
     195    if (!CheckAddToList(task, type, where))
     196        return kFALSE;
     197
     198    *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     199    task->SetStreamId(type);
     200    fTasks->AddBefore((TObject*)where, task);
     201    *fLog << "Done." << endl;
     202
     203    return kTRUE;
     204}
     205
     206// --------------------------------------------------------------------------
     207//
     208// schedule task for execution, after 'where'.
     209// 'type' is the event type which should be processed
     210//
     211Bool_t MTaskList::AddToListAfter(MTask *task, const MTask *where, const char *type)
     212{
     213    // FIXME: We agreed to put the task into list in an ordered way.
     214
     215    if (!CheckAddToList(task, type, where))
     216        return kFALSE;
     217
     218    *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     219    task->SetStreamId(type);
     220    fTasks->AddAfter((TObject*)where, task);
     221    *fLog << "Done." << endl;
     222
     223    return kTRUE;
     224}
     225
     226// --------------------------------------------------------------------------
     227//
     228// schedule task for execution, 'type' is the event type which should
     229// be processed
     230//
     231Bool_t MTaskList::AddToList(MTask *task, const char *type)
     232{
     233    // FIXME: We agreed to put the task into list in an ordered way.
     234
     235    if (!CheckAddToList(task, type))
     236        return kFALSE;
     237
     238    *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
    195239    task->SetStreamId(type);
    196240    fTasks->Add(task);
    197 
    198241    *fLog << "Done." << endl;
    199242
     
    325368        *fLog << all << task->GetName() << "... " << flush;
    326369
    327         if (CheckClassForProcess(task->IsA()))
    328             fTasksProcess.Add(task);
    329 
    330370        //
    331371        // PreProcess the task and check for it's return value.
     
    350390
    351391    *fLog << all << endl;
     392
     393    Next.Reset();
     394
     395    //
     396    // loop over all tasks for preproccesing
     397    //
     398    while ((task=(MTask*)Next()))
     399        if (CheckClassForProcess(task->IsA()))
     400            fTasksProcess.Add(task);
    352401
    353402    return kTRUE;
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r1540 r1661  
    3535    void StreamPrimitive(ofstream &out) const;
    3636
     37    Bool_t CheckAddToList(MTask *task, const char *tType, const MTask *where=NULL) const;
     38
    3739public:
    3840    MTaskList(const char *name=NULL, const char *title=NULL);
     
    4345    void SetLogStream(MLog *log);
    4446
    45     Bool_t AddToList(MTask *task, const char *tType="All", MTask *where = NULL);
     47    Bool_t AddToListBefore(MTask *task, const MTask *where, const char *tType="All");
     48    Bool_t AddToListAfter(MTask *task, const MTask *where, const char *tType="All");
     49    Bool_t AddToList(MTask *task, const char *tType="All");
    4650
    4751    TObject *FindObject(const char *name) const;
  • trunk/MagicSoft/Mars/mdata/MDataChain.cc

    r1629 r1661  
    6969//   atan(x)   arc tangent (inverse tangent) of x
    7070//   sqrt(x)   square root of x
     71//   sqr(x)    square of x
    7172//   abs(x)    absolute value of x, |x|
    7273//   floor(x)  round down to the nearest integer (floor(9.9)=9)
     
    225226    if (txt=="atan")  return kEATan;
    226227    if (txt=="sqrt")  return kESqrt;
     228    if (txt=="sqr")   return kESqr;
    227229    if (txt=="exp")   return kEExp;
    228230    if (txt=="pow10") return kEPow10;
     
    468470    case kEATan:     return atan(val);
    469471    case kESqrt:     return sqrt(val);
     472    case kESqr:      return val*val;
    470473    case kEExp:      return exp(val);
    471474    case kEPow10:    return pow(10, val);
     
    551554    case kEATan:     str += "atan" ; break;
    552555    case kESqrt:     str += "sqrt" ; break;
     556    case kESqr:      str += "sqr"  ; break;
    553557    case kEExp:      str += "exp"  ; break;
    554558    case kEPow10:    str += "pow10"; break;
  • trunk/MagicSoft/Mars/mdata/MDataChain.h

    r1629 r1661  
    3434        kEATan,
    3535        kESqrt,
     36        kESqr,
    3637        kEPow10,
    3738        kEExp,
  • trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h

    r1588 r1661  
    1212#pragma link C++ class MFTriggerLvl1+;
    1313#pragma link C++ class MFParticleId+;
     14#pragma link C++ class MFDataChain+;
    1415#pragma link C++ class MFDataMember+;
    1516
  • trunk/MagicSoft/Mars/mfilter/MF.cc

    r1588 r1661  
    4444//   "MHillas.fSize>200 || (MHillas.fWidth<0.5 && MHillas.fLength<0.6)"
    4545//
     46// If you want to use mathematic expressions (as defined in MDataChain)
     47// you must encapsulate it in {}-Brackets, eg:
     48//   "{log10(MHillas.fSize)}>3"
     49//
    4650// The allowed logigal conditionals are:
    4751//   &&: logical and
     
    5357// are allowed.
    5458//
     59//
    5560// Warning: There is no priority rule build in. So better use brackets
    5661//   to get correct results. The rule is parsed/evaluated from the left
     
    8085
    8186#include "MFilterList.h"
     87#include "MFDataChain.h"
    8288#include "MFDataMember.h"
    8389
     
    139145// in the given string
    140146//
    141 Int_t MF::IsAlNum(TString txt)
     147Int_t MF::IsAlNum(TString txt) const
    142148{
    143149    int l = txt.Length();
     
    149155}
    150156
     157MFilter *MF::ParseRule(TString &txt, MFilter *filter0) const
     158{
     159    TString text;
     160
     161    Bool_t isrule = kFALSE;
     162
     163    if (txt[0]=='{')
     164    {
     165        //
     166        // Search for the corresponding bracket
     167        //
     168        Int_t first=1;
     169        for (int cnt=0; first<txt.Length(); first++)
     170        {
     171            if (txt[first]=='{')
     172                cnt++;
     173            if (txt[first]=='}')
     174                cnt--;
     175
     176            if (cnt==-1)
     177                break;
     178        }
     179
     180        if (first==txt.Length())
     181        {
     182            *fLog << err << dbginf << "Syntax Error: '}' missing." << endl;
     183            return NULL;
     184        }
     185
     186        //
     187        // Make a copy of the 'interieur' and delete the substringä
     188        // including the brackets
     189        //
     190        TString sub = txt(1, first-1);
     191        txt.Remove(0, first+1);
     192
     193        text=sub;
     194        isrule = kTRUE;
     195    }
     196    else
     197    {
     198        int i = IsAlNum(txt);
     199
     200        if (i==0)
     201        {
     202            *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl;
     203            return NULL;
     204        }
     205
     206        text = txt(0, i);
     207
     208        txt.Remove(0, i);
     209    }
     210
     211    txt = txt.Strip(TString::kBoth);
     212
     213    if (txt.IsNull())
     214    {
     215        *fLog << err << dbginf << "Syntax Error: No conditional in '" << text << "'" << endl;
     216        return NULL;
     217    }
     218
     219    char c;
     220    switch (txt[0])
     221    {
     222    case '>':
     223    case '<':
     224        c = txt[0];
     225        txt.Remove(0, 1);
     226        break;
     227
     228    default:
     229        *fLog << err << dbginf << "Syntax Error: Conditional '" << txt[0] << "' unknown." << endl;
     230        return NULL;
     231    }
     232
     233    char *end;
     234    Double_t num = strtod(txt.Data(), &end);
     235    if (!end || txt.Data()==end)
     236    {
     237        *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl;
     238        return NULL;
     239    }
     240
     241    txt.Remove(0, end-txt.Data());
     242
     243    MFilter *newfilter;
     244    if (isrule)
     245        newfilter = new MFDataChain(text.Data(), c, num);
     246    else
     247        newfilter = new MFDataMember(text.Data(), c, num);
     248
     249    newfilter->SetName(Form("%s%c%f", text.Data(), c, num));
     250
     251    return newfilter;
     252}
    151253// --------------------------------------------------------------------------
    152254//
     
    222324            return NULL;
    223325
     326
    224327        case '&':
    225328        case '|':
     
    264367
    265368        default:
    266             int i = IsAlNum(txt);
    267 
    268             if (i==0)
     369            newfilter = ParseRule(txt, filter0);
     370            if (!newfilter)
    269371            {
    270                 *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl;
    271372                if (filter0)
    272373                    delete filter0;
    273374                return NULL;
    274375            }
    275 
    276             TString text = txt(0, i);
    277 
    278             txt.Remove(0, i);
    279             txt = txt.Strip(TString::kBoth);
    280 
    281             if (txt.IsNull())
    282             {
    283                 *fLog << err << dbginf << "Syntax Error: No conditional in '" << text << "'" << endl;
    284                 if (filter0)
    285                     delete filter0;
    286                 return NULL;
    287             }
    288 
    289             char c;
    290             switch (txt[0])
    291             {
    292             case '>':
    293             case '<':
    294                 c = txt[0];
    295                 txt.Remove(0, 1);
    296                 break;
    297 
    298             default:
    299                 *fLog << err << dbginf << "Syntax Error: Conditional '" << txt[0] << "' unknown." << endl;
    300                 if (filter0)
    301                     delete filter0;
    302                 return NULL;
    303             }
    304 
    305             char *end;
    306             Double_t num = strtod(txt.Data(), &end);
    307             if (!end || txt.Data()==end)
    308             {
    309                 *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl;
    310                 if (filter0)
    311                     delete filter0;
    312                 return NULL;
    313             }
    314 
    315             txt.Remove(0, end-txt.Data());
    316 
    317             newfilter = new MFDataMember(text.Data(), c, num);
    318             newfilter->SetName(Form("%s%c%f", text.Data(), c, num));
    319376        }
    320377
  • trunk/MagicSoft/Mars/mfilter/MF.h

    r1588 r1661  
    2323    MFilter *fFilter; // Filter
    2424
    25     Int_t IsAlNum(TString txt);
     25    Int_t IsAlNum(TString txt) const;
    2626
     27    MFilter *ParseRule(TString &txt, MFilter *filter0) const;
    2728    MFilter *ParseString(TString txt, Int_t level);
    2829
  • trunk/MagicSoft/Mars/mfilter/MFDataMember.cc

    r1493 r1661  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
     18!   Author(s): Thomas Bretz  01/2002 <mailto:tbretz@astro.uni-wueruburg.de>
    1919!
    2020!   Copyright: MAGIC Software Development, 2000-2002
  • trunk/MagicSoft/Mars/mfilter/Makefile

    r1588 r1661  
    3535           MFilterList.cc \
    3636           MFEventSelector.cc \
     37           MFDataChain.cc \
    3738           MFDataMember.cc \
    3839           MFParticleId.cc \
Note: See TracChangeset for help on using the changeset viewer.