Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 695)
+++ 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 
