Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 886)
+++ trunk/MagicSoft/Mars/Changelog	(revision 887)
@@ -1,5 +1,37 @@
                                                                   -*-*- END -*-*-
+ 2001/07/19: Thomas Bretz
+ 
+   * mbase/MEvtLoop.cc:
+     - added comments
+     
+   * mbase/MTaskList.cc:
+     - changed the wrong 'break' for kCONTINUE into 'return kTRUE'
+     
+   * mhist/HistLinkDef.h:
+     - added MH
+     - added MFillH
+     
+   * mhist/MFillHFadc.cc:
+     - moved source for filling to corresponding histogram class
+     
+   * mhist/MFillHHillas.cc:
+     - included MHillas.h
+     
+   * mhist/MHFadcCam.[cc, h]:
+     - added Fill
+     - made FillHi, FillLo private
+     
+   * mhist/MHHillas.[cc, h], mhist/MHStarMap.[h,cc]:
+     - changed Fill function to new style
+     - derived class from MH
+
+   * mhist/Makefile:
+     - added MH.cc
+     - added MFillH.cc
+
+
+
  2001/07/18: Oscar Blanch
-
+ 
    * macros/getRate.C:
      - Macro to compute the trigger rate from a MonteCarlo file
@@ -11,4 +43,6 @@
    * mmontecarlo/MMcTriggerRateCalc.[h,cc]:
      - Task to compute trigger rate
+
+
 
  2001/07/13: Thomas Bretz
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 887)
@@ -61,4 +61,10 @@
 ClassImp(MEvtLoop);
 
+
+//!
+//! Maybe we can add a static parameter list to MEvtLoop
+//! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too
+//!
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 887)
@@ -270,5 +270,5 @@
             // something occured: skip the rest of the tasks for this event
             //
-            break;
+            return kTRUE;
         }
     }
Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 887)
@@ -5,4 +5,5 @@
 #pragma link off all functions;
 
+#pragma link C++ class MH;
 #pragma link C++ class MHFadcCam;
 #pragma link C++ class MHFadcPix;
@@ -14,4 +15,5 @@
 #pragma link C++ class MHMcRate;
 
+#pragma link C++ class MFillH;
 #pragma link C++ class MFillHFadc;
 #pragma link C++ class MFillHHillas;
Index: trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 887)
+++ trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 887)
@@ -0,0 +1,124 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MFillHHillas                                                            //
+//                                                                          //
+//  This task fills the hillas parameter from MHillas into                  //
+//  histograms (MHHillas)                                                   //
+//                                                                          //
+//  Input Containers:                                                       //
+//   MHillas                                                                //
+//                                                                          //
+//  Output Containers:                                                      //
+//   MHHillas                                                               //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MFillH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.h"
+#include "MParList.h"
+
+ClassImp(MFillH);
+
+// --------------------------------------------------------------------------
+void MFillH::Init(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MFillH";
+    *fTitle = title ? title : "Task to fill Mars histograms";
+}
+
+MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainerName = par;
+    fHName = hist;
+}
+
+MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainer = par;
+    fHName = hist;
+}
+
+MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainerName = par;
+    fH = hist;
+}
+
+MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainer = par;
+    fH = hist;
+}
+
+// --------------------------------------------------------------------------
+Bool_t MFillH::PreProcess(MParList *pList)
+{
+    if (!fParContainer)
+    {
+        fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+        if (!fParContainer)
+        {
+            *fLog << dbginf << fParContainerName << " not found... aborting." << endl;
+            return kFALSE ;
+        }
+    }
+
+    if (!fH)
+    {
+        fH = (MH*)pList->FindCreateObj(fHName);
+        if (!fH)
+            return kFALSE;
+    }
+
+    return kTRUE ;
+} 
+
+// --------------------------------------------------------------------------
+Bool_t MFillH::Process()
+{
+    fH->Fill(fParContainer);
+
+    return kTRUE;
+} 
+
+Bool_t MFillH::PostProcess()
+{
+    fH->SetReadyToSave();
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mhist/MFillH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 887)
+++ trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 887)
@@ -0,0 +1,40 @@
+#ifndef MFILLH_H
+#define MFILLH_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MH;
+class MParList;
+
+class MFillH : public MTask
+{
+private:
+    const MParContainer *fParContainer;
+    TString fParContainerName;
+
+    MH* fH;
+    TString fHName;
+
+    void Init(const char *name, const char *title);
+
+public:
+    MFillH(const char *par,          const char *hist, const char *name=NULL, const char *title=NULL);
+    MFillH(const MParContainer *par, const char *hist, const char *name=NULL, const char *title=NULL);
+    MFillH(const char *par,          MH *hist,         const char *name=NULL, const char *title=NULL);
+    MFillH(const MParContainer *par, MH *hist,         const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MFillH, 0) // Task to fill the Hillas parameters into histograms
+};
+    
+#endif
+
Index: trunk/MagicSoft/Mars/mhist/MFillHFadc.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillHFadc.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MFillHFadc.cc	(revision 887)
@@ -93,24 +93,5 @@
 {
     //  loop over the pixels and fill the values in the histograms
-  
-    MRawEvtPixelIter pixel(fRawEvtData);
-
-    const Int_t nhisamples = fRawEvtData->GetNumHiGainSamples() ;
-    const Int_t nlosamples = fRawEvtData->GetNumLoGainSamples() ;
-
-    while ( pixel.Next() )
-    {
-        const UInt_t id = pixel.GetPixelId();
-
-        for (Int_t i=0;  i<nhisamples; i++)
-            fHistos->FillHi(id, pixel.GetHiGainFadcSamples()[i]);
-
-        if (!pixel.HasLoGain())
-            continue;
-
-        for (Int_t i=0; i<nlosamples; i++)
-            fHistos->FillLo(id, pixel.GetLoGainFadcSamples()[i]);
-    }
-
+    fHistos->Fill(fRawEvtData);
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhist/MFillHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillHHillas.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MFillHHillas.cc	(revision 887)
@@ -42,4 +42,6 @@
 #include "MLog.h"
 #include "MLogManip.h"
+
+#include "MHillas.h"
 #include "MHHillas.h"
 #include "MParList.h"
Index: trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.cc	(revision 887)
+++ trunk/MagicSoft/Mars/mhist/MH.cc	(revision 887)
@@ -0,0 +1,21 @@
+///////////////////////////////////////////////////////////////////////
+//
+// MHHillas
+//
+// This class contains histograms for every Hillas parameter
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MH.h"
+
+ClassImp(MH);
+
+MH::MH(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    *fName  = name  ? name  : "MH" ;
+    *fTitle = title ? title : "Base class for Mars histograms" ;
+}
+
Index: trunk/MagicSoft/Mars/mhist/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.h	(revision 887)
+++ trunk/MagicSoft/Mars/mhist/MH.h	(revision 887)
@@ -0,0 +1,23 @@
+#ifndef MH_H
+#define MH_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+
+class MH : public MParContainer
+{
+public:
+     MH(const char *name=NULL, const char *title=NULL);
+
+    virtual void Fill(const MParContainer *par) = 0;
+
+    ClassDef(MH, 1) // Container which holds hostograms for the Hillas parameters
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mhist/MHFadcCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 887)
@@ -36,4 +36,7 @@
 #include <TH1.h>
 
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
 ClassImp(MHFadcCam);
 
@@ -69,4 +72,28 @@
 }
 
+void MHFadcCam::Fill(const MParContainer *par)
+{
+    MRawEvtData *evt = (MRawEvtData*)par;
+
+    MRawEvtPixelIter pixel(evt);
+
+    const Int_t nhisamples = evt->GetNumHiGainSamples();
+    const Int_t nlosamples = evt->GetNumLoGainSamples();
+
+    while (pixel.Next())
+    {
+        const UInt_t id = pixel.GetPixelId();
+
+        for (Int_t i=0;  i<nhisamples; i++)
+            FillHi(id, pixel.GetHiGainFadcSamples()[i]);
+
+        if (!pixel.HasLoGain())
+            continue;
+
+        for (Int_t i=0; i<nlosamples; i++)
+            FillLo(id, pixel.GetLoGainFadcSamples()[i]);
+    }
+
+}
 /*void MHFadcCam::SaveHist(char *name)
 {
Index: trunk/MagicSoft/Mars/mhist/MHFadcCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 887)
@@ -10,6 +10,6 @@
 #endif
 
-#ifndef MPARCONTAINER_H
-#include "MParContainer.h"
+#ifndef MH_H
+#include "MH.h"
 #endif
 #ifndef MHFADCPIX_H
@@ -19,15 +19,15 @@
 class TH1F;
 
-class MHFadcCam : public MParContainer
+class MHFadcCam : public MH
 {
 private:
     TObjArray *fArray;	// List of Lo/Hi gain Histograms
 
+    void FillHi(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillHi(data); }
+    void FillLo(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillLo(data); }
+
 public:
      MHFadcCam(const char *name=NULL, const char *title=NULL);
     ~MHFadcCam();
-
-    void FillHi(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillHi(data); }
-    void FillLo(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillLo(data); }
 
     //    void SaveHist(char *name);
@@ -37,4 +37,6 @@
     TH1F *GetHistHi(UInt_t i)  { return (*this)[i]->GetHistHi(); }
     TH1F *GetHistLo(UInt_t i)  { return (*this)[i]->GetHistLo(); }
+
+    void Fill(const MParContainer *par);
 
     //
Index: trunk/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 887)
@@ -55,10 +55,12 @@
 }
 
-void MHHillas::Fill(const MHillas *par)
+void MHHillas::Fill(const MParContainer *par)
 {
-    fAlpha ->Fill(fabs(par->GetAlpha()));
-    fWidth ->Fill(par->GetWidth());
-    fLength->Fill(par->GetLength());
-    fDist  ->Fill(par->GetDist());
+    MHillas &h = *(MHillas*)par;
+
+    fAlpha ->Fill(fabs(h.GetAlpha()));
+    fWidth ->Fill(h.GetWidth());
+    fLength->Fill(h.GetLength());
+    fDist  ->Fill(h.GetDist());
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHHillas.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillas.h	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MHHillas.h	(revision 887)
@@ -6,6 +6,6 @@
 #endif
 
-#ifndef MPARCONTAINER_H
-#include "MParContainer.h"
+#ifndef MH_H
+#include "MH.h"
 #endif
 
@@ -13,5 +13,5 @@
 class MHillas;
 
-class MHHillas : public MParContainer
+class MHHillas : public MH
 {
 private:
@@ -25,5 +25,5 @@
     ~MHHillas();
 
-    void Fill(const MHillas *par);
+    void Fill(const MParContainer *par);
 
     TH1F *GetHistAlpha()  { return fAlpha; }
Index: trunk/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 887)
@@ -133,9 +133,11 @@
 }
 
-void MHStarMap::Fill(const MHillas *par)
+void MHStarMap::Fill(const MParContainer *par)
 {
-    const float dist  = par->GetDist();
-    const float theta = par->GetTheta();
-    const float alpha = par->GetAlpha()/kRad2Deg;
+    const MHillas &h = *(MHillas*)par;
+
+    const float dist  = h.GetDist();
+    const float theta = h.GetTheta();
+    const float alpha = h.GetAlpha()/kRad2Deg;
 
     const float m = tan(theta+alpha-kPI);
Index: trunk/MagicSoft/Mars/mhist/MHStarMap.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHStarMap.h	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/MHStarMap.h	(revision 887)
@@ -6,6 +6,6 @@
 #endif
 
-#ifndef MPARCONTAINER_H
-#include "MParContainer.h"
+#ifndef MH_H
+#include "MH.h"
 #endif
 
@@ -18,5 +18,5 @@
 class MHillas;
 
-class MHStarMap : public MParContainer
+class MHStarMap : public MH
 {
 private:
@@ -27,5 +27,5 @@
     ~MHStarMap();
 
-    void Fill(const MHillas *par);
+    void Fill(const MParContainer *par);
 
     TH2F *GetHist()               { return fStarMap; }
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 886)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 887)
@@ -28,7 +28,9 @@
 .SUFFIXES: .c .cc .cxx .h .hxx .o 
 
-SRCFILES = MFillHFadc.cc \
+SRCFILES = MFillH.cc \
+	   MFillHFadc.cc \
            MFillHHillas.cc \
            MFillHStarMap.cc \
+           MH.cc \
            MHFadcPix.cc \
            MHFadcCam.cc \
