Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8656)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8657)
@@ -18,4 +18,34 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2007/08/06 Thomas Bretz
+
+   * mcalib/CalibLinkDef.h, mcalib/Makefile:
+     - removed obsolete MMcCalibrationCalc
+
+   * mhbase/MH.[h,cc]:
+     - adde ApplyBinning member functions for two- and three-dim hists
+
+   * mimage/MHHillasExt.[h,cc]:
+     - removed plot for max dist
+     - added plot for SlopeL
+     - increased class version number
+
+   * mjobs/MJCut.cc:
+     - added BinningSlope to list of binnings
+     - added BinningM3Trans to list of binnings
+     - added BinningM3Asym to list of binnings
+     - removed BinningMaxDist from list of binnings
+
+   * mjtrain/MJTrainDisp.cc:
+     - renamed TrainDist to Train 
+
+   * mpointing/MHSrcPosCam.cc:
+     - changed default palette from glow1 to pretty
+
+   * mpointing/MSrcPosCam.h:
+     - added a function to return the distance to the camera center
+
+
 
  2007/08/02 Thomas Bretz
Index: /trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 8656)
+++ /trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 8657)
@@ -39,5 +39,3 @@
 #pragma link C++ class MCalibrationChargePINDiode+;
 
-#pragma link C++ class MMcCalibrationCalc+;
-
 #endif
Index: /trunk/MagicSoft/Mars/mcalib/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/Makefile	(revision 8656)
+++ /trunk/MagicSoft/Mars/mcalib/Makefile	(revision 8657)
@@ -59,6 +59,5 @@
            MCalibrationBlindCamTwoNewStyle.cc  \
            MCalibrationBlindCamThreeNewStyle.cc  \
-           MCalibrationChargePINDiode.cc  \
-	   MMcCalibrationCalc.cc 
+           MCalibrationChargePINDiode.cc
 
 ############################################################
Index: /trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 8656)
+++ /trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 8657)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.32 2007-01-10 12:58:25 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.33 2007-08-06 14:44:13 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -619,4 +619,64 @@
 }
 
+Bool_t MH::ApplyBinning(const MParList &plist, TString x, TString y, TH2 *h)
+{
+    const MBinning *binsx = (MBinning*)plist.FindObject("Binning"+x);
+    if (!binsx)
+    {
+        gLog << inf << "Object 'Binning" << x << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+    const MBinning *binsy = (MBinning*)plist.FindObject("Binning"+y);
+    if (!binsy)
+    {
+        gLog << inf << "Object 'Binning" << y << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    if (binsx->IsDefault() && binsy->IsDefault())
+        return kTRUE;
+
+    // -------------------------
+    /*
+     MBinning binsx, binsy, binsz;
+     binsx.SetEdges(fHist, 'x');
+     binsy.SetEdges(fHist, 'y');
+     binsz.SetEdges(fHist, 'z');
+     */
+    // -------------------------
+
+    SetBinning(h, binsx, binsy);
+
+    return kTRUE;
+}
+
+Bool_t MH::ApplyBinning(const MParList &plist, TString x, TString y, TString z, TH3 *h)
+{
+    const MBinning *binsx = (MBinning*)plist.FindObject("Binning"+x);
+    if (!binsx)
+    {
+        gLog << inf << "Object 'Binning" << x << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+    const MBinning *binsy = (MBinning*)plist.FindObject("Binning"+y);
+    if (!binsy)
+    {
+        gLog << inf << "Object 'Binning" << y << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+    const MBinning *binsz = (MBinning*)plist.FindObject("Binning"+z);
+    if (!binsz)
+    {
+        gLog << inf << "Object 'Binning" << z << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    if (binsx->IsDefault() && binsy->IsDefault() && binsz->IsDefault())
+        return kTRUE;
+
+    SetBinning(h, binsx, binsy, binsz);
+    return kTRUE;
+}
+
 void MH::FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger)
 {
Index: /trunk/MagicSoft/Mars/mhbase/MH.h
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH.h	(revision 8656)
+++ /trunk/MagicSoft/Mars/mhbase/MH.h	(revision 8657)
@@ -80,5 +80,7 @@
     static void RemoveFirstBin(TH1 &h);
 
-    static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h);
+    static Bool_t ApplyBinning(const MParList &plist, TString x, TH1 *h);
+    static Bool_t ApplyBinning(const MParList &plist, TString x, TString y, TH2 *h);
+    static Bool_t ApplyBinning(const MParList &plist, TString x, TString y, TString z, TH3 *h);
 
     static void    ScaleArray(TArrayD &bins, Double_t f);
Index: /trunk/MagicSoft/Mars/mimage/MHHillasExt.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillasExt.cc	(revision 8656)
+++ /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 8656)
+++ /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
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8656)
+++ /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 8657)
@@ -618,7 +618,9 @@
     MBinning bins6("BinningLength");
     MBinning bins7("BinningDist");
-    MBinning bins8("BinningMaxDist");
+    MBinning bins8("BinningSlope");
     MBinning bins9("BinningM3Long");
-    MBinning bins0("BinningConc1");
+    MBinning bins0("BinningM3Trans");
+    MBinning binsa("BinningAsym");
+    MBinning binsb("BinningConc1");
     plist.AddToList(&bins1);
     plist.AddToList(&bins2);
@@ -631,4 +633,6 @@
     plist.AddToList(&bins9);
     plist.AddToList(&bins0);
+    plist.AddToList(&binsa);
+    plist.AddToList(&binsb);
     //plist.AddToList(&binsT);
 
Index: /trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc	(revision 8656)
+++ /trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc	(revision 8657)
@@ -189,5 +189,5 @@
 // Run Disp optimization
 //
-Bool_t MJTrainDisp::TrainDisp(const char *out, const MDataSet &set, Int_t num)
+Bool_t MJTrainDisp::Train(const char *out, const MDataSet &set, Int_t num)
 {
     SetTitle(Form("TrainDisp: %s", out));
Index: /trunk/MagicSoft/Mars/mpointing/MHSrcPosCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MHSrcPosCam.cc	(revision 8656)
+++ /trunk/MagicSoft/Mars/mpointing/MHSrcPosCam.cc	(revision 8657)
@@ -167,5 +167,5 @@
 void MHSrcPosCam::Paint(Option_t *)
 {
-    MH::SetPalette("glow1", 99);
+    MH::SetPalette("pretty", 99);
 }
 
Index: /trunk/MagicSoft/Mars/mpointing/MSrcPosCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MSrcPosCam.h	(revision 8656)
+++ /trunk/MagicSoft/Mars/mpointing/MSrcPosCam.h	(revision 8657)
@@ -27,4 +27,6 @@
     void Add(const TVector2 &v);
 
+    Float_t GetDist() const { return TMath::Hypot(fX, fY); }
+
     Float_t GetX() const             { return fX; }
     Float_t GetY() const             { return fY; }
