Ignore:
Timestamp:
12/08/03 17:03:08 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MEventRate.h

    r2565 r2626  
    99{
    1010private:
    11     Double_t fRate; // [Hz] Event rate
     11    Double_t fRate;      // [Hz] Event rate
     12    UInt_t   fNumEvents; // Number of events correspoding to this rate
    1213
    1314public:
    1415    MEventRate(const char *name=NULL, const char *title=NULL);
    1516
    16     void SetRate(Double_t r) { fRate = r; }
     17    void SetRate(Double_t r, UInt_t n) { fRate = r; fNumEvents = n; }
    1718    Double_t GetRate() const { return fRate; }
     19    UInt_t GetNumEvents() const { return fNumEvents; }
    1820
    1921    ClassDef(MEventRate, 1) // Storage Container for the event rate
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc

    r2607 r2626  
    5959//
    6060MEventRateCalc::MEventRateCalc(const char *name, const char *title)
    61     : fNumEvents(10000)
     61    : /*fNumEvents(10000),*/ fTimes(1000)
    6262{
    6363    fName  = name  ? name  : "MEventRateCalc";
     
    8383        return kFALSE;
    8484
    85     fEvtNumber = 0;
     85    //fEvtNumber = 0;
     86
     87    memset(fTimes.GetArray(), 0, sizeof(Double_t)*fTimes.GetSize());
    8688
    8789    return kTRUE;
     
    9193//
    9294//
    93 #include <TSystem.h>
    9495Int_t MEventRateCalc::Process()
    9596{
    96     fTime->Now();
     97    const ULong_t exec = GetNumExecutions()-1;
    9798
    98     const ULong_t exec = GetNumExecutions();
     99    const UInt_t n = fTimes.GetSize();
    99100
    100     if (fEvtNumber>0)
    101     {
    102         if (exec<fEvtNumber)
    103             return kTRUE;
     101    const UInt_t n1 = exec;
     102    const UInt_t n2 = exec>=n ? exec+1 : 0;
    104103
    105         const Double_t rate = (Double_t)fNumEvents/(*fTime - fEvtTime);
     104    fTimes[n1%n] = *fTime;
    106105
    107         *fLog << inf << "Event Rate [Hz]: " << rate << endl;
     106    const UInt_t cnt = n1<n2 ? n : n1-n2;
    108107
    109         fRate->SetRate(rate);
    110         fRate->SetReadyToSave();
    111     }
     108    const Double_t rate = (Double_t)cnt/(fTimes[n1%n]-fTimes[n2%n]);
    112109
    113     fEvtNumber = exec+fNumEvents;
    114     fEvtTime   = *fTime;
     110    fRate->SetRate(exec>1?rate:0, cnt);
     111    fRate->SetReadyToSave();
     112
     113    // *fLog << inf << "   ---   Event Rate [Hz]: " << rate << "  (" << cnt << ")" << endl;
    115114
    116115    return kTRUE;
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h

    r2565 r2626  
    88#include "MTime.h"
    99#endif
     10#ifndef ROOT_TArrayD
     11#include <TArrayD.h>
     12#endif
    1013
    1114class MEventRate;
     
    1619    MEventRate *fRate;  //!
    1720
    18     ULong_t fEvtNumber; //!
    19     MTime   fEvtTime;   //!
     21    //ULong_t fEvtNumber; //!
     22    //MTime   fEvtTime;   //!
    2023
    21     UInt_t  fNumEvents;
     24    //UInt_t  fNumEvents;
     25
     26    TArrayD fTimes;     //!
     27
     28
    2229
    2330    Int_t PreProcess(MParList *pList);
     
    2734    MEventRateCalc(const char *name=NULL, const char *title=NULL);
    2835
    29     void SetNumEvents(ULong_t num) { fNumEvents = num; }
     36    void SetNumEvents(ULong_t num) { /*fNumEvents = num;*/ fTimes.Set(num); }
    3037
    3138    ClassDef(MEventRateCalc, 0)// Task to calculate event rates
Note: See TracChangeset for help on using the changeset viewer.