Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2264)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2265)
@@ -30,4 +30,37 @@
    * macros/pixsatrate.C:
      - added
+
+   * Makefile.conf.general:
+     - added -lHistPainter
+     
+   * NEWS:
+     - updated
+     
+   * macros/pixsatrate.C:
+     - added Saturation rate of lo gains
+     
+   * macros/sumevents.C, macros/sumeventserr.C,
+     macros/sumpedestalrms.C, macros/sumpedestals.C:
+     - fixed axis titles
+     - use new SetOptStat
+     
+   * manalysis/MCerPhotAnal2.[h,cc]:
+     - count and print number of skipped events
+     
+   * meventdisp/MGCamDisplay.cc:
+     - fixed a 'division by zero'
+     
+   * mhist/MHCamEvent.cc, mhist/MHTriggerLvl0.cc:
+     - take name from MHCamEvent if fNameEvt not available
+     
+   * mhist/MHCamera.[h,cc]:
+     - use THistPainter to Draw title and statistics box
+     - added fOptStat
+     - added GetMean
+     - added GetRMS
+     - some modification for a better layout
+     
+   * mraw/MRawEvtHeader.cc:
+     - calculate time from clock ticks
 
 
Index: /trunk/MagicSoft/Mars/Makefile.conf.general
===================================================================
--- /trunk/MagicSoft/Mars/Makefile.conf.general	(revision 2264)
+++ /trunk/MagicSoft/Mars/Makefile.conf.general	(revision 2265)
@@ -4,6 +4,6 @@
 
 ROOTVER    =  `root-config --version`
-ROOTLIBS   =  `root-config --libs` -lMinuit
-ROOTGLIBS  =  `root-config --glibs` -lMinuit
+ROOTLIBS   =  `root-config --libs` -lMinuit -lHistPainter
+ROOTGLIBS  =  `root-config --glibs` -lMinuit -lHistPainter
 ROOTCFLAGS =  `root-config --cflags`
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 2264)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 2265)
@@ -78,4 +78,6 @@
 
    - logarithmic scale in camera
+
+   - added class to iterate through directory contents (MDirIter)
 
 
Index: /trunk/MagicSoft/Mars/macros/pixsatrate.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/pixsatrate.C	(revision 2264)
+++ /trunk/MagicSoft/Mars/macros/pixsatrate.C	(revision 2265)
@@ -76,10 +76,13 @@
     tlist.AddToList(&read);
 
-    MHTriggerLvl0 trigmap(254, "Saturation", "Saturation");
-    trigmap.SetType(1);
+    MHTriggerLvl0 trighi(254, "SaturationHi", "Saturation Rate of Hi Gains");
+    MHTriggerLvl0 triglo(254, "SaturationLo", "Saturation Rate of Lo Gains");
+    trighi.SetType(1);
+    triglo.SetType(2);
 
-    MFillH fillh(trigmap, "MRawEvtData");
-    plist.AddToList(&trigmap);
-    tlist.AddToList(&fillh);
+    MFillH fillhi(&trighi, "MRawEvtData");
+    MFillH filllo(&triglo, "MRawEvtData");
+    tlist.AddToList(&fillhi);
+    tlist.AddToList(&filllo);
 
     MEvtLoop evtloop;
Index: /trunk/MagicSoft/Mars/macros/sumevents.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/sumevents.C	(revision 2264)
+++ /trunk/MagicSoft/Mars/macros/sumevents.C	(revision 2265)
@@ -86,10 +86,22 @@
     disp3->SetCamContent(*disp0, 2);
 
-    disp2->SetStats(kFALSE);
-    disp3->SetStats(kFALSE);
+    disp1->SetYTitle("S [au]");
+    disp2->SetYTitle("\\sigma_{S} [au]");
+    disp3->SetYTitle("\\sigma_{S} [%]");
 
-    disp1->SetYTitle("a.u.");
-    disp2->SetYTitle("err");
-    disp3->SetYTitle("rel.err [%]");
+    disp1->SetOptStat(1111);
+    disp2->SetOptStat(1101);
+    disp3->SetOptStat(1101);
+
+    c->cd(1);
+    disp1->Draw("hist");
+
+    c->cd(2);
+    gPad->SetLogy();
+    disp2->Draw("hist");
+
+    c->cd(3);
+    gPad->SetLogy();
+    disp3->Draw("hist");
 
     c->cd(4);
@@ -114,15 +126,4 @@
     disp3->Draw();
 
-    c->cd(1);
-    disp1->Draw("hist");
-
-    c->cd(2);
-    gPad->SetLogy();
-    disp2->Draw("hist");
-
-    c->cd(3);
-    gPad->SetLogy();
-    disp3->Draw("hist");
-
     c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
     //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
@@ -138,5 +139,5 @@
 {
     MDirIter Next;
-    Next.AddDirectory(dirname, "raw*.root", -1);
+    Next.AddDirectory(dirname, "*1947*.root", -1);
 
     TString fname;
Index: /trunk/MagicSoft/Mars/macros/sumeventserr.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/sumeventserr.C	(revision 2264)
+++ /trunk/MagicSoft/Mars/macros/sumeventserr.C	(revision 2265)
@@ -48,8 +48,8 @@
     read.DisableAutoScheme();
 
-    MPedestalSum  ncalc;
+    //MPedestalSum  ncalc;
     //MCerPhotCalc  ncalc;
     //MCerPhotAnal  ncalc;
-    //MCerPhotAnal2 ncalc;
+    MCerPhotAnal2 ncalc;
 
     tlist.AddToList(&read);
@@ -89,10 +89,11 @@
     disp3->SetCamContent(*disp0, 2);
 
-    disp2->SetStats(kFALSE);
-    disp3->SetStats(kFALSE);
+    disp1->SetYTitle("S_{err} [au]");
+    disp2->SetYTitle("\\sigma_{S_{err}} [au]");
+    disp3->SetYTitle("\\sigma_{S_{err}} [%]");
 
-    disp1->SetYTitle("a.u.");
-    disp2->SetYTitle("err");
-    disp3->SetYTitle("rel.err [%]");
+    disp1->SetOptStat(1111);
+    disp2->SetOptStat(1101);
+    disp3->SetOptStat(1101);
 
     c->cd(4);
@@ -138,8 +139,8 @@
 //  This macro shows how to fill and display a histogram using Mars
 //
-void sumevents(const char *dirname=".")
+void sumeventserr(const char *dirname=".")
 {
     MDirIter Next;
-    Next.AddDirectory(dirname, "*ped*.root", -1);
+    Next.AddDirectory(dirname, "*1947*.root", -1);
 
     TString fname;
Index: /trunk/MagicSoft/Mars/macros/sumpedestalrms.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/sumpedestalrms.C	(revision 2264)
+++ /trunk/MagicSoft/Mars/macros/sumpedestalrms.C	(revision 2265)
@@ -90,11 +90,21 @@
     disp3->SetCamContent(*disp0, 2);
 
-    disp2->SetStats(kFALSE);
-    disp3->SetStats(kFALSE);
+    disp1->SetYTitle("P_{rms} [au]");
+    disp2->SetYTitle("\\sigma_{P_{rms}} [au]");
+    disp3->SetYTitle("\\sigma_{P_{rms}} [%]");
 
-    disp1->SetXTitle("a.u.");
-    disp2->SetXTitle("err");
-    disp3->SetXTitle("rel.err [%]");
+    disp1->SetOptStat(1111);
+    disp2->SetOptStat(1101);
+    disp3->SetOptStat(1101);
 
+    c->cd(1);
+    disp1->Draw("hist");
+
+    c->cd(2);
+    disp2->Draw("hist");
+
+    c->cd(3);
+    disp3->Draw("hist");
+ 
     c->cd(4);
     gPad->SetBorderMode(0);
@@ -118,13 +128,4 @@
     disp3->Draw();
 
-    c->cd(1);
-    disp1->Draw("hist");
-
-    c->cd(2);
-    disp2->Draw("hist");
-
-    c->cd(3);
-    disp3->Draw("hist");
-
     c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
     //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
@@ -140,5 +141,5 @@
 {
     MDirIter Next;
-    Next.AddDirectory(dirname, "raw*.root", -1);
+    Next.AddDirectory(dirname, "*1947*.root", -1);
 
     TString fname;
Index: /trunk/MagicSoft/Mars/macros/sumpedestals.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/sumpedestals.C	(revision 2264)
+++ /trunk/MagicSoft/Mars/macros/sumpedestals.C	(revision 2265)
@@ -86,10 +86,20 @@
     disp3->SetCamContent(*disp0, 2);
 
-    disp2->SetStats(kFALSE);
-    disp3->SetStats(kFALSE);
+    disp1->SetYTitle("P [au]");
+    disp2->SetYTitle("\\sigma_{P} [au]");
+    disp3->SetYTitle("\\sigma_{P} [%]");
 
-    disp1->SetXTitle("a.u.");
-    disp2->SetXTitle("err");
-    disp3->SetXTitle("rel.err [%]");
+    disp1->SetOptStat(1111);
+    disp2->SetOptStat(1101);
+    disp3->SetOptStat(1101);
+
+    c->cd(1);
+    disp1->Draw("hist");
+
+    c->cd(2);
+    disp2->Draw("hist");
+
+    c->cd(3);
+    disp3->Draw("hist");
 
     c->cd(4);
@@ -114,13 +124,4 @@
     disp3->Draw();
 
-    c->cd(1);
-    disp1->Draw("hist");
-
-    c->cd(2);
-    disp2->Draw("hist");
-
-    c->cd(3);
-    disp3->Draw("hist");
-
     c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
     //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
@@ -136,5 +137,5 @@
 {
     MDirIter Next;
-    Next.AddDirectory(dirname, "raw*.root", -1);
+    Next.AddDirectory(dirname, "*1947*.root", -1);
 
     TString fname;
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal2.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal2.cc	(revision 2264)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal2.cc	(revision 2265)
@@ -86,4 +86,6 @@
 Int_t MCerPhotAnal2::PreProcess(MParList *pList)
 {
+    fSkip = 0;
+
     fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     if (!fRunHeader)
@@ -149,4 +151,5 @@
             if (ptr[i]==255)
                 sat++;
+
             //if (sat>1)
             //    continue;
@@ -184,5 +187,8 @@
             {
                 if (ptr[i]>250)
+                {
+                    fSkip++;
                     return kCONTINUE;
+                }
                 if (i<max-fBefore || i>max+fAfter)
                 {
@@ -237,2 +243,14 @@
 }
 
+Int_t MCerPhotAnal2::PostProcess()
+{
+    if (GetNumExecutions()==0 || fSkip==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fSkip << " (" << setw(3) << (int)(fSkip*100/GetNumExecutions()) << "%) Evts skipped due to: lo gain saturated." << endl;
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal2.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal2.h	(revision 2264)
+++ /trunk/MagicSoft/Mars/manalysis/MCerPhotAnal2.h	(revision 2265)
@@ -22,4 +22,5 @@
 class MCerPhotAnal2 : public MTask
 {
+private:
     MPedestalCam  *fPedestals;  // Pedestals of all pixels in the camera
     MRawEvtData   *fRawEvt;     // raw event data (time slices)
@@ -30,9 +31,12 @@
     Byte_t fAfter;
 
-public:
-    MCerPhotAnal2(Byte_t b=2, Byte_t a=5, const char *name=NULL, const char *title=NULL);
+    Int_t fSkip;                //!
 
     Int_t PreProcess(MParList *pList);
     Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MCerPhotAnal2(Byte_t b=2, Byte_t a=5, const char *name=NULL, const char *title=NULL);
 
     ClassDef(MCerPhotAnal2, 0)   // Task to calculate cerenkov photons from raw data
Index: /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 2264)
+++ /trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 2265)
@@ -259,5 +259,5 @@
             continue;
         MPedestalPix &ppix = (*ped)[i];
-        if (ppix.GetPedestalRms()<0)
+        if (ppix.GetPedestalRms()<=0)
             continue;
         val[i] = pix->GetNumPhotons()/ppix.GetPedestalRms();
Index: /trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 2264)
+++ /trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 2265)
@@ -99,5 +99,8 @@
     if (fSum)
         delete (fSum);
-    fSum = new MHCamera(*cam, fNameEvt+";avg", fTitle);
+
+    const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
+
+    fSum = new MHCamera(*cam, name+";avg", fTitle);
     fSum->SetYTitle("a.u.");
 
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2264)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2265)
@@ -47,5 +47,10 @@
 #include <TRandom.h>
 #include <TPaveText.h>
+#include <TPaveStats.h>
 #include <TClonesArray.h>
+#include <THistPainter.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
 
 #include "MH.h"
@@ -76,5 +81,5 @@
 //  Default Constructor. To be used by the root system ONLY.
 //
-MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
+MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend), fOptStat(-1)
 {
     SetDirectory(NULL);
@@ -215,4 +220,31 @@
    fTsumwx2 += z*x*x;
    return bin;
+}
+
+Stat_t MHCamera::GetMean(Int_t axis) const
+{
+    Stat_t mean = 0;
+    for (int i=1; i<fNcells-1; i++)
+        mean += fArray[i];
+
+    return mean/(fNcells-2);
+}
+
+Stat_t MHCamera::GetRMS(Int_t axis) const
+{
+    const Int_t n = fNcells-2;
+
+    Stat_t sum = 0;
+    Stat_t sq  = 0;
+    for (int i=1; i<n+1; i++)
+    {
+        sum += fArray[i];
+        sq  += fArray[i]*fArray[i];
+    }
+
+    sum /= n;
+    sq  /= n;
+
+    return sqrt(sq-sum*sum);
 }
 
@@ -314,5 +346,5 @@
 void MHCamera::SetRange()
 {
-    const Float_t range = fGeomCam->GetMaxRadius();
+    const Float_t range = fGeomCam->GetMaxRadius()*1.05;
 
     //
@@ -373,5 +405,10 @@
     {
         if (IsUsed(i) && iscol)
+        {
+            if (TMath::IsNaN(fArray[i+1]))
+                gLog << warn << "MHCamera::Update: " << GetName() << " <" << GetTitle() << "> - Pixel Index #" << i << " contents is NaN (Not a Number)..." << endl;
+
             hex.SetFillColor(GetColor(fArray[i+1], min, max, islog));
+        }
         else
             hex.SetFillColor(10);
@@ -381,5 +418,5 @@
             hex.PaintHexagon(pix.GetX(), pix.GetY(), pix.GetD());
         else
-            if (IsUsed(i))
+            if (IsUsed(i) && !TMath::IsNaN(fArray[i+1]))
             {
                 Float_t size = pix.GetD()*(fArray[i+1]-min)/(max-min);
@@ -413,10 +450,11 @@
 void MHCamera::PaintAxisTitle()
 {
-    Float_t fRange = fGeomCam->GetMaxRadius();
-
-    TLatex *ptitle = new TLatex(1.2*fRange, .97*fRange, GetYaxis()->GetTitle());
-
-    ptitle->SetTextSize(0.03);
-    ptitle->SetTextAlign(33);
+    const Float_t range = fGeomCam->GetMaxRadius()*1.05;
+    const Float_t w = (1 + 1.5/sqrt((float)(fNcells-2)))*range;
+
+    TLatex *ptitle = new TLatex(w, -.90*range, GetYaxis()->GetTitle());
+
+    ptitle->SetTextSize(0.05);
+    ptitle->SetTextAlign(21);
 
     // box with the histogram title
@@ -430,79 +468,4 @@
 // ------------------------------------------------------------------------
 //
-// Paint the histogram title
-//
-void MHCamera::PaintTitle()
-{
-//    *-*-*-*-*-*-*-*-*-*Draw the histogram title*-*-*-*-*-*-*-*-*-*-*-*-*
-//                       ========================
-   //if (Hoption.Same) return;
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00)
-    if (TestBit(kNoTitle))
-        return;
-#endif
-
-    const Int_t nt = strlen(GetTitle());
-
-    TPaveText *title = (TPaveText*)gPad->FindObject("title");
-    if (nt == 0 || gStyle->GetOptTitle() <= 0)
-    {
-        if (title)
-            delete title;
-        return;
-    }
-
-    Double_t ht = gStyle->GetTitleH();
-    Double_t wt = gStyle->GetTitleW();
-
-    if (ht <= 0)
-        ht = 0.05;
-    if (wt <= 0)
-    {
-        TLatex l;
-        l.SetTextSize(ht);
-        l.SetTitle(GetTitle());
-        Double_t wndc = l.GetXsize()/(gPad->GetX2() - gPad->GetX1());
-        wt = TMath::Min(0.7, 0.02+wndc);
-    }
-    if (title)
-    {
-        TText *t0 = (TText*)title->GetLine(0);
-        if (t0)
-        {
-            if (!strcmp(t0->GetTitle(), GetTitle()))
-                return;
-
-            t0->SetTitle(GetTitle());
-            if (wt > 0)
-                title->SetX2NDC(title->GetX1NDC()+wt);
-        }
-        return;
-    }
-
-    TPaveText *ptitle = new TPaveText(
-                                      gStyle->GetTitleX(),
-                                      gStyle->GetTitleY()-ht,
-                                      gStyle->GetTitleX()+wt,
-                                      gStyle->GetTitleY(),"blNDC");
-
-    // box with the histogram title
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,05,01)
-    ptitle->SetFillColor(gStyle->GetTitleFillColor());
-    ptitle->SetTextFont(gStyle->GetTitleFont(""));
-    if (gStyle->GetTitleFont("")%10 > 2)
-        ptitle->SetTextSize(gStyle->GetTitleFontSize());
-#endif
-    ptitle->SetFillStyle(gStyle->GetTitleStyle());
-    ptitle->SetName("title");
-    ptitle->SetBorderSize(gStyle->GetTitleBorderSize());
-    ptitle->SetTextColor(gStyle->GetTitleTextColor());
-    ptitle->AddText(GetTitle());
-    ptitle->SetBit(kCanDelete);
-    ptitle->Draw();
-    ptitle->Paint();
-}
-
-// ------------------------------------------------------------------------
-//
 // Paints the camera.
 //
@@ -515,9 +478,8 @@
     {
         opt.ReplaceAll("hist", "");
-
         Int_t mode = gStyle->GetOptStat();
         TVirtualPad *save = gPad;
         gPad=NULL;
-        gStyle->SetOptStat(1000011);
+        gStyle->SetOptStat(fOptStat<0 ? mode : fOptStat);
         gPad=save;
         TH1D::Paint(o);
@@ -534,9 +496,16 @@
     Bool_t iscol = isbox ? !opt.Contains("nocol") : 1;
 
+    THistPainter paint;
+    if (!TestBit(TH1::kNoStats))
+    {
+        paint.SetHistogram(this);
+        paint.PaintStat(fOptStat<0?gStyle->GetOptStat():fOptStat, NULL);
+    }
+
     // Update Contents of the pixels and paint legend
     Update(gPad->GetLogy(), isbox, iscol);
 
     // Paint primitives (pixels, color legend, photons, ...)
-    PaintTitle();
+    paint.PaintTitle();
     PaintAxisTitle();
 }
@@ -619,5 +588,5 @@
         const MGeomPix &h = (*fGeomCam)[i];
         TText *nt = txt.DrawText(h.GetX(), h.GetY(), num);
-        nt->SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius());
+        nt->SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius()/1.05);
     }
 }
@@ -642,5 +611,5 @@
         const MGeomPix &h = (*fGeomCam)[i];
         TText *nt = txt.DrawText(h.GetX(), h.GetY(), num);
-        nt->SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius());
+        nt->SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius()/1.05);
     }
 }
@@ -848,8 +817,5 @@
 {
     if (TMath::IsNaN(val)) // FIXME: gLog!
-    {
-        cout << "MHCamera::GetColor: " << GetName() << " <" << GetTitle() << "> - Color for val=NaN (Not a Number) requested... set val=min." << endl;
-        val = min;
-    }
+        return 10;
 
     //
@@ -877,4 +843,16 @@
 }
 
+TPaveStats *MHCamera::GetStats()
+{
+    TObject *obj = 0;
+
+    TIter Next(fFunctions);
+    while ((obj = Next()))
+        if (obj->InheritsFrom(TPaveStats::Class()))
+            return static_cast<TPaveStats*>(obj);
+
+    return NULL;
+}
+
 // ------------------------------------------------------------------------
 //
@@ -883,15 +861,17 @@
 void MHCamera::UpdateLegend(Float_t min, Float_t max, Bool_t islog)
 {
-    const Float_t range = fGeomCam->GetMaxRadius();
-
-    const Float_t H = 0.9*range;
+    TPaveStats *stats = GetStats();
+
+    const Float_t hndc   = 0.92 - (stats ? stats->GetY1NDC() : 1);
+    const Float_t range  = fGeomCam->GetMaxRadius()*1.05;
+    const Float_t H      = (0.75-hndc)*range;
+    const Float_t offset = hndc*range;
+
     const Float_t h = 2./kItemsLegend;
-    const Float_t offset = 0.04*range;
-
     const Float_t w = range/sqrt((float)(fNcells-2));
 
     TBox newbox;
     TText newtxt;
-    newtxt.SetTextSize(0.025);
+    newtxt.SetTextSize(0.03);
     newtxt.SetTextAlign(12);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
Index: /trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2264)
+++ /trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2265)
@@ -17,4 +17,6 @@
 #include <TH1.h>
 #endif
+
+class TPaveStats;
 
 class MGeomCam;
@@ -33,4 +35,6 @@
     TList         *fNotify;      //!
 
+    Int_t          fOptStat;
+
     //TGStatusBar   *fStatusBar;
 
@@ -41,7 +45,8 @@
     void  SetRange();
 
+    TPaveStats *GetStats();
+
     Int_t GetPixelIndex(Int_t px, Int_t py) const;
 
-    void PaintTitle();
     void PaintAxisTitle();
 
@@ -130,8 +135,12 @@
 
     void  SetAutoScale(); // *MENU*
+    void  SetOptStat(Int_t os=-1); // *MENU*
 
     void  SetPix(const Int_t pixnum, const Int_t color, Float_t min, Float_t max);      // New function added by M.Lopez in 31-01-03
 
     void  AddNotify(const MCamEvent &event) { fNotify->Add((TObject*)(&event)); }
+
+    Stat_t GetMean(Int_t axis) const;
+    Stat_t GetRMS(Int_t axis) const;
 
     //void SetStatusBar(TGStatusBar *bar) { fStatusBar = bar; }
@@ -141,4 +150,5 @@
 
 inline void MHCamera::SetAutoScale() { fMinimum = fMaximum = -1111; }
+inline void MHCamera::SetOptStat(Int_t os) { fOptStat = os; }
 
 #endif
Index: /trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc	(revision 2264)
+++ /trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc	(revision 2265)
@@ -104,5 +104,8 @@
     if (fSum)
         delete (fSum);
-    fSum = new MHCamera(*cam, fNameEvt+";avg", fTitle);
+
+    const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
+
+    fSum = new MHCamera(*cam, name+";avg", fTitle);
     fSum->SetYTitle("%");
 
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 2264)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 2265)
@@ -245,4 +245,12 @@
     // store the time of the event in the corresponding container
     //
+    const Double_t mhz = 9.375;                          // [1e6 ticks/s]
+    const Double_t t   = (Double_t)fAbsTime[0]/mhz*1e-3; // [ns]
+    const Double_t ns  = (UShort_t)fmod(t, 1e9);
+    const Double_t s   = (Byte_t)fmod(t/1e9, 60);
+    const Double_t m   = (Byte_t)fmod(t/60e9, 60);
+    const Double_t h   = (Byte_t)(t/3600e9);
+
+    fTime->SetTime(h, m, s, ns);
     fTime->SetTime(fAbsTime[0], fAbsTime[1]);
 
