Index: trunk/MagicSoft/Mars/manalysis/MEventRate.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEventRate.h	(revision 2607)
+++ trunk/MagicSoft/Mars/manalysis/MEventRate.h	(revision 2626)
@@ -9,11 +9,13 @@
 {
 private:
-    Double_t fRate; // [Hz] Event rate
+    Double_t fRate;      // [Hz] Event rate
+    UInt_t   fNumEvents; // Number of events correspoding to this rate
 
 public:
     MEventRate(const char *name=NULL, const char *title=NULL);
 
-    void SetRate(Double_t r) { fRate = r; }
+    void SetRate(Double_t r, UInt_t n) { fRate = r; fNumEvents = n; }
     Double_t GetRate() const { return fRate; }
+    UInt_t GetNumEvents() const { return fNumEvents; }
 
     ClassDef(MEventRate, 1) // Storage Container for the event rate
Index: trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc	(revision 2607)
+++ trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc	(revision 2626)
@@ -59,5 +59,5 @@
 //
 MEventRateCalc::MEventRateCalc(const char *name, const char *title)
-    : fNumEvents(10000)
+    : /*fNumEvents(10000),*/ fTimes(1000)
 {
     fName  = name  ? name  : "MEventRateCalc";
@@ -83,5 +83,7 @@
         return kFALSE;
 
-    fEvtNumber = 0;
+    //fEvtNumber = 0;
+
+    memset(fTimes.GetArray(), 0, sizeof(Double_t)*fTimes.GetSize());
 
     return kTRUE;
@@ -91,26 +93,23 @@
 //
 //
-#include <TSystem.h>
 Int_t MEventRateCalc::Process()
 {
-    fTime->Now();
+    const ULong_t exec = GetNumExecutions()-1;
 
-    const ULong_t exec = GetNumExecutions();
+    const UInt_t n = fTimes.GetSize();
 
-    if (fEvtNumber>0)
-    {
-        if (exec<fEvtNumber)
-            return kTRUE;
+    const UInt_t n1 = exec;
+    const UInt_t n2 = exec>=n ? exec+1 : 0;
 
-        const Double_t rate = (Double_t)fNumEvents/(*fTime - fEvtTime);
+    fTimes[n1%n] = *fTime;
 
-        *fLog << inf << "Event Rate [Hz]: " << rate << endl;
+    const UInt_t cnt = n1<n2 ? n : n1-n2;
 
-        fRate->SetRate(rate);
-        fRate->SetReadyToSave();
-    }
+    const Double_t rate = (Double_t)cnt/(fTimes[n1%n]-fTimes[n2%n]);
 
-    fEvtNumber = exec+fNumEvents;
-    fEvtTime   = *fTime;
+    fRate->SetRate(exec>1?rate:0, cnt);
+    fRate->SetReadyToSave();
+
+    // *fLog << inf << "   ---   Event Rate [Hz]: " << rate << "  (" << cnt << ")" << endl;
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h	(revision 2607)
+++ trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h	(revision 2626)
@@ -8,4 +8,7 @@
 #include "MTime.h"
 #endif
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
 
 class MEventRate;
@@ -16,8 +19,12 @@
     MEventRate *fRate;  //!
 
-    ULong_t fEvtNumber; //!
-    MTime   fEvtTime;   //!
+    //ULong_t fEvtNumber; //!
+    //MTime   fEvtTime;   //!
 
-    UInt_t  fNumEvents;
+    //UInt_t  fNumEvents;
+
+    TArrayD fTimes;     //!
+
+
 
     Int_t PreProcess(MParList *pList);
@@ -27,5 +34,5 @@
     MEventRateCalc(const char *name=NULL, const char *title=NULL);
 
-    void SetNumEvents(ULong_t num) { fNumEvents = num; }
+    void SetNumEvents(ULong_t num) { /*fNumEvents = num;*/ fTimes.Set(num); }
 
     ClassDef(MEventRateCalc, 0)// Task to calculate event rates
