Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4990)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4991)
@@ -19,5 +19,38 @@
 
                                                  -*-*- END OF LINE -*-*-
-
+ 2004/09/14: Thomas Bretz
+
+   * mbase/MFilter.[h,cc]:
+     - added PrintSkipped
+
+   * mbase/MTask.[h,cc]:
+     - added PrintSkipped
+
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MFDeltaT
+
+   * mhbase/MFillH.[h,cc]:
+     - added forwarding of number of executions
+     - removed obsolete ->cd() around filling
+
+   * mhbase/MH.[h,cc]:
+     - simplified the new Projecttion functions
+     - added PrintSkipped
+     - increased ClassDef version number to 2
+
+   * mhcalib/HCalibLinkDef.h:
+     - removed second + from MHGausEvents
+
+   * mjobs/MJCalibration.cc:
+     - fixed a comment
+
+   * mjobs/MJStar.cc:
+     - added MFDeltaT
+
+   * mpedestal/MPedCalcFromLoGain.cc: 
+     - fixed a typo in a comment
+
+
+ 
  2004/09/13: Antonio Stamerra
 
@@ -76,4 +109,33 @@
    * mhcalib/MHCalibrationChargeCam.[h,cc]
      - wrote a ReadEnv function
+
+   * mbase/MFilter.[h,cc]:
+     - added PrintSkipped
+
+   * mbase/MTask.[h,cc]:
+     - added PrintSkipped
+
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MFDeltaT
+
+   * mhbase/MFillH.[h,cc]:
+     - added forwarding of number of executions
+
+   * mhbase/MH.[h,cc]:
+     - simplified the new Projecttion functions
+     - added PrintSkipped
+     - increased ClassDef version number to 2
+
+   * mhcalib/HCalibLinkDef.h:
+     - removed second + from MHGausEvents
+
+   * mjobs/MJCalibration.cc:
+     - fixed a comment
+
+   * mjobs/MJStar.cc:
+     - added MFDeltaT
+
+   * mpedestal/MPedCalcFromLoGain.cc: 
+     - fixed a typo in a comment
 
 
Index: trunk/MagicSoft/Mars/mbase/MFilter.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilter.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mbase/MFilter.cc	(revision 4991)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -24,55 +24,63 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-//   MFilter                                                               //
-//                                                                         //
-//   This is a base class which defines an interface to create your own    //
-//   filters. To do it derive a class from MFilter.                        //
-//                                                                         //
-//   You can invert the meaning of a filter (logical NOT '!') by calling   //
-//   SetInverted().                                                        //
-//                                                                         //
-//   You can create two types of Filters:                                  //
-//    - static Filters and                                                 //
-//    - dynamic Filters                                                    //
-//                                                                         //
-//   Static Filters:                                                       //
-//    A static filter is a filter which value doesn't change dynamically,  //
-//    which mean only once while running through your tasklist. To create  //
-//    a static filter override the Process-function of MFilter (this is    //
-//    the function in which the filer-value should be updated). If         //
-//    necessary you can also overwrite Pre-/PostProcess. The process       //
-//    function should calculate the return value of IsExpressionTrue.      //
-//    IsExpressionTrue should simply return this value. This kind of       //
-//    filter must be added to the tasklist at a point which is forseen to  //
-//    update the value of the filter (eg. after the reading task).         //
-//                                                                         //
-//   Dynamic Filters:                                                      //
-//    A dynamic filter is a filter which returns a value which must be     //
-//    calculated at the time the filter is called. To create such a        //
-//    filter you have to overwrite IsExpressionTrue only. If there is      //
-//    no need for a 'one-point' update this filter must not be added to    //
-//    the tasklist.                                                        //
-//                                                                         //
-//   Usage:                                                                //
-//    A Filter is connected to a task by calling MTask::SetFilter. The     //
-//    task is now executed when IsExpressionTrue returns a value           //
-//    (different from kFALSE) only.                                        //
-//                                                                         //
-//   Remarks:                                                              //
-//    - Make sure, that all tasks which depends on this filter are either  //
-//      collected in a MTaskList-object or are conected to the same        //
-//      filter.                                                            //
-//    - If you want to use different filters (combined logically) for one  //
-//      task please look for the MFilterList class.                        //
-//    - Be careful, the return value of IsExpressionTrue is NOT a real     //
-//      boolean. You can return other values, too.                         //
-//                                                                         //
+//
+//   MFilter
+//
+//   This is a base class which defines an interface to create your own
+//   filters. To do it derive a class from MFilter.
+//
+//   You can invert the meaning of a filter (logical NOT '!') by calling
+//   SetInverted().
+//
+//   You can create two types of Filters:
+//    - static Filters and
+//    - dynamic Filters
+//
+//   Static Filters:
+//    A static filter is a filter which value doesn't change dynamically,
+//    which mean only once while running through your tasklist. To create
+//    a static filter override the Process-function of MFilter (this is
+//    the function in which the filer-value should be updated). If
+//    necessary you can also overwrite Pre-/PostProcess. The process
+//    function should calculate the return value of IsExpressionTrue.
+//    IsExpressionTrue should simply return this value. This kind of
+//    filter must be added to the tasklist at a point which is forseen to
+//    update the value of the filter (eg. after the reading task).
+//
+//   Dynamic Filters:
+//    A dynamic filter is a filter which returns a value which must be
+//    calculated at the time the filter is called. To create such a
+//    filter you have to overwrite IsExpressionTrue only. If there is
+//    no need for a 'one-point' update this filter must not be added to
+//    the tasklist.
+//
+//   Usage:
+//    A Filter is connected to a task by calling MTask::SetFilter. The
+//    task is now executed when IsExpressionTrue returns a value
+//    (different from kFALSE) only.
+//
+//   Remarks:
+//    - Make sure, that all tasks which depends on this filter are either
+//      collected in a MTaskList-object or are conected to the same
+//      filter.
+//    - If you want to use different filters (combined logically) for one
+//      task please look for the MFilterList class.
+//    - Be careful, the return value of IsExpressionTrue is NOT a real
+//      boolean. You can return other values, too.
+//
 /////////////////////////////////////////////////////////////////////////////
+#include "MFilter.h"
 
-#include "MFilter.h"
+#include "MLog.h"
+#include "MLogManip.h"
 
 ClassImp(MFilter);
 
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor for a filter. Initializes fInverted with kFALSE
+//
 MFilter::MFilter(const char *name, const char *title) : fInverted(kFALSE)
 {
@@ -81,6 +89,22 @@
 }
 
+// --------------------------------------------------------------------------
+//
+//  return the Rule corresponding to this filter (see MF and MDataChain)
+//
 TString MFilter::GetRule() const
 {
     return "<GetRule n/a for " + fName + ">";
 }
+
+// --------------------------------------------------------------------------
+//
+//  This is used to print the output in the PostProcess/Finalize.
+//  Or everywhere else in a nice fashioned and unified way.
+//
+void MFilter::PrintSkipped(UInt_t n, const char *str)
+{
+    *fLog << " " << setw(7) << n << " (";
+    *fLog << setw(3) << TMath::Nint(100.*n/GetNumExecutions());
+    *fLog << "%) Evts fullfilled: " << str << endl;
+}
Index: trunk/MagicSoft/Mars/mbase/MFilter.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MFilter.h	(revision 4990)
+++ trunk/MagicSoft/Mars/mbase/MFilter.h	(revision 4991)
@@ -25,4 +25,6 @@
     Bool_t IsInverted() const  { return fInverted; }
 
+    void PrintSkipped(UInt_t n, const char *str);
+
     ClassDef(MFilter, 1)		// Abstract base class for the filters
 };
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 4991)
@@ -483,2 +483,14 @@
     MParContainer::SetDisplay(d);
 }
+
+// --------------------------------------------------------------------------
+//
+//  This is used to print the output in the PostProcess/Finalize.
+//  Or everywhere else in a nice fashioned and unified way.
+//
+void MTask::PrintSkipped(UInt_t n, const char *str)
+{
+    *fLog << " " << setw(7) << n << " (";
+    *fLog << setw(3) << TMath::Nint(100.*n/GetNumExecutions());
+    *fLog << "%) Evts skipped: " << str << endl;
+}
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 4990)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 4991)
@@ -95,4 +95,5 @@
     Double_t GetRealTime() const;
     virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
+    virtual void PrintSkipped(UInt_t n, const char *str);
 
     // Task overwrite functions
Index: trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h	(revision 4990)
+++ trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h	(revision 4991)
@@ -9,4 +9,5 @@
 #pragma link C++ class MFTriggerLvl2+;
 #pragma link C++ class MFGeomag+;
+#pragma link C++ class MFDeltaT+;
 #pragma link C++ class MFParticleId+;
 
Index: trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc	(revision 4991)
+++ trunk/MagicSoft/Mars/mfilter/MFDeltaT.cc	(revision 4991)
@@ -0,0 +1,158 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  09/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MFDeltaT
+//
+//  for more details see Construtor and Process()
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFDeltaT.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MFDeltaT);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Constructor. First argument is the upper limit of the filter (default=0.5).
+// Second argument is the name of the parameter container storing the time.
+// (default="MTime")
+//
+MFDeltaT::MFDeltaT(Float_t max, const char *time,
+                   const char *name, const char *title)
+{
+    Init(name, title, max, time);
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. Initializes upper limit of the filter (default=0.5)
+// and name of the parameter container storing the time (default="MTime")
+//
+MFDeltaT::MFDeltaT(const char *name, const char *title)
+{
+    Init(name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFDeltaT::Init(const char *name, const char *title,
+                    Float_t max, const char *time)
+{
+    fName  = name  ? name  : "MFDeltaT";
+    fTitle = title ? title : "Filter for time differences of consecutive events";
+
+    fUpperLimit = max;
+    fNameTime   = time;
+
+    fErrors.Set(4);
+
+    AddToBranchList(Form("%s.*", (const char*)fNameTime));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return result of conditional
+//
+Bool_t MFDeltaT::IsExpressionTrue() const
+{
+    return fResult;
+}
+
+// --------------------------------------------------------------------------
+//
+// Search for fNameTime [MTime]
+//
+Int_t MFDeltaT::PreProcess(MParList *pList)
+{
+    fErrors.Reset();
+
+    fTime = (MTime*)pList->FindObject(fNameTime, "MTime");
+    if (fTime)
+        return kTRUE;
+
+    *fLog << err << fNameTime << " [MTime] not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the consition. The consition is true if the time difference
+// between two consecutive events are >0 or <= upper limit.
+//
+Int_t MFDeltaT::Process()
+{
+    fResult = kFALSE;
+
+    const Double_t dt = *fTime - fLastTime;
+    fLastTime = *fTime;
+
+    Int_t i=0;
+
+    if (GetNumExecutions()>0)
+    {
+        if (dt<0)
+            i=1;
+        if (dt==0)
+            i=2;
+        if (dt>fUpperLimit)
+            i=3;
+    }
+
+    fResult = i==0;
+    fErrors[i]++;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print some statistics.
+//
+Int_t MFDeltaT::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " filter statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    PrintSkipped(fErrors[1], "Delta-T  < 0");
+    PrintSkipped(fErrors[2], "Delta-T == 0");
+    PrintSkipped(fErrors[3], Form("Delta-T > %.2fs", fUpperLimit));
+    *fLog << " " << (int)fErrors[0] << " (" << (int)(100.*fErrors[0]/GetNumExecutions()) << "%) Evts fullfilled filter condition!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mfilter/MFDeltaT.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDeltaT.h	(revision 4991)
+++ trunk/MagicSoft/Mars/mfilter/MFDeltaT.h	(revision 4991)
@@ -0,0 +1,50 @@
+#ifndef MARS_MFDeltaT
+#define MARS_MFDeltaT
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+class MTime;
+class MParList;
+
+class MFDeltaT : public MFilter
+{
+private:
+    MTime  *fTime;     //!
+    TString fNameTime;
+
+    Float_t fUpperLimit;
+
+    MTime  fLastTime;  //!
+    Bool_t fResult;    //!
+
+    TArrayI fErrors;
+
+    void Init(const char *name, const char *title, Float_t max=0.5, const char *time="MTime");
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MFDeltaT(Float_t max, const char *time="MTime", const char *name=0, const char *title=0);
+    MFDeltaT(const char *name=0, const char *title=0);
+
+    void SetUpperLimit(Float_t max) { fUpperLimit=max; }
+    Float_t GetUpperLimit() const { return fUpperLimit; }
+
+    Bool_t IsExpressionTrue() const;
+
+    ClassDef(MFDeltaT, 1) // A Filter for time differences of consecutive events
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mfilter/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mfilter/Makefile	(revision 4990)
+++ trunk/MagicSoft/Mars/mfilter/Makefile	(revision 4991)
@@ -21,4 +21,5 @@
 	   MFTriggerLvl2.cc \
 	   MFGeomag.cc \
+           MFDeltaT.cc \
 	   MFParticleId.cc \
 	   MFAlpha.cc \
Index: trunk/MagicSoft/Mars/mhbase/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MFillH.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mhbase/MFillH.cc	(revision 4991)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -24,51 +24,56 @@
 
 //////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-//  MFillH                                                                  //
-//                                                                          //
-//  This is a common interface (task) to fill mars histograms. Every mars   //
-//  histogram which is derived from MH can be filled with this task.        //
-//                                                                          //
-//  There are two options to use:                                           //
-//                                                                          //
-//  1) You specifiy the parameter container with which data the             //
-//     histogram container should be filled, and the histogram container    //
-//     which has to be filled. This can be done by either specifing the     //
-//     name of the objects in the parameter list or by specifiing a pointer //
-//     to the object. (s. Constructor)                                      //
-//                                                                          //
-//  2) You specify the name and/or type of the histogram to become filled.  //
-//     Any other action imust be taken by the histogram class.              //
-//                                                                          //
-//  PreProcess: In the preprocessing of this task we setup all pointers     //
-//              to instances which are needed and call FillSetup of the     //
-//              histogram class with the parameter list as an argument.     //
-//                                                                          //
-//  Process: The process function calls the Fill member function of the     //
-//           histogram class instance (inheriting from MH) with either      //
-//           a NULL pointer or a pointer to the corresponding container     //
-//           as an argument.                                                //
-//                                                                          //
-// To use a weight for each event filled in a histogram call                //
-// SetWeight(). You can eithe use the name of a MWeight container stored    //
-// in the parameter list or a pointer to it as an argument.                 //
-//                                                                          //
-//                                                                          //
-//  WARNING:                                                                //
-//   Because MFillH is a generalized task to fill histograms it doesn't     //
-//   know about which branches from a file are necessary to fill the        //
-//   histograms. If you are reading data from a file which is directly      //
-//   filled into a histogram via MFillH, please call either                 //
-//   MReadTree::DisableAutoScheme() or enable the necessary branches by     //
-//   yourself, using MReadTree::EnableBranch()                              //
-//                                                                          //
-//   Checkout the Warning in MTaskList.                                     //
-//                                                                          //
-//  Input Containers:                                                       //
-//   A parameter container                                                  //
-//                                                                          //
-//  Output Containers:                                                      //
-//   A histogram container                                                  //
-//                                                                          //
+//
+//  MFillH
+//
+//  This is a common interface (task) to fill mars histograms. Every mars
+//  histogram which is derived from MH can be filled with this task.
+//
+//  There are two options to use:
+//
+//  1) You specifiy the parameter container with which data the
+//     histogram container should be filled, and the histogram container
+//     which has to be filled. This can be done by either specifing the
+//     name of the objects in the parameter list or by specifiing a pointer
+//     to the object. (s. Constructor)
+//
+//  2) You specify the name and/or type of the histogram to become filled.
+//     Any other action imust be taken by the histogram class.
+//
+//  PreProcess: In the preprocessing of this task we setup all pointers
+//              to instances which are needed and call FillSetup of the
+//              histogram class with the parameter list as an argument.
+//
+//  Process: The process function calls the Fill member function of the
+//           histogram class instance (inheriting from MH) with either
+//           a NULL pointer or a pointer to the corresponding container
+//           as an argument.
+//
+// To use a weight for each event filled in a histogram call
+// SetWeight(). You can eithe use the name of a MWeight container stored
+// in the parameter list or a pointer to it as an argument.
+//
+//
+//  WARNING:
+//   Because MFillH is a generalized task to fill histograms it doesn't
+//   know about which branches from a file are necessary to fill the
+//   histograms. If you are reading data from a file which is directly
+//   filled into a histogram via MFillH, please call either
+//   MReadTree::DisableAutoScheme() or enable the necessary branches by
+//   yourself, using MReadTree::EnableBranch()
+//
+//   Checkout the Warning in MTaskList.
+//
+//  Version 2:
+//  ----------
+//   - added fNumExcutions
+//
+//
+//  Input Containers:
+//   A parameter container
+//
+//  Output Containers:
+//   A histogram container
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MFillH.h"
@@ -457,4 +462,5 @@
     //
     fH->SetSerialNumber(GetSerialNumber());
+    fH->SetNumExecutions(0);
     if (!fH->SetupFill(pList))
     {
@@ -519,14 +525,15 @@
      ((MHArray*)fH)->SetIndex(idx);
      */
-
+/*
     TVirtualPad *save = gPad;
     if (fCanvas)
         fCanvas->cd();
-
+  */
     const Bool_t rc = fH->Fill(fParContainer, fWeight?fWeight->GetWeight():1);
-
+    fH->SetNumExecutions(GetNumExecutions()+1);
+/*
     if (save && fCanvas)
         save->cd();
-
+  */
     return rc;
 } 
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4991)
@@ -1271,42 +1271,6 @@
                        const char* name, const char* title)
 {
-    const Int_t size = array.GetSize();
-
-    TH1I *h1=0;
-
-    //check if histogram with identical name exist
-    TObject *h1obj = gROOT->FindObject(name);
-    if (h1obj && h1obj->InheritsFrom("TH1I"))
-    {
-        h1 = (TH1I*)h1obj;
-        h1->Reset();
-    }
-
-    Double_t min = size>0 ? array[0] : 0;
-    Double_t max = size>0 ? array[0] : 1;
-
-    // first loop over array to find the min and max
-    for (Int_t i=1; i<size;i++)
-    {
-        max = TMath::Max((Double_t)array[i], max);
-        min = TMath::Min((Double_t)array[i], min);
-    }
-
-    Int_t newbins = 0;
-    FindGoodLimits(nbins, newbins, min, max, kFALSE);
-
-    if (!h1)
-    {
-        h1 = new TH1I(name, title, nbins, min, max);
-        h1->SetXTitle("");
-        h1->SetYTitle("Counts");
-        h1->SetDirectory(gROOT);
-    }
-
-    // Second loop to fill the histogram
-    for (Int_t i=0;i<size;i++)
-        h1->Fill(array[i]);
-
-    return h1;
+    const TArrayF arr(array.GetSize(), array.GetArray());
+    return ProjectArray(array, nbins, name, title);
 }
 
@@ -1317,41 +1281,16 @@
 TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title)
 {
-    const Int_t size = array.GetSize();
-    TH1I *h1=0;
-
-    //check if histogram with identical name exist
-    TObject *h1obj = gROOT->FindObject(name);
-    if (h1obj && h1obj->InheritsFrom("TH1I"))
-    {
-        h1 = (TH1I*)h1obj;
-        h1->Reset();
-    }
-
-    Double_t min = size>0 ? array[0] : 0;
-    Double_t max = size>0 ? array[0] : 1;
-
-    // first loop over array to find the min and max
-    for (Int_t i=1; i<size;i++)
-    {
-        max = TMath::Max(array[i], max);
-        min = TMath::Min(array[i], min);
-    }
-
-    Int_t newbins = 0;
-    FindGoodLimits(nbins, newbins, min, max, kFALSE);
-
-    if (!h1)
-    {
-        h1 = new TH1I(name, title, newbins, min, max);
-        h1->SetXTitle("");
-        h1->SetYTitle("Counts");
-        h1->SetDirectory(gROOT);
-    }
-
-    // Second loop to fill the histogram
-    for (Int_t i=0;i<size;i++)
-        h1->Fill(array[i]);
-
-    return h1;
-}
-
+    const TArrayD arr(array.GetSize(), array.GetArray());
+    return ProjectArray(array, nbins, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+// See MTask::PrintSkipped
+//
+void MH::PrintSkipped(UInt_t n, const char *str)
+{
+    *fLog << " " << setw(7) << n << " (";
+    *fLog << setw(3) << (int)(100.*n/GetNumExecutions());
+    *fLog << "%) Evts skipped: " << str << endl;
+}
Index: trunk/MagicSoft/Mars/mhbase/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.h	(revision 4990)
+++ trunk/MagicSoft/Mars/mhbase/MH.h	(revision 4991)
@@ -24,9 +24,9 @@
 {
 private:
-    Byte_t fSerialNumber;
+    Byte_t fSerialNumber;   // Serial number (eg of telecope)
+    UInt_t fNumExecutions;  // Number of calls to Fill function
 
 public:
     MH(const char *name=NULL, const char *title=NULL);
-
 
     virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
@@ -34,4 +34,9 @@
     TString AddSerialNumber(const char *str) const { TString s(str); if (fSerialNumber==0) return s; s += ";"; s += fSerialNumber; return s; }
     TString AddSerialNumber(const TString &str) const { return AddSerialNumber((const char*)str); }
+
+    UInt_t GetNumExecutions() const { return fNumExecutions; }
+    void SetNumExecutions(UInt_t n) { fNumExecutions=n; }
+
+    void PrintSkipped(UInt_t n, const char *str);
 
     Bool_t OverwritesDraw(TClass *cls=NULL) const;
@@ -110,5 +115,5 @@
     static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL);
 
-    ClassDef(MH, 1) //A base class for Mars histograms
+    ClassDef(MH, 2) //A base class for Mars histograms
 };
 
Index: trunk/MagicSoft/Mars/mhcalib/HCalibLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/HCalibLinkDef.h	(revision 4990)
+++ trunk/MagicSoft/Mars/mhcalib/HCalibLinkDef.h	(revision 4991)
@@ -16,5 +16,5 @@
 #pragma link C++ class MHCalibrationTestTimeCam+;
 
-#pragma link C++ class MHGausEvents++;
+#pragma link C++ class MHGausEvents+;
 
 #endif
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4991)
@@ -1369,4 +1369,5 @@
 //   MJCalibration.Datacheck: yes,no
 //   MJCalibration.Debug: yes,no
+//   MJCalibration.Intensity: yes,no
 //   MJCalibration.UseBlindPixel: yes,no
 //   MJCalibration.UsePINDiode: yes,no
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 4991)
@@ -50,4 +50,6 @@
 #include "MReadReports.h"
 #include "MReadMarsFile.h"
+#include "MFDeltaT.h"
+#include "MContinue.h"
 #include "MGeomApply.h"
 #include "MEventRateCalc.h"
@@ -160,4 +162,8 @@
 
     // ------------------ Setup general tasks ----------------
+
+    MFDeltaT               fdeltat;
+    MContinue              cont(&fdeltat, "FilterDeltaT", "Filter events with wrong timing");
+    cont.SetInverted();
 
     MGeomApply             apply; // Only necessary to craete geometry
@@ -218,5 +224,5 @@
     if (ismc)
     {
-        write.AddContainer("MPointingPos", "Events");
+        write.AddContainer("MPointingPos",        "Events");
         // Monte Carlo
         write.AddContainer("MMcEvt",              "Events");
@@ -229,5 +235,5 @@
     else
     {
-        write.AddContainer("MTime",         "Events");
+        write.AddContainer("MTime",               "Events");
         // Run Header
         write.AddContainer("MRawRunHeader",       "RunHeaders");
@@ -237,7 +243,7 @@
         // Drive
         //write.AddContainer("MSrcPosCam",   "Drive");
-        write.AddContainer("MPointingPos", "Drive");
-        write.AddContainer("MReportDrive", "Drive");
-        write.AddContainer("MTimeDrive",   "Drive");
+        write.AddContainer("MPointingPos",        "Drive");
+        write.AddContainer("MReportDrive",        "Drive");
+        write.AddContainer("MTimeDrive",          "Drive");
         // Effective On Time
         write.AddContainer("MEffectiveOnTime",     "EffectiveOnTime");
@@ -249,4 +255,5 @@
     if (!ismc)
     {
+        tlist2.AddToList(&cont);
         tlist2.AddToList(&rate);
         //tlist2.AddToList(&rate10000);
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 4990)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 4991)
@@ -33,5 +33,5 @@
 //
 //
-//  This task is devide form MPedCalcPedRun, described below. However, It 
+//  This task is derived form MPedCalcPedRun, described below. However, It
 //  calculates the pedstals using the low gain slices, whenever the difference 
 //  between the highest and the lowest slice in the high gain
