Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 9315)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 9362)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.45 2009-02-11 12:08:23 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.46 2009-02-22 23:36:00 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -698,5 +698,8 @@
 
     if (bins->IsDefault())
+    {
+        gLog << inf << "Object 'Binning" << name << "' [MBinning] is default... binning unchanged." << endl;
         return kTRUE;
+    }
 
     SetBinning(h, bins);
@@ -707,58 +710,85 @@
 {
     const MBinning *binsx = (MBinning*)plist.FindObject("Binning"+x);
+    const MBinning *binsy = (MBinning*)plist.FindObject("Binning"+y);
+
+    if (!binsx && !binsy)
+    {
+        gLog << inf << "Neither 'Binning" << x << "' nor 'Binning" << y;
+        gLog << "' [MBinning] found... no binning applied." << endl;
+        return kFALSE;
+    }
+
     if (!binsx)
-    {
-        gLog << inf << "Object 'Binning" << x << "' [MBinning] not found... no binning applied." << endl;
+        gLog << inf << "Object 'Binning" << x << "' [MBinning] not found... binning unchanged." << endl;
+    if (!binsy)
+        gLog << inf << "Object 'Binning" << y << "' [MBinning] not found... binning unchanged." << endl;
+
+    if (binsx && binsx->IsDefault())
+    {
+        gLog << inf << "Object 'Binning" << x << "' [MBinning] is default... binning unchanged." << endl;
+        binsx = 0;
+    }
+
+    if (binsy && binsy->IsDefault())
+    {
+        gLog << inf << "Object 'Binning" << y << "' [MBinning] is default... binning unchanged." << endl;
+        binsy = 0;
+    }
+
+    MBinning binsxx, binsyy;
+    binsxx.SetEdges(*h, 'x');
+    binsyy.SetEdges(*h, 'y');
+
+    SetBinning(h, binsx?binsx:&binsxx, binsy?binsy:&binsyy);
+
+    return kTRUE;
+}
+
+Bool_t MH::ApplyBinning(const MParList &plist, TString x, TString y, TString z, TH3 *h)
+{
+    const MBinning *binsx = (MBinning*)plist.FindObject("Binning"+x);
+    const MBinning *binsy = (MBinning*)plist.FindObject("Binning"+y);
+    const MBinning *binsz = (MBinning*)plist.FindObject("Binning"+z);
+
+    if (!binsx && !binsy && !binsz)
+    {
+        gLog << inf << "Neither 'Binning" << x << "', 'Binning" << y;
+        gLog << "' nor 'Binning" << z << "' [MBinning] found... ";
+        gLog << "no binning applied." << endl;
         return kFALSE;
     }
-    const MBinning *binsy = (MBinning*)plist.FindObject("Binning"+y);
+
+    if (!binsx)
+        gLog << inf << "Object 'Binning" << x << "' [MBinning] not found... binning unchanged." << endl;
     if (!binsy)
-    {
-        gLog << inf << "Object 'Binning" << y << "' [MBinning] not found... no binning applied." << endl;
-        return kFALSE;
-    }
-
-    if (binsx->IsDefault() && binsy->IsDefault())
-        return kTRUE;
-
-    // -------------------------
-    /*
-     MBinning binsx, binsy, binsz;
-     binsx.SetEdges(fHist, 'x');
-     binsy.SetEdges(fHist, 'y');
-     binsz.SetEdges(fHist, 'z');
-     */
-    // -------------------------
-
-    SetBinning(h, binsx, binsy);
-
-    return kTRUE;
-}
-
-Bool_t MH::ApplyBinning(const MParList &plist, TString x, TString y, TString z, TH3 *h)
-{
-    const MBinning *binsx = (MBinning*)plist.FindObject("Binning"+x);
-    if (!binsx)
-    {
-        gLog << inf << "Object 'Binning" << x << "' [MBinning] not found... no binning applied." << endl;
-        return kFALSE;
-    }
-    const MBinning *binsy = (MBinning*)plist.FindObject("Binning"+y);
-    if (!binsy)
-    {
-        gLog << inf << "Object 'Binning" << y << "' [MBinning] not found... no binning applied." << endl;
-        return kFALSE;
-    }
-    const MBinning *binsz = (MBinning*)plist.FindObject("Binning"+z);
+        gLog << inf << "Object 'Binning" << y << "' [MBinning] not found... binning unchanged." << endl;
     if (!binsz)
-    {
-        gLog << inf << "Object 'Binning" << z << "' [MBinning] not found... no binning applied." << endl;
-        return kFALSE;
-    }
-
-    if (binsx->IsDefault() && binsy->IsDefault() && binsz->IsDefault())
-        return kTRUE;
-
-    SetBinning(h, binsx, binsy, binsz);
+        gLog << inf << "Object 'Binning" << z << "' [MBinning] not found... binning unchanged." << endl;
+
+    if (binsx && binsx->IsDefault())
+    {
+        gLog << inf << "Object 'Binning" << x << "' [MBinning] is default... binning unchanged." << endl;
+        binsx = 0;
+    }
+
+    if (binsy && binsy->IsDefault())
+    {
+        gLog << inf << "Object 'Binning" << y << "' [MBinning] is default... binning unchanged." << endl;
+        binsy = 0;
+    }
+
+    if (binsz && binsz->IsDefault())
+    {
+        gLog << inf << "Object 'Binning" << z << "' [MBinning] is default... binning unchanged." << endl;
+        binsy = 0;
+    }
+
+    MBinning binsxx, binsyy, binszz;
+    binsxx.SetEdges(*h, 'x');
+    binsyy.SetEdges(*h, 'y');
+    binszz.SetEdges(*h, 'z');
+
+    SetBinning(h, binsx?binsx:&binsxx, binsy?binsy:&binsyy, binsz?binsz:&binszz);
+
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 9315)
+++ trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 9362)
@@ -583,5 +583,5 @@
                 if (!binsx)
                 {
-                    *fLog << err << dbginf << "Neither '" << bx << "' nor '" << fName << "' found... aborting." << endl;
+                    *fLog << err << dbginf << "Neither '" << bx << "' nor 'Binning" << fName << "' found... aborting." << endl;
                     return kFALSE;
                 }
