Index: trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 666)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 695)
@@ -1,4 +1,3 @@
 #ifndef __CINT__
-
 
 #include <TClonesArray.h>
Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 666)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 695)
@@ -11,3 +11,9 @@
 #pragma link C++ class MCT1Pedestals;
 
+#pragma link C++ class MPedestalPix;
+#pragma link C++ class MPedestalCam;
+
+#pragma link C++ class MHillas;
+#pragma link C++ class MHillasCalc;
+
 #endif
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 666)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 695)
@@ -8,5 +8,4 @@
 
 #include "MLog.h"
-#include "MGeomCam.h"
 #include "MCamNeighbor.h"
 #include "MCamDisplay.h"
@@ -15,5 +14,5 @@
 ClassImp(MCerPhotEvt)
 
-MCerPhotEvt::MCerPhotEvt(const char *name, const char *title ) : fType(0), fNbPixels(0)
+MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
 {
   //   the default constructor 
@@ -31,17 +30,24 @@
 }
 
+#include "MGeomCamMagic.h"
+#include "MGeomCamCT1.h"
+
 void MCerPhotEvt::Draw(Option_t* option) 
 {
-  //   FIXME!!!
-  // 
-  
-  MCamDisplay *disp = new MCamDisplay(fType)  ; 
-  
-  disp->DrawPhotNum(this) ;
-}
-
-Int_t MCerPhotEvt::GetNbPixels() 
-{
-  return fNbPixels;
+    //
+    //   FIXME!!! Here the Draw function of the CamDisplay
+    //   should be called to add the CamDisplay to the Pad.
+    //   The drawing should be done in MCamDisplay::Paint
+    //
+
+    //    MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
+    //    MCamDisplay *disp = new MCamDisplay(geom);
+    //    delete geom;
+    //    disp->DrawPhotNum(this);
+}
+
+Int_t MCerPhotEvt::GetNumPixels()
+{
+    return fNumPixels;
 } 
 
@@ -52,5 +58,5 @@
     // of valid pixels in the list by one
     //
-    (*fPixels)[fNbPixels++] = new MCerPhotPix( id, nph, err);
+    (*fPixels)[fNumPixels++] = new MCerPhotPix( id, nph, err);
 }
 
@@ -60,5 +66,5 @@
     // reset counter and delete netries in list.
     //
-    fNbPixels = 0 ;
+    fNumPixels = 0 ;
     fPixels->Clear() ;
 }
@@ -69,5 +75,5 @@
 
     *fLog << "MCerPhotEvt::Print()" << endl
-        << "Number of Pixels: " << fNbPixels
+        << "Number of Pixels: " << fNumPixels
         << "(" << entries << ")"
         << endl ;
@@ -276,10 +282,10 @@
 } 
 
-Float_t MCerPhotEvt::GetMinNumPhotons()
+Float_t MCerPhotEvt::GetNumPhotonsMin()
 {
     //
     // get the minimum number of photons of all valid pixels in the list
     //
-    if (fNbPixels <= 0)
+    if (fNumPixels <= 0)
         return -5. ;
 
@@ -287,5 +293,5 @@
 
     Float_t testval;
-    for (Int_t i=1 ; i<fNbPixels; i++ )
+    for (Int_t i=1 ; i<fNumPixels; i++ )
     {
         testval = (*this)[i].GetNumPhotons();
@@ -298,10 +304,10 @@
 }
 
-Float_t MCerPhotEvt::GetMaxNumPhotons()
+Float_t MCerPhotEvt::GetNumPhotonsMax()
 {
     //
     // get the maximum number of photons of all valid pixels in the list
     //
-    if (fNbPixels <= 0)
+    if (fNumPixels <= 0)
         return 50.;
 
@@ -309,5 +315,5 @@
 
     Float_t testval;
-    for (Int_t i=1; i<fNbPixels; i++)
+    for (Int_t i=1; i<fNumPixels; i++)
     {
         testval = (*this)[i].GetNumPhotons();
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 666)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 695)
@@ -21,6 +21,5 @@
 private:
 
-    Int_t         fType;
-    Int_t         fNbPixels;
+    Int_t         fNumPixels;
     TClonesArray *fPixels;
 
@@ -32,5 +31,5 @@
   void Draw(Option_t* option = "" ) ; 
 
-  Int_t    GetNbPixels() ; 
+  Int_t    GetNumPixels() ;
 
   void AddPixel(Int_t id, Float_t nph, Float_t err );
@@ -48,6 +47,6 @@
   Bool_t  IsPixelCore    ( Int_t id ) ;
  
-  Float_t GetMinNumPhotons();
-  Float_t GetMaxNumPhotons();
+  Float_t GetNumPhotonsMin();
+  Float_t GetNumPhotonsMax();
 
   MCerPhotPix &operator[](int i) { return *(MCerPhotPix*)(fPixels->At(i)); }
Index: trunk/MagicSoft/Mars/manalysis/MHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MHillas.cc	(revision 695)
@@ -0,0 +1,172 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MHillas                                                                 //
+//                                                                         //
+// Storage Container for the Hillas parameter                              //
+//                                                                         //
+// FIXME: Here everybody should find an explanation of the parameters      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillas.h"
+
+#include <TEllipse.h>
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+#include "MGeomCam.h"
+
+#include "MLog.h"
+
+ClassImp(MHillas)
+
+    MHillas::MHillas(const char *name, const char *title) : fEllipse(NULL)
+{
+    *fName  = name  ? name  : "MHillas";
+    *fTitle = title ? title : "Storage container for Hillas parameter of one event";
+
+    // FIXME: Initialization of values missing
+}
+
+MHillas::~MHillas()
+{
+    Clear();
+}
+
+void MHillas::Print(Option_t *)
+{
+    *fLog << "Hillas Parameter:" << endl;
+    *fLog << " - Alpha  = " << fAlpha  << endl;
+    *fLog << " - Width  = " << fWidth  << endl;
+    *fLog << " - Length = " << fLength << endl;
+    *fLog << " - Dist   = " << fDist   << endl;
+}
+
+void MHillas::Draw(Option_t *)
+{
+    //
+    // Instead of adding MHillas itself to the Pad
+    // (s. AppendPad in TObject) we create an ellipse,
+    // which is added to the Pad by it's Draw function
+    // You can remove it by deleting the Ellipse Object
+    // (s. Clear() )
+    //
+
+    Clear();
+
+    fEllipse = new TEllipse(cos(fTheta)*fDist, sin(fTheta)*fDist,
+                            fWidth, fLength,
+                            0, 360, fAlpha);
+
+    fEllipse->SetLineWidth(2);
+    fEllipse->Draw();
+}
+
+void MHillas::Clear(Option_t *)
+{
+    if (!fEllipse)
+        return;
+
+    delete fEllipse;
+
+    fEllipse = NULL;
+}
+
+void MHillas::Calc(MGeomCam &geom, MCerPhotEvt &evt)
+{
+    const UInt_t nevt = evt.GetNumPixels();
+
+    //
+    // calculate mean valu of pixels
+    //
+    float xav =0;
+    float yav =0;
+    float spix=0;
+
+    for (UInt_t i=0; i<nevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const MGeomPix &gpix = geom[pix.GetPixId()];
+
+        const float nphot = pix.GetNumPhotons();
+
+        spix += nphot;
+        xav  += nphot * gpix.GetX();
+        yav  += nphot * gpix.GetY();
+    }
+
+    xav /= spix;
+    yav /= spix;
+
+    //
+    // calculate sdev
+    //
+    float dis11=0;
+    float dis12=0;
+    float dis22=0;
+
+    for (UInt_t i=0; i<nevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const MGeomPix &gpix = geom[pix.GetPixId()];
+
+        const float dx = gpix.GetX() - xav;
+        const float dy = gpix.GetY() - yav;
+
+        const float nphot = pix.GetNumPhotons();
+
+        dis11 += nphot * dx*dx;
+        dis12 += nphot * dx*dy;
+        dis22 += nphot * dy*dy;
+    }
+
+    //
+    // check for orientation
+    //
+    const float theta = atan(dis12/(dis11-dis22)*2)/2;
+
+    float c = cos(theta);
+    float s = sin(theta);
+
+    const float direction = c*xav+s*yav;
+
+    if (direction<0)
+    {
+        c = -c;
+        s = -s;
+    }
+
+    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;
+
+    rot1 /= spix;
+    rot2 /= spix;
+
+    //
+    // check for numerical negatives
+    //
+    if (rot1 < 0) rot1=0;
+    if (rot2 < 0) rot2=0;
+
+    //
+    // check the rotation of the axis
+    //
+    const int rotation = rot1<rot2;
+
+    fLength = rotation ? sqrt(rot2) : sqrt(rot1);
+    fWidth  = rotation ? sqrt(rot1) : sqrt(rot2);
+
+    fAlpha = 180/kPI*atan((-xav*s+yav*c)/direction);
+
+    fDist  = sqrt(xav*xav + yav*yav);
+
+    fTheta = atan(yav/xav);
+    if (xav<0) fTheta += kPI;
+}
Index: trunk/MagicSoft/Mars/manalysis/MHillas.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MHillas.h	(revision 695)
@@ -0,0 +1,40 @@
+#ifndef MHILLAS_H
+#define MHILLAS_H
+
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+
+class TEllipse;
+
+class MGeomCam;
+class MCerPhotEvt;
+
+class MHillas : public MParContainer
+{
+private:
+    Float_t fAlpha;     // Angle between the length axis of the ellipse and the camera center
+    Float_t fTheta;     // Angle between the x axis and the center of the ellipse
+    Float_t fWidth;     // Width of the ellipse
+    Float_t fLength;    // Length of the ellipse
+    Float_t fSize;      // Size of the ellipse
+    Float_t fDist;      // Distance of the ellipse COM from the camera center
+
+    TEllipse *fEllipse; //! Graphical Object to Display Ellipse
+
+public:
+    MHillas(const char *name=NULL, const char *title=NULL);
+    ~MHillas();
+
+    void Calc(MGeomCam &geom, MCerPhotEvt &pix);
+
+    void Print(Option_t *opt=NULL);
+    void Draw(Option_t *opt=NULL);
+
+    void Clear(Option_t *opt=NULL);
+
+    ClassDef(MHillas, 1) // Storage Container for Hillas Parameter
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc	(revision 695)
@@ -0,0 +1,53 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MHillas Calc                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHillasCalc.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasCalc)
+
+MHillasCalc::MHillasCalc(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MHillasCalc";
+    *fTitle = title ? title : "Task to calculate Hillas parameters";
+}
+
+Bool_t MHillasCalc::PreProcess( MParList *pList )
+{
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fCerPhotEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeomCam)
+    {
+        *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillas = (MHillas*)pList->FindCreateObj("MHillas");
+    if (!fHillas)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Bool_t MHillasCalc::Process()
+{
+    fHillas->Calc(*fGeomCam, *fCerPhotEvt);
+
+    return kTRUE;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MHillasCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHillasCalc.h	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MHillasCalc.h	(revision 695)
@@ -0,0 +1,35 @@
+#ifndef MHILLASCALC_H
+#define MHILLASCALC_H
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MHillasCalkc                                                            //
+//                                                                         //
+// Task to calculate Hillas Parameters                                     //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MHillas;
+
+class MHillasCalc : public MTask
+{
+    MGeomCam    *fGeomCam;    // Camera Geometry used to calculate Hillas
+    MCerPhotEvt *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+    MHillas     *fHillas;     // ouput container to store result
+
+public:
+    MHillasCalc(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MHillasCalc, 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 695)
@@ -0,0 +1,26 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCam                                                            //
+//                                                                         //
+// Hold the Pedestal information for all pixels in the camera              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCam.h"
+
+#include "MLog.h"
+
+ClassImp(MPedestalCam)
+
+MPedestalCam::MPedestalCam(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MPedestalCam";
+    *fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
+
+    fArray = new TClonesArray("MPedestalPix", 577);
+}
+
+MPedestalCam::~MPedestalCam()
+{
+    delete fArray;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 695)
@@ -0,0 +1,31 @@
+#ifndef MPEDESTALCAM_H
+#define MPEDESTALCAM_H
+
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+
+#ifndef MPEDESTALPIX_H
+#include "MPedestalPix.h"
+#endif
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class MPedestalCam : public MParContainer
+{
+private:
+    TClonesArray *fArray;
+
+public:
+    MPedestalCam(const char *name=NULL, const char *title=NULL);
+    ~MPedestalCam();
+
+    MPedestalPix &operator[](Int_t i) { return *(MPedestalPix*)fArray->At(i); }
+
+    ClassDef(MPedestalCam, 1)	// Storage Container for all pedestal information of the camera
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 695)
@@ -0,0 +1,21 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalPix                                                            //
+//                                                                         //
+// This is the storage container to hold informations about the pedestal   //
+// (offset) value of one Pixel (PMT).                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalPix.h"
+
+//#include <fstream.h>
+
+#include "MLog.h"
+
+ClassImp(MPedestalPix)
+
+MPedestalPix::MPedestalPix()
+    : fMean(0.0), fSigma(0.0), fMeanRms(0.0), fSigmaRms(0.0)
+{
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MPedestalPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 695)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 695)
@@ -0,0 +1,33 @@
+#ifndef MPEDESTALPIX_H
+#define MPEDESTALPIX_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+class MPedestalPix : public TObject
+{
+private:
+    Float_t fMean;     // mean value of pedestal (PMT offset)
+    Float_t fSigma;    // sigma (standard deviation) of pedestal
+    Float_t fMeanRms;  // root mean square of pedestal
+    Float_t fSigmaRms; // root mean sqare of sigma of the pedestal
+
+public:
+    MPedestalPix();
+
+    Float_t GetMean()     { return fMean;     }
+    Float_t GetSigma()    { return fSigma;    }
+    Float_t GetMeanRms()  { return fMeanRms;  }
+    Float_t GetSigmaRms() { return fSigmaRms; }
+
+    void SetMean(Float_t f)     { fMean = f;     }
+    void SetSigma(Float_t f)    { fSigma = f;    }
+    void SetMeanRms(Float_t f)  { fMeanRms = f;  }
+    void SetSigmaRms(Float_t f) { fSigmaRms = f; }
+
+    ClassDef(MPedestalPix, 1)	// Storage Container for Pedestal information of one pixel
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- trunk/MagicSoft/Mars/manalysis/Makefile	(revision 666)
+++ trunk/MagicSoft/Mars/manalysis/Makefile	(revision 695)
@@ -30,4 +30,8 @@
 SRCFILES = MCT1Pedestals.cc \
 	   MCT1ReadAscii.cc \
+           MPedestalCam.cc \
+           MPedestalPix.cc \
+           MHillas.cc \
+           MHillasCalc.cc \
 	   MCerPhotEvt.cc \
 	   MCerPhotPix.cc 
