Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5142)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5143)
@@ -20,4 +20,71 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2004/09/28: Thomas Bretz
+
+   * mbase/MGMap.h:
+     - added Clear() function
+
+   * mfileio/MReadReports.[h,cc]:
+     - added GetReader member function
+
+   * mhbase/MBinning.h:
+     - set a default for a constructor argument
+
+   * mhbase/MH.cc:
+     - do not treat errors when enhancing histograms
+       if errors are not set
+
+   * mhflux/MHEffectiveOnTime.cc:
+     - changed conditions for fit:
+       + 5% - 95%  --->  60% - 99%
+       + start value 200Hz
+       + ok if chi2<3*NDF
+     - resturn chi2 as result of fit
+     - changed some text output in pads
+
+   * mhflux/MHFalseSource.cc:
+     - made work without MPointingPos
+     - fixed crash if star-display is used
+     - fixed dissapearing alpha plot
+
+   * mhist/MHCamEvent.[h,cc]:
+     - removed rms histogram
+     - enhanced display
+     - fixed handling of title
+
+   * mhist/MHCamera.[h,cc]:
+     - simplified projection functions a bit
+     - simplified profile functions a bit
+     - added default for binning
+     - added binning to Profiles
+
+   * mimage/MConcentration.c:
+     - fixed author list
+
+   * mimage/MHHillas.cc:
+     - display size as logy
+
+   * mimage/MHHillasExt.cc, mimage/MHHillasSrc.cc:
+     - fixed binnings
+     - removed obsolete pad->Update in Draw
+
+   * mimage/MHImagePar.cc:
+     - fixed setting of log-scale
+
+   * mjobs/MJCalibrateSignal.cc:
+     - fixed histogram titles and axis titles
+
+   * mjobs/MJStar.cc:
+     - added EventRate cut which cuts out events with extremely
+       changing rates
+
+   * mmain/MEventDisplay.cc:
+     - unlock event display
+
+   * msignal/MArrivalTime.cc:
+     - fixed GetPixelContent
+
+
+
  2004/09/28: Raquel de los Reyes
 
@@ -27,4 +94,6 @@
        00035488 (2004_08_30)
 
+
+
  2004/09/27: Abelardo Moralejo
 
@@ -32,4 +101,6 @@
      - Added. Macro to compare the piled-up signals for many pixels and
        events together, intended to check the noise fluctuations.
+
+
 
  2004/09/23: Markus Gaug
@@ -76,13 +147,17 @@
 
 
+
  2004/09/23: Abelardo Moralejo
    * mtemp/mpadova/macros/area.C, RanForestPD.C, gammarate.C
      - Added
+
    * macros/starmc.C
      - Added some missing RunHeaders in the output
 
+
+
  2004/09/19: Thomas Bretz
 
-   * mbadpixels/MBadPIxlesCam.[h,cc]:
+   * mbadpixels/MBadPixlesCam.[h,cc]:
      - added Reset-function. This makes sure, that the event-wise
        bad pixels determined by MBadPIxelsCalc are deleted after
@@ -92,4 +167,5 @@
    * mpointing/MPointingPos.cc, mreport/MReportDrive.cc:
      - initialize the variables in the constructor
+
 
 
Index: trunk/MagicSoft/Mars/mbase/MGMap.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGMap.h	(revision 5142)
+++ trunk/MagicSoft/Mars/mbase/MGMap.h	(revision 5143)
@@ -11,4 +11,6 @@
 class TString;
 class TGToolTip;
+
+#include <iostream>
 
 class MGMap : public TExMap
@@ -31,4 +33,5 @@
     void     Add(TObject *k, TString *v=0);
     void     Delete(Option_t *opt = "");
+    void     Clear(Option_t *o="") { TExMap::Delete(); }
 
     //    void   SetNoToolTips(Bool_t b=kTRUE) { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
Index: trunk/MagicSoft/Mars/mfileio/MReadReports.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 5143)
@@ -198,4 +198,9 @@
 }
 
+MReadTree *MReadReports::GetReader(const char *tree) const
+{
+    return (MReadTree*)fTrees->FindObject(tree);
+}
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mfileio/MReadReports.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadReports.h	(revision 5142)
+++ trunk/MagicSoft/Mars/mfileio/MReadReports.h	(revision 5143)
@@ -13,4 +13,5 @@
 class MTime;
 class MTaskList;
+class MReadTree;
 
 class MReadReports : public MRead
@@ -55,4 +56,6 @@
     void  EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } // Must be called BEFORE AddTree!
 
+    MReadTree *GetReader(const char *tree) const;
+
     ClassDef(MReadReports, 0) // Reads events and reports from a root file ordered in time
 };
Index: trunk/MagicSoft/Mars/mhbase/MBinning.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 5142)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 5143)
@@ -37,5 +37,5 @@
 public:
     MBinning(const char *name=NULL, const char *title=NULL);
-    MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt="", const char *title=NULL);
+    MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name=0, const char *opt="", const char *title=NULL);
 
     void SetEdges(const TArrayD &arr)
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 5143)
@@ -483,4 +483,6 @@
         return;
 
+    const Bool_t haserr = h.GetSumw2N()>0;
+
     const Int_t n0 = h.GetNbinsX();
     if (n0<2)
@@ -488,9 +490,10 @@
 
     TArrayD val(n0-1);
-    TArrayD err(n0-1);
+    TArrayD err(haserr ? n0-1 : 0);
     for (int i=1; i<n0; i++)
     {
         val[i-1] = h.GetBinContent(i+1);
-        err[i-1] = h.GetBinError(i+1);
+        if (haserr)
+            err[i-1] = h.GetBinError(i+1);
     }
 
@@ -505,5 +508,6 @@
     {
         h.SetBinContent(i, val[i-1]);
-        h.SetBinError(i, err[i-1]);
+        if (haserr)
+            h.SetBinError(i, err[i-1]);
     }
 }
Index: trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 5143)
@@ -304,5 +304,5 @@
     // within the range (yq[0], yq[1]) there must be no empty bin;
     // choose pedestrian approach as long as GetQuantiles is not available
-    Double_t xq[2] = { 0.05, 0.95 };
+    Double_t xq[2] = { 0.6, 0.99 };
     Double_t yq[2];
     h->GetQuantiles(2, yq, xq);
@@ -321,5 +321,5 @@
     //func.SetParNames("lambda", "N0", "del");
 
-    func.SetParameter(0, 100);       // Hz
+    func.SetParameter(0, 200);       // Hz
     func.SetParameter(1, Nm);
     func.FixParameter(2, Nmdel/Nm);
@@ -335,5 +335,5 @@
 
     // was fit successful ?
-    const Bool_t ok = NDF>0 && chi2<2.5*NDF;
+    const Bool_t ok = NDF>0 && chi2<3*NDF;
 
     if (paint)
@@ -343,7 +343,4 @@
         func.Paint("same");
     }
-
-    if (!ok)
-        return kFALSE;
 
     const Double_t lambda = func.GetParameter(0);
@@ -385,9 +382,12 @@
     res[5] = NDF;
 
+    // Chi2
+    res[6] = chi2;
+
     // Rdead (from fit) is the fraction from real time lost by the dead time
     //fHRdead.SetBinContent(i, Rdead);
     //fHRdead.SetBinError  (i,dRdead);
 
-    return kTRUE;
+    return ok;
 }
 
@@ -415,5 +415,5 @@
         h = fH2DeltaT.ProjectionX(name, i, i, "E");
 
-        Double_t res[6];
+        Double_t res[7];
         if (!FitH(h, res))
             continue;
@@ -457,5 +457,5 @@
     // Fit histogram
     //
-    Double_t res[6];
+    Double_t res[7];
     if (!FitH(&fH1DeltaT, res))
         return;
@@ -551,7 +551,9 @@
 
     //
-    // If we reached the event number limit for the time-bins fit the histogram
-    //
-    if (fH1DeltaT.GetEntries()>=fNumEvents)
+    // If we reached the event number limit for the time-bins fit the
+    // histogram - if it fails try again when 1.6% more events available
+    //
+    const Int_t n = (Int_t)fH1DeltaT.GetEntries();
+    if (n>=fNumEvents && n%(fNumEvents/60)==0)
         FitTimeBin();
 
@@ -592,6 +594,6 @@
 void MHEffectiveOnTime::PaintText(Double_t *res) const
 {
-    TLatex text(0.25, 0.94, Form("T_{eff}=%.1fs\\pm%.1fs  \\labda=%.1f\\pm%.1f  p=%.1f%%  NDF=%d",
-                                 res[0], res[1], res[3], res[4], res[2], res[5]));
+    TLatex text(0.27, 0.94, Form("T_{eff}=%.1fs\\pm%.1fs  \\lambda=%.1f\\pm%.1fHz  p=%.1f%%  \\chi^{2}/%d=%.1f",
+                                 res[0], res[1], res[3], res[4], res[2], (int)res[5], res[6]/res[5]));
     text.SetBit(TLatex::kTextNDC);
     text.SetTextSize(0.04);
@@ -613,5 +615,5 @@
         return;
 
-    TLatex text(0.45, 0.94, Form("\\bar{p} = %.1f%%  (n=%d)", sum/n, n));
+    TLatex text(0.47, 0.94, Form("\\bar{p} = %.1f%%", sum/n));
     text.SetBit(TLatex::kTextNDC);
     text.SetTextSize(0.04);
@@ -692,5 +694,5 @@
         if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT)))
         {
-            Double_t res[6];
+            Double_t res[7];
             FitH(h, res, kTRUE);
             PaintText(res);
Index: trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5143)
@@ -290,6 +290,6 @@
     // for the current pointing position and add a offset in the
     // Fill function!
-    fRa  = fPointPos->GetRa();
-    fDec = fPointPos->GetDec();
+    fRa  = fPointPos ? fPointPos->GetRa()  :  0;
+    fDec = fPointPos ? fPointPos->GetDec() : 90;
 
     return kTRUE;
@@ -592,8 +592,5 @@
     stars->ReadBSC("bsc5.dat");
 
-    *fLog << err << "FIXME - The catalog will never be deleted, because this crashes!" << endl;
-
-//    stars->SetBit(kCanDelete);
-
+    stars->SetBit(kCanDelete);
     return stars;
 }
@@ -612,10 +609,10 @@
     pad->Divide(1, 2, 0, 0.03);
 
-    *fLog << err << "FIXME - Plotting the catalog is broken!" << endl;
-
     TObject *catalog = GetCatalog();
 
     // Initialize upper part
     pad->cd(1);
+    // Make sure that the catalog is deleted only once
+    gROOT->GetListOfCleanups()->Add(gPad);
     gPad->SetBorderMode(0);
     gPad->Divide(3, 1);
@@ -662,4 +659,6 @@
     // Initialize lower part
     pad->cd(2);
+    // Make sure that the catalog is deleted only once
+    gROOT->GetListOfCleanups()->Add(gPad);
     gPad->SetBorderMode(0);
     gPad->Divide(3, 1);
@@ -673,5 +672,5 @@
     h1->SetXTitle(fHist.GetZaxis()->GetTitle());
     h1->SetYTitle("Counts");
-    h1->Draw(opt);
+    h1->Draw();
     h1->SetBit(kCanDelete);
 
@@ -942,5 +941,6 @@
 
 
-    TF2 f2d("Gaus-2D", FcnGauss2d, -1.5, 1.5, -1.5, 1.5, 6);
+    const Double_t maxr = 0.9*TMath::Abs(fHist.GetBinCenter(1));
+    TF2 f2d("Gaus-2D", FcnGauss2d, -maxr, maxr, -maxr, maxr, 6);
     f2d.SetLineWidth(1);
     f2d.SetParName(0, "Max   sigma");
@@ -950,16 +950,16 @@
     f2d.SetParName(4, "Sigma_2 deg");
     f2d.SetParName(5, "Phi     deg");
-    f2d.SetParLimits(1, -1, 1);    // mu_1
-    f2d.SetParLimits(3, -1, 1);    // mu_2
-    f2d.SetParLimits(2, 0, 1);     // sigma_1
-    f2d.SetParLimits(4, 0, 1);     // sigma_2
-    f2d.SetParLimits(5, 0, 90);    // phi
-    f2d.SetParameter(0, maxs);     // A
-    f2d.SetParameter(1, 0);        // mu_1
-    f2d.SetParameter(2, 0.5);      // sigma_1
-    f2d.SetParameter(3, 0);        // mu_2
-    f2d.SetParameter(4, 0.5);      // sigma_2
-    f2d.SetParameter(5, 0);        // phi
-    hist->Fit(&f2d, "NI0");
+    f2d.SetParLimits(1, -maxr/2, maxr/2); // mu_1
+    f2d.SetParLimits(3, -maxr/2, maxr/2); // mu_2
+    f2d.SetParLimits(2, 0, maxr);         // sigma_1
+    f2d.SetParLimits(4, 0, maxr);         // sigma_2
+    f2d.SetParLimits(5, 0, 45);           // phi
+    f2d.SetParameter(0, maxs);            // A
+    f2d.SetParameter(1, hist->GetXaxis()->GetBinCenter(maxx)); // mu_1
+    f2d.SetParameter(2, 0.1);             // sigma_1
+    f2d.SetParameter(3, hist->GetYaxis()->GetBinCenter(maxy)); // mu_2
+    f2d.SetParameter(4, 0.1);             // sigma_2
+    f2d.FixParameter(5, 0);               // phi
+    hist->Fit(&f2d, "NI0R");
     f2d.DrawCopy("cont2same");
 
Index: trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mhist/MHCamEvent.cc	(revision 5143)
@@ -30,8 +30,27 @@
 // currents or enything else derived from MCamEvent
 //
+// To plot the variance instead of the rms use:
+//    MHCamEvent::SetBit(MHCamera::kVariance);
+//
+// Axis titles
+// ===========
+//
+// 1) If no other title is given 'a.u.' is used.
+// 2) If the title of MHCamEvent is different from the default,
+//    it is used as histogram title. You can use this to set the
+//    axis title, too. For more information see TH1::SetTitle, eg.
+//       SetTitle("MyHist;;y[cm];Counts");
+//    Make sure to set an empty x-axis title.
+//
+//
+// For example:
+//   MHCamEvent myhist("Titele;;y [cm]");
+//
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MHCamEvent.h"
 
 #include <TCanvas.h>
+#include <TPaveStats.h>
 
 #include "MLog.h"
@@ -48,17 +67,38 @@
 using namespace std;
 
-// --------------------------------------------------------------------------
-//
-// Initialize the name and title of the task.
-// Resets the sum histogram
-//
-MHCamEvent::MHCamEvent(const char *name, const char *title)
-    : fSum(NULL), fRms(NULL), fEvt(NULL), fType(0)
+const TString MHCamEvent::gsDefName  = "MHCamEvent";
+const TString MHCamEvent::gsDefTitle = "Average of MCamEvents";
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task
+//
+void MHCamEvent::Init(const char *name, const char *title)
 {
     //
     //   set the name and title of this object
     //
-    fName  = name  ? name  : "MHCamEvent";
-    fTitle = title ? title : "Average of MCamEvents";
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task. Set fType to 0
+//
+MHCamEvent::MHCamEvent(const char *name, const char *title)
+    : fSum(NULL), fEvt(NULL), fType(0)
+{
+    Init(name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task. Set fType to type
+//
+MHCamEvent::MHCamEvent(Int_t type, const char *name, const char *title)
+    : fSum(NULL), fEvt(NULL), fType(type)
+{
+    Init(name, title);
 }
 
@@ -71,6 +111,4 @@
     if (fSum)
         delete fSum;
-    if (fRms)
-        delete fRms;
 }
 
@@ -104,17 +142,15 @@
     if (fSum)
         delete (fSum);
-    if (fRms)
-        delete (fRms);
 
     const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
 
-    fSum = new MHCamera(*cam, name+";avg", fTitle);
-    fSum->SetYTitle("a.u.");
+    fSum = new MHCamera(*cam, name+";avg");
+    if (fTitle!=gsDefTitle)
+        fSum->SetTitle(fTitle);
+    if (!fTitle.Contains(";"))
+        fSum->SetYTitle("a.u.");
     fSum->SetBit(MHCamera::kProfile);
-    if(TestBit(MHCamera::kVariance))
-      fSum->SetBit(MHCamera::kVariance);
-
-    fRms = new MHCamera(*cam, name+";rms", fTitle);
-    fRms->SetYTitle("a.u.");
+    if (TestBit(MHCamera::kVariance))
+        fSum->SetBit(MHCamera::kVariance);
 
     return kTRUE;
@@ -134,15 +170,4 @@
     }
     fSum->AddCamContent(*evt, fType);
-    fRms->SetCamContent(*fSum, 1);
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Scale the sum container with the number of entries
-//
-Bool_t MHCamEvent::Finalize()
-{
-    //fRms->AddCamContent(*fSum, 1);
     return kTRUE;
 }
@@ -176,12 +201,32 @@
 TH1 *MHCamEvent::GetHistByName(const TString name)
 {
-//    name.ToLower();
-
-    if (name=="sum")
-        return fSum;
-    if (name=="rms")
-        return fRms;
-
-    return NULL;
+    return fSum;
+}
+
+void MHCamEvent::Paint(Option_t *)
+{
+    TVirtualPad *pad = gPad;
+
+    pad->cd(2);
+    if (gPad->FindObject(Form("Proj_%p", this)))
+    {
+        TH1 *h=fSum->Projection(Form("Proj_%p", this));
+        if (h->GetMaximum()>0)
+            gPad->SetLogy();
+    }
+
+    pad->cd(5);
+    if (gPad->FindObject(Form("ProfR_%p", this)))
+        fSum->RadialProfile(Form("ProfR_%p", this));
+
+    pad->cd(6);
+    if (gPad->FindObject(Form("ProfA_%p", this)))
+        fSum->AzimuthProfile(Form("ProfA_%p", this));
+
+    pad->cd(4);
+    gPad->cd(1);
+    MHCamera *cam = (MHCamera*)gPad->FindObject(Form("Err_%p", this));
+    if (cam)
+        cam->SetCamContent(*fSum, 1);
 }
 
@@ -191,21 +236,58 @@
     pad->SetBorderMode(0);
 
-    pad->Divide(1,2);
+    AppendPad();
+
+    TString name = Form("%s_5", pad->GetName());
+    TPad *p = new TPad(name,name,6./8,0.25,0.99,0.5,pad->GetFillColor(),0,0);
+    p->SetNumber(5);
+    p->Draw();
+
+    name = Form("%s_6", pad->GetName());
+    p = new TPad(name,name,6./8,0.01,0.99,0.25,pad->GetFillColor(),0,0);
+    p->SetNumber(6);
+    p->Draw();
+
+    pad->Divide(2,2);
 
     pad->cd(1);
     gPad->SetBorderMode(0);
+    gPad->SetPad(0.01, 0.5, 0.66, 0.99);
     fSum->Draw("EPhist");
 
     pad->cd(2);
     gPad->SetBorderMode(0);
-    gPad->Divide(2, 1);
-    pad = gPad;
-
-    pad->cd(1);
+    gPad->SetPad(0.66, 0.5, 0.99, 0.99);
+    TH1 *h = fSum->Projection(Form("Proj_%p", this), 50);
+    h->SetTitle("Projection");
+    h->SetBit(kCanDelete);
+    h->Draw();
+
+    pad->cd(3);
+    gPad->SetPad(0.01, 0.01, 3./8, 0.5);
     gPad->SetBorderMode(0);
     fSum->Draw();
 
-    pad->cd(2);
-    gPad->SetBorderMode(0);
-    fRms->Draw();
-}
+    pad->cd(4);
+    gPad->SetPad(3./8, 0.01, 6./8, 0.5);
+    gPad->SetBorderMode(0);
+
+    MHCamera *cam = new MHCamera(*fSum->GetGeometry());
+    cam->SetName(Form("Err_%p", this));
+    cam->SetTitle(TestBit(MHCamera::kVariance)?"Variance":"Root Mean Squared (rms)");
+    cam->SetYTitle(fSum->GetYaxis()->GetTitle());
+    cam->SetCamContent(*fSum, 1);
+    cam->SetBit(kCanDelete);
+    cam->Draw();
+
+    pad->cd(5);
+    h = (TH1*)fSum->RadialProfile(Form("ProfR_%p", this), 20);
+    h->SetTitle("Radial Profile");
+    h->SetBit(kCanDelete|TH1::kNoStats);
+    h->Draw();
+
+    pad->cd(6);
+    h = (TH1*)fSum->AzimuthProfile(Form("ProfA_%p", this), 30);
+    h->SetTitle("Azimuth Profile");
+    h->SetBit(kCanDelete|TH1::kNoStats);
+    h->Draw();
+}
Index: trunk/MagicSoft/Mars/mhist/MHCamEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamEvent.h	(revision 5142)
+++ trunk/MagicSoft/Mars/mhist/MHCamEvent.h	(revision 5143)
@@ -12,6 +12,8 @@
 {
 private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
     MHCamera  *fSum; // storing the sum
-    MHCamera  *fRms; // storing the rms
     MCamEvent *fEvt; //! the current event
 
@@ -20,10 +22,12 @@
     Int_t fType;
 
+    void Init(const char *name, const char *title);
+
     Bool_t SetupFill(const MParList *pList);
     Bool_t Fill(const MParContainer *par, const Stat_t w=1);
-    Bool_t Finalize();
 
 public:
     MHCamEvent(const char *name=NULL, const char *title=NULL);
+    MHCamEvent(Int_t type, const char *name=NULL, const char *title=NULL);
     ~MHCamEvent();
 
@@ -33,4 +37,5 @@
     TH1 *GetHistByName(const TString name="");
 
+    void Paint(Option_t *o="");
     void Draw(Option_t *o="");
 
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 5143)
@@ -75,4 +75,5 @@
 
 #include "MH.h"
+#include "MBinning.h"
 #include "MHexagon.h"
 
@@ -576,17 +577,27 @@
     if (!h1)
     {
-        Double_t min = GetMinimumSectors(sector, aidx);
-        Double_t max = GetMaximumSectors(sector, aidx);
-
-        Int_t newbins=0;
-
-        THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
-
-        h1 = new TH1D(pname, GetTitle(), nbins, min, max);
-        h1->SetDirectory(pname.IsNull() ? NULL : gROOT);
+        h1 = new TH1D;
+        h1->UseCurrentStyle();
+        h1->SetName(pname);
+        h1->SetTitle(GetTitle());
+        h1->SetDirectory(0);
         h1->SetXTitle(GetYaxis()->GetTitle());
         h1->SetYTitle("Counts");
         //h1->Sumw2();
     }
+
+    Double_t min = GetMinimumSectors(sector, aidx);
+    Double_t max = GetMaximumSectors(sector, aidx);
+
+    if (min==max && max>0)
+        min=0;
+    if (min==max && min<0)
+        max=0;
+
+    Int_t newbins=0;
+    THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
+
+    MBinning bins(nbins, min, max);
+    bins.Apply(*h1);
 
     // Fill the projected histogram
@@ -630,55 +641,59 @@
 TProfile *MHCamera::RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name, const Int_t nbins) const
 {
+    // Create the projection histogram
+    TString pname(name);
+    if (name=="_rad")
+    {
+        pname.Prepend(GetName());
+        if (sector.GetSize()>0)
+        {
+            pname += ";";
+            for (int i=0; i<sector.GetSize(); i++)
+                pname += sector[i];
+        }
+        if (aidx.GetSize()>0)
+        {
+            pname += ";";
+            for (int i=0; i<aidx.GetSize(); i++)
+                pname += aidx[i];
+        }
+    }
+
+    TProfile *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(pname);
+    if (h1obj && h1obj->InheritsFrom("TProfile")) {
+        h1 = (TProfile*)h1obj;
+        h1->Reset();
+    }
+
+    if (!h1)
+    {
+        h1 = new TProfile;
+        h1->UseCurrentStyle();
+        h1->SetName(pname);
+        h1->SetTitle(GetTitle());
+        h1->SetDirectory(0);
+        h1->SetXTitle("Radius from camera center [mm]");
+        h1->SetYTitle(GetYaxis()->GetTitle());
+    }
+
+    Double_t min = 0.;
+    Double_t max = fGeomCam->GetMaxRadius();
+
+    Int_t newbins=0;
+
+    THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
+
+    MBinning bins(nbins, min, max);
+    bins.Apply(*h1);
   
-  // Create the projection histogram
-  TString pname(name);
-  if (name=="_rad")
-    {
-      pname.Prepend(GetName());
-      if (sector.GetSize()>0)
-        {
-          pname += ";";
-          for (int i=0; i<sector.GetSize(); i++)
-            pname += sector[i];
-        }
-      if (aidx.GetSize()>0)
-        {
-          pname += ";";
-          for (int i=0; i<aidx.GetSize(); i++)
-            pname += aidx[i];
-        }
-    }
-  
-  TProfile *h1=0;
-  
-  //check if histogram with identical name exist
-  TObject *h1obj = gROOT->FindObject(pname);
-  if (h1obj && h1obj->InheritsFrom("TProfile")) {
-    h1 = (TProfile*)h1obj;
-    h1->Reset();
-  }
-  
-  if (!h1)
-    {
-      
-      Double_t min = 0.;
-      Double_t max = fGeomCam->GetMaxRadius();
-      
-      Int_t newbins=0;
-      
-      THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
-      
-      h1 = new TProfile(pname, GetTitle(), nbins, min, max);
-      h1->SetDirectory(pname.IsNull() ? NULL : gROOT);
-      h1->SetXTitle("Radius from camera center [mm]");
-      h1->SetYTitle(GetYaxis()->GetTitle());
-    }
-  
-  // Fill the projected histogram
-  for (Int_t idx=0; idx<fNcells-2; idx++)
-    if (IsUsed(idx) && MatchSector(idx, sector, aidx))
-      h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()),
-               GetBinContent(idx+1));
-  return h1;
+    // Fill the projected histogram
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (IsUsed(idx) && MatchSector(idx, sector, aidx))
+            h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()),
+                     GetBinContent(idx+1));
+    return h1;
 }
 
@@ -710,53 +725,57 @@
 TProfile *MHCamera::AzimuthProfileA(const TArrayI &aidx, const char *name, const Int_t nbins) const
 {
-  
-  // Create the projection histogram
-  TString pname(name);
-  if (name=="_azi")
-    {
-      pname.Prepend(GetName());
-      if (aidx.GetSize()>0)
+    // Create the projection histogram
+    TString pname(name);
+    if (name=="_azi")
+    {
+        pname.Prepend(GetName());
+        if (aidx.GetSize()>0)
         {
-          pname += ";";
-          for (int i=0; i<aidx.GetSize(); i++)
-            pname += aidx[i];
+            pname += ";";
+            for (int i=0; i<aidx.GetSize(); i++)
+                pname += aidx[i];
         }
     }
-  
-  TProfile *h1=0;
-  
-  //check if histogram with identical name exist
-  TObject *h1obj = gROOT->FindObject(pname);
-  if (h1obj && h1obj->InheritsFrom("TProfile")) {
-    h1 = (TProfile*)h1obj;
-    h1->Reset();
-  }
-  
-  if (!h1)
-    {
-      
-      Double_t min = -0.5;
-      Double_t max = 359.5;
-      
-      Int_t newbins=0;
-      
-      THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
-      
-      h1 = new TProfile(pname, GetTitle(), nbins, min, max);
-      h1->SetDirectory(pname.IsNull() ? NULL : gROOT);
-      h1->SetXTitle("Azimuth in camera [deg]");
-      h1->SetYTitle(GetYaxis()->GetTitle());
-    }
-  
-  // Fill the projected histogram
-  for (Int_t idx=0; idx<fNcells-2; idx++)
-    {
-      if (IsUsed(idx) && MatchSector(idx, TArrayI(), aidx))
-        h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*180./TMath::Pi()+180.,
-                 GetPixContent(idx));
-      
-    }
-  
-  return h1;
+
+    TProfile *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(pname);
+    if (h1obj && h1obj->InheritsFrom("TProfile")) {
+        h1 = (TProfile*)h1obj;
+        h1->Reset();
+    }
+
+    if (!h1)
+    {
+
+        h1 = new TProfile;
+        h1->UseCurrentStyle();
+        h1->SetName(pname);
+        h1->SetTitle(GetTitle());
+        h1->SetDirectory(0);
+        h1->SetXTitle("Azimuth in camera [deg]");
+        h1->SetYTitle(GetYaxis()->GetTitle());
+    }
+
+    Double_t min = 0;
+    Double_t max = 360;
+
+    Int_t newbins=0;
+    THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
+
+    MBinning bins(nbins, min, max);
+    bins.Apply(*h1);
+
+    // Fill the projected histogram
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        if (IsUsed(idx) && MatchSector(idx, TArrayI(), aidx))
+            h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*TMath::RadToDeg()+180,
+                     GetPixContent(idx));
+
+    }
+
+    return h1;
 }
 
@@ -1599,5 +1618,6 @@
         return TObject::GetObjectInfo(px, py);
 
-    sprintf(info, "Software Pixel Index: %d (Hardware Id=%d)", idx, idx+1);
+    sprintf(info, "Software Pixel Idx: %d (Hardware Id=%d) c=%.1f <%s>",
+            idx, idx+1, GetBinContent(idx+1), IsUsed(idx)?"on":"off");
     return info;
 }
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 5142)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 5143)
@@ -262,5 +262,5 @@
     TH1D    *ProjectionS(const TArrayI &sector, const TArrayI &aidx, const char *name="_py", const Int_t nbins=50) const;
 
-    TProfile *RadialProfile(const char *name="_rad") const { return  RadialProfileS(TArrayI(), TArrayI(), name);}
+    TProfile *RadialProfile(const char *name="_rad", Int_t nbins=25) const { return  RadialProfileS(TArrayI(), TArrayI(), name, nbins);}
     TProfile *RadialProfileS(Int_t sector, Int_t aidx, const char *name="_rad", const Int_t nbins=25) const
     {
@@ -269,5 +269,5 @@
     TProfile *RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=25) const;
 
-    TProfile *AzimuthProfile(const char *name="_azi") const { return  AzimuthProfileA(TArrayI(), name);  }
+    TProfile *AzimuthProfile(const char *name="_azi", Int_t nbins=25) const { return  AzimuthProfileA(TArrayI(), name, nbins);  }
     TProfile *AzimuthProfile(Int_t aidx, const char *name="_rad", const Int_t nbins=25) const
       {
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5143)
@@ -306,22 +306,19 @@
     MBadPixelsTreat        treat;
 
-    MHCamEvent evt0("PedestalFLG");
-    MHCamEvent evt1("Extra'd");
-    MHCamEvent evt2("PedPhot");
-    MHCamEvent evt3("Interp'd");
-    MHCamEvent evt4("Unsuitable");
-    MHCamEvent evt5("Times");
-    evt0.SetType(0);
-    evt1.SetType(0);
-    evt2.SetType(0);
-    evt3.SetType(0);
-    evt4.SetType(2);
-    evt5.SetType(0);
+    MHCamEvent evt0(0, "PedestalFLG", "Pedestal from Lo Gain;;P [fadc/sl]");
+    MHCamEvent evt1(0, "Extra'd",     "Extracted Signal;;S [fadc/sl]");
+    MHCamEvent evt2(0, "PedPhot",     "Calibrated Pedestal;;P [\\gamma]");
+    MHCamEvent evt3(1, "PedRMS",      "Calibrated Pedestal RMS;;\\sigma_{p} [\\gamma]");
+    MHCamEvent evt4(0, "Interp'd",    "Interpolated Signal;;S [\\gamma]");
+    MHCamEvent evt5(2, "Unsuitable",  "Unsuitable event ratio;;%");
+    MHCamEvent evt6(0, "Times",       "Arrival Time;;T [slice]");
+
     MFillH fill0(&evt0, "MPedestalCam",        "FillPedestalFLG");
     MFillH fill1(&evt1, "MExtractedSignalCam", "FillExtracted");
     MFillH fill2(&evt2, "MPedPhotCam",         "FillPedPhot");
-    MFillH fill3(&evt3, "MCerPhotEvt",         "FillInterpolated");
-    MFillH fill4(&evt4, "MBadPixelsCam",       "FillUnsuitable");
-    MFillH fill5(&evt5, "MArrivalTime",        "FillTimes");
+    MFillH fill3(&evt3, "MPedPhotCam",         "FillPedRMS");
+    MFillH fill4(&evt4, "MCerPhotEvt",         "FillInterpolated");
+    MFillH fill5(&evt5, "MBadPixelsCam",       "FillUnsuitable");
+    MFillH fill6(&evt6, "MArrivalTime",        "FillTimes");
 
     MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", fPathOut.Data()), fOverwrite);
@@ -386,4 +383,5 @@
     tlist2.AddToList(&fill4);
     tlist2.AddToList(&fill5);
+    tlist2.AddToList(&fill6);
 
     // Setup List for Drive-tree
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 5143)
@@ -169,4 +169,9 @@
     MGeomApply             apply; // Only necessary to craete geometry
     MEventRateCalc         rate;
+    MEventRateCalc         rate1; // 5min
+    rate.SetNumEvents(1200);
+    rate1.SetNumEvents(60000);
+    rate1.SetNameEventRate("MEventRate2");
+    rate1.SetNameTimeRate("MTimeRate2");
 /*
     MEventRateCalc         rate10000;
@@ -179,9 +184,10 @@
 
     // ------------------ Setup histograms and fill tasks ----------------
-    MHCamEvent evt0("Cleaned");
+    MHCamEvent evt0("Cleaned", "Signal after Cleaning;;S [\\gamma]");
     evt0.SetType(0);
 
     MH3 h1("MEventRate.fRate");
     h1.SetName("MHEventRate");
+    h1.SetTitle("Event Rate distribution;R [Hz];Counts");
     h1.SetLogy();
 /*
@@ -194,5 +200,14 @@
     plist.AddToList(&b1);
 
-    MFillH fill0(&evt0, "MCerPhotEvt",            "FillCerPhotEvt");
+    MHVsTime hvs("MEventRate.fRate");
+    hvs.SetTitle("Rate per 500 events;R [Hz];Counts");
+    hvs.SetNumEvents(500);
+
+    MContinue cont1("MEventRate2.fRate/MEventRate.fRate>1.1");
+    MContinue cont2("MEventRate.fRate/MEventRate2.fRate>1.1");
+
+    MFillH fillvs(&hvs,           "MTime",        "FillEventRate10s");
+
+    MFillH fill0(&evt0,           "MCerPhotEvt",  "FillCerPhotEvt");
     MFillH fill1("MHHillas",      "MHillas",      "FillHillas");
     MFillH fill2("MHHillasExt",   "",             "FillHillasExt");
@@ -257,5 +272,8 @@
         tlist2.AddToList(&cont);
         tlist2.AddToList(&rate);
-        //tlist2.AddToList(&rate10000);
+        tlist2.AddToList(&rate1);
+        tlist2.AddToList(&fillvs);
+        tlist2.AddToList(&cont1);
+        tlist2.AddToList(&cont2);
         tlist2.AddToList(&fill8);
         tlist2.AddToList(&fill9);
Index: trunk/MagicSoft/Mars/mmain/MEventDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 5143)
@@ -602,4 +602,6 @@
         return;
 
+    UnLock();
+
     //
     // Get parlist
Index: trunk/MagicSoft/Mars/msignal/MArrivalTime.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTime.cc	(revision 5142)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTime.cc	(revision 5143)
@@ -63,12 +63,12 @@
 void MArrivalTime::Reset()
 {
-  fData.Reset(-1);
-  fDataErr.Reset(-1);
+    fData.Reset(-1);
+    fDataErr.Reset(-1);
 }
 
 void MArrivalTime::InitSize(const UInt_t i)
 {
-  fData.Set(i);
-  fDataErr.Set(i);
+    fData.Set(i);
+    fDataErr.Set(i);
 }
 
@@ -112,10 +112,11 @@
     {
     case 0:
-    case 1:
         val = fData[idx];
         break;
+    default:
+        return kFALSE;
     }
 
-    return kTRUE;
+    return val>=0;
 }
 
