Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 697)
+++ trunk/MagicSoft/Mars/Changelog	(revision 698)
@@ -1,3 +1,93 @@
                                                                   -*-*- END -*-*-
+
+ 2000/03/21: Thomas Bretz
+                                                                  
+   * macros/CT1Hillas.C, manalysis/MImgCleanStd.cc, manalysis/MImgCleanStd.h,
+     manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalCopy.h,
+     manalysis/MCerPhotCalc.h, manalysis/MCerPhotCalc.cc, mdatacheck/MHHillas.h,
+     mdatacheck/MHHillas.cc, mdatacheck/MFillHFadc.cc, mdatacheck/MFillHFadc.h,
+     mdatacheck/MHFadcCam.cc, mdatacheck/MHFadcCam.h, mdatacheck/MHFadcPix.cc,
+     mdatacheck/MHFadcPix.h, mdatacheck/MFillHHillas.cc, 
+     mdatacheck/MFillHHillas.h
+     - added
+
+   * mdatacheck/MHistosAdc.[h,cc]:
+     - replaced by MHFadc[Cam,Pix]
+     
+   * mdatacheck/MFillAdcSpect.[h,cc]:
+     - replaced by MFillHFadc
+     
+   * macros/readCT1.C:
+     - uses the new classes now
+     - calculates and displays hillas
+     
+   * manalysis/AnalysisLinkDef.h:
+     - added MCerPhotCalc, MImgCleanStd, MMcPedestalCopy
+     
+   * manalysis/MCT1ReadAscii.cc:
+     - PreProcess uses FindCreateObj now
+     
+   * manalysis/MCerPhotEvt.cc, manalysis/MPedestalCam.cc:
+     - changed the new back to 'new with placement'
+     
+   * manalysis/MCerPhotEvt.[h, cc]:
+     - removed cleaning from this class
+     
+   * manalysis/MHillas.cc:
+     - some small changes in the naming inside Calc()
+     
+   * manalysis/MHillas.h:
+     - added Get-functions
+     
+   * manalysis/MPedestalCam.h:
+     - added InitSize-function
+     
+   * manalysis/MPedestalPix.h:
+     - made Get-functions const
+     
+   * manalysis/Makefile:
+     - added MMcPedestalCopy, MImgCleanStd, MCerPhotCalc
+     
+   * mbase/MLogManip.h:
+     - "l." before line number
+     
+   * mbase/MParList.cc:
+     - added the autodelete feature for automatically created classes
+     
+   * mdatacheck/DataCheckLinkDef.h:
+     - added MHFadc[Cam,Pix], MHHillas
+     - removed MHistosAdc
+     - added MFillHFadc, MFillHHillas
+     
+   * mdatacheck/MGDisplayAdc.[h,cc], MShowSpect.[h,cc],
+     mdatacheck/MViewAdcSpectra.[h,cc], :
+     - changed from MHistaosAdc to MHFadcCam
+     
+   * mdatacheck/Makefile:
+     - added MFillHFadc.cc, MFillHHillas.cc
+     - removed MFillAdcSpect.cc
+
+   * manalysis/MCT1ReadAscii.h, mbase/MEvtLoop.h, mbase/MLog.h,
+     mbase/MParList.h, mbase/MReadTree.h, mbase/MTask.h,
+     mbase/MTaskList.h, mdatacheck/MDumpEvtHeader.h,
+     meventdisp/MGFadcDisp.h, mgui/MCamDisplay.h,
+     mgui/MCamNeighbor.h, mgui/MGDataCheckMain.h,
+     mgui/MGEventDispMain.h, mgui/MGMarsMain.h,
+     mgui/MGMonteCarloMain.h, mgui/MGPrototyp.h, mgui/MHexagon.h,
+     mmontecarlo/MCollAreaTrigger.h, mraw/MRawEvtPixelIter.h,
+     mraw/MRawFileRead.h, mraw/MRawFileWrite.h:
+     - set version number to '0' (no i/o for this class)
+
+   * mgui/MGeomCamCT1.cc:
+     - new claculation algorith for the CT1 camera. It is more
+       exact in the camera plain
+       
+   * mgui/MHexagon.cc:
+     - removed Draw-function (it is inherited from TObject)
+     
+   * mmc/MMcFadcHeader.hxx:
+     - Added get-functions
+     
+
 
  2000/03/20: Thomas Bretz
Index: trunk/MagicSoft/Mars/macros/CT1Hillas.C
===================================================================
--- trunk/MagicSoft/Mars/macros/CT1Hillas.C	(revision 698)
+++ trunk/MagicSoft/Mars/macros/CT1Hillas.C	(revision 698)
@@ -0,0 +1,64 @@
+void CT1Hillas()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a CT1 dataset.
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist->AddToList(&tlist);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamMagic camct1;
+    plist->AddToList(&camct1);
+
+    //
+    // The Hillas histograms (MHHillas) could be created automatically
+    // but to make sure, that they are not deleted when the macro is
+    // finished you must create them yourself and add it to the list
+    //
+    MHHillas *hists = new MHHillas;
+    plist->AddToList(hists);
+
+    //
+    // Now setup the tasks and tasklist:
+    //
+    //  1) read in the data from a ct1 ascii file
+    //  2) clean the image
+    //  3) calculate hillas
+    //  4) fill the hillas into the histograms
+    //
+    MCT1ReadAscii readct1("CT1_99_on1.dat") ;
+    MImgCleanStd  clean;
+    MHillasCalc   hcalc;
+    MFillHHillas  hfill;
+
+    tlist.AddToList(&readct1);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&hfill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    evtloop.Eventloop();
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    hists->Draw();
+}
Index: trunk/MagicSoft/Mars/macros/readCT1.C
===================================================================
--- trunk/MagicSoft/Mars/macros/readCT1.C	(revision 697)
+++ trunk/MagicSoft/Mars/macros/readCT1.C	(revision 698)
@@ -3,7 +3,7 @@
     MParList plist;
 
-    MGeomCamMagic camct1;
-    MHillas       hillas;
-    MTaskList     tlist;
+    MGeomCamCT1 camct1;
+    MHillas     hillas;
+    MTaskList   tlist;
 
     plist->AddToList(&camct1);
@@ -12,7 +12,9 @@
 
     MCT1ReadAscii readct1("CT1_99_on1.dat") ;
-    MHillasCalc hcalc;
+    MImgCleanStd  clean;
+    MHillasCalc   hcalc;
 
     tlist.AddToList(&readct1);
+    tlist.AddToList(&clean);
     tlist.AddToList(&hcalc);
 
@@ -40,13 +42,5 @@
             break;
 
-        phevt.CleanLevel1();
-        phevt.CleanLevel2();
-        display.DrawPhotNum(&phevt);
-        gClient->HandleInput();
-        if(getchar()=='q')
-            break;
-
-        phevt.CleanLevel3();
-
+        clean.Process();
         hcalc.Process();
 
Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 698)
@@ -7,4 +7,7 @@
 #pragma link C++ class MCerPhotPix;
 #pragma link C++ class MCerPhotEvt; 
+#pragma link C++ class MCerPhotCalc;
+
+#pragma link C++ class MImgCleanStd;
 
 #pragma link C++ class MCT1ReadAscii;
@@ -13,4 +16,5 @@
 #pragma link C++ class MPedestalPix;
 #pragma link C++ class MPedestalCam;
+#pragma link C++ class MMcPedestalCopy;
 
 #pragma link C++ class MHillas;
Index: trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.cc	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.cc	(revision 698)
@@ -34,8 +34,8 @@
     // skip the next 4 values
     //
-    fin >> dummyF;
-    fin >> dummyF;
-    fin >> dummyF;
-    fin >> dummyF;
+    fin >> dummyF; 
+    fin >> dummyF; 
+    fin >> dummyF; 
+    fin >> dummyF; 
 
     //
Index: trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc	(revision 698)
@@ -10,4 +10,6 @@
 
 #include "MLog.h"
+#include "MLogManip.h"
+
 #include "MParList.h"
 #include "MCerPhotEvt.h"
@@ -41,5 +43,5 @@
     if (!(*fIn))
     {
-        *fLog << "Error: MCT1ReadAscii::PreProcess: Cannot open file." << endl;
+        *fLog << dbginf << "Cannot open file." << endl;
         return kFALSE;
     }
@@ -48,22 +50,14 @@
     //  look for the MCerPhotEvt class in the plist
     //
-    fNphot = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    fNphot = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
     if (!fNphot)
-    {
-        *fLog << "MRawCT1Ascii::PreProcess - WARNING: MCerPhotEvt not found... creating." << endl;
-        fNphot = new MCerPhotEvt;
-        pList->AddToList(fNphot);
-    }
+        return kFALSE;
 
     //
     //  look for the pedestal class in the plist
     //
-    fPedest = (MCT1Pedestals*)pList->FindObject("MCT1Pedestals");
+    fPedest = (MCT1Pedestals*)pList->FindCreateObj("MCT1Pedestals");
     if (!fPedest)
-    {
-        *fLog << "MRawCT1Ascii::PreProcess - WARNING: MCT1Pedestals not found... creating." << endl;
-        fPedest = new MCT1Pedestals;
-        pList->AddToList(fPedest);
-    }
+        return kFALSE;
 
     return kTRUE;
@@ -73,4 +67,11 @@
 {
     //
+    // FIXME. This function should switch between reading pedestals and
+    // reading event data by the 'switch entry'.
+    // After reading it should set the InputStreamID correctly.
+    // ( should use MPedestalCam )
+    //
+ 
+    //
     // read in a dummy number (event number)
     //
@@ -78,9 +79,9 @@
     *fIn >> dummyI;
 
+    //
+    // check if we are done
+    //
     if (fIn->eof())
-    {
-        *fLog << "MRawCT1Ascii::Process - Error: EOF reached." << endl;
         return kFALSE;
-    }
 
     //
@@ -94,8 +95,8 @@
     // five unsused numbers
     //
-    *fIn >> dummyI;
-    *fIn >> dummyI;
-    *fIn >> dummyI;
-    *fIn >> dummyI;
+    *fIn >> dummyI;   // ener
+    *fIn >> dummyI;   // zenang
+    *fIn >> dummyI;   // sec1
+    *fIn >> dummyI;   // sec2
 
     //
@@ -110,10 +111,10 @@
     for (Int_t i = 0; i<127; i++ )
     {
-        Float_t dummyF;
+        Float_t nphot;
 
-        *fIn >> dummyF;
+        *fIn >> nphot;
 
-        if (dummyF > 0.0)
-            fNphot->AddPixel(i, dummyF, (*fPedest)[i]);
+        if (nphot > 0.0)
+            fNphot->AddPixel(i, nphot, (*fPedest)[i]);
     }
 
Index: trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h	(revision 698)
@@ -26,5 +26,5 @@
     Bool_t PostProcess();
 
-    ClassDef(MCT1ReadAscii, 1)	// Reads the CT1 data file
+    ClassDef(MCT1ReadAscii, 0)	// Reads the CT1 data file
 };
 
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 698)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 698)
@@ -0,0 +1,74 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MCerPhotCalc                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MCerPhotCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawEvtPixelIter.h"
+#include "MCerPhotEvt.h"
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+ClassImp(MCerPhotCalc)
+
+    MRawEvtData  *fRawEvt;     // raw event data (time slices)
+    MPedestalCam *fPedestals;  // Pedestals of all pixels in the camera
+    MCerPhotEvt  *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+
+MCerPhotCalc::MCerPhotCalc(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MCerPhotCalc";
+    *fTitle = title ? title : "Task to calculate Cerenkov photons from raw data";
+}
+
+Bool_t MCerPhotCalc::PreProcess( MParList *pList )
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
+    if (!fPedestals)
+    {
+        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Bool_t MCerPhotCalc::Process()
+{
+    fCerPhotEvt->Clear();
+
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+        const UInt_t pixid = pixel.GetPixelId();
+
+        const MPedestalPix &ped = (*fPedestals)[pixid];
+
+        const Float_t nphot = (Float_t)pixel.GetSumHiGainFadcSamples() - ped.GetMean();
+        fCerPhotEvt->AddPixel(pixid, nphot, 0);
+
+        // FIXME! Handling of Lo Gains is missing!
+    }
+
+    return kTRUE;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h	(revision 698)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h	(revision 698)
@@ -0,0 +1,36 @@
+#ifndef MCERPHOTCALC_H
+#define MCERPHOTCALC_H
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotCalc                                                            //
+//                                                                         //
+// Integrates the time slices of one pixel and substracts the pedestal     //
+// (offset) value                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MPedestalCam;
+class MCerPhotEvt;
+
+class MCerPhotCalc : public MTask
+{
+    MRawEvtData  *fRawEvt;     // raw event data (time slices)
+    MPedestalCam *fPedestals;  // Pedestals of all pixels in the camera
+    MCerPhotEvt  *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+
+public:
+    MCerPhotCalc(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MCerPhotCalc, 0)   // Task to calculate cerenkov photons from raw data
+};
+
+#endif
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 698)
@@ -47,9 +47,4 @@
 }
 
-Int_t MCerPhotEvt::GetNumPixels()
-{
-    return fNumPixels;
-} 
-
 void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err)
 {
@@ -58,5 +53,7 @@
     // of valid pixels in the list by one
     //
-    (*fPixels)[fNumPixels++] = new MCerPhotPix( id, nph, err);
+
+    // TClonesArray -> 'operator new with placement' should be used
+    new ((*fPixels)[fNumPixels++]) MCerPhotPix( id, nph, err);
 }
 
@@ -83,4 +80,5 @@
 }
 
+/*
 void MCerPhotEvt::CleanLevel1()
 {
@@ -228,5 +226,5 @@
     }
 }
-
+*/
 
 Bool_t MCerPhotEvt::IsPixelExisting(Int_t id)
@@ -293,5 +291,5 @@
 
     Float_t testval;
-    for (Int_t i=1 ; i<fNumPixels; i++ )
+    for (UInt_t i=1 ; i<fNumPixels; i++ )
     {
         testval = (*this)[i].GetNumPhotons();
@@ -315,5 +313,5 @@
 
     Float_t testval;
-    for (Int_t i=1; i<fNumPixels; i++)
+    for (UInt_t i=1; i<fNumPixels; i++)
     {
         testval = (*this)[i].GetNumPhotons();
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 698)
@@ -6,5 +6,5 @@
 #endif
 #ifndef ROOT_TClonesArray
-#include "TClonesArray.h"
+#include <TClonesArray.h>
 #endif
 #ifndef MPARCONTAINER_H
@@ -21,5 +21,5 @@
 private:
 
-    Int_t         fNumPixels;
+    UInt_t         fNumPixels;
     TClonesArray *fPixels;
 
@@ -27,9 +27,10 @@
 
 public:
-  MCerPhotEvt(const char *name=NULL, const char *title=NULL) ;
+    MCerPhotEvt(const char *name=NULL, const char *title=NULL) ;
+    ~MCerPhotEvt() { delete fPixels; }
 
   void Draw(Option_t* option = "" ) ; 
 
-  Int_t    GetNumPixels() ;
+  UInt_t GetNumPixels() const { return fNumPixels; }
 
   void AddPixel(Int_t id, Float_t nph, Float_t err );
@@ -39,11 +40,11 @@
   void Print(Option_t *opt=NULL) ;
 
-  void CleanLevel1() ; 
-  void CleanLevel2() ; 
-  void CleanLevel3() ; 
+  //  void CleanLevel1() ;
+  //  void CleanLevel2() ;
+  //  void CleanLevel3() ;
   
-  Bool_t  IsPixelExisting( Int_t id ) ;
-  Bool_t  IsPixelUsed    ( Int_t id ) ;
-  Bool_t  IsPixelCore    ( Int_t id ) ;
+  Bool_t  IsPixelExisting( Int_t id );
+  Bool_t  IsPixelUsed    ( Int_t id );
+  Bool_t  IsPixelCore    ( Int_t id );
  
   Float_t GetNumPhotonsMin();
Index: trunk/MagicSoft/Mars/manalysis/MHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 698)
@@ -79,7 +79,8 @@
     // calculate mean valu of pixels
     //
-    float xav =0;
-    float yav =0;
-    float spix=0;
+    float xmean =0;
+    float ymean =0;
+
+    fSize = 0;
 
     for (UInt_t i=0; i<nevt; i++)
@@ -94,18 +95,18 @@
         const float nphot = pix.GetNumPhotons();
 
-        spix += nphot;
-        xav  += nphot * gpix.GetX();
-        yav  += nphot * gpix.GetY();
+        fSize += nphot;
+        xmean += nphot * gpix.GetX(); // [mm]
+        ymean += nphot * gpix.GetY(); // [mm]
     }
 
-    xav /= spix;
-    yav /= spix;
+    xmean /= fSize; // [mm]
+    ymean /= fSize; // [mm]
 
     //
     // calculate sdev
     //
-    float dis11=0;
-    float dis12=0;
-    float dis22=0;
+    float sigmaxx=0;
+    float sigmaxy=0;
+    float sigmayy=0;
 
     for (UInt_t i=0; i<nevt; i++)
@@ -118,12 +119,12 @@
         const MGeomPix &gpix = geom[pix.GetPixId()];
 
-        const float dx = gpix.GetX() - xav;
-        const float dy = gpix.GetY() - yav;
+        const float dx = gpix.GetX() - xmean;
+        const float dy = gpix.GetY() - ymean;
 
         const float nphot = pix.GetNumPhotons();
 
-        dis11 += nphot * dx*dx;
-        dis12 += nphot * dx*dy;
-        dis22 += nphot * dy*dy;
+        sigmaxx += nphot * dx*dx; // [mm^2]
+        sigmaxy += nphot * dx*dy; // [mm^2]
+        sigmayy += nphot * dy*dy; // [mm^2]
     }
 
@@ -131,10 +132,10 @@
     // check for orientation
     //
-    const float theta = atan(dis12/(dis11-dis22)*2)/2;
+    const float theta = atan(sigmaxy/(sigmaxx-sigmayy)*2)/2;
 
-    float c = cos(theta);
-    float s = sin(theta);
+    float c = cos(theta); // [1]
+    float s = sin(theta); // [1]
 
-    const float direction = c*xav+s*yav;
+    const float direction = c*xmean + s*ymean;
 
     if (direction<0)
@@ -144,29 +145,29 @@
     }
 
-    float rot1 =  2.0*c*s*dis12 + c*c*dis11 + s*s*dis22;
-    float rot2 = -2.0*c*s*dis12 + s*s*dis11 + c*c*dis22;
+    float axis1 =  2.0*c*s*sigmaxy + c*c*sigmaxx + s*s*sigmayy; // [mm^2]
+    float axis2 = -2.0*c*s*sigmaxy + s*s*sigmaxx + c*c*sigmayy; // [mm^2]
 
-    rot1 /= spix;
-    rot2 /= spix;
+    axis1 /= fSize; // [mm^2]
+    axis2 /= fSize; // [mm^2]
 
     //
     // check for numerical negatives
     //
-    if (rot1 < 0) rot1=0;
-    if (rot2 < 0) rot2=0;
+    if (axis1 < 0) axis1=0;
+    if (axis2 < 0) axis2=0;
 
     //
     // check the rotation of the axis
     //
-    const int rotation = rot1<rot2;
+    const int rotation = axis1<axis2;
 
-    fLength = rotation ? sqrt(rot2) : sqrt(rot1);
-    fWidth  = rotation ? sqrt(rot1) : sqrt(rot2);
+    fLength = rotation ? sqrt(axis2) : sqrt(axis1);      // [mm]
+    fWidth  = rotation ? sqrt(axis1) : sqrt(axis2);      // [mm]
 
-    fAlpha = 180/kPI*atan((-xav*s+yav*c)/direction);
+    fAlpha = 180/kPI*atan((-xmean*s+ymean*c)/direction); // [deg]
 
-    fDist  = sqrt(xav*xav + yav*yav);
+    fDist  = sqrt(xmean*xmean + ymean*ymean);            // [mm]
 
-    fTheta = atan(yav/xav);
-    if (xav<0) fTheta += kPI;
+    fTheta = atan(ymean/xmean);                          // [rad]
+    if (xmean<0) fTheta += kPI;                          // [deg]
 }
Index: trunk/MagicSoft/Mars/manalysis/MHillas.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 698)
@@ -34,4 +34,9 @@
     void Clear(Option_t *opt=NULL);
 
+    Float_t GetAlpha() const  { return fAlpha; }
+    Float_t GetWidth() const  { return fWidth; }
+    Float_t GetLength() const { return fLength; }
+    Float_t GetDist() const   { return fDist; }
+
     ClassDef(MHillas, 1) // Storage Container for Hillas Parameter
 };
Index: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 698)
+++ trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 698)
@@ -0,0 +1,191 @@
+#include "MImgCleanStd.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+#include "MCamNeighbor.h"
+
+ClassImp(MImgCleanStd)
+
+MImgCleanStd::MImgCleanStd(const char *name, const char *title)
+{
+    //
+    //   the default constructor
+    //
+  
+    *fName  = name  ? name  : "MImgCleanStd";
+    *fTitle = name  ? name  : "Task which does a standard image cleaning";
+}
+
+void MImgCleanStd::CleanLevel1()
+{
+    //
+    //  This method looks for all pixels with an entry (photons)
+    //  that is three times bigger than the noise of the pixel
+    //
+
+    const Int_t entries = fEvt->GetNumPixels();
+
+    //
+    // check the number of all pixels against the noise level and
+    // set them to 'unused' state if necessary
+    //
+    for (Int_t il=0; il<entries; il++ )
+    {
+        MCerPhotPix &pix = (*fEvt)[il];
+
+        const Float_t entry = pix.GetNumPhotons();
+        const Float_t noise = pix.GetErrorPhot();
+
+        if (entry < 3 * noise )
+            pix.SetPixelUnused();
+    }
+}
+
+void MImgCleanStd::CleanLevel2()
+{
+    //
+    //  check if the  survived pixel have a neighbor, that also
+    //  survived
+    //
+
+    const Int_t entries = fEvt->GetNumPixels();
+
+    for (Int_t il=0; il<entries; il++)
+    {
+        //
+        // get entry il from list
+        //
+        MCerPhotPix &pix = (*fEvt)[il];
+
+        //
+        // check if pixel is in use, if not goto next pixel in list
+        //
+        if (!pix.IsPixelUsed())
+            continue;
+
+        //
+        // get pixel id of this entry
+        //
+        const Int_t id = pix.GetPixId() ;
+
+        //
+        // count number of next neighbors of this pixel which
+        // state is 'used'
+        //
+        Int_t itest = 0 ;
+        for (Int_t in=0 ; in < 6; in++ )
+        {
+            const Int_t id2 = fNN.GetNN(id, in) ;
+
+            if (id2 < 0)
+                continue;
+
+            if (fEvt->IsPixelUsed(id2))
+                itest++ ;
+        }
+
+        //
+        // check if no next neighbor has the state 'used'
+        // set this pixel to 'unused', too.
+        //
+        if (itest==0)
+            pix.SetPixelUnused();
+    }
+
+    //
+    // now we declare all pixels that survive as CorePixels
+    //
+    for (Int_t il=0; il<entries; il++)
+    {
+        MCerPhotPix &pix = (*fEvt)[il];
+
+        if (pix.IsPixelUsed())
+            pix.SetCorePixel();
+    }
+
+} 
+
+void MImgCleanStd::CleanLevel3()
+{
+    //
+    //   Look for the boundary pixels around the core pixels
+    //   if a pixel has more than 2.5 sigma, and a core neigbor
+    //   it is declared as used.
+    //
+    const Int_t entries = fEvt->GetNumPixels();
+
+    for (Int_t il=0; il<entries; il++)
+    {
+        //
+        // get pixel as entry il from list
+        //
+        MCerPhotPix &pix = (*fEvt)[il];
+
+        //
+        // if pixel is a core pixel go to the next pixel
+        //
+        if (pix.IsCorePixel())
+            continue;
+
+        //
+        // check the num of photons against the noise level
+        //
+        const Float_t entry = pix.GetNumPhotons();
+        const Float_t noise = pix.GetErrorPhot();
+
+        if (entry <= 2.5 * noise )
+            continue;
+
+        //
+        // get pixel id of this entry
+        //
+        const Int_t id = pix.GetPixId();
+
+        //
+        // check if the pixel's next neighbor is a core pixel.
+        // if it is a core pixel set pixel state to: used.
+        //
+        for (Int_t in=0; in<6 ; in++)
+        {
+            const Int_t id2 = fNN.GetNN(id, in);
+
+            if (id2 <0)
+                continue;
+
+            if (!fEvt->IsPixelCore(id2))
+                continue;
+
+            pix.SetPixelUsed();
+
+            break ;
+        }
+    }
+}
+
+Bool_t MImgCleanStd::PreProcess (MParList *pList)
+{
+    //
+    //  check if MEvtHeader exists in the Parameter list already.
+    //  if not create one and add them to the list
+    //
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (fEvt)
+        return kTRUE;
+
+    *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+    return kFALSE;
+}
+    
+Bool_t MImgCleanStd::Process()
+{
+    CleanLevel1();
+    CleanLevel2();
+    CleanLevel3();
+
+    return kTRUE;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 698)
+++ trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 698)
@@ -0,0 +1,37 @@
+#ifndef MIMGCLEANSTD_H
+#define MIMGCLEANSTD_H
+
+#ifndef MAGIC_h
+#include "MAGIC.h"
+#endif
+#ifndef MPARCONTAINER_H
+#include "MTask.h"
+#endif
+#ifndef MCAMNEIGHBOR_H
+#include "MCamNeighbor.h"
+#endif
+
+class MCerPhotEvt;
+
+class MImgCleanStd : public MTask
+{
+private:
+    MCamNeighbor  fNN;   //! the class with the information about neighbors
+
+    MCerPhotEvt *fEvt;
+
+public:
+    MImgCleanStd(const char *name=NULL, const char *title=NULL) ;
+
+    void CleanLevel1();
+    void CleanLevel2();
+    void CleanLevel3();
+
+    Bool_t PreProcess (MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MImgCleanStd, 0)    // class for Nphotons Events
+}; 
+
+#endif
+
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 698)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 698)
@@ -0,0 +1,55 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MMcPedestalCopy                                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MMcPedestalCopy.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MPedestalCam.h"
+#include "MMcFadcHeader.hxx"
+
+ClassImp(MMcPedestalCopy)
+
+MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MMcPedestalCopy";
+    *fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
+}
+
+Bool_t MMcPedestalCopy::PreProcess( MParList *pList )
+{
+    fMcPedestals = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
+    if (!fMcPedestals)
+    {
+        *fLog << dbginf << "MMcFadcHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Bool_t MMcPedestalCopy::Process()
+{
+    fPedestals->InitSize(fMcPedestals->GetNumPixel());
+
+    for (int i=0; i<MFADC_CHANNELS; i++)
+    {
+        MPedestalPix &pix = (*fPedestals)[i];
+
+        pix.SetPedestal(fMcPedestals->GetPedestal(i), 0);
+        pix.SetPedestalRms(fMcPedestals->GetPedestalRms(i), 0);
+    }
+
+    return kTRUE;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 698)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 698)
@@ -0,0 +1,39 @@
+#ifndef MMCPEDESTALCOPY_H
+#define MMCPEDESTALCOPY_H
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MMcPedestalCopy                                                         //
+//                                                                         //
+// This task copies the pedestals from the MC data into the corresponding  //
+// MARS Container (MPedestals). This seems to be overdone, but at this     //
+// point you have a standard interface to access the pedestals             //
+// (MPedestals), which makes it possible that from now on all pedestals    //
+// can be treated in the same way                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MMcFadcHeader;
+class MPedestalCam;
+
+class MMcPedestalCopy : public MTask
+{
+    MMcFadcHeader *fMcPedestals;  //
+    MPedestalCam  *fPedestals;    //
+
+    TString       *fSrc;
+
+public:
+    MMcPedestalCopy(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MMcPedestalCopy, 0)   // Task to calculate Hillas parameters
+};
+
+#endif
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 698)
@@ -18,4 +18,10 @@
 
     fArray = new TClonesArray("MPedestalPix", 577);
+
+    //
+    // TClonesArray: The 'new operator with placement' must be used
+    //
+    for (int i=0; i<577; i++)
+        new ((*fArray)[i]) MPedestalPix;
 }
 
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 698)
@@ -23,4 +23,6 @@
     ~MPedestalCam();
 
+    void InitSize(const UInt_t i) { fArray->ExpandCreateFast(i); }
+
     MPedestalPix &operator[](Int_t i) { return *(MPedestalPix*)fArray->At(i); }
 
Index: trunk/MagicSoft/Mars/manalysis/MPedestalPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 698)
@@ -17,8 +17,8 @@
     MPedestalPix();
 
-    Float_t GetMean()     { return fMean;     }
-    Float_t GetSigma()    { return fSigma;    }
-    Float_t GetMeanRms()  { return fMeanRms;  }
-    Float_t GetSigmaRms() { return fSigmaRms; }
+    Float_t GetMean() const     { return fMean;     }
+    Float_t GetSigma() const    { return fSigma;    }
+    Float_t GetMeanRms() const  { return fMeanRms;  }
+    Float_t GetSigmaRms() const { return fSigmaRms; }
 
     void SetMean(Float_t f)     { fMean = f;     }
@@ -27,4 +27,7 @@
     void SetSigmaRms(Float_t f) { fSigmaRms = f; }
 
+    void SetPedestal(Float_t m, Float_t s) { fMean = m; fSigma = s; }
+    void SetPedestalRms(Float_t m, Float_t s) { fMeanRms = m; fSigmaRms = s; }
+
     ClassDef(MPedestalPix, 1)	// Storage Container for Pedestal information of one pixel
 };
Index: trunk/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- trunk/MagicSoft/Mars/manalysis/Makefile	(revision 697)
+++ trunk/MagicSoft/Mars/manalysis/Makefile	(revision 698)
@@ -22,5 +22,5 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES = -I. -I../mbase -I../mgui
+INCLUDES = -I. -I../mbase -I../mgui -I../mmc -I../mraw
 
 #------------------------------------------------------------------------------
@@ -32,6 +32,9 @@
            MPedestalCam.cc \
            MPedestalPix.cc \
+           MMcPedestalCopy.cc \
+           MImgCleanStd.cc \
            MHillas.cc \
            MHillasCalc.cc \
+           MCerPhotCalc.cc \
 	   MCerPhotEvt.cc \
 	   MCerPhotPix.cc 
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 698)
@@ -39,5 +39,5 @@
     void Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
 
-    ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
+    ClassDef(MEvtLoop, 0) // Class to execute the tasks in a tasklist
 };
 
Index: trunk/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MLog.h	(revision 698)
@@ -116,5 +116,5 @@
     }
 
-    ClassDef(MLog, 1)
+    ClassDef(MLog, 0)
 };
 
Index: trunk/MagicSoft/Mars/mbase/MLogManip.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLogManip.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MLogManip.h	(revision 698)
@@ -53,5 +53,5 @@
 //
 #ifndef __CINT__
-#define dbginf        __FILE__ << " " << __LINE__ << ": "
+#define dbginf        __FILE__ << " l." << __LINE__ << ": "
 #endif
 //
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 698)
@@ -24,4 +24,8 @@
 ClassImp(MParList)
 
+    //
+    // FIXME: The Automatic created classes are NEVER deleted!!!!!
+    //
+
 MParList::MParList(const char *name, const char *title)
 {
@@ -32,4 +36,10 @@
     *fName  = name  ? name  : "MParList";
     *fTitle = title ? title : "List of Parameter Containers";
+
+    //
+    // This sets a flag that the list is the owner, which means
+    // that the destructor of the list deletes all it's objects
+    //
+    fAutodelete.SetOwner();
 }
 
@@ -151,4 +161,6 @@
     AddToList(pcont);
 
+    fAutodelete.Add(pcont);
+
     //
     //  Find an object in the list.
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 698)
@@ -27,4 +27,5 @@
 private:
     TOrdCollection fContainer;	// Collection of Parameter and Data Containers
+    TOrdCollection fAutodelete; // All what this list contains is deleted in the destructor
 
 public:
@@ -45,5 +46,5 @@
     void Print(Option_t *t = NULL);
 
-    ClassDef(MParList, 1)	//list of parameter containers (MParContainer)
+    ClassDef(MParList, 0) // list of parameter containers (MParContainer)
 };
 
Index: trunk/MagicSoft/Mars/mbase/MReadTree.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MReadTree.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MReadTree.h	(revision 698)
@@ -36,5 +36,5 @@
     UInt_t GetEntries() {return fNumEntries;}
 
-    ClassDef(MReadTree, 1)	// Reads one tree
+    ClassDef(MReadTree, 0)	// Reads one tree
 };
 
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 698)
@@ -27,5 +27,5 @@
     virtual Bool_t PostProcess();
 
-    ClassDef(MTask, 1)		//Abstract base class for a task
+    ClassDef(MTask, 0)		//Abstract base class for a task
 };
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 697)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 698)
@@ -41,5 +41,5 @@
     void Print(Option_t *t = NULL);
 
-    ClassDef(MTaskList, 1)	//collection of tasks to be performed in the eventloop
+    ClassDef(MTaskList, 0)	//collection of tasks to be performed in the eventloop
 };
 
Index: trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 698)
@@ -5,7 +5,12 @@
 #pragma link off all functions;
 
+#pragma link C++ class MHFadcCam;
+#pragma link C++ class MHFadcPix;
+#pragma link C++ class MHHillas;
+
 #pragma link C++ class MShowSpect;
-#pragma link C++ class MHistosAdc;
-#pragma link C++ class MFillAdcSpect;
+
+#pragma link C++ class MFillHFadc;
+#pragma link C++ class MFillHHillas;
 
 #pragma link C++ class MDumpEvtHeader;
Index: trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 698)
@@ -26,5 +26,5 @@
   Bool_t Process() ;
   
-  ClassDef(MDumpEvtHeader, 1)	// Class to dump the pixel ids of a raw evt to the screen
+  ClassDef(MDumpEvtHeader, 0)	// Class to dump the pixel ids of a raw evt to the screen
 
 };
Index: trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc	(revision 697)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#include "MFillAdcSpect.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-#include "MParList.h"
-#include "MHistosAdc.h"
-#include "MRawEvtData.h"
-#include "MRawEvtPixelIter.h"
-
-ClassImp(MFillAdcSpect)
-
-    MFillAdcSpect::MFillAdcSpect (const char *name, const char *title) : fRawEvtData(NULL)
-{
-  *fName  = name  ? name  : "MFillAdcSpect";
-  *fTitle = title ? title : "Task to fill the adc spectra with  raw data";
-}
-
-Bool_t MFillAdcSpect::PreProcess (MParList *pList)
-{
-  // connect the raw data with this task
-  
-  fHistos = (MHistosAdc*)pList->FindCreateObj("MHistosAdc");
-  if (!fHistos)
-      return kFALSE;
-
-  fRawEvtData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
-  if (!fRawEvtData)
-  {
-      *fLog << dbginf << " Error: MRawEvtData not found... exit." << endl;
-      return kFALSE ;
-  }
-
-  return kTRUE ; 
-
-} 
-
-Bool_t MFillAdcSpect::Process()
-{
-  //  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() ;
-
-  //  cout << "HighSamples " << iHighSamples ;
-
-  while ( pixel.Next() )
-    { 
-      for (Int_t i=0 ; i<nhisamples ; i++ )
-	{ 
-	  fHistos->FillAdcHistHi ( pixel.GetPixelId(),
-                                   pixel.GetHiGainFadcSamples()[i] );
-	}
-
-      for (Int_t i=0 ; i<nlosamples ; i++ )
-	{ 
-	  fHistos->FillAdcHistLo ( pixel.GetPixelId(),
-				   pixel.GetLoGainFadcSamples()[i] );
-	}
-    } 
-  
-  return kTRUE;
-  
-} 
Index: trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h	(revision 697)
+++ 	(revision )
@@ -1,33 +1,0 @@
-#ifndef MFILLADCSPECT_H
-#define MFILLADCSPECT_H
-
-#ifndef MAGIC_H
-#include "MAGIC.h"
-#endif
-
-#ifndef MTASK_H
-#include "MTask.h"
-#endif
-
-class MParList;
-class MHistosAdc;
-class MRawEvtData;
-
-class MFillAdcSpect : public MTask {
- private:
-  MRawEvtData      *fRawEvtData;
-
-  MHistosAdc       *fHistos ; 
-
- public:   
-  MFillAdcSpect (const char *name=NULL, const char *title=NULL); 
-
-  Bool_t PreProcess(MParList *pList);
-  Bool_t Process() ;
-  
-  ClassDef(MFillAdcSpect, 1)	// Task to fill a MHistosAdc Container with data
-
-};
-    
-#endif
-
Index: trunk/MagicSoft/Mars/mdatacheck/MFillHFadc.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillHFadc.cc	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MFillHFadc.cc	(revision 698)
@@ -0,0 +1,65 @@
+#include "MFillHFadc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+#include "MHFadcCam.h"
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MFillHFadc)
+
+    MFillHFadc::MFillHFadc (const char *name, const char *title) : fRawEvtData(NULL)
+{
+  *fName  = name  ? name  : "MFillHFadc";
+  *fTitle = title ? title : "Task to fill the adc spectra with  raw data";
+}
+
+Bool_t MFillHFadc::PreProcess (MParList *pList)
+{
+  // connect the raw data with this task
+  
+  fHistos = (MHFadcCam*)pList->FindCreateObj("MHFadcCam");
+  if (!fHistos)
+      return kFALSE;
+
+  fRawEvtData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
+  if (!fRawEvtData)
+  {
+      *fLog << dbginf << " Error: MRawEvtData not found... exit." << endl;
+      return kFALSE ;
+  }
+
+  return kTRUE ; 
+
+} 
+
+Bool_t MFillHFadc::Process()
+{
+  //  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() ;
+
+  //  cout << "HighSamples " << iHighSamples ;
+
+  while ( pixel.Next() )
+    { 
+      for (Int_t i=0 ; i<nhisamples ; i++ )
+	{ 
+            fHistos->FillHi ( pixel.GetPixelId(),
+                              pixel.GetHiGainFadcSamples()[i] );
+	}
+
+      for (Int_t i=0 ; i<nlosamples ; i++ )
+	{ 
+            fHistos->FillLo ( pixel.GetPixelId(),
+                              pixel.GetLoGainFadcSamples()[i] );
+	}
+    } 
+  
+  return kTRUE;
+  
+} 
Index: trunk/MagicSoft/Mars/mdatacheck/MFillHFadc.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillHFadc.h	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MFillHFadc.h	(revision 698)
@@ -0,0 +1,33 @@
+#ifndef MFILLHFADC_H
+#define MFILLHFADC_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MParList;
+class MHFadcCam;
+class MRawEvtData;
+
+class MFillHFadc : public MTask {
+ private:
+  MRawEvtData      *fRawEvtData;
+
+  MHFadcCam        *fHistos ;
+
+ public:   
+  MFillHFadc (const char *name=NULL, const char *title=NULL); 
+
+  Bool_t PreProcess(MParList *pList);
+  Bool_t Process() ;
+  
+  ClassDef(MFillHFadc, 0)	// Task to fill a MHistosAdc Container with data
+
+};
+    
+#endif
+
Index: trunk/MagicSoft/Mars/mdatacheck/MFillHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillHHillas.cc	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MFillHHillas.cc	(revision 698)
@@ -0,0 +1,37 @@
+#include "MFillHHillas.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MHHillas.h"
+#include "MParList.h"
+
+ClassImp(MFillHHillas)
+
+MFillHHillas::MFillHHillas (const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MFillHHillas";
+    *fTitle = title ? title : "Task to fill Hillas histograms";
+}
+
+Bool_t MFillHHillas::PreProcess (MParList *pList)
+{
+    fEvt = (MHillas*)pList->FindObject("MHillas");
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MHillas not found... aborting." << endl;
+        return kFALSE ;
+    }
+
+    fHistos = (MHHillas*)pList->FindCreateObj("MHHillas");
+    if (!fHistos)
+        return kFALSE;
+
+    return kTRUE ;
+} 
+
+Bool_t MFillHHillas::Process()
+{
+    fHistos->Fill(fEvt);
+
+    return kTRUE;
+} 
Index: trunk/MagicSoft/Mars/mdatacheck/MFillHHillas.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillHHillas.h	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MFillHHillas.h	(revision 698)
@@ -0,0 +1,32 @@
+#ifndef MFILLHHILLAS_H
+#define MFILLHHILLAS_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MParList;
+class MHHillas;
+class MHillas;
+
+class MFillHHillas : public MTask {
+ private:
+  MHillas  *fEvt;
+  MHHillas *fHistos ;
+
+ public:   
+  MFillHHillas (const char *name=NULL, const char *title=NULL); 
+
+  Bool_t PreProcess(MParList *pList);
+  Bool_t Process() ;
+  
+  ClassDef(MFillHHillas, 0)	// Task to fill the Hillas histograms
+
+};
+    
+#endif
+
Index: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 698)
@@ -23,5 +23,5 @@
 } ; 
 
-MGDisplayAdc::MGDisplayAdc ( MHistosAdc *histos,
+MGDisplayAdc::MGDisplayAdc ( MHFadcCam *histos,
 			    const TGWindow *p, const TGWindow *main, 
 			    UInt_t w, UInt_t h, 
@@ -218,5 +218,5 @@
     //   Histogramms in there.
     //
-    //   In the class MHistosAdc are in fact two lists. One for the high and
+    //   In the class MHFadcCam are in fact two lists. One for the high and
     //   one for the low gain. Here we will use only the high gain list!!!
     //   With some special options (settings in the gui) we will also be able
@@ -224,5 +224,5 @@
     //
 
-    const Int_t nhi = fHists->GetHiEntries();
+    const Int_t nhi = fHists->GetEntries();
     for ( Int_t i=0 ; i < nhi; i++ ) {
         fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1) ;
Index: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 698)
@@ -12,6 +12,6 @@
 #endif
 
-#ifndef MHISTOSADC_H
-#include "MHistosAdc.h"
+#ifndef MHFADCCAM_H
+#include "MHFadcCam.h"
 #endif
 
@@ -24,5 +24,5 @@
     private:
 	
-	MHistosAdc *fHists;		// Pointer to Container with the histograms
+	MHFadcCam *fHists;		// Pointer to Container with the histograms
 	
 	// Create a main frame with a number of different buttons.
@@ -71,5 +71,5 @@
 	TCanvas *fCanvas;
 	
-	MGDisplayAdc(MHistosAdc *fHists , 
+	MGDisplayAdc(MHFadcCam *fHists ,
 		     const TGWindow *p, const TGWindow *main, 
 		     UInt_t w, UInt_t h, 
Index: trunk/MagicSoft/Mars/mdatacheck/MHFadcCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHFadcCam.cc	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MHFadcCam.cc	(revision 698)
@@ -0,0 +1,66 @@
+///////////////////////////////////////////////////////////////////////
+//
+// MHFadcCam
+//
+// This class contains a list of all ADC spektra histograms
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHFadcCam.h"
+
+#include <TH1.h>
+
+ClassImp(MHFadcCam)
+
+MHFadcCam::MHFadcCam (const char *name, const char *title)
+{
+    //
+    //  default constructor
+    //  creates an a list of histograms for all pixels and both gain channels
+    //
+
+    //
+    //   set the name and title of this object
+    //
+    
+    *fName  = name  ? name  : "MHFadcCam" ;
+    *fTitle = title ? title : "Container for ADC spectra histograms" ;
+
+    //
+    //   loop over all Pixels and create two histograms
+    //   one for the Low and one for the High gain
+    //   connect all the histogram with the container fHist
+    //
+    fArray = new TObjArray(577);
+
+    for (Int_t i=0; i<577; i++)
+        (*fArray)[i] = new MHFadcPix(i);
+}
+
+MHFadcCam::~MHFadcCam ()
+{
+    delete fArray;
+}
+
+/*void MHFadcCam::SaveHist(char *name)
+{
+    //
+    //   save all histogram in this class to a root file
+    //
+
+    //
+    // FIXME: Don't open a file and write to this file!
+    // just Fill the current container (or the two histograms
+    // to an open file. The user must choose a file before.
+    //
+    TFile out( name, "recreate") ;
+
+    //
+    //  loop over all pixels and write the files out
+    //
+
+    fHistLo->Write() ;
+    fHistHi->Write() ;
+}
+
+  */
Index: trunk/MagicSoft/Mars/mdatacheck/MHFadcCam.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHFadcCam.h	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MHFadcCam.h	(revision 698)
@@ -0,0 +1,54 @@
+#ifndef MHFADCCAM_H
+#define MHFADCCAM_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+#ifndef MHFADCPIX_H
+#include "MHFadcPix.h"
+#endif
+
+class TH1F;
+
+class MHFadcCam : public MParContainer
+{
+private:
+    TObjArray *fArray;	// List of Lo/Hi gain Histograms
+
+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);
+
+    MHFadcPix *operator[](UInt_t i) { return (MHFadcPix*)(fArray->At(i)); }
+
+    TH1F *GetHistHi(UInt_t i)  { return (*this)[i]->GetHistHi(); }
+    TH1F *GetHistLo(UInt_t i)  { return (*this)[i]->GetHistLo(); }
+
+    void DrawHi(UInt_t i) { GetHistHi(i)->Draw(); }
+    void DrawLo(UInt_t i) { GetHistLo(i)->Draw(); }
+
+    void Draw(UInt_t i) { (*this)[i]->Draw(); }
+
+    Int_t GetEntries()
+    {
+        return fArray->GetEntries() ;
+    }
+
+    ClassDef(MHFadcCam, 1)	// list of Histograms with ADC spectra
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mdatacheck/MHFadcPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHFadcPix.cc	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MHFadcPix.cc	(revision 698)
@@ -0,0 +1,31 @@
+///////////////////////////////////////////////////////////////////////
+//
+// MHistosAdc
+//
+// This class contains a list of all ADC spektra histograms
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHFadcPix.h"
+
+#include <TPad.h>
+
+ClassImp(MHFadcPix)
+
+void MHFadcPix::Draw(Option_t *)
+{
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
+
+    gPad->Divide(1, 2);
+
+    gPad->cd(0);
+    fHistHi->Draw();
+
+    gPad->cd(1);
+    fHistLo->Draw();
+}
Index: trunk/MagicSoft/Mars/mdatacheck/MHFadcPix.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHFadcPix.h	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MHFadcPix.h	(revision 698)
@@ -0,0 +1,54 @@
+#ifndef MHFADCPIX_H
+#define MHFADCPIX_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MHFadcPix : public TObject
+{
+private:
+    TH1F *fHistHi;
+    TH1F *fHistLo;
+
+public:
+    MHFadcPix(UInt_t pixid)
+    {
+        Char_t tmp1[40];
+        Char_t tmp2[40];
+
+        sprintf(tmp1, "high%d", pixid);
+        sprintf(tmp2, "high gain Pixel %d", pixid);
+
+        fHistHi =  new TH1F(tmp1, tmp2, 256, 0, 255);
+
+        sprintf(tmp1, "low %d", pixid);
+        sprintf(tmp2, "low gain Pixel %d", pixid);
+
+        fHistLo =  new TH1F(tmp1, tmp2, 256, 0, 255);
+    }
+    ~MHFadcPix()
+    {
+        delete fHistHi;
+        delete fHistLo;
+    }
+    TH1F *GetHistHi() { return fHistHi; }
+    TH1F *GetHistLo() { return fHistLo; }
+
+    void FillHi(Byte_t i) { fHistHi->Fill(i); }
+    void FillLo(Byte_t i) { fHistLo->Fill(i); }
+
+    void DrawHi() { fHistHi->Draw(); }
+    void DrawLo() { fHistLo->Draw(); }
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHFadcPix, 1)
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mdatacheck/MHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHHillas.cc	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MHHillas.cc	(revision 698)
@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////////////
+//
+// MHHillas
+//
+// This class contains histograms for every Hillas parameter
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHHillas.h"
+
+#include <TH1.h>
+#include <TPad.h>
+
+#include "MHillas.h"
+
+ClassImp(MHHillas)
+
+MHHillas::MHHillas (const char *name, const char *title)
+{
+    //
+    //  default constructor
+    //  creates an a list of histograms for all pixels and both gain channels
+    //
+
+    //
+    //   set the name and title of this object
+    //
+    
+    *fName  = name  ? name  : "MHHillas" ;
+    *fTitle = title ? title : "Container for Hillas histograms" ;
+
+    //
+    //   loop over all Pixels and create two histograms
+    //   one for the Low and one for the High gain
+    //   connect all the histogram with the container fHist
+    //
+    fAlpha  = new TH1F("Alpha [deg]", "Alpha of Hillas",   90, 0,  90);
+    fWidth  = new TH1F("Width [mm]",  "Width of Hillas",  150, 0, 150);
+    fLength = new TH1F("Length [mm]", "Length of Hillas", 150, 0, 150);
+    fDist   = new TH1F("Dist [mm]",   "Dist of Hillas",   200, 0, 200);
+}
+
+MHHillas::~MHHillas()
+{
+    delete fAlpha;
+    delete fWidth;
+    delete fLength;
+    delete fDist;
+}
+
+void MHHillas::Fill(MHillas *par)
+{
+    fAlpha ->Fill(par->GetAlpha());
+    fWidth ->Fill(par->GetWidth());
+    fLength->Fill(par->GetLength());
+    fDist  ->Fill(par->GetDist());
+}
+
+#include <TCanvas.h>
+void MHHillas::Draw(Option_t *)
+{
+
+    TCanvas *c = new TCanvas("Hillas", "Histograms of Hillas Parameters");
+    c->Divide(2,2);
+
+    c->cd(1);
+    fAlpha->Draw();
+    c->cd(2);
+    fLength->Draw();
+    c->cd(3);
+    fDist->Draw();
+    c->cd(4);
+    fWidth->Draw();
+
+    c->Modified();
+    c->Update();
+}
Index: trunk/MagicSoft/Mars/mdatacheck/MHHillas.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHHillas.h	(revision 698)
+++ trunk/MagicSoft/Mars/mdatacheck/MHHillas.h	(revision 698)
@@ -0,0 +1,48 @@
+#ifndef MHHILLAS_H
+#define MHHILLAS_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+
+class MHillas;
+
+class MHHillas : public MParContainer
+{
+private:
+    TH1F *fAlpha;
+    TH1F *fWidth;
+    TH1F *fLength;
+    TH1F *fDist;
+
+public:
+     MHHillas(const char *name=NULL, const char *title=NULL);
+    ~MHHillas();
+
+    void Fill(MHillas *par);
+
+    TH1F *GetHistAlpha()  { return fAlpha; }
+    TH1F *GetHistWidth()  { return fWidth; }
+    TH1F *GetHistLength() { return fLength; }
+    TH1F *GetHistDist()   { return fDist; }
+
+    void DrawAlpha()  { fAlpha->Draw(); }
+    void DrawWidth()  { fWidth->Draw(); }
+    void DrawLength() { fLength->Draw(); }
+    void DrawDist()   { fDist->Draw(); }
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHHillas, 1)	// list of Histograms with ADC spectra
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mdatacheck/MHistosAdc.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHistosAdc.cc	(revision 697)
+++ 	(revision )
@@ -1,108 +1,0 @@
-///////////////////////////////////////////////////////////////////////
-//
-// MHistosAdc
-//
-// This class contains a list of all ADC spektra histograms
-//
-///////////////////////////////////////////////////////////////////////
-
-#include "MHistosAdc.h"
-
-#include <iostream.h>
-
-#include <TH1.h>
-#include <TFile.h>
-
-ClassImp(MHistosAdc)
-
-MHistosAdc::MHistosAdc (const char *name, const char *title)
-{
-    //
-    //  default constructor
-    //  creates an a list of histograms for all pixels and both gain channels
-    //
-
-    //
-    //   set the name and title of this object
-    //
-    
-    *fName  = name  ? name  : "MHistosAdc" ;
-    *fTitle = title ? title : "Container for ADC spectra histograms" ;
-
-    //
-    //   loop over all Pixels and create two histograms
-    //   one for the Low and one for the High gain
-    //   connect all the histogram with the container fHist
-    //
-    fHistHi = new TObjArray(577);
-    fHistLo = new TObjArray(577);
-
-    Char_t  tmp1[40];
-    Char_t  tmp2[40];
-
-    for ( Int_t i = 0 ; i < 577 ; i++)
-    {
-        sprintf ( tmp1, "high%d", i ) ;
-        sprintf ( tmp2, "high gain Pixel %d", i ) ;
-
-        fHistHi->Add( new TH1F ( tmp1, tmp2, 256, 0., 255. )  ) ;
-
-        sprintf ( tmp1, "low %d", i ) ;
-        sprintf ( tmp2, "low gain Pixel %d", i ) ;
-
-        fHistLo->Add( new TH1F ( tmp1, tmp2, 256, 0., 255. ) ) ;
-    }
-}
-
-MHistosAdc::~MHistosAdc ()
-{
-  
-  //   default destructor 
-  //
-  delete fHistHi ;
-  delete fHistLo ;
-}
-
-void MHistosAdc::Print(Option_t *)
-{
-  for ( Int_t i = 0 ; i < 576 ; i++)
-    {
-      fHistHi[i].Print() ;
-    }
-}
-
-void MHistosAdc::FillAdcHistHi ( Int_t iPix, Byte_t data)
-{
-  //
-  
-  GetHistHi(iPix)->Fill( (Float_t) data ) ;
-}
-
-void MHistosAdc::FillAdcHistLo ( Int_t iPix, Byte_t data)
-{
-  //
-  
-  GetHistLo(iPix)->Fill( (Float_t) data ) ;
-}
-
-void MHistosAdc::SaveHist ( char *name )
-{
-    //
-    //   save all histogram in this class to a root file
-    //
-
-    //
-    // FIXME: Don't open a file and write to this file!
-    // just Fill the current container (or the two histograms
-    // to an open file. The user must choose a file before.
-    //
-    TFile out( name, "recreate") ;
-
-    //
-    //  loop over all pixels and write the files out
-    //
-
-    fHistLo->Write() ;
-    fHistHi->Write() ;
-}
-
Index: trunk/MagicSoft/Mars/mdatacheck/MHistosAdc.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MHistosAdc.h	(revision 697)
+++ 	(revision )
@@ -1,68 +1,0 @@
-#ifndef MHISTOSADC_H
-#define MHISTOSADC_H
-
-#ifndef MAGIC_H
-#include "MAGIC.h"
-#endif
-
-#ifndef ROOT_TH1
-#include <TH1.h>
-#endif
-#ifndef ROOT_TObjArray
-#include <TObjArray.h>
-#endif
-
-#ifndef MPARCONTAINER_H
-#include "MParContainer.h"
-#endif
-
-class MHistosAdc : public MParContainer
-{
-private:
-    TObjArray *fHistHi;	// List of High gain Histograms
-    TObjArray *fHistLo;	// List of Low  gain Histograms
-
-public:
-     MHistosAdc(const char *name=NULL, const char *title=NULL);
-    ~MHistosAdc();
-
-    void FillAdcHistHi (Int_t iPix, Byte_t data);
-    void FillAdcHistLo (Int_t iPix, Byte_t data);
-
-    void SaveHist(char *name);
-
-    void Print(Option_t *t = NULL);
-
-    TH1F *GetHistHi(Int_t i)  { return (TH1F*)(fHistHi->At(i)); }
-    TH1F *GetHistLo(Int_t i)  { return (TH1F*)(fHistLo->At(i)); }
-
-    void DrawHi(Int_t i) { GetHistHi(i)->Draw(); }
-    void DrawLo(Int_t i) { GetHistHi(i)->Draw(); }
-
-/*
-    TObjArray* GetHiList()
-      { 
-	return fHistHi ;
-      }   
-
-    TObjArray* GetLoList()
-      { 
-	return fHistLo ;
-      } 
-*/
-    Int_t GetHiEntries()
-      { 
-	return fHistHi->GetEntries() ;
-      } 
-
-    Int_t GetLoEntries()
-      { 
-	return fHistLo->GetEntries() ;
-      } 
-
-      
-    ClassDef(MHistosAdc, 1)	// list of Histograms with ADC spectra
-};
-
-#endif
-
Index: trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 698)
@@ -34,12 +34,12 @@
   //   Do the preprocessing for MShowSpect
   // 
-  //   Connects Histogramms in the MHistosAdc container as the input
+  //   Connects Histogramms in the MHFadcCam container as the input
   //
 
-  fHists = (MHistosAdc*) pList->FindObject( fHistName );
+  fHists = (MHFadcCam*) pList->FindObject( fHistName );
   
   if (!fHists)
     {
-        *fLog << dbginf << " Error: MHistosAdc '" << fHistName << "' not found!" << endl;
+        *fLog << dbginf << " Error: MHFadcCam '" << fHistName << "' not found!" << endl;
         return kFALSE;
     }
Index: trunk/MagicSoft/Mars/mdatacheck/MShowSpect.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MShowSpect.h	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MShowSpect.h	(revision 698)
@@ -11,5 +11,5 @@
 
 class MGDisplayAdc;
-class MHistosAdc;
+class MHFadcCam;
 class MParList ;
 
@@ -19,5 +19,5 @@
     char       fHistName[256] ;
 
-    MHistosAdc *fHists;		// Pointer to Container with the histograms
+    MHFadcCam *fHists;		// Pointer to Container with the histograms
   
  public:
@@ -29,5 +29,5 @@
      Bool_t PostProcess();
 
-     ClassDef(MShowSpect, 1)	// Fill the raw ADC in the histograms
+     ClassDef(MShowSpect, 0)	// Fill the raw ADC in the histograms
 };
 
Index: trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc	(revision 698)
@@ -15,7 +15,7 @@
 #include "MReadTree.h" 
 #include "MDumpEvtHeader.h" 
-#include "MFillAdcSpect.h" 
+#include "MFillHFadc.h"
 #include "MShowSpect.h" 
-#include "MHistosAdc.h" 
+#include "MHFadcCam.h"
 
 MViewAdcSpectra::MViewAdcSpectra() 
@@ -65,5 +65,5 @@
   plist.AddToList(&evttime);
 
-  fHistosAdc= new MHistosAdc;
+  fHistosAdc= new MHFadcCam;
   plist.AddToList( fHistosAdc ) ;
 
@@ -80,8 +80,8 @@
   //  tasks->AddToList( dumpheader ) ; 
  
-  MFillAdcSpect fillspect;
+  MFillHFadc fillspect;
   tasks.AddToList( &fillspect ) ;
 
-  MShowSpect showspect( "MHistosAdc" ) ;
+  MShowSpect showspect( "MHFadcCam" ) ;
   tasks.AddToList( &showspect ) ;
 
Index: trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h	(revision 698)
@@ -6,5 +6,5 @@
 #endif
 
-class MHistosAdc;
+class MHFadcCam;
 
 class MViewAdcSpectra {
@@ -12,5 +12,5 @@
  private:
 
-     MHistosAdc *fHistosAdc;
+     MHFadcCam *fHistosAdc;
 
  public:
Index: trunk/MagicSoft/Mars/mdatacheck/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/Makefile	(revision 697)
+++ trunk/MagicSoft/Mars/mdatacheck/Makefile	(revision 698)
@@ -22,5 +22,5 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES = -I. -I../mbase -I../mraw
+INCLUDES = -I. -I../mbase -I../mraw -I../manalysis
 
 #------------------------------------------------------------------------------
@@ -29,7 +29,10 @@
 
 SRCFILES = MDumpEvtHeader.cc \
-	   MFillAdcSpect.cc \
+	   MFillHFadc.cc \
+           MFillHHillas.cc \
 	   MGDisplayAdc.cc \
-	   MHistosAdc.cc \
+           MHFadcPix.cc \
+           MHFadcCam.cc \
+           MHHillas.cc \
 	   MShowSpect.cc \
 	   MViewAdcSpectra.cc 
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 697)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 698)
@@ -36,6 +36,6 @@
 
   //   first connect the file with this Object
-  
-  pList = new MParList();
+
+    pList = new MParList();
 
   fRunHeader = new MRawRunHeader();
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 697)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 698)
@@ -118,5 +118,5 @@
   virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
  
-  ClassDef(MGFadcDisp, 1)
+  ClassDef(MGFadcDisp, 0)
 }; 
 
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 698)
@@ -73,5 +73,5 @@
     } 
 
-  ClassDef(MCamDisplay, 1) // Display the magic camera
+  ClassDef(MCamDisplay, 0) // Display the magic camera
 };
 
Index: trunk/MagicSoft/Mars/mgui/MCamNeighbor.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamNeighbor.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MCamNeighbor.h	(revision 698)
@@ -20,5 +20,5 @@
   void Print(Option_t *opt=NULL) ;
 
-  ClassDef(MCamNeighbor, 1) // Conatins the neighbors in the magic camera
+  ClassDef(MCamNeighbor, 0) // Conatins the neighbors in the magic camera
 } ; 
 
Index: trunk/MagicSoft/Mars/mgui/MGDataCheckMain.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGDataCheckMain.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGDataCheckMain.cc	(revision 698)
@@ -252,8 +252,8 @@
   if ( strcmp ( fInputFile, "\n") == 0 )
     { 
-      return ( kFALSE ) ; 
+      return kFALSE ;
     } 
   
-  return (kTRUE) ; 
+  return kTRUE ;
 } 
 
Index: trunk/MagicSoft/Mars/mgui/MGDataCheckMain.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGDataCheckMain.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGDataCheckMain.h	(revision 698)
@@ -86,5 +86,5 @@
   Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
 
-  ClassDef(MGDataCheckMain, 1)
+  ClassDef(MGDataCheckMain, 0)
 
 } ; 
Index: trunk/MagicSoft/Mars/mgui/MGEventDispMain.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGEventDispMain.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGEventDispMain.h	(revision 698)
@@ -97,5 +97,5 @@
   Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
 
-  ClassDef(MGEventDispMain, 1)
+  ClassDef(MGEventDispMain, 0)
 
 } ; 
Index: trunk/MagicSoft/Mars/mgui/MGMarsMain.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGMarsMain.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGMarsMain.h	(revision 698)
@@ -58,5 +58,5 @@
   Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
 
-  ClassDef(MGMarsMain, 1)
+  ClassDef(MGMarsMain, 0)
 } ; 
 
Index: trunk/MagicSoft/Mars/mgui/MGMonteCarloMain.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGMonteCarloMain.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGMonteCarloMain.h	(revision 698)
@@ -81,5 +81,5 @@
   Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
 
-  ClassDef(MGMonteCarloMain, 1)
+  ClassDef(MGMonteCarloMain, 0)
 
 } ; 
Index: trunk/MagicSoft/Mars/mgui/MGPrototyp.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGPrototyp.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGPrototyp.h	(revision 698)
@@ -93,5 +93,5 @@
   Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
 
-  ClassDef(MGPrototyp, 1)
+  ClassDef(MGPrototyp, 0)
 
 } ; 
Index: trunk/MagicSoft/Mars/mgui/MGeomCamCT1.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGeomCamCT1.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MGeomCamCT1.cc	(revision 698)
@@ -34,47 +34,49 @@
     // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz
    
-    const Float_t pixdiameter = 21 ;    // units are cm
+    const Float_t diameter = 21 ;    // units are mm
+    const Float_t kS32  = sqrt(3)/2;
 
     //
     //  add the first pixel to the list
     //
-    (*this)[0].Set(0, 0, pixdiameter);
-    //fPixels->Add( new MGeomPix( ) ;
-
-    const Float_t kS32  = sqrt(3)/2;
-    const Float_t kPI23 = kPI*2/3;
-
     Int_t pixnum = 1;
 
-    for (Int_t ringcounter=1; ringcounter<7; ringcounter++) {
-        //
-        // calc. numofpix in ring number i first
-        //
-        const Int_t numpixthisring = ringcounter*6;
+    (*this)[pixnum++].Set(0, 0, diameter);
 
+    for (Int_t ring=1; ring<7; ring++)
+    {
         //
         // calc. coords for this ring counting from the
         // starting number to the ending number
         //
-        for (Int_t ipix = 0; ipix < numpixthisring; ipix++) {
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((-ring+i*0.5)*diameter,
+                                  i*kS32*diameter,
+                                  diameter);
 
-            Float_t ang     = 60.0/ringcounter * ipix;
-            Float_t fracang = ang - 60*(int)floor(ang/60);
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((-ring*0.5+i)*diameter,
+                                  ring*kS32 * diameter,
+                                  diameter);
 
-            ang     /= kRad2Deg;
-            fracang /= kRad2Deg;
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring+i)*0.5*diameter,
+                                  (ring-i)*kS32*diameter,
+                                  diameter);
 
-            Float_t rad  = pixdiameter * ringcounter;
-                    rad *= sin(kPI23-fracang) * kS32;
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring-0.5*i)*diameter,
+                                  -i*kS32*diameter,
+                                  diameter);
 
-            //
-            //   fill the Data into the array
-            //
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring*0.5-i)*diameter,
+                                  -ring*kS32 * diameter,
+                                  diameter);
 
-            (*this)[pixnum++].Set(rad * cos(ang),
-                                  rad * sin(ang),
-                                  pixdiameter);
-            // fPixels->Add( new MGeomPix( ) ;
-        }
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((-ring-i)*0.5*diameter,
+                                  (-ring+i)*kS32*diameter,
+                                  diameter);
     }
 }
Index: trunk/MagicSoft/Mars/mgui/MHexagon.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 698)
@@ -92,12 +92,5 @@
 } 
 
-
-void MHexagon::Draw(Option_t *option ) 
-{ 
-  //   Draw this ellipse with its current attributes
-  AppendPad(option) ; 
-} 
-
-void MHexagon::DrawHexagon( Float_t x, Float_t y, Float_t d ) 
+void MHexagon::DrawHexagon( Float_t x, Float_t y, Float_t d )
 { 
   //   Draw this ellipse with new coordinate
Index: trunk/MagicSoft/Mars/mgui/MHexagon.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MHexagon.h	(revision 697)
+++ trunk/MagicSoft/Mars/mgui/MHexagon.h	(revision 698)
@@ -43,5 +43,4 @@
 
   virtual Int_t  DistancetoPrimitive(Int_t px, Int_t py ) ; 
-  virtual void   Draw( Option_t *Option="") ; 
   virtual void   DrawHexagon( Float_t x, Float_t y, Float_t d ) ; 
   
@@ -53,5 +52,5 @@
   virtual void   Print(Option_t *Option="") ;
 
-  ClassDef ( MHexagon, 1 )    //  a hexagon for MAGIC
+  ClassDef ( MHexagon, 0 )    //  a hexagon for MAGIC
 
 } ; 
Index: trunk/MagicSoft/Mars/mmontecarlo/MCollAreaTrigger.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MCollAreaTrigger.h	(revision 697)
+++ trunk/MagicSoft/Mars/mmontecarlo/MCollAreaTrigger.h	(revision 698)
@@ -24,5 +24,5 @@
   Bool_t PostProcess() ;
   
-  ClassDef(MCollAreaTrigger, 1)	// Task to fill the collection area histograms
+  ClassDef(MCollAreaTrigger, 0)	// Task to fill the collection area histograms
 
 };
Index: trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 697)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 698)
@@ -89,5 +89,5 @@
     void Draw(Option_t *t="GRAPH");
 
-    ClassDef(MRawEvtPixelIter, 1) // iterates over all pixels of one MRawEvtData object
+    ClassDef(MRawEvtPixelIter, 0) // iterates over all pixels of one MRawEvtData object
 };
 
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 697)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 698)
@@ -33,5 +33,5 @@
     Bool_t Process();
 
-    ClassDef(MRawFileRead, 1)	// Task to read the raw data binary file
+    ClassDef(MRawFileRead, 0)	// Task to read the raw data binary file
 };
 
Index: trunk/MagicSoft/Mars/mraw/MRawFileWrite.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 697)
+++ trunk/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 698)
@@ -44,5 +44,5 @@
     Bool_t PostProcess();
 
-    ClassDef(MRawFileWrite, 1)	// Task to write the raw data containers to a root file
+    ClassDef(MRawFileWrite, 0)	// Task to write the raw data containers to a root file
 };
 
Index: trunk/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx
===================================================================
--- trunk/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx	(revision 697)
+++ trunk/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx	(revision 698)
@@ -56,4 +56,9 @@
       fElecNoise[i]=sigma[i];
   }
+  
+  Float_t GetPedestal(UInt_t i) const    { return fPedesMean[i]; }
+  Float_t GetPedestalRms(UInt_t i) const { return fElecNoise[i]; }
+
+  const UInt_t GetNumPixel() const { return MFADC_CHANNELS; }
 
   ClassDef(MMcFadcHeader, 1)  //Stores Montecarlo Information 
