Index: trunk/MagicSoft/Mars/mhbase/MBinning.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.cc	(revision 4956)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.cc	(revision 4966)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -24,7 +24,17 @@
 
 //////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-//  MBinning                                                                //
-//                                                                          //
+//
+//  MBinning
+//
+// This is a MParCOntainer storing a binning for a histogram. Doing this
+// you are able to distribute a single binning to several histograms
+// in your parameter list.
+//
+// In some classes the title of the container is used to set the
+// axis-title of the corresponding axis in your histogram.
+//
+// For all the features supported see the function descriptions in
+//  MBinning and MH
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MBinning.h"
@@ -64,4 +74,9 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Instantiate MBinning with nbins number of bins between lo (lower edge)
+// and hi (upper edge), name name and title title.
+//
 MBinning::MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt, const char *title)
 {
@@ -70,7 +85,10 @@
 
     SetEdges(nbins, lo, hi, opt);
-
-}
-
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the edges stored in MBinning from the TAxis axe
+//
 void MBinning::SetEdges(const TAxis &axe)
 {
@@ -85,4 +103,18 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Add a new upper edge to the edges stored in MBinning. The new upper
+// edge must be greater than the current greatest. Using this you can
+// enhance a histogram bin-by-bin, eg:
+//   TH1F h("", "", 2, 0, 1);
+//   MBinning b;
+//   b.SetEdges(h);
+//   b.AddEdge(2);
+//   b.Apply(h);
+//   b.AddEdge(3);
+//   b.Apply(h);
+//   [...]
+//
 void MBinning::AddEdge(Axis_t up)
 {
@@ -101,21 +133,38 @@
 }
 
+void MBinning::RemoveFirstEdge()
+{
+    const Int_t n = fEdges.GetSize();
+    for (int i=0; i<n-1; i++)
+        fEdges[i] = fEdges[i+1];
+    fEdges.Set(n-1);
+}
+
+void MBinning::RemoveLastEdge()
+{
+    fEdges.Set(fEdges.GetSize()-1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the edges in MBinning from a histogram-axis. Which axis is
+// specified by axis ('x', 'y', 'z')
+//
 void MBinning::SetEdges(const TH1 &h, const Char_t axis)
 {
-    TH1 &hist = (TH1&)h; // get rid of const qualifier
     switch (tolower(axis))
     {
     case 'x':
-        SetEdges(*hist.GetXaxis());
+        SetEdges(*h.GetXaxis());
         return;
     case 'y':
-        SetEdges(*hist.GetYaxis());
+        SetEdges(*h.GetYaxis());
         return;
     case 'z':
-        SetEdges(*hist.GetZaxis());
+        SetEdges(*h.GetZaxis());
         return;
     default:
         *fLog << warn << "MBinning::SetEdges: Axis '" << axis << "' unknown... using x." << endl;
-        SetEdges(*hist.GetXaxis());
+        SetEdges(*h.GetXaxis());
     }
 }
Index: trunk/MagicSoft/Mars/mhbase/MBinning.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 4956)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 4966)
@@ -46,4 +46,5 @@
 
     void SetEdges(const TAxis &axe);
+    void SetEdges(const MBinning &bins) { SetEdges(fEdges); }
     void SetEdges(const TH1 &h, const Char_t axis='x');
     void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
@@ -59,5 +60,5 @@
 	for (int i=1; i<fEdges.GetSize(); i++)
         {
-            if (((TArrayD)fEdges)[i] >= val)
+            if (fEdges[i] >= val)
                 return i-1;
         }
@@ -70,22 +71,24 @@
     }
 
-    // FIXME: ROOT workaround: "operator[] const" missing
-    Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
-    Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; }
+    Double_t GetEdgeLo() const { return fEdges[0]; }
+    Double_t GetEdgeHi() const { return fEdges[fEdges.GetSize()-1]; }
 
-    Int_t GetNumEdges() const { return fEdges.GetSize(); }
-    Int_t GetNumBins() const { return fEdges.GetSize()-1; }
+    Int_t GetNumEdges() const  { return fEdges.GetSize(); }
+    Int_t GetNumBins() const   { return fEdges.GetSize()-1; }
 
     Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); }
+    const TArrayD &GetEdgesD() const { return fEdges; }
 
     void AddEdge(Axis_t up);
+    void RemoveFirstEdge();
+    void RemoveLastEdge();
 
-    Bool_t IsLinear() const { return fType==kIsLinear; }
+    Bool_t IsLinear() const      { return fType==kIsLinear; }
     Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; }
-    Bool_t IsCosinic() const { return fType==kIsCosinic; }
-    Bool_t IsDefault() const { return fType==kIsDefault; }
-    Bool_t IsUserArray() const { return fType==kIsUserArray; }
+    Bool_t IsCosinic() const     { return fType==kIsCosinic; }
+    Bool_t IsDefault() const     { return fType==kIsDefault; }
+    Bool_t IsUserArray() const   { return fType==kIsUserArray; }
 
-    Bool_t HasTitle() const { return gsDefTitle!=fTitle; }
+    Bool_t HasTitle() const      { return gsDefTitle!=fTitle; }
 
     void Apply(TH1 &) const;
@@ -95,3 +98,2 @@
 
 #endif
-
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4956)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 4966)
@@ -478,4 +478,35 @@
 }
 
+void MH::RemoveFirstBin(TH1 &h)
+{
+    if (h.InheritsFrom(TH2::Class()) || h.InheritsFrom(TH3::Class()))
+        return;
+
+    const Int_t n0 = h.GetNbinsX();
+    if (n0<2)
+        return;
+
+    TArrayD val(n0-1);
+    TArrayD err(n0-1);
+    for (int i=1; i<n0; i++)
+    {
+        val[i-1] = h.GetBinContent(i+1);
+        err[i-1] = h.GetBinError(i+1);
+    }
+
+    MBinning bins;
+    bins.SetEdges(h, 'x');
+    bins.RemoveFirstEdge();
+    bins.Apply(h);
+
+    h.Reset();
+
+    for (int i=1; i<n0; i++)
+    {
+        h.SetBinContent(i, val[i-1]);
+        h.SetBinError(i, err[i-1]);
+    }
+}
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mhbase/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.h	(revision 4956)
+++ trunk/MagicSoft/Mars/mhbase/MH.h	(revision 4966)
@@ -69,4 +69,6 @@
     static void SetBinning(TH1 *h, const TH1 *x);
 
+    static void RemoveFirstBin(TH1 &h);
+
     static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h);
 
