Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5079)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5080)
@@ -25,4 +25,5 @@
    * mhcalib/MHGausEvents.cc
      - added call to gROOT->GetListOfFunctions->Remove(f) in destructor
+
 
 
@@ -87,4 +88,16 @@
    * star.rc:
      - use scaled image cleaning by default
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - fixed some possible crashes
+
+   * mhflux/MAlphaFitter.h:
+     - remove function from global list
+
+   * mhflux/MHFalseSource.cc:
+     - added a 2D Gauss-Fit
+
+   * mimage/MHillasSrc.[h,cc]:
+     - fixed a bug in the output of DCA (wrong units)
 
 
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 5079)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 5080)
@@ -42,4 +42,5 @@
     MAlphaFitter() : fFunc(new TF1("", "gaus(0) + pol1(3)", 0, 90)), fSigInt(10), fSigMax(75), fBgMin(45), fBgMax(85), fPolynomOrder(1), fCoefficients(3+fPolynomOrder+1)
     {
+        gROOT->GetListOfFunctions()->Remove(fFunc);
     }
 
@@ -67,4 +68,5 @@
         TF1 *fcn = f.fFunc;
         f.fFunc = new TF1(*fFunc);
+        gROOT->GetListOfFunctions()->Remove(f.fFunc);
         delete fcn;
     }
@@ -74,5 +76,7 @@
     void SetBackgroundFitMin(Float_t s)    { fBgMin        = s; }
     void SetBackgroundFitMax(Float_t s)    { fBgMax        = s; }
-    void SetPolynomOrder(Int_t s)          { fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s)); fCoefficients.Set(3+s+1); fCoefficients.Reset(); }
+    void SetPolynomOrder(Int_t s)          { fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s));
+        gROOT->GetListOfFunctions()->Remove(fFunc);
+        fCoefficients.Set(3+s+1); fCoefficients.Reset(); }
 
     Double_t GetEventsExcess() const       { return fEventsExcess; }
Index: trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5079)
+++ trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5080)
@@ -115,4 +115,5 @@
 
 #include <TF1.h>
+#include <TF2.h>
 #include <TH2.h>
 #include <TGraph.h>
@@ -729,4 +730,15 @@
     gPad->Modified();
     gPad->cd();
+}
+
+Double_t FcnGauss2d(Double_t *x, Double_t *par)
+{
+    TVector2 v = TVector2(x[0], x[1]).Rotate(par[5]*TMath::DegToRad());
+
+    const Double_t g0 = TMath::Gaus(v.X(), par[1], par[2]);
+    const Double_t g1 = TMath::Gaus(v.Y(), par[3], par[4]);
+
+    //Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE);
+    return par[0]*(g0+g1);
 }
 
@@ -897,4 +909,6 @@
         }
 
+    *fLog << "Done." << endl;
+
     h0a.GetXaxis()->SetRangeUser(0, maxalpha0*1.5);
     h0b.GetXaxis()->SetRangeUser(0, maxalpha0*1.5);
@@ -926,4 +940,28 @@
     hist->Draw("colz");
     hist->SetBit(kCanDelete);
+
+
+    TF2 f2d("", FcnGauss2d, -1.5, 1.5, -1.5, 1.5, 6);
+    f2d.SetParName(0, "Max   sigma");
+    f2d.SetParName(1, "Mean_1  deg");
+    f2d.SetParName(2, "Sigma_1 deg");
+    f2d.SetParName(3, "Mean_2  deg");
+    f2d.SetParName(4, "Sigma_2 deg");
+    f2d.SetParName(5, "Phi     deg");
+    f2d.SetParLimits(1, -1, 1);    // mu_1
+    f2d.SetParLimits(3, -1, 1);    // mu_2
+    f2d.SetParLimits(2, 0, 1);     // sigma_1
+    f2d.SetParLimits(4, 0, 1);     // sigma_2
+    f2d.SetParLimits(5, 0, 90);    // phi
+    f2d.SetParameter(0, maxs); // A
+    f2d.SetParameter(1, 0);    // mu_1
+    f2d.SetParameter(2, 0.2);  // sigma_1
+    f2d.SetParameter(3, 0);    // mu_2
+    f2d.SetParameter(4, 0.2);  // sigma_2
+    f2d.SetParameter(5, 0);    // phi
+    hist->Fit(&f2d, "IN0");
+    //f2d.DrawClone("cont2same")->SetBit(kCanDelete);
+
+
     catalog->Draw("mirror same *");
     c->cd(3);
Index: trunk/MagicSoft/Mars/mimage/MHillasSrc.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasSrc.cc	(revision 5079)
+++ trunk/MagicSoft/Mars/mimage/MHillasSrc.cc	(revision 5080)
@@ -71,4 +71,7 @@
 #include <TArrayF.h>
 
+#include <TLine.h>
+#include <TMarker.h>
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -179,4 +182,32 @@
 }
 
+void MHillasSrc::Paint(Option_t *opt)
+{
+    const Float_t x = fSrcPos ? fSrcPos->GetX() : 0;
+    const Float_t y = fSrcPos ? fSrcPos->GetY() : 0;
+
+    TMarker m;
+    m.SetMarkerColor(kYellow);
+    m.SetMarkerStyle(kStar);
+    m.PaintMarker(x, y);
+/*
+    m.SetMarkerColor(kMagenta);
+    m.PaintMarker(fDist*cos((fDCADelta-fAlpha)*TMath::DegToRad()),
+                  fDist*sin((fDCADelta-fAlpha)*TMath::DegToRad()));
+
+    TLine line;
+    line.SetLineWidth(1);
+    line.SetLineColor(108);
+
+    line.PaintLine(-radius, y, radius, y);
+    line.PaintLine(x, -radius, x, radius);
+  
+    // COG line
+    TLine line(x, y, meanX, meanY);
+    line.SetLineWidth(1);
+    line.SetLineColor(2);
+    line.Paint();*/
+}
+
 // --------------------------------------------------------------------------
 //
@@ -191,5 +222,5 @@
     *fLog << " - CosDeltaAlpha        = " << fCosDeltaAlpha << endl;
     *fLog << " - DCA            [mm]  = " << fDCA << endl;
-    *fLog << " - DCA delta      [deg] = " << fDCADelta*TMath::RadToDeg() << endl;
+    *fLog << " - DCA delta      [deg] = " << fDCADelta << endl;
 }
 
@@ -207,5 +238,5 @@
     *fLog << " - CosDeltaAlpha        = " << fCosDeltaAlpha << endl;
     *fLog << " - DCA            [deg] = " << fDCA*geom.GetConvMm2Deg() << endl;
-    *fLog << " - DCA delta      [deg] = " << fDCADelta*TMath::RadToDeg() << endl;
+    *fLog << " - DCA delta      [deg] = " << fDCADelta << endl;
 }
 
Index: trunk/MagicSoft/Mars/mimage/MHillasSrc.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasSrc.h	(revision 5079)
+++ trunk/MagicSoft/Mars/mimage/MHillasSrc.h	(revision 5080)
@@ -36,4 +36,5 @@
     void Print(Option_t *opt=NULL) const;
     void Print(const MGeomCam &geom) const;
+    void Paint(Option_t *opt=NULL);
 
     virtual Int_t Calc(const MHillas &hillas);
