Index: trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1965)
@@ -72,4 +72,5 @@
 
 #include <TClass.h>
+#include <TCanvas.h>
 
 #include "MDataChain.h"
@@ -82,4 +83,5 @@
 
 #include "MParList.h"
+#include "MStatusDisplay.h"
 
 ClassImp(MFillH);
@@ -99,4 +101,5 @@
 
     fIndex  = NULL;
+    fCanvas = NULL;
 }
 
@@ -143,5 +146,5 @@
 
     fTitle = "Fill " + fHName;
-    if (!par)
+    if (fParContainerName.IsNull())
         return;
 
@@ -313,4 +316,15 @@
 }
 
+Bool_t MFillH::DrawToDisplay()
+{
+    if (!fDisplay)
+        return kTRUE;
+
+    fCanvas = &fDisplay->AddTab(fH->GetName());
+    fH->Draw();
+
+    return kTRUE;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -353,6 +367,8 @@
         if (!obj)
         {
+            /*
             if (cls==name)
-                *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl;
+            *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl;
+            */
             obj = pList->FindCreateObj(cls, name);
         }
@@ -369,5 +385,5 @@
         if (!obj->InheritsFrom(tcls))
         {
-            *fLog << err << dbginf << obj->GetName() << " doesn't inherit ";
+            *fLog << err << obj->GetName() << " doesn't inherit ";
             *fLog << "from " << tcls->GetName() << " - cannot be used for MFillH...";
             *fLog << "aborting." << endl;
@@ -383,5 +399,5 @@
     if (!fH->SetupFill(pList))
     {
-        *fLog << err << dbginf << "Error: calling SetupFill for ";
+        *fLog << err << "ERROR - Calling SetupFill for ";
         *fLog << fH->GetDescriptor() << "... aborting." << endl;
         return kFALSE;
@@ -392,22 +408,21 @@
     //
     if (fParContainer)
-        return kTRUE;
-
-    //
-    // If a name is given try to find the input container in the
-    // list. If it could not be found we cannot proceed.
+        return DrawToDisplay();
+
+    //
+    // This case means, that the MH sets up its container to be filled
+    // by itself. Check there if it has something to be filled with!
     //
     if (fParContainerName.IsNull())
     {
-        fParContainer = NULL; 
-        return kTRUE;
+        fParContainer = NULL;
+        return DrawToDisplay();
     }
 
     fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
-
     if (fParContainer)
-        return kTRUE;
-
-    *fLog << err << dbginf << "'" << fParContainerName << "' [MParContainer] not found... aborting." << endl;
+        return DrawToDisplay();
+
+    *fLog << err << fParContainerName << " [MParContainer] not found... aborting." << endl;
     return kFALSE;
 }
@@ -443,5 +458,5 @@
     if (!fH->Finalize())
     {
-        *fLog << err << dbginf << "Error: calling Finalize for ";
+        *fLog << err << "ERROR - Calling Finalize for ";
         *fLog << fH->GetDescriptor() << "... aborting." << endl;
         return kFALSE;
@@ -449,4 +464,11 @@
 
     fH->SetReadyToSave();
+
+    if (fDisplay)
+    {
+        fCanvas->cd();
+        fH->DrawClone("nonew");
+    }
+
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhist/MFillH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 1965)
@@ -7,8 +7,9 @@
 
 class MH;
+class MMap;
 class MData;
 class MParList;
 
-class MMap;
+class TCanvas;
 
 class MFillH : public MTask
@@ -24,4 +25,6 @@
     MMap  *fMapIdx;   //! Map to map key-index-pair for an MHArray (MMap see MFillH.cc)
 
+    TCanvas *fCanvas;
+
     TString ExtractName(const char *name) const;
     TString ExtractClass(const char *name) const;
@@ -30,4 +33,6 @@
 
     void StreamPrimitive(ofstream &out) const;
+
+    Bool_t DrawToDisplay();
 
 public:
Index: trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1965)
@@ -585,4 +585,5 @@
     //
     TH1 *h1 = (TH1*)((TH1&)hist1).DrawCopy();
+    gPad->SetBorderMode(0);
     gPad->Update();
 
@@ -653,4 +654,5 @@
     //
     hist1.Draw();
+    gPad->SetBorderMode(0);
     gPad->Update();
 
@@ -710,2 +712,46 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// If the opt string contains 'nonew' or gPad is not given NULL is returned.
+// Other wise the present gPad is cleared and returned.
+//
+TVirtualPad *MH::GetNewPad(Option_t *opt)
+{
+    TString str(opt);
+
+    if (!str.Contains("nonew", TString::kIgnoreCase) || !gPad)
+        return NULL;
+
+    gPad->Clear();
+    return gPad;
+}
+
+// --------------------------------------------------------------------------
+//
+// The object is cloned and drawn to the present pad. The kCanDelete
+// bit is set for the clone.
+//
+TObject *MH::DrawClone(Option_t *opt="") const
+{
+    gROOT->SetSelectedPad(NULL);
+
+    TObject *o = MParContainer::DrawClone(opt);
+    o->SetBit(kCanDelete);
+    return o;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the opt string contains 'nonew' or gPad is not given a new canvas
+// with size w/h is created. Otherwise the object is cloned and drawn
+// to the present pad. The kCanDelete bit is set for the clone.
+//
+TObject *MH::DrawClone(Option_t *opt, Int_t w, Int_t h) const
+{
+    TVirtualPad *p = GetNewPad(opt);
+    if (!p)
+        p = MakeDefCanvas(this, w, h);
+
+    return MH::DrawClone(opt);
+}
Index: trunk/MagicSoft/Mars/mhist/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.h	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MH.h	(revision 1965)
@@ -15,7 +15,17 @@
 class MBinning;
 class MParList;
-
+#include <iostream.h>
+#include <TClass.h>
 class MH : public MParContainer
 {
+private:
+    /*
+    void Draw(Option_t *opt="")
+    {
+        cout << "MH::Draw" << endl;
+        MParContainer::Draw(opt);
+        }
+        */
+
 public:
     MH(const char *name=NULL, const char *title=NULL);
@@ -59,6 +69,14 @@
     static void Draw(TH1 &hist1, TH1 &hist2, const TString title);
 
+    void Draw(Option_t *o="") { MParContainer::Draw(o); }
+    TObject *DrawClone(Option_t *opt="") const;
+    TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const;
+
+    static TVirtualPad *GetNewPad(Option_t *opt);
+
     static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
     static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
+
+
 
     ClassDef(MH, 1) //A histogram base class for Mars histograms
Index: trunk/MagicSoft/Mars/mhist/MH3.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MH3.cc	(revision 1965)
@@ -600,25 +600,21 @@
 MParContainer *MH3::New() const
 {
-  cout << "1" <<endl;
     MH3 *h = NULL;
-  cout << "1a" <<endl;
-
-  if (fData[0] == NULL) 
-    {
-      h=new MH3(fDimension);
-    }
-  else
-    switch (fDimension)
-    {
-    case 1:
-        h=new MH3(fData[0]->GetRule());
-        break;
-    case 2:
-        h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
-        break;
-    case 3:
-        h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
-        break;
-    }
+
+    if (fData[0] == NULL)
+        h=new MH3(fDimension);
+    else
+        switch (fDimension)
+        {
+        case 1:
+            h=new MH3(fData[0]->GetRule());
+            break;
+        case 2:
+            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
+            break;
+        case 3:
+            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
+            break;
+        }
     switch (fDimension)
     {
Index: trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 1965)
@@ -30,4 +30,6 @@
 #include "MHCerPhotEvt.h"
 
+#include <TCanvas.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -35,4 +37,8 @@
 #include "MParList.h"
 #include "MCerPhotEvt.h"
+#include "MCamDisplay.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
 
 ClassImp(MHCerPhotEvt);
@@ -40,18 +46,39 @@
 // --------------------------------------------------------------------------
 //
-// Setup four histograms for Width, Length
-//
-MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
-    : fEvt(NULL)
-{
-    //
-    //   set the name and title of this object
-    //
-    fName  = name  ? name  : "MHCerPhotEvt";
-    fTitle = title ? title : "Sum up camera events";
-
+// Reset all pixels to 0 and reset fEntries to 0.
+//
+void MHCerPhotEvt::Clear()
+{
+    fSum.Reset();
     fSum.InitSize(577);
     for (int i=0; i<577; i++)
+    {
         fSum.AddPixel(i, 0, 0);
+        fSum[i].SetPixelUnused();
+    }
+
+    fEntries = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
+    : fEvt(NULL), fCam(NULL), fDispl(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCerPhotEvt";
+    fTitle = title ? title : "Average of MCerPhotEvts";
+
+    Clear();
+}
+
+MHCerPhotEvt::~MHCerPhotEvt()
+{
+    if (fDispl)
+        delete fDispl;
 }
 
@@ -72,4 +99,10 @@
         *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
 
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fCam)
+        *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
+
+    Clear();
+
     return kTRUE;
 }
@@ -95,7 +128,74 @@
         const MCerPhotPix &pix = (*evt)[i];
 
-        fSum[pix.GetPixId()].AddNumPhotons(pix.GetNumPhotons());
-    }
+        const Int_t id = pix.GetPixId();
+
+        const Double_t ratio = fCam ? fCam->GetPixRatio(id) : 1;
+
+        const Double_t val = pix.GetNumPhotons()/ratio;
+
+        fSum[id].SetPixelUsed();
+        fSum[id].AddNumPhotons(val);
+    }
+
+    fEntries++;
+
     return kTRUE;
 }
 
+Bool_t MHCerPhotEvt::Finalize()
+{
+    fSum.Scale(fEntries);
+    return kTRUE;
+}
+
+TObject *MHCerPhotEvt::DrawClone(Option_t *opt) const
+{
+    return MH::DrawClone(opt, 750, 600);
+}
+
+void MHCerPhotEvt::Draw(Option_t *)
+{
+    if (!fCam)
+    {
+        *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
+    pad->SetBorderMode(0);
+
+    //
+    // All this is necessary to get the background in the correct color
+    //
+    pad->Divide(1,1);
+    pad->cd(1);
+
+    gPad->SetBorderMode(0);
+    gPad->SetFillColor(gPad->GetFillColor());
+
+    //
+    // set the color palette for the TBox elements
+    //
+    AppendPad("");
+
+    //
+    // Necessary to visualize the background color (FIXME?)
+    //
+    gPad->Modified();
+    gPad->Update();
+}
+
+void MHCerPhotEvt::Paint(Option_t *option="")
+{
+    if (!fCam)
+    {
+        *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    if (!fDispl)
+        fDispl = new MCamDisplay(fCam);
+
+    fDispl->FillPhotNum(fSum);
+    fDispl->Paint();
+}
Index: trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h	(revision 1965)
@@ -11,4 +11,6 @@
 
 class TH1D;
+class MGeamCam;
+class MCamDisplay;
 
 class MHCerPhotEvt : public MH
@@ -16,11 +18,20 @@
 private:
     MCerPhotEvt  fSum;
-    MCerPhotEvt *fEvt; //!
+    Int_t        fEntries;
+    MCerPhotEvt *fEvt;   //!
+    MGeomCam    *fCam; 
+    MCamDisplay *fDispl; //!
 
 public:
     MHCerPhotEvt(const char *name=NULL, const char *title=NULL);
+    ~MHCerPhotEvt();
+
+    //    TObject *Clone(const char *newname="") const;
+
+    void Clear();
 
     Bool_t SetupFill(const MParList *pList);
     Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
 
     TH1 *GetHistByName(const TString name) { return NULL; }
@@ -28,5 +39,9 @@
     const MCerPhotEvt &GetSum() const { return fSum; }
 
-    ClassDef(MHCerPhotEvt, 1) // Container which holds histograms for the source independent image parameters
+    TObject *DrawClone(Option_t *opt) const;
+    void Draw(Option_t *);
+    void Paint(Option_t *option="");
+
+    ClassDef(MHCerPhotEvt, 1) // Histogram to sum camera events
 };
 
Index: trunk/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1965)
@@ -68,6 +68,4 @@
     fTitle = title ? title : "Container for a Star Map" ;
 
-    *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;
-
     //
     //   loop over all Pixels and create two histograms
@@ -137,4 +135,6 @@
         return kTRUE;
     }
+
+    *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;
 
     return kTRUE;
@@ -293,5 +293,4 @@
 }
 
-
 // --------------------------------------------------------------------------
 //
@@ -304,19 +303,5 @@
 TObject *MHStarMap::DrawClone(Option_t *opt) const
 {
-    TCanvas *c=MakeDefCanvas(fStarMap, 500, 500);
-
-    //
-    // This is necessary to get the expected bahviour of DrawClone
-    //
-    gROOT->SetSelectedPad(NULL);
-
-    PrepareDrawing();
-
-    fStarMap->DrawCopy("colz");
-
-    c->Modified();
-    c->Update();
-
-    return c;
+    return MH::DrawClone(opt, 500, 500);
 }
 
@@ -329,12 +314,36 @@
 void MHStarMap::Draw(Option_t *)
 {
-    if (!gPad)
-        MakeDefCanvas(fStarMap, 500, 500);
-
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 500, 500);
+    pad->SetBorderMode(0);
+
+    pad->Divide(1,1);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+
+    AppendPad("");
+}
+
+void MHStarMap::Paint(Option_t *opt="")
+{
+    //
+    // Maintain aspect ratio
+    //
+    const float w = gPad->GetWw();
+    const float h = gPad->GetWh();
+
+    if (h<w)
+        gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 1);
+    else
+        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2);
+
+    //
+    // Maintain colors
+    //
     PrepareDrawing();
 
-    fStarMap->Draw("colz");
-
-    gPad->Modified();
-    gPad->Update();
-}
+    //
+    // Paint Histogram
+    //
+    fStarMap->Paint("colz");
+}
Index: trunk/MagicSoft/Mars/mhist/MHStarMap.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHStarMap.h	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/MHStarMap.h	(revision 1965)
@@ -15,5 +15,5 @@
 {
 private:
-    TH2F *fStarMap;
+    TH2F *fStarMap; //->
 
     Float_t fMm2Deg;
@@ -22,4 +22,6 @@
 
     void PrepareDrawing() const;
+
+    void Paint(Option_t *opt="");
 
 public:
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 1962)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 1965)
@@ -23,5 +23,6 @@
 #
 INCLUDES = -I. -I../mbase -I../mraw -I../manalysis -I../mmc \
-	   -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage
+	   -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \
+           -I../mmain
 
 #------------------------------------------------------------------------------
