Index: trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 2177)
+++ trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 2178)
@@ -501,8 +501,9 @@
 
     //
-    // Check whether fDisplay has previously been used (fCanvas)
-    // and fDisplay is still open.
-    //
-    if (fCanvas && fDisplay)
+    // Check whether fDisplay has previously been used (fCanvas),
+    // fDisplay is still open and the corresponding Canvas/Tab is
+    // still existing.
+    //
+    if (fDisplay && fDisplay->HasCanvas(fCanvas))
     {
         fCanvas->cd();
Index: trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 2177)
+++ trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 2178)
@@ -127,12 +127,12 @@
     const UInt_t n = evt->GetNumPixels();
 
-    for (UInt_t i=0; i<n; i++)
+    for (UInt_t idx=0; idx<n; idx++)
     {
-        const MCerPhotPix &pix = (*evt)[i];
+        Float_t val;
+        if (!evt->GetPixelContent(val, idx))
+            continue;
 
-        const Int_t id = pix.GetPixId();
-
-        fSum[id].SetPixelUsed();
-        fSum[id].AddNumPhotons(pix.GetNumPhotons());
+        fSum[idx].SetPixelUsed();
+        fSum[idx].AddNumPhotons(val);
     }
 
@@ -148,5 +148,8 @@
 Bool_t MHCerPhotEvt::Finalize()
 {
-    fSum.Scale(fEntries);
+    if (fEntries<1)
+        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain entries." << endl;
+    else
+        fSum.Scale(fEntries);
     return kTRUE;
 }
@@ -185,5 +188,5 @@
         fDispl = new MCamDisplay(fCam);
 
-    fDispl->FillPhotNum(fSum);
+    fDispl->Fill(fSum);
     fDispl->Paint();
 }
Index: trunk/MagicSoft/Mars/mhist/MHCurrents.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCurrents.cc	(revision 2177)
+++ trunk/MagicSoft/Mars/mhist/MHCurrents.cc	(revision 2178)
@@ -36,4 +36,5 @@
 
 #include "MParList.h"
+#include "MBinning.h"
 #include "MCurrents.h"
 #include "MCamDisplay.h"
@@ -54,5 +55,8 @@
     // FIXME: Implement a clear function with setmem
     for (int i=0; i<577; i++)
+    {
         fSum[i] = 0;
+        fRms[i] = 0;
+    }
 
     fEntries = 0;
@@ -65,5 +69,5 @@
 //
 MHCurrents::MHCurrents(const char *name, const char *title)
-    : fSum(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
+    : fSum(577), fRms(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
 {
     //
@@ -74,4 +78,9 @@
 
     Clear();
+
+    fHist.SetName("currents");
+    fHist.SetTitle("Avg.Currents [nA]");
+    fHist.SetDirectory(NULL);
+    fHist.Sumw2();
 }
 
@@ -105,4 +114,8 @@
     Clear();
 
+    MBinning bins;
+    bins.SetEdges(577, -0.5, 576.5);
+    bins.Apply(fHist);
+
     return kTRUE;
 }
@@ -121,9 +134,45 @@
     }
 
+    for (UInt_t idx=0; idx<577; idx++)
+    {
+        Float_t val;
+        if (!evt->GetPixelContent(val, idx))
+            continue;
+
+        fSum[idx] += val;
+        fRms[idx] += val*val;
+    }
+
+    fEntries++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scale the sum container with the number of entries
+//
+Bool_t MHCurrents::Finalize()
+{
+    if (fEntries<2)
+    {
+        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain enough entries." << endl;
+        return kTRUE;
+    }
+
     for (UInt_t i=0; i<577; i++)
-        fSum[i] += (*evt)[i];
-
-    fEntries++;
-
+    {
+        // calc sdev^2 for pixel index i
+        // var^2 = (sum[xi^2] - sum[xi]^2/n) / (n-1);
+        fRms[i] -= fSum[i]*fSum[i]/fEntries;
+        fRms[i] /= fEntries-1;
+        fRms[i]  = TMath::Sqrt(fRms[i]);
+
+        // calc mean value for pixel index i
+        fSum[i] /= fEntries;
+
+        fHist.SetBinContent(i+1, fSum[i]);
+        fHist.SetBinError(  i+1, fRms[i]);
+    }
     return kTRUE;
 }
@@ -131,19 +180,7 @@
 // --------------------------------------------------------------------------
 //
-// Scale the sum container with the number of entries
-//
-Bool_t MHCurrents::Finalize()
-{
-    for (UInt_t i=0; i<577; i++)
-        fSum[i] /= fEntries;
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
 // Draw the present 'fill status'
 //
-void MHCurrents::Draw(Option_t *)
+void MHCurrents::Draw(Option_t *o)
 {
     if (!fCam)
@@ -156,4 +193,5 @@
     pad->SetBorderMode(0);
 
+    SetDrawOption(o);
     AppendPad("");
 }
@@ -174,5 +212,7 @@
         fDispl = new MCamDisplay(fCam);
 
-    fDispl->FillCurrents(fSum);
+    TString opt(GetDrawOption());
+
+    fDispl->Fill(opt.Contains("rms", TString::kIgnoreCase) ? fRms : fSum);
     fDispl->Paint();
 }
Index: trunk/MagicSoft/Mars/mhist/MHCurrents.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCurrents.h	(revision 2177)
+++ trunk/MagicSoft/Mars/mhist/MHCurrents.h	(revision 2178)
@@ -6,9 +6,13 @@
 #endif
 
-#ifndef MARS_MCurrents
-#include "MCurrents.h"
+#ifndef ROOT_TH1
+#include <TH1.h>
 #endif
 
-class TH1D;
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MCurrents;
 class MGeomCam;
 class MCamDisplay;
@@ -17,9 +21,12 @@
 {
 private:
-    MCurrents    fSum;      // storing the sum
+    TArrayF      fSum;      // storing the sum
+    TArrayF      fRms;      // storing the rms
     Int_t        fEntries;  // number of entries in the histogram
     MGeomCam    *fCam;      // the present geometry
     MCurrents   *fEvt;      //! the current event
     MCamDisplay *fDispl;    //! the camera display
+
+    TH1F         fHist;
 
 public:
@@ -35,5 +42,8 @@
     TH1 *GetHistByName(const TString name) { return NULL; }
 
-    const MCurrents &GetSum() const { return fSum; }
+    const TArrayF &GetSum() const { return fSum; }
+    const TArrayF &GetRms() const { return fRms; }
+
+    const TH1F    &GetHist() const { return fHist; }
 
     void Draw(Option_t *opt="");
