Index: trunk/MagicSoft/Mars/mhist/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 3568)
+++ trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 3574)
@@ -625,148 +625,4 @@
     gPad->cd();
 }
-/*
-Double_t fcn(Double_t *arg, Double_t *p)
-{
-    const Double_t x = arg[0];
-
-    const Double_t dx = (x-p[1])/p[2];
-
-    const Double_t f1 = p[0]*TMath::Exp(-0.5*dx*dx);
-    const Double_t f2 = p[3] + p[5]*x*x;
-
-    return f1 + f2;
-}
-
-Double_t FcnI1(Double_t x, Double_t *p)
-{
-    return (p[5]*x*x/3+p[3])*x;
-}
-Double_t FcnI2(Double_t x, Double_t *p)
-{
-    static const Double_t sqrt2   = TMath::Sqrt(2.);
-    static const Double_t sqrt2pi = TMath::Sqrt(TMath::TwoPi());
-
-    const Double_t dx = (x-p[1])/p[2];
-
-    const Double_t f2 = p[0]*p[2]*sqrt2pi*TMath::Erf(dx/sqrt2)/2;
-
-    return f2;
-}
-*/
-/*
-class MHSignificance : public MH
-{
-private:
-    TH1D fHist;
-
-    MParameterD *fParam;
-
-public:
-    MHSignificance() : fParam(0)
-    {
-        fHist.SetName("Alpha");
-        fHist.SetTitle("Distribution of \\alpha");
-        fHist.SetXTitle("\\alpha [\\circ]");
-        fHist.SetYTitle("Counts");
-    }
-    Int_t SetupFill(MParList *p)
-    {
-        fHist.Reset();
-
-        fParam = (MParameterD*)p->FindCreateObj("Significance", "MParameterD");
-        if (fParam)
-            return kFALSE;
-
-        return kTRUE;
-    }
-    Int_t Process(MParContainer *p, Double_t w=1)
-    {
-        MHillasSrc *hil = dynamic_cast<MHillasSrc*>(p);
-        if (!hil)
-        {
-            *fLog << err << dbginf << "Got no MHillasSrc as argument of Fill()..." << endl;
-            return kFALSE;
-        }
-
-        fHist->Fill(hil->GetAlpha(), w);
-
-        return kTRUE;
-    }
-    Int_t Finalize()
-    {
-        if (fHist.GetEntries()==0)
-        {
-            *fLog << err << "Histogram empty." << endl;
-            return kFALSE;
-        }
-
-        Float_t sigmax=15;
-        Float_t bgmin =45;
-        Float_t bgmax =80;
-
-        fHist.SetNameTitle("Significance",
-                           Form("Fit Region: Signal<%.1f\\circ, %.1f\\circ<Bg<%.1f\\circ",
-                                sigmax, bgmin, bgmax));
-
-        // Implementing the function yourself is not faster at all!
-        TF1 func("gaus(0) + pol2(3)", fcn, 0, 90, 6);
-        TArrayD maxpar(func.GetNpar());
-
-        func.FixParameter(1, 0);
-        func.FixParameter(4, 0);
-        func.SetParLimits(3, -1, 1);
-
-        const Double_t alpha0 = fHist.GetBinContent(1);
-
-        // First fit a polynom in the off region
-        func.FixParameter(0, 0);
-        func.FixParameter(2, 1);
-        func.ReleaseParameter(3);
-        func.ReleaseParameter(5);
-
-        h->Fit(&func, "N0Q", "", bgmin, bgmax);
-
-        // Now fit a gaus in the on region on top of the polynom
-        func.SetParameter(0, alpha0-func.GetParameter(4));
-        func.SetParameter(2, sigmax*0.75);
-
-        func.ReleaseParameter(0);
-        func.ReleaseParameter(2);
-        func.FixParameter(3, func.GetParameter(3));
-        func.FixParameter(5, func.GetParameter(5));
-
-        func.SetParLimits(2, 0, 80);
-        h->Fit(&func, "N0Q", "", 0, sigmax);
-
-        TArrayD p(func.GetNpar(), func.GetParameters());
-
-        Double_t sig=0;
-
-        const Int_t n = hist->GetBin(ix+1, iy+1);
-        if (!(func.GetParameter(0)>alpha0*2 ||
-              func.GetParameter(2)<2.5      ||
-              func.GetParameter(2)>70))
-        {
-            // Implementing the integral as analytical function
-            // gives the same result in the order of 10e-5
-            // and it is not faster at all...
-            const Double_t s = func.Integral(0, 15);
-
-            func.SetParameter(0, 0);
-            func.SetParameter(2, 1);
-
-            const Double_t b = func.Integral(0, 15);
-
-            sig = Significance(s, b);
-        }
-
-        fParam->SetValue(sig);
-        fParam->SetReadyToSave();
-        return kTRUE;
-    }
-    ClassDef(MHSignificance, 0)
-};
-*/
-
 
 // --------------------------------------------------------------------------
@@ -843,4 +699,6 @@
     histb->SetYTitle(fHist.GetXaxis()->GetTitle());
 
+    const Double_t w = fHist.GetZaxis()->GetBinWidth(1);
+
     //                      xmin, xmax, npar
     //TF1 func("MyFunc", fcn, 0, 90, 6);
@@ -889,5 +747,4 @@
 
             const Double_t alpha0 = h->GetBinContent(1);
-            const Double_t alphaw = h->GetXaxis()->GetBinWidth(1);
 
             // Check for the regios which is not filled...
@@ -959,10 +816,14 @@
             */
 
-            const Double_t s = func.Integral(0, sigint);
+            // The fitted function returned units of
+            // counts bin binwidth. To get the correct number
+            // of events we must adapt the functions by dividing
+            // the result of the integration by the bin-width
+            const Double_t s = func.Integral(0, sigint)/w;
 
             func.SetParameter(0, 0);
             func.SetParameter(2, 1);
 
-            const Double_t b   = func.Integral(0, sigint);
+            const Double_t b   = func.Integral(0, sigint)/w;
             const Double_t sig = Significance(s, b);
 
