Index: trunk/MagicSoft/Mars/mimage/MHillasExt.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasExt.cc	(revision 3666)
+++ trunk/MagicSoft/Mars/mimage/MHillasExt.cc	(revision 3682)
@@ -16,9 +16,9 @@
 !
 !
-!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
 !   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -101,5 +101,5 @@
     fM3Trans =  0;
 
-    fMaxDist = -1;
+    fMaxDist =  0;
 }
 
@@ -170,12 +170,12 @@
         const Double_t dy = gpix.GetY() - hil.GetMeanY();      // [mm]
 
-        const Double_t dist = dx*dx+dy*dy;
-        if (dist>maxdist)
-            maxdist=dist;                                      // [mm^2]
-
         Double_t nphot = pix.GetNumPhotons();                  // [1]
 
         const Double_t dzx =  hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
         const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
+
+        const Double_t dist = dx*dx+dy*dy;
+        if (TMath::Abs(dist)>TMath::Abs(maxdist))
+            maxdist = dzx<0 ? -dist : dist;                    // [mm^2]
 
         m3x += nphot * dzx*dzx*dzx;                            // [mm^3]
@@ -210,5 +210,6 @@
     fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3);      // [mm]
 
-    fMaxDist = TMath::Sqrt(maxdist);                           // [mm]
+    const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
+    fMaxDist = maxdist<0 ? -md : md;                           // [mm]
 
     SetReadyToSave();
@@ -224,9 +225,10 @@
 void MHillasExt::Set(const TArrayF &arr)
 {
-    if (arr.GetSize() != 3)
+    if (arr.GetSize() != 4)
         return;
 
-    fAsym    = arr.At(0); // [mm] fDist minus dist: center of ellipse, highest pixel
-    fM3Long  = arr.At(1); // [mm] 3rd moment (e-weighted) along major axis
-    fM3Trans = arr.At(2); // [mm] 3rd moment (e-weighted) along minor axis
-}
+    fAsym    = arr.At(0);
+    fM3Long  = arr.At(1);
+    fM3Trans = arr.At(2);
+    fMaxDist = arr.At(3);
+}
