Index: /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc	(revision 4832)
+++ /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc	(revision 4833)
@@ -47,4 +47,8 @@
 //
 //
+//  In addition the difference between the event time of the current event
+//  and the last event is written into a MParameterD calles MTimeDiff.
+//
+//
 //  Input Containers:
 //    MTime
@@ -52,4 +56,5 @@
 //  Output Containers:
 //    MEventRate
+//    MTimeDiff [MParameterD]
 //    MTimeRate [MTime] (missing)
 //
@@ -62,11 +67,14 @@
 #include "MEventRateCalc.h"
 
-#include "MParList.h"
+#include <fstream>
 
 #include "MLog.h"
 #include "MLogManip.h"
 
+#include "MParList.h"
+
 #include "MTime.h"
 #include "MEventRate.h"
+#include "MParameters.h"
 
 ClassImp(MEventRateCalc);
@@ -74,4 +82,13 @@
 using namespace std;
 
+const TString MEventRateCalc::gsDefName  = "MEventRateCalc";
+const TString MEventRateCalc::gsDefTitle = "Calculate event rate";
+
+const TString MEventRateCalc::gsNameTime      = "MTime";
+const TString MEventRateCalc::gsNameEventRate = "MEventRate";
+const TString MEventRateCalc::gsNameTimeDiff  = "MTimeDiff";
+
+const Int_t MEventRateCalc::gsNumEvents = 1000;
+
 // --------------------------------------------------------------------------
 //
@@ -79,8 +96,9 @@
 //
 MEventRateCalc::MEventRateCalc(const char *name, const char *title)
-    : fTimes(1000)
-{
-    fName  = name  ? name  : "MEventRateCalc";
-    fTitle = title ? title : "Calculate trigger rate";
+    : fNameTime(gsNameTime), fNameEventRate(gsNameEventRate),
+    fNameTimeDiff(gsNameTimeDiff), fTimes(gsNumEvents)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
 }
 
@@ -97,5 +115,5 @@
 Int_t MEventRateCalc::PreProcess(MParList *pList)
 {
-    fTime = (MTime*)pList->FindObject("MTime");
+    fTime = (MTime*)pList->FindObject(AddSerialNumber(fNameTime), "MTime");
     if (!fTime)
     {
@@ -104,6 +122,10 @@
     }
 
-    fRate = (MEventRate*)pList->FindCreateObj("MEventRate");
+    fRate = (MEventRate*)pList->FindCreateObj("MEventRate", AddSerialNumber(fNameEventRate));
     if (!fRate)
+        return kFALSE;
+
+    fTimeDiff = (MParameterD*)pList->FindCreateObj("MParameterD", AddSerialNumber(fNameTimeDiff));
+    if (!fTimeDiff)
         return kFALSE;
 
@@ -137,4 +159,45 @@
     fRate->SetReadyToSave();
 
+    fTimeDiff->SetVal(exec==0 ? -1 : fTimes[n1%n] - fTimes[(n1+n-1)%n]);
+    fTimeDiff->SetReadyToSave();
+
     return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MEventRateCalc::StreamPrimitive(ofstream &out) const
+{
+    out << "   MEventRateCalc " << GetUniqueName() << "(";
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "\"" <<fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+    if (fTimes.GetSize()!=gsNumEvents)
+        out << "   " << GetUniqueName() << ".SetNumEvents(" << fTimes.GetSize() << ");" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv, eg:
+//   MEventRateCalc.NumEvents: 1000
+//
+Int_t MEventRateCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (IsEnvDefined(env, prefix, "NumEvents", print))
+    {
+        rc = kTRUE;
+        SetNumEvents(GetEnvValue(env, prefix, "NumEvents", fTimes.GetSize()));
+    }
+
+    return rc;
+}
Index: /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h	(revision 4832)
+++ /trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h	(revision 4833)
@@ -5,25 +5,34 @@
 #include "MTask.h"
 #endif
-#ifndef MARS_MTime
-#include "MTime.h"
-#endif
 #ifndef ROOT_TArrayD
 #include <TArrayD.h>
 #endif
 
+class MTime;
 class MEventRate;
+class MParameterD;
 
 class MEventRateCalc : public MTask
 {
-    MTime      *fTime;  //!
-    MEventRate *fRate;  //!
+private:
+    static const TString gsDefName;       //! Default name of container
+    static const TString gsDefTitle;      //! Default title of container
 
-    //ULong_t fEvtNumber; //!
-    //MTime   fEvtTime;   //!
+    static const TString gsNameTime;      //! Default name of time container
+    static const TString gsNameEventRate; //! default name of rate container
+    static const TString gsNameTimeDiff;  //! default name of time-diff container
 
-    //UInt_t  fNumEvents;
+    static const Int_t gsNumEvents;       //! Default number of events
 
-    TArrayD fTimes;     //!
 
+    MTime       *fTime;       //! pointer to event time
+    MEventRate  *fRate;       //! pointer to rate storage container
+    MParameterD *fTimeDiff;   //! Difference of time between two consecutive events
+
+    TString fNameTime;       // name of time container
+    TString fNameEventRate;  // name of event rate container
+    TString fNameTimeDiff;   // name of time-diff container
+
+    TArrayD  fTimes;         //! internal array to store the last n event times
 
 
@@ -31,10 +40,17 @@
     Int_t Process();
 
+    void  StreamPrimitive(ofstream &out) const;
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
 public:
     MEventRateCalc(const char *name=NULL, const char *title=NULL);
 
-    void SetNumEvents(ULong_t num) { /*fNumEvents = num;*/ fTimes.Set(num); }
+    void SetNumEvents(ULong_t num) { fTimes.Set(num); }
 
-    ClassDef(MEventRateCalc, 0)// Task to calculate event rates
+    void SetNameTime(const char *name)      { fNameTime = name; }
+    void SetNameEventRate(const char *name) { fNameEventRate = name; }
+    void SetNameTimeDiff(const char *name)  { fNameTimeDiff = name; }
+
+    ClassDef(MEventRateCalc, 1)// Task to calculate event rates
 };
  
Index: /trunk/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 4832)
+++ /trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 4833)
@@ -120,8 +120,8 @@
     }
 
-    fTaskList = (MTaskList*)list->FindObject("MTaskList");
+    fTaskList = (MTaskList*)list->FindTaskListWithTask(this);
     if (!fTaskList)
     {
-        *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
+        *fLog << err << dbginf << "ERROR - MTasklist not found... abort." << endl;
         return kFALSE;
     }
Index: /trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc	(revision 4832)
+++ /trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc	(revision 4833)
@@ -200,4 +200,17 @@
 }
 
+void MHNewImagePar::Paint(Option_t *)
+{
+    TVirtualPad *savepad = gPad;
+    if (fHistLeakage1.GetEntries()>0 && fHistLeakage2.GetEntries()>0)
+    {
+        fHistLeakage1.SetMinimum(-1111);
+        fHistLeakage2.SetMinimum(-1111);
+        gPad->cd(1);
+        gPad->SetLogy();
+    }
+    gPad = savepad;
+}
+
 // --------------------------------------------------------------------------
 //
Index: /trunk/MagicSoft/Mars/mimage/MHNewImagePar.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHNewImagePar.h	(revision 4832)
+++ /trunk/MagicSoft/Mars/mimage/MHNewImagePar.h	(revision 4833)
@@ -46,5 +46,6 @@
     TH1F &GetHistConc1()     { return fHistConc1; }
 
-    void Draw(Option_t *opt=NULL);
+    void Draw(Option_t *opt="");
+    void Paint(Option_t *opt="");
 
     ClassDef(MHNewImagePar, 1) // Histograms of new image parameters
