Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 7804)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 8047)
@@ -1316,4 +1316,29 @@
 // --------------------------------------------------------------------------
 //
+// This is a workaround for rrot-version <5.13/04 to get correct
+// binomial errors even if weights have been used, do:
+//    h->Divide(h1, h2, 5, 2, "b");
+//    MH::SetBinomialErrors(*h, *h1, *h2, 5, 2);
+//
+// see http://root.cern.ch/phpBB2/viewtopic.php?p=14818
+//
+void MH::SetBinomialErrors(TH1 &hres, const TH1 &h1, const TH1 &h2, Double_t c1, Double_t c2)
+{
+    for (Int_t binx=0; binx<=hres.GetNbinsX()+1; binx++)
+    {
+        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);
+
+        hres.SetBinError(binx, TMath::Sqrt(TMath::Abs(rc)));
+    }
+}
+
+// --------------------------------------------------------------------------
+//
 // See MTask::PrintSkipped
 //
Index: trunk/MagicSoft/Mars/mhbase/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.h	(revision 7804)
+++ trunk/MagicSoft/Mars/mhbase/MH.h	(revision 8047)
@@ -76,4 +76,6 @@
     static void SetBinning(TH1 *h, const TH1 *x);
 
+    static void SetBinomialErrors(TH1 &hres, const TH1 &h1, const TH1 &h2, Double_t c1=1, Double_t c2=1);
+
     static void RemoveFirstBin(TH1 &h);
 
