Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 8072)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 8073)
@@ -34,5 +34,5 @@
 //             "(4.4*MHillas.fSize*MHillas.fLength) + (5.5*MHillasSrc.fDist*MHillas.fLength)");
 //
-// For description of rules, see MDataChain.
+// For description of rules, see MDataPhrase.
 //
 // The default rule is "MMcEvt.fEnergy"
Index: trunk/MagicSoft/Mars/manalysis/MParameterCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MParameterCalc.cc	(revision 8072)
+++ trunk/MagicSoft/Mars/manalysis/MParameterCalc.cc	(revision 8073)
@@ -33,5 +33,5 @@
 //             "(4.4*MHillas.fSize*MHillas.fLength) + (5.5*MHillasSrc.fDist*MHillas.fLength)");
 //
-// For description of rules, see MDataChain.
+// For description of rules, see MDataPhrase.
 //
 // Output:
@@ -43,5 +43,5 @@
 #include "MParList.h"
 
-#include "MDataChain.h"
+#include "MDataPhrase.h"
 #include "MParameters.h"
 
@@ -63,5 +63,5 @@
     fTitle = title ? title : "Task to calculate a MParameterD";
 
-    fData = new MDataChain(def);
+    fData = new MDataPhrase(def);
 }
 
@@ -77,5 +77,5 @@
 // --------------------------------------------------------------------------
 //
-// Delete fData. Initialize a new MDataChain with rule.
+// Delete fData. Initialize a new MDataPhrase with rule.
 // Returns if fData->IsValid()
 //
@@ -83,5 +83,5 @@
 {
     delete fData;
-    fData = new MDataChain(rule);
+    fData = new MDataPhrase(rule);
 
     return fData->IsValid();
@@ -183,9 +183,9 @@
 //     MyEstimator.1: 5.5
 //
-// For more details see MDataChain::ReadEnv
+// For more details see MDataPhrase::ReadEnv
 //
 Int_t MParameterCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
-    MDataChain *f = new MDataChain;
+    MDataPhrase *f = new MDataPhrase;
     f->SetName(fName);
 
Index: trunk/MagicSoft/Mars/manalysis/MParameterCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MParameterCalc.h	(revision 8072)
+++ trunk/MagicSoft/Mars/manalysis/MParameterCalc.h	(revision 8073)
@@ -12,5 +12,5 @@
 {
 private:
-    MData       *fData;          //-> Input MDataChain with rule
+    MData       *fData;          //-> Input MDataPhrase with rule
     MParameterD *fParameter;     //!  Output parameter
 
Index: trunk/MagicSoft/Mars/mbase/MMath.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 8072)
+++ trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 8073)
@@ -554,5 +554,5 @@
 // An exact solution of the cubic polynomial equation:
 //
-// x^3 + a*x^2 + b*x + c = 0
+//   x^3 + a*x^2 + b*x + c = 0
 //
 // was first published by Gerolamo Cardano (1501-1576) in his treatise,
@@ -563,4 +563,6 @@
 // discovered. Zeno source code
 //
+// http://home.att.net/~srschmitt/cubizen.html
+//
 // % compute real or complex roots of cubic polynomial
 // function cubic( var z1, z2, z3 : real, a, b, c : real ) : real
@@ -598,7 +600,12 @@
 // end function
 //
+// see also http://en.wikipedia.org/wiki/Cubic_equation
+//
 Int_t MMath::SolvePol3(Double_t a, Double_t b, Double_t c,
                        Double_t &x1, Double_t &x2, Double_t &x3)
 {
+    //    Double_t coeff[4] = { 1, a, b, c };
+    //    return TMath::RootsCubic(coeff, x1, x2, x3) ? 1 : 3;
+
     const Double_t Q = (a*a - 3*b)/9;
     const Double_t R = (9*b*a - 27*c - 2*a*a*a)/54;
@@ -607,11 +614,20 @@
     // ----- The single-real / duplicate-roots solution -----
 
+    // D<0:  three real roots
+    // D>0:  one real root
+    // D==0: maximum two real roots (two identical roots)
+
+    // R==0: only one unique root
+    // R!=0: two roots
+
     if (D==0)
     {
         const Double_t r = MMath::Sqrt3(R);
 
-        x1 = 2*r - a/3.;               // real root
-        x2 =   r - a/3.;               // real root
-
+        x1 = r - a/3.;               // real root
+        if (R==0)
+            return 1;
+
+        x2 = 2*r - a/3.;               // real root
         return 2;
     }
Index: trunk/MagicSoft/Mars/mdata/DataLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/DataLinkDef.h	(revision 8072)
+++ trunk/MagicSoft/Mars/mdata/DataLinkDef.h	(revision 8073)
@@ -14,3 +14,5 @@
 #pragma link C++ class MDataFormula+;
 
+#pragma link C++ class MDataPhrase+;
+
 #endif
Index: trunk/MagicSoft/Mars/mdata/MDataList.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataList.cc	(revision 8072)
+++ trunk/MagicSoft/Mars/mdata/MDataList.cc	(revision 8073)
@@ -310,5 +310,5 @@
 //
 // Builds a rule from all the list members. This is a rule which could
-// be used to rebuild the list using the constructor of a MDataChain
+// be used to rebuild the list using the constructor of a MDataPhrase
 //
 TString MDataList::GetRule() const
Index: trunk/MagicSoft/Mars/mdata/MDataMember.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataMember.cc	(revision 8072)
+++ trunk/MagicSoft/Mars/mdata/MDataMember.cc	(revision 8073)
@@ -187,5 +187,5 @@
 // --------------------------------------------------------------------------
 //
-// Builds a rule which cn be used in a MDataChain to describe this object
+// Builds a rule which can be used in a MDataPhrase to describe this object
 //
 TString MDataMember::GetRule() const
Index: trunk/MagicSoft/Mars/mdata/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mdata/Makefile	(revision 8072)
+++ trunk/MagicSoft/Mars/mdata/Makefile	(revision 8073)
@@ -16,4 +16,5 @@
 
 SRCFILES = MData.cc \
+	   MDataPhrase.cc \
 	   MDataArray.cc \
            MDataElement.cc \
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 8072)
+++ 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)));
