Index: trunk/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1441)
+++ 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);
