Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 8047)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 8073)
@@ -1322,4 +1322,5 @@
 //
 // see http://root.cern.ch/phpBB2/viewtopic.php?p=14818
+// see http://savannah.cern.ch/bugs/?20722
 //
 void MH::SetBinomialErrors(TH1 &hres, const TH1 &h1, const TH1 &h2, Double_t c1, Double_t c2)
@@ -1329,9 +1330,14 @@
         const Double_t b1 = h1.GetBinContent(binx);
         const Double_t b2 = h2.GetBinContent(binx);
-        const Double_t w  = c2*b2 ? (c1*b1)/(c2*b2) : 0;
         const Double_t e1 = h2.GetBinError(binx);
         const Double_t e2 = h1.GetBinError(binx);
 
-        const Double_t rc = ((1-2*w)*e1*e1+w*w*e2*e2)/(b2*b2);
+        //const Double_t w  = c2*b2 ? (c1*b1)/(c2*b2) : 0;
+        //const Double_t rc = ((1-2*w)*e1*e1+w*w*e2*e2)/(b2*b2);
+
+        const Double_t c = c2==0 ? 1 : c1/c2;
+        const Double_t u = b2==0 ? 0 : b1/b2;
+
+        const Double_t rc = c*((1-2*u)*e1*e1+u*u*e2*e2)/(b2*b2);
 
         hres.SetBinError(binx, TMath::Sqrt(TMath::Abs(rc)));
