Ignore:
Timestamp:
10/24/01 15:12:21 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r965 r988  
    4242// calling MReadTree::UseLeaf.                                             //
    4343//                                                                         //
     44// FIXME: An automatic enabeling scheme would be nice.                     //
     45//                                                                         //
    4446// Later we'll use TChain::SetNotify to notify MReadTree if the TChain     //
    4547// starts to read a new file.                                              //
     
    258260Bool_t MReadTree::Process()
    259261{
    260     return fChain->GetEntry(fNumEntry++, 0) == 0 ? kFALSE : kTRUE;
     262    return fChain->GetEntry(fNumEntry++) == 0 ? kFALSE : kTRUE;
    261263}
    262264
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r961 r988  
    6767#include "MTask.h"
    6868
     69#include "MLog.h"
     70#include "MLogManip.h"
     71
     72#include "MFilter.h"
     73
    6974ClassImp(MTask);
     75
     76MTask::MTask(const char *name, const char *title)
     77    : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions()
     78{
     79    *fName  = name  ? name  : "MTask";
     80    *fTitle = title ? title : "Base class for all tasks (dummy task).";
     81}
     82
     83// --------------------------------------------------------------------------
     84//
     85// Mapper function for PreProcess.
     86// Sets the preprocessed flag dependend on the return value of PreProcess.
     87//
     88Bool_t MTask::CallPreProcess(MParList *plist)
     89{
     90    if (!PreProcess(plist))
     91        return kFALSE;
     92
     93    fIsPreprocessed = kTRUE;
     94    return kTRUE;
     95}
     96
     97// --------------------------------------------------------------------------
     98//
     99// Mapper function for Process.
     100// Executes Process dependent on the existance of a filter and its possible
     101// return value.
     102// If Process is executed, the execution counter is increased.
     103//
     104inline Bool_t MTask::CallProcess()
     105{
     106    //
     107    // Check for the existance of a filter. If a filter is existing
     108    // check for its value. If the value is kFALSE don't execute
     109    // this task.
     110    //
     111    const Bool_t exec = fFilter ? fFilter->IsExpressionTrue() : kTRUE;
     112
     113    if (!exec)
     114        return kTRUE;
     115
     116    fNumExecutions++;
     117    return Process();
     118}
     119
     120// --------------------------------------------------------------------------
     121//
     122// Mapper function for PreProcess.
     123// Calls Postprocess dependent on the state of the preprocessed flag,
     124// resets this flag.
     125//
     126Bool_t MTask::CallPostProcess()
     127{
     128    if (!fIsPreprocessed)
     129        return kTRUE;
     130
     131    fIsPreprocessed = kFALSE;
     132    return PostProcess();
     133}
    70134
    71135// --------------------------------------------------------------------------
     
    105169}
    106170
    107 
     171// --------------------------------------------------------------------------
     172//
     173// Prints the number of times this task has been processed.
     174// For convinience the lvl argument results in a number of spaces at the
     175// beginning of the line. So that the structur of a tasklist can be
     176// identified.
     177//
     178void MTask::PrintStatistics(const Int_t lvl) const
     179{
     180    *fLog << setw(lvl) << " " << GetName() << " [";
     181    *fLog << ClassName() << "] \t" << fNumExecutions;
     182    *fLog << endl;
     183}
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r867 r988  
    2323
    2424    Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList)
    25 
    26 public:
    27     MTask() : fFilter(NULL), fIsPreprocessed(kFALSE) {}
    28     ~MTask()
    29     {
    30     }
    31 
    32     const MFilter *GetFilter() const { return fFilter; }
    33     void SetFilter(const MFilter *filter) { fFilter=filter; }
    34 
    35     Bool_t IsPreprocessed() const { return fIsPreprocessed; }
    36     void SetIsPreprocessed(Bool_t state=kTRUE) { fIsPreprocessed = state; }
     25    UInt_t fNumExecutions;  // Number of Excutions
    3726
    3827    virtual Bool_t PreProcess(MParList *pList);
     
    4029    virtual Bool_t PostProcess();
    4130
     31public:
     32    MTask(const char *name=NULL, const char *title=NULL);
     33    virtual ~MTask()
     34    {
     35    }
     36
     37    void SetFilter(const MFilter *filter) { fFilter=filter; }
     38    virtual void PrintStatistics(const Int_t lvl=0) const;
     39
     40    Bool_t CallPreProcess(MParList *plist);
     41    Bool_t CallProcess();
     42    Bool_t CallPostProcess();
     43
    4244    ClassDef(MTask, 0)          //Abstract base class for a task
    4345};
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r961 r988  
    4949#include "MLog.h"
    5050#include "MLogManip.h"
    51 #include "MFilter.h"
     51
    5252#include "MParList.h"
    5353#include "MInputStreamID.h"
     
    232232        *fLog << task->GetName() << "... " << flush;
    233233
    234         if (!task->PreProcess(fParList))
     234        if (!task->CallPreProcess(fParList))
    235235            return kFALSE;
    236 
    237         task->SetIsPreprocessed();
    238236    }
    239237
     
    278276
    279277        //
    280         // Check for the existance of a filter. If a filter is existing
    281         // check for its value. If the value is kFALSE don't execute
    282         // this task.
    283         //
    284         const MFilter *filter = task->GetFilter();
    285 
    286         const Bool_t rc = filter ? filter->IsExpressionTrue() : kTRUE;
    287 
    288         if (!rc)
    289             continue;
    290 
    291         //
    292         // if it has the right stream id execute the Process() function
     278        // if it has the right stream id execute the CallProcess() function
    293279        // and check what the result of it is.
    294         //
    295         switch (task->Process())
     280        // The CallProcess() function increases the execution counter and
     281        // calls the Process() function dependent on the existance and
     282        // return value of a filter.
     283        //
     284        switch (task->CallProcess())
    296285        {
    297286        case kTRUE:
     
    312301            //
    313302            return kTRUE;
     303
     304        default:
     305            *fLog << "MTaskList::Process: Unknown return value from MTask::Process()... ignored." << endl;
    314306        }
    315307    }
     
    349341    while ( (task=(MTask*)Next()) )
    350342    {
    351         if (!task->IsPreprocessed())
    352             continue;
     343        if (!task->CallPostProcess())
     344            return kFALSE;
    353345
    354346        *fLog << task->GetName() << "... " << flush;
    355 
    356         //
    357         // FIXME: should we only skip this task?
    358         //
    359         if (!task->PostProcess())
    360             return kFALSE;
    361347    }
    362348
     
    367353
    368354// --------------------------------------------------------------------------
    369 void MTaskList::Print(Option_t *t)
    370 {
    371     *fLog << "TaskList: " << this->GetName() << " <" <<  this->GetTitle() << ">" << endl;
     355//
     356//  Prints the number of times all the tasks in the list has been.
     357//  For convinience the lvl argument results in a number of spaces at the
     358//  beginning of the line. So that the structur of a tasklist can be
     359//  identified. Use MTaskList::PrintStatistics without an argument.
     360//
     361void MTaskList::PrintStatistics(const Int_t lvl) const
     362{
     363    if (lvl==0)
     364    {
     365        *fLog << endl;
     366        *fLog << "Execution Statistics: " << endl;
     367        *fLog << "---------------------" << endl;
     368        *fLog << GetName() << " [" << ClassName() << "]" << endl;
     369    }
     370    else
     371    {
     372        *fLog << setw(lvl) << " " << GetName() << " [";
     373        *fLog << ClassName() << "]" << endl;
     374    }
     375
     376    //
     377    //  create the Iterator for the TaskList
     378    //
     379    TIter Next(&fTasks);
     380
     381    MTask *task=NULL;
     382    //
     383    //  loop over all tasks for postprocessing
     384    //  only tasks which have successfully been preprocessed are postprocessed.
     385    //
     386    while ( (task=(MTask*)Next()) )
     387        task->PrintStatistics(lvl+1);
     388
     389    if (lvl==0)
     390        *fLog << endl;
     391}
     392
     393// --------------------------------------------------------------------------
     394void MTaskList::Print(Option_t *t) const
     395{
     396    *fLog << "TaskList: " << GetName() << " <" << GetTitle() << ">" << endl;
    372397
    373398    fTasks.Print();
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r959 r988  
    2727    MParList      *fParList;
    2828
     29    UInt_t *fCntContinue;
     30    UInt_t *fCntTrue;
     31
    2932    enum { kIsOwner = BIT(14) };
    3033
     
    4649    Bool_t PostProcess();
    4750
    48     void Print(Option_t *opt = "");
     51    void Print(Option_t *opt = "") const;
     52    void PrintStatistics(const Int_t lvl=0) const;
    4953    void SetOwner(Bool_t enable=kTRUE);
    5054
Note: See TracChangeset for help on using the changeset viewer.