Index: trunk/MagicSoft/Mars/mimage/MHHillasExt.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHHillasExt.cc	(revision 8647)
+++ trunk/MagicSoft/Mars/mimage/MHHillasExt.cc	(revision 8657)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 2001 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2007
 !
 !
@@ -28,4 +28,9 @@
 //
 // This class contains histograms for every Hillas parameter
+//
+// Class Version 2:
+// ----------------
+//  - fHMaxDist
+//  + fHSlopeL
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -34,5 +39,4 @@
 #include <math.h>
 
-#include <TH1.h>
 #include <TPad.h>
 #include <TLegend.h>
@@ -47,4 +51,6 @@
 
 #include "MBinning.h"
+
+#include "MHillas.h"
 #include "MHillasExt.h"
 #include "MHillasSrc.h"
@@ -59,5 +65,6 @@
 //
 MHHillasExt::MHHillasExt(const char *name, const char *title)
-    : fMm2Deg(1), fUseMmScale(kTRUE), fHilName("MHillasExt")
+    : fHillas(0), fHillasExt(0), fMm2Deg(1),
+    fUseMmScale(kTRUE), fHilName("MHillasExt")
 {
     //
@@ -75,49 +82,50 @@
     fHM3Long.UseCurrentStyle();
     fHM3Trans.UseCurrentStyle();
-    fHMaxDist.UseCurrentStyle();
+    fHSlopeL.UseCurrentStyle();
 
     fHAsym.SetName("Asymmetry");
     fHM3Long.SetName("M3l");
     fHM3Trans.SetName("M3t");
-    fHMaxDist.SetName("MaxDist");
+    fHSlopeL.SetName("SlopeL");
 
     fHAsym.SetTitle("Asymmetry");
     fHM3Long.SetTitle("3^{rd} Moment Longitudinal");
     fHM3Trans.SetTitle("3^{rd} Moment Transverse");
-    fHMaxDist.SetTitle("Distance of max distant pixel");
+    fHSlopeL.SetTitle("Longitudinal time-slope vs. Dist");
 
     fHAsym.SetXTitle("Asym [mm]");
     fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
     fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
-    fHMaxDist.SetXTitle("D_{max} [mm]");
+    fHSlopeL.SetXTitle("D [mm]");
 
     fHAsym.SetYTitle("Counts");
     fHM3Long.SetYTitle("Counts");
     fHM3Trans.SetYTitle("Counts");
-    fHMaxDist.SetYTitle("Counts");
+    fHSlopeL.SetYTitle("S_{l} [ns/mm]");
 
     fHAsym.SetFillStyle(4000);
     fHM3Long.SetFillStyle(4000);
     fHM3Trans.SetFillStyle(4000);
-    fHMaxDist.SetFillStyle(4000);
+    //fHSlopeL.SetFillStyle(4000);
 
     fHAsym.SetDirectory(NULL);
     fHM3Long.SetDirectory(NULL);
     fHM3Trans.SetDirectory(NULL);
-    fHMaxDist.SetDirectory(NULL);
+    fHSlopeL.SetDirectory(NULL);
 
     fHM3Trans.SetLineColor(kBlue);
 
-    MBinning bins;
-
-    bins.SetEdges(51, -326, 326);
-    bins.Apply(fHM3Long);
-    bins.Apply(fHM3Trans);
-
-    bins.SetEdges(51, -593, 593);
-    bins.Apply(fHAsym);
-
-    bins.SetEdges(100, 0, 593);
-    bins.Apply(fHMaxDist);
+    MBinning binsx, binsy;
+
+    binsx.SetEdges(51, -326, 326);
+    binsx.Apply(fHM3Long);
+    binsx.Apply(fHM3Trans);
+
+    binsx.SetEdges(51, -593, 593);
+    binsx.Apply(fHAsym);
+
+    binsx.SetEdges(100,     0,  445);
+    binsy.SetEdges(100, -0.04, 0.04);
+    MH::SetBinning(&fHSlopeL, &binsx, &binsy);
 }
 
@@ -141,4 +149,11 @@
     }
 
+    fHillas = (MHillas*)plist->FindObject("MHillas");
+    if (!fHillas)
+    {
+        *fLog << err << "MHillas not found in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+
     const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     if (!geom)
@@ -150,8 +165,8 @@
     }
 
-    ApplyBinning(*plist, "Asym",    &fHAsym);
-    ApplyBinning(*plist, "M3Long",  &fHM3Long);
+    ApplyBinning(*plist, "Asym", &fHAsym);
+    ApplyBinning(*plist, "M3Long", &fHM3Long);
     ApplyBinning(*plist, "M3Trans", &fHM3Trans);
-    ApplyBinning(*plist, "MaxDist", &fHMaxDist);
+    ApplyBinning(*plist, "Dist", "Slope", &fHSlopeL);
 
     return kTRUE;
@@ -168,9 +183,10 @@
 
     const Double_t scale = TMath::Sign(fUseMmScale?1:fMm2Deg, (src ? src->GetCosDeltaAlpha() : 1));
+    const Double_t dist  = src ? src->GetDist() : fHillas->GetDist0();
 
     fHAsym.Fill(scale*fHillasExt->GetAsym(), w);
     fHM3Long.Fill(scale*fHillasExt->GetM3Long(), w);
     fHM3Trans.Fill(scale*fHillasExt->GetM3Trans(), w);
-    fHMaxDist.Fill(TMath::Abs(scale*fHillasExt->GetMaxDist()), w);
+    fHSlopeL.Fill(scale*dist, fHillasExt->GetSlopeLong()/scale, w);
 
     return kTRUE;
@@ -197,5 +213,5 @@
     MH::ScaleAxis(&fHM3Long,  scale);
     MH::ScaleAxis(&fHM3Trans, scale);
-    MH::ScaleAxis(&fHMaxDist, scale);
+    MH::ScaleAxis(&fHSlopeL,  scale, 1./scale);
 
     if (mmscale)
@@ -204,5 +220,6 @@
         fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
         fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
-        fHMaxDist.SetXTitle("D_{max} [mm]");
+        fHSlopeL.SetXTitle("D [mm]");
+        fHSlopeL.SetYTitle("S_{l} [ns/mm]");
     }
     else
@@ -211,5 +228,6 @@
         fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
         fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
-        fHMaxDist.SetXTitle("D_{max} [\\circ]");
+        fHSlopeL.SetXTitle("D [\\circ]");
+        fHSlopeL.SetYTitle("S_{l} [ns/\\circ]");
     }
 
@@ -262,15 +280,15 @@
         fHM3Long.SetName("M3lSame");
         fHM3Trans.SetName("M3tSame");
-        fHMaxDist.SetName("MaxDistSame");
+        fHSlopeL.SetName("SlopeLSame");
 
         fHAsym.SetDirectory(0);
         fHM3Long.SetDirectory(0);
         fHM3Trans.SetDirectory(0);
-        fHMaxDist.SetDirectory(0);
+        fHSlopeL.SetDirectory(0);
 
         fHM3Long.SetLineColor(kMagenta);
         fHM3Trans.SetLineColor(kCyan);
         fHAsym.SetLineColor(kBlue);
-        fHMaxDist.SetLineColor(kBlue);
+        fHSlopeL.SetMarkerColor(kBlue);
     }
 
@@ -288,6 +306,23 @@
     pad->cd(2);
     gPad->SetBorderMode(0);
-    RemoveFromPad("MaxDistSame");
-    fHMaxDist.Draw(same?"same":"");
+    //RemoveFromPad("SlopeLSame");
+    //fHSlopeL.Draw(same?"same":"");
+    if (same)
+    {
+        TH2 *h=dynamic_cast<TH2*>(gPad->FindObject("SlopeL"));
+        if (h)
+        {
+            // This causes crashes in THistPainter::PaintTable
+            // if the z-axis is not kept. No idea why...
+            h->SetDrawOption("z");
+            h->SetMarkerColor(kBlack);
+        }
+
+        RemoveFromPad("SlopeLSame");
+        fHSlopeL.SetMarkerColor(kGreen);
+        fHSlopeL.Draw("same");
+    }
+    else
+        fHSlopeL.Draw("colz");
 
     delete pad->GetPad(4);
@@ -302,6 +337,6 @@
     if (name.Contains("M3T", TString::kIgnoreCase))
         return const_cast<TH1F*>(&fHM3Trans);
-    if (name.Contains("MaxDist", TString::kIgnoreCase))
-        return const_cast<TH1F*>(&fHMaxDist);
+    if (name.Contains("SlopeL", TString::kIgnoreCase))
+        return const_cast<TH2F*>(&fHSlopeL);
 
     return NULL;
Index: trunk/MagicSoft/Mars/mimage/MHHillasExt.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHHillasExt.h	(revision 8647)
+++ trunk/MagicSoft/Mars/mimage/MHHillasExt.h	(revision 8657)
@@ -2,6 +2,6 @@
 #define MARS_MHHillasExt
 
-#ifndef ROOT_TH1
-#include <TH1.h>
+#ifndef ROOT_TH2
+#include <TH2.h>
 #endif
 #ifndef MARS_MH
@@ -9,4 +9,5 @@
 #endif
 
+class MHillas;
 class MHillasExt;
 
@@ -14,4 +15,5 @@
 {
 private:
+    MHillas    *fHillas;    //! Pointer to the MHillas container
     MHillasExt *fHillasExt; //! Pointer to the MHillasExt container
 
@@ -19,5 +21,5 @@
     TH1F fHM3Long;  // [mm]    3rd moment (e-weighted) along major axis
     TH1F fHM3Trans; // [mm]    3rd moment (e-weighted) along minor axis
-    TH1F fHMaxDist; // [mm]    Distance between shower center maximum distant pixel
+    TH2F fHSlopeL;  //
 
     Float_t fMm2Deg;
@@ -46,5 +48,5 @@
     void Draw(Option_t *opt=NULL);
 
-    ClassDef(MHHillasExt, 1) // Container which holds histograms for the extended hillas parameters
+    ClassDef(MHHillasExt, 2) // Container which holds histograms for the extended hillas parameters
 };
 
