Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1462)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1463)
@@ -33,4 +33,20 @@
    * manalysis/MImgCleanStd.cc:
      - changed ispixused array size from max to max+1
+
+   * macros/MagicHillas.C:
+     - use the default binning of the histograms
+
+   * mhist/MH.[h,cc]:
+     - changed argument of SetBinning from TArrayD* to TArrayD&
+     - added ScaleArray
+     - added ScaleAxis
+     - proved that ScaleAxis is really working
+     - Added ApplyBinning
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - corrected the default binning
+     - take use of MH::ApplyBinning
+     - don't stop execution if no binning was found (take default)
+     - made sure, that rescaling of the axis is working properly
 
 
Index: trunk/MagicSoft/Mars/macros/MagicHillas.C
===================================================================
--- trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 1462)
+++ trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 1463)
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!   Author(s): Thomas Bretz et al,  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2002
 !
 !
@@ -24,9 +24,10 @@
 
 
-void MagicHillas(const char *filename="~/data/gamma*.root")
+void MagicHillas(const char *filename="~/data/Gamma*.root")
 {
     //
     // This is a demonstration program which calculates the Hillas
-    // parameter out of a Magic root file.
+    // parameter out of a Magic root file (raw data file).
+    //
 
     //
@@ -43,6 +44,8 @@
     // of MHillas
     //
-    //MHillasExt hext;
-    //plist.AddToList(&hext);
+    /*
+     MHillasExt hext;
+     plist.AddToList(&hext);
+     */
 
     //
@@ -54,22 +57,32 @@
 
     //
-    // Setup binning for your histograms.
+    // Use this if you want to change the binning of one of
+    // the histograms
     //
-    MBinning binswidth("BinningWidth");
-    binswidth.SetEdges(100, 0, 1);   // 100 bins from 0 to 1 deg
+    /*
+     MBinning binswidth("BinningWidth");
+     binswidth.SetEdges(100, 0, 0.1);     // 100 bins from 0 to 1 deg
+     plist.AddToList(&binswidth);
 
-    MBinning binslength("BinningLength");
-    binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
+     MBinning binslength("BinningLength");
+     binslength.SetEdges(100, 0, 1);      // 100 bins from 0 to 1 deg
+     plist.AddToList(&binslength);
 
-    MBinning binsalpha("BinningAlpha");
-    binsalpha.SetEdges(90, 0, 90);   // 90 bins from 0 to 90 deg
+     MBinning binsdist("BinningDist");
+     binsdist.SetEdges(100, 0, 1.5);      // 100 bins from 0 to 1 deg
+     plist.AddToList(&binsdist);
 
-    MBinning binsdist("BinningDist");
-    binsdist.SetEdges(100, 0, 2);    // 100 bins from 0 to 2 deg
+     MBinning binsht("BinningHeadTail");
+     binsht.SetEdges(100, -1.5, 1.5);     // 100 bins from 0 to 1 deg
+     plist.AddToList(&binsht);
 
-    plist.AddToList(&binswidth);
-    plist.AddToList(&binslength);
-    plist.AddToList(&binsalpha);
-    plist.AddToList(&binsdist);
+     MBinning binsalpha("BinningAlpha");
+     binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
+     plist.AddToList(&binsalpha);
+
+     MBinning binscam("BinningCamera");
+     binscam.SetEdges(50, -1.5, 1.5);     //  20 bins from -2 to 2 deg
+     plist.AddToList(&binscam);
+    */
 
     //
@@ -101,12 +114,15 @@
     MMcPedestalCopy   pcopy;
     MMcPedestalNSBAdd pnsb;
+
     MCerPhotCalc      ncalc;
-
-//  Alternative photon calculation:
-//    MCerPhotCalc2     ncalc;
-//  Example: use only 2nd to 6th FADC slices for photon calculation:
-//    const Float_t x[15]={0., 1., 1., 1., 1., 1., 0.,0.,0.,0.,0.,0.,0.,0.,0.};
-//    TArrayF w(15,x);
-//    ncalc.SetWeights(w);
+    //
+    //  Alternative photon calculation:
+    //  Example: use only 2nd to 6th FADC slices for photon calculation:
+    //
+    //    MCerPhotCalc2 ncalc;
+    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    //    TArrayF w(15,x);
+    //    ncalc.SetWeights(w);
+    //
 
     MImgCleanStd      clean;
@@ -121,12 +137,12 @@
     MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
 
+    MWriteRootFile write("hillas.root");
+    write.AddContainer("MHillas",       "Hillas");
+    write.AddContainer("HillasSource",  "Hillas");
+    write.AddContainer("HillasAntiSrc", "Hillas");
+    write.AddContainer("MHStarMap");
+    write.AddContainer("MMcEvt","Hillas");
+
     /*
-     MWriteRootFile write("hillas.root");
-     write.AddContainer("MHillas",       "Hillas");
-     write.AddContainer("HillasSource",  "Hillas");
-     write.AddContainer("HillasAntiSrc", "Hillas");
-     write.AddContainer("MMcEvt",        "Hillas");
-     write.AddContainer("MHStarMap");
-
      MWriteAsciiFile write("hillas.txt");
      write.AddColumn("MHillas.fLength*MGeomCam.fConvMm2Deg");
@@ -143,4 +159,5 @@
     tlist.AddToList(&hcalc);
     tlist.AddToList(&csrc1);
+
     tlist.AddToList(&csrc2);
     tlist.AddToList(&hfill);
@@ -148,4 +165,5 @@
     tlist.AddToList(&hfill2s);
     tlist.AddToList(&hfill2a);
+    tlist.AddToList(&write);
 
     //
@@ -165,8 +183,9 @@
     //
     // After the analysis is finished we can display the histograms
-
+    //
+    plist.FindObject("HistSource")->DrawClone();
     plist.FindObject("MHHillas")->DrawClone();
-    plist.FindObject("HistSource")->DrawClone();
     plist.FindObject("HistAntiSrc")->DrawClone();
     plist.FindObject("MHStarMap")->DrawClone();
 }
+
Index: trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1462)
+++ trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1463)
@@ -56,4 +56,8 @@
 
 #include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MParContainer.h"
 
 #include "MBinning.h"
@@ -228,28 +232,28 @@
 }
 
-void MH::SetBinning(TH1 *h, const TArrayD *binsx)
+void MH::SetBinning(TH1 *h, const TArrayD &binsx)
 {
     MBinning bx;
-    bx.SetEdges(*binsx);
+    bx.SetEdges(binsx);
     SetBinning(h, &bx);
 }
 
-void MH::SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy)
+void MH::SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy)
 {
     MBinning bx;
     MBinning by;
-    bx.SetEdges(*binsx);
-    by.SetEdges(*binsy);
+    bx.SetEdges(binsx);
+    by.SetEdges(binsy);
     SetBinning(h, &bx, &by);
 }
 
-void MH::SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)
+void MH::SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz)
 {
     MBinning bx;
     MBinning by;
     MBinning bz;
-    bx.SetEdges(*binsx);
-    by.SetEdges(*binsy);
-    bz.SetEdges(*binsz);
+    bx.SetEdges(binsx);
+    by.SetEdges(binsy);
+    bz.SetEdges(binsz);
     SetBinning(h, &bx, &by, &bz);
 }
@@ -263,5 +267,5 @@
     bx[nx] = binsx->GetXmax();
 
-    SetBinning(h, &bx);
+    SetBinning(h, bx);
 }
 
@@ -278,5 +282,5 @@
     by[ny] = binsy->GetXmax();
 
-    SetBinning(h, &bx, &by);
+    SetBinning(h, bx, by);
 }
 
@@ -297,5 +301,5 @@
     bz[nz] = binsz->GetXmax();
 
-    SetBinning(h, &bx, &by, &bz);
+    SetBinning(h, bx, by, bz);
 }
 
@@ -319,5 +323,5 @@
 }
 
-void MH::ScaleAxis(TArrayD &bins, Double_t f)
+void MH::ScaleArray(TArrayD &bins, Double_t f)
 {
     for (int i=0; i<bins.GetSize(); i++)
@@ -325,14 +329,50 @@
 }
 
+TArrayD MH::ScaleAxis(TAxis &axe, Double_t f)
+{
+    TArrayD arr(axe.GetNbins()+1);
+
+    for (int i=1; i<=axe.GetNbins()+1; i++)
+        arr[i-1] = axe.GetBinLowEdge(i);
+
+    ScaleArray(arr, f);
+
+    return arr;
+}
+
 void MH::ScaleAxis(TH1 *h, Double_t fx, Double_t fy, Double_t fz)
 {
     if (h->InheritsFrom(TH3::Class()))
-        ScaleAxis(*((TH3*)h)->GetZaxis()->GetXbins(), fz);
+    {
+        SetBinning((TH3*)h,
+                   ScaleAxis(*h->GetXaxis(), fx),
+                   ScaleAxis(*h->GetYaxis(), fy),
+                   ScaleAxis(*h->GetZaxis(), fz));
+        return;
+    }
 
     if (h->InheritsFrom(TH2::Class()))
-        ScaleAxis(*((TH2*)h)->GetYaxis()->GetXbins(), fy);
+    {
+        SetBinning((TH2*)h,
+                   ScaleAxis(*h->GetXaxis(), fx),
+                   ScaleAxis(*h->GetYaxis(), fy));
+        return;
+    }
 
     if (h->InheritsFrom(TH1::Class()))
-        ScaleAxis(*h->GetXaxis()->GetXbins(), fx);
+        SetBinning(h, ScaleAxis(*h->GetXaxis(), fx));
+}
+
+Bool_t MH::ApplyBinning(const MParList &plist, TString name, TH1 *h)
+{
+    const MBinning *bins = (MBinning*)plist.FindObject("Binning"+name);
+    if (!bins)
+    {
+        gLog << warn << "Object 'Binning" << name << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(h, bins);
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mhist/MH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MH.h	(revision 1462)
+++ trunk/MagicSoft/Mars/mhist/MH.h	(revision 1463)
@@ -34,7 +34,7 @@
     static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
 
-    static void SetBinning(TH1 *h, const TArrayD *binsx);
-    static void SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy);
-    static void SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);
+    static void SetBinning(TH1 *h, const TArrayD &binsx);
+    static void SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy);
+    static void SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz);
 
     static void SetBinning(TH1 *h, const TAxis *binsx);
@@ -44,6 +44,9 @@
     static void SetBinning(TH1 *h, TH1 *x);
 
-    static void ScaleAxis(TArrayD &bins, Double_t f);
-    static void ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
+    static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h);
+
+    static void    ScaleArray(TArrayD &bins, Double_t f);
+    static TArrayD ScaleAxis(TAxis &axe, Double_t f);
+    static void    ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
 
     static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
Index: trunk/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1462)
+++ trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1463)
@@ -59,5 +59,5 @@
 //
 MHHillas::MHHillas(const char *name, const char *title)
-    : fMm2Deg(1), fUseMmScale(kFALSE)
+    : fMm2Deg(1), fUseMmScale(kTRUE)
 {
     //
@@ -67,22 +67,22 @@
     fTitle = title ? title : "Source independent image parameters";
 
-    fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300);
+    fLength = new TH1F("Length", "Length of Ellipse",               100,   0, 296.7);
+    fWidth  = new TH1F("Width",  "Width of Ellipse",                100,   0, 296.7);
+    fDistC  = new TH1F("DistC",  "Distance from center of camera",  100,   0, 445);
+    fDelta  = new TH1F("Delta",  "Angle (Main axis - x-axis)",      101, -90,  90);
+
     fLength->SetDirectory(NULL);
+    fWidth->SetDirectory(NULL);
+    fDistC->SetDirectory(NULL);
+    fDelta->SetDirectory(NULL);
+
     fLength->SetXTitle("Length [mm]");
+    fWidth->SetXTitle("Width [mm]");
+    fDistC->SetXTitle("Distance [mm]");
+    fDelta->SetXTitle("Delta [\\circ]");
+
     fLength->SetYTitle("Counts");
-
-    fWidth  = new TH1F("Width",  "Width of Ellipse",  100, 0, 300);
-    fWidth->SetDirectory(NULL);
-    fWidth->SetXTitle("Width [mm]");
     fWidth->SetYTitle("Counts");
-
-    fDistC  = new TH1F("DistC",  "Distance from center of camera",  100, 0, 600);
-    fDistC->SetDirectory(NULL);
-    fDistC->SetXTitle("Distance [mm]");
     fDistC->SetYTitle("Counts");
-
-    fDelta  = new TH1F("Delta",  "Angle (Main axis - x-axis)", 100, -90, 90);
-    fDelta->SetDirectory(NULL);
-    fDelta->SetXTitle("Delta [\\circ]");
     fDelta->SetYTitle("Counts");
 
@@ -101,5 +101,5 @@
     MH::SetBinning(fSize, &bins);
 
-    fCenter = new TH2F("Center", "Center of Ellipse", 60, -600, 600, 60, -600, 600);
+    fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445);
     fCenter->SetDirectory(NULL);
     fCenter->SetXTitle("x [mm]");
@@ -136,35 +136,19 @@
 Bool_t MHHillas::SetupFill(const MParList *plist)
 {
-    const MBinning *binsw = (MBinning*)plist->FindObject("BinningWidth");
-    const MBinning *binsl = (MBinning*)plist->FindObject("BinningLength");
-    const MBinning *binsd = (MBinning*)plist->FindObject("BinningDist");
-    const MBinning *binsc = (MBinning*)plist->FindObject("BinningCamera");
-
-    if (!binsw || !binsl || !binsd || !binsc)
-    {
-        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    SetBinning(fWidth,  binsw);
-    SetBinning(fLength, binsl);
-    SetBinning(fDistC,  binsd);
-    SetBinning(fCenter, binsc, binsc);
-
     const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     if (!geom)
-    {
         *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
-        return kTRUE;
-    }
-
-    fMm2Deg     = geom->GetConvMm2Deg();
-    fUseMmScale = kFALSE;
-
-    fLength->SetXTitle("Length [\\circ]");
-    fWidth->SetXTitle("Width [\\circ]");
-    fDistC->SetXTitle("Distance [\\circ]");
-    fCenter->SetXTitle("x [\\circ]");
-    fCenter->SetYTitle("y [\\circ]");
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Width",  fWidth);
+    ApplyBinning(*plist, "Length", fLength);
+    ApplyBinning(*plist, "Dist",   fDistC);
+    ApplyBinning(*plist, "Camera", fCenter);
+    ApplyBinning(*plist, "Delta",  fDelta);
+    ApplyBinning(*plist, "Size",   fSize);
 
     return kTRUE;
@@ -208,13 +192,15 @@
     }
 
-    if (fUseMmScale)
-    {
-        MH::ScaleAxis(fLength, 1./fMm2Deg);
-        MH::ScaleAxis(fWidth,  1./fMm2Deg);
-        MH::ScaleAxis(fDistC,  1./fMm2Deg);
-        MH::ScaleAxis(fCenter, 1./fMm2Deg, 1./fMm2Deg);
-
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(fLength, scale);
+    MH::ScaleAxis(fWidth,  scale);
+    MH::ScaleAxis(fDistC,  scale);
+    MH::ScaleAxis(fCenter, scale, scale);
+
+    if (mmscale)
+    {
         fLength->SetXTitle("Length [mm]");
         fWidth->SetXTitle("Width [mm]");
+        fDistC->SetXTitle("Distance [mm]");
         fCenter->SetXTitle("x [mm]");
         fCenter->SetYTitle("y [mm]");
@@ -222,9 +208,4 @@
     else
     {
-        MH::ScaleAxis(fLength, fMm2Deg);
-        MH::ScaleAxis(fWidth,  fMm2Deg);
-        MH::ScaleAxis(fDistC,  fMm2Deg);
-        MH::ScaleAxis(fCenter, fMm2Deg, fMm2Deg);
-
         fLength->SetXTitle("Length [\\circ]");
         fWidth->SetXTitle("Width [\\circ]");
@@ -247,22 +228,12 @@
 
     const Double_t d = sqrt(h.GetMeanX()*h.GetMeanX() + h.GetMeanY()*h.GetMeanY());
-
-    if (fUseMmScale)
-    {
-        fLength->Fill(h.GetLength());
-        fWidth ->Fill(h.GetWidth());
-        fDistC ->Fill(d);
-        fCenter->Fill(h.GetMeanX(), h.GetMeanY());
-    }
-    else
-    {
-        fLength->Fill(fMm2Deg*h.GetLength());
-        fWidth ->Fill(fMm2Deg*h.GetWidth());
-        fDistC ->Fill(fMm2Deg*d);
-        fCenter->Fill(fMm2Deg*h.GetMeanX(), fMm2Deg*h.GetMeanY());
-    }
-
-    fDelta->Fill(kRad2Deg*h.GetDelta());
-    fSize->Fill(h.GetSize());
+    const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
+
+    fLength->Fill(scale*h.GetLength());
+    fWidth ->Fill(scale*h.GetWidth());
+    fDistC ->Fill(scale*d);
+    fCenter->Fill(scale*h.GetMeanX(), scale*h.GetMeanY());
+    fDelta ->Fill(kRad2Deg*h.GetDelta());
+    fSize  ->Fill(h.GetSize());
 
     return kTRUE;
@@ -275,4 +246,5 @@
 void MHHillas::SetColors() const
 {
+    // FIXME: This must be redone each time the canvas is repainted....
     gStyle->SetPalette(51, NULL);
     Int_t c[50];
@@ -292,5 +264,5 @@
 TObject *MHHillas::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("Hillas", fTitle, 700, 750);
+    TCanvas *c = MakeDefCanvas("Hillas", fTitle, 720, 810);
     c->Divide(2,3);
 
@@ -332,5 +304,5 @@
 {
     if (!gPad)
-        MakeDefCanvas("Hillas", fTitle, 700, 750);
+        MakeDefCanvas("Hillas", fTitle, 720, 810);
 
     gPad->Divide(2,3);
Index: trunk/MagicSoft/Mars/mhist/MHHillas.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillas.h	(revision 1462)
+++ trunk/MagicSoft/Mars/mhist/MHHillas.h	(revision 1463)
@@ -14,12 +14,12 @@
 private:
 
-    TH1F *fLength;
-    TH1F *fWidth;
+    TH1F *fLength; //->
+    TH1F *fWidth;  //->
 
-    TH1F *fDistC;
-    TH1F *fDelta;
+    TH1F *fDistC;  //->
+    TH1F *fDelta;  //->
 
-    TH1F *fSize;
-    TH2F *fCenter;
+    TH1F *fSize;   //->
+    TH2F *fCenter; //->
 
     void SetColors() const;
Index: trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1462)
+++ trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1463)
@@ -68,8 +68,8 @@
     // connect all the histogram with the container fHist
     //
-    fAlpha    = new TH1F("Alpha",    "Alpha of Ellipse",             90,  0,  90);
-    fDist     = new TH1F("Dist",     "Dist of Ellipse",             100,  0, 600);
-    fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse",          45,  0,  90);
-    fCosDA    = new TH1F("CosDA",    "cos(Delta,Alpha) of Ellipse", 100, -1,   1);
+    fAlpha    = new TH1F("Alpha",    "Alpha of Ellipse",             90,    0,  90);
+    fDist     = new TH1F("Dist",     "Dist of Ellipse",             100,    0, 445);
+    fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse",         101, -445, 445);
+    fCosDA    = new TH1F("CosDA",    "cos(Delta,Alpha) of Ellipse", 101,   -1,   1);
 
     fAlpha->SetDirectory(NULL);
@@ -80,5 +80,5 @@
     fAlpha->SetXTitle("\\alpha [\\circ]");
     fDist->SetXTitle("Dist [mm]");
-    fHeadTail->SetXTitle("Head-Tail [\\circ]");
+    fHeadTail->SetXTitle("Head-Tail [mm]");
     fCosDA->SetXTitle("cos(\\delta,\\alpha) [mm]");
 
@@ -113,26 +113,16 @@
 Bool_t MHHillasSrc::SetupFill(const MParList *plist)
 {
-    const MBinning* binsa = (MBinning*)plist->FindObject("BinningAlpha");
-    const MBinning* binsd = (MBinning*)plist->FindObject("BinningDist");
-    if (!binsa || !binsd)
-    {
-        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    SetBinning(fAlpha, binsa);
-    SetBinning(fDist,  binsd);
-
     const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     if (!geom)
-    {
         *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
-        return kTRUE;
-    }
-
-    fDist->SetXTitle("Dist [\\circ]");
-
-    fMm2Deg = geom->GetConvMm2Deg();
-    fUseMmScale = kFALSE;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Alpha",    fAlpha);
+    ApplyBinning(*plist, "Dist",     fDist);
+    ApplyBinning(*plist, "HeadTail", fHeadTail);
 
     return kTRUE;
@@ -150,8 +140,63 @@
     fAlpha   ->Fill(fabs(h.GetAlpha()));
     fDist    ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist());
-    fHeadTail->Fill(h.GetHeadTail());
+    fHeadTail->Fill(fUseMmScale ? h.GetHeadTail() : fMm2Deg*h.GetHeadTail());
     fCosDA   ->Fill(h.GetCosDeltaAlpha());
 
     return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillasSrc::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(fDist,     scale);
+    MH::ScaleAxis(fHeadTail, scale);
+
+    if (mmscale)
+    {
+        fDist->SetXTitle("Dist [mm]");
+        fHeadTail->SetXTitle("Head-Tail [mm]");
+    }
+    else
+    {
+        fDist->SetXTitle("Dist [\\circ]");
+        fHeadTail->SetXTitle("Head-Tail [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
 }
 
@@ -187,4 +232,5 @@
 
     c->cd(4);
+    gPad->SetLogy();
     fCosDA->DrawCopy();
 
@@ -221,4 +267,5 @@
 
     gPad->cd(2);
+    gPad->SetLogy();
     fCosDA->Draw();
 
Index: trunk/MagicSoft/Mars/mhist/MHHillasSrc.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillasSrc.h	(revision 1462)
+++ trunk/MagicSoft/Mars/mhist/MHHillasSrc.h	(revision 1463)
@@ -12,8 +12,8 @@
 {
 private:
-    TH1F *fAlpha;
-    TH1F *fDist;
-    TH1F *fHeadTail;     
-    TH1F *fCosDA;
+    TH1F *fAlpha;     //->
+    TH1F *fDist;      //->
+    TH1F *fHeadTail;  //->   
+    TH1F *fCosDA;     //->
 
     Float_t fMm2Deg;
@@ -24,5 +24,6 @@
     ~MHHillasSrc();
 
-    void SetUseMmScale(Bool_t mmscale=kTRUE) { fUseMmScale = mmscale; }
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    void SetMm2Deg(Float_t mmdeg);
 
     Bool_t SetupFill(const MParList *pList);
