Index: trunk/MagicSoft/Mars/mbase/MMath.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 7898)
+++ trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 7899)
@@ -163,9 +163,12 @@
 // ------------------------------------------------------------------------
 //
-// Return the median value of the distribution of abs(a[i]-Median)
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
 //
 template <class Size, class Element>
-Double_t MMath::MedianDevImp(Size n, const Element *a)
-{
+Double_t MMath::MedianDevImp(Size n, const Element *a, Double_t &med)
+{
+    static const Double_t prob = 0.682689477208650697; //MMath::.GaissProb(1.0);
+
     // Sanity check
     if (n <= 0 || !a)
@@ -173,5 +176,5 @@
 
     // Get median of distribution
-    const Double_t med = TMath::Median(n, a);
+    med = TMath::Median(n, a);
 
     // Create the abs(a[i]-med) distribution
@@ -188,5 +191,5 @@
 
     // Define where to divide
-    const Int_t div = TMath::Nint(n*MMath::GaussProb(1.0));
+    const Int_t div = TMath::Nint(n*prob);
 
     // Calculate result
@@ -203,55 +206,68 @@
 // ------------------------------------------------------------------------
 //
-// Return the median value of the distribution of abs(a[i]-Median)
-//
-Double_t MMath::MedianDev(Long64_t n, const Short_t *a)
-{
-    return MedianDevImp(n, a);
-}
-
-// ------------------------------------------------------------------------
-//
-// Return the median value of the distribution of abs(a[i]-Median)
-//
-Double_t MMath::MedianDev(Long64_t n, const Int_t *a)
-{
-    return MedianDevImp(n, a);
-}
-
-// ------------------------------------------------------------------------
-//
-// Return the median value of the distribution of abs(a[i]-Median)
-//
-Double_t MMath::MedianDev(Long64_t n, const Float_t *a)
-{
-    return MedianDevImp(n, a);
-}
-
-// ------------------------------------------------------------------------
-//
-// Return the median value of the distribution of abs(a[i]-Median)
-//
-Double_t MMath::MedianDev(Long64_t n, const Double_t *a)
-{
-    return MedianDevImp(n, a);
-}
-
-// ------------------------------------------------------------------------
-//
-// Return the median value of the distribution of abs(a[i]-Median)
-//
-Double_t MMath::MedianDev(Long64_t n, const Long_t *a)
-{
-    return MedianDevImp(n, a);
-}
-
-// ------------------------------------------------------------------------
-//
-// Return the median value of the distribution of abs(a[i]-Median)
-//
-Double_t MMath::MedianDev(Long64_t n, const Long64_t *a)
-{
-    return MedianDevImp(n, a);
-}
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
+//
+Double_t MMath::MedianDev(Long64_t n, const Short_t *a, Double_t &med)
+{
+    return MedianDevImp(n, a, med);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
+//
+Double_t MMath::MedianDev(Long64_t n, const Int_t *a, Double_t &med)
+{
+    return MedianDevImp(n, a, med);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
+//
+Double_t MMath::MedianDev(Long64_t n, const Float_t *a, Double_t &med)
+{
+    return MedianDevImp(n, a, med);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
+//
+Double_t MMath::MedianDev(Long64_t n, const Double_t *a, Double_t &med)
+{
+    return MedianDevImp(n, a, med);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
+//
+Double_t MMath::MedianDev(Long64_t n, const Long_t *a, Double_t &med)
+{
+    return MedianDevImp(n, a, med);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the "median" (at 68.3%) value of the distribution of
+// abs(a[i]-Median)
+//
+Double_t MMath::MedianDev(Long64_t n, const Long64_t *a, Double_t &med)
+{
+    return MedianDevImp(n, a, med);
+}
+
+Double_t MMath::MedianDev(Long64_t n, const Short_t  *a) { Double_t med; return MedianDevImp(n, a, med); }
+Double_t MMath::MedianDev(Long64_t n, const Int_t    *a) { Double_t med; return MedianDevImp(n, a, med); }
+Double_t MMath::MedianDev(Long64_t n, const Float_t  *a) { Double_t med; return MedianDevImp(n, a, med); }
+Double_t MMath::MedianDev(Long64_t n, const Double_t *a) { Double_t med; return MedianDevImp(n, a, med); }
+Double_t MMath::MedianDev(Long64_t n, const Long_t   *a) { Double_t med; return MedianDevImp(n, a, med); }
+Double_t MMath::MedianDev(Long64_t n, const Long64_t *a) { Double_t med; return MedianDevImp(n, a, med); }
 
 // --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mbase/MMath.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MMath.h	(revision 7898)
+++ trunk/MagicSoft/Mars/mbase/MMath.h	(revision 7899)
@@ -19,5 +19,12 @@
     Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0);
 
-    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a);
+    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a) { Double_t med; return MedianDevImp(n, a, med); }
+    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a, Double_t &med);
+    Double_t  MedianDev(Long64_t n, const Short_t  *a, Double_t &med);
+    Double_t  MedianDev(Long64_t n, const Int_t    *a, Double_t &med);
+    Double_t  MedianDev(Long64_t n, const Float_t  *a, Double_t &med);
+    Double_t  MedianDev(Long64_t n, const Double_t *a, Double_t &med);
+    Double_t  MedianDev(Long64_t n, const Long_t   *a, Double_t &med);
+    Double_t  MedianDev(Long64_t n, const Long64_t *a, Double_t &med);
     Double_t  MedianDev(Long64_t n, const Short_t  *a);
     Double_t  MedianDev(Long64_t n, const Int_t    *a);
Index: trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc	(revision 7898)
+++ trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc	(revision 7899)
@@ -350,8 +350,8 @@
 {
     TH2D *hyx=0;
-    if (!(hyx=(TH2D*)gPad->FindObject(MString::Form("%s_%s", h.GetName(), how))))
+    if (!(hyx=(TH2D*)gPad->FindObject(MString::Format("%s_%s", h.GetName(), how))))
         return;
 
-    TH2D *h2 = (TH2D*)h.Project3D(MString::Form("dum_%s", how));
+    TH2D *h2 = (TH2D*)h.Project3D(MString::Format("dum_%s", how));
     hyx->Reset();
     hyx->Add(h2);
@@ -359,5 +359,5 @@
 
     TH1D *hx = 0;
-    if ((hx=(TH1D*)gPad->FindObject(Form("Prof%s", h.GetName()))))
+    if ((hx=(TH1D*)gPad->FindObject(MString::Format("Prof%s", h.GetName()))))
     {
         hx = hyx->ProfileX(Form("Prof%s", h.GetName()), -1, 9999, "s");
