Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7777)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7778)
@@ -30,5 +30,5 @@
      datacenter/macros/setupdb.C:
      - make sure that 'res' is correctly deleted
-     
+
    * datacenter/macros/doexclusions.C:
      - fixed some variable name overrides
@@ -36,4 +36,9 @@
    * mhflux/MAlphaFitter.[h,cc]:
      - added the possibility to DrawResult()
+
+   * mhflux/MHAlpha.[h,cc]:
+     - added new output container (Bin) which contains the number
+       of the bin the event was assigned to
+     - fixed drawing the significance in DrawAll
 
 
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 7777)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 7778)
@@ -54,5 +54,4 @@
 #include <TStopwatch.h>
 
-#include "MGeomCam.h"
 #include "MSrcPosCam.h"
 #include "MHillasSrc.h"
@@ -82,5 +81,5 @@
 MHAlpha::MHAlpha(const char *name, const char *title)
     : fNameParameter("MHillasSrc"), fParameter(0),
-    fOffData(0), fResult(0), /*fExcess(0),*/ fEnergy(0),
+    fOffData(0), fResult(0), fEnergy(0), fBin(0),
     fPointPos(0), fTimeEffOn(0), fTime(0), fNumTimeBins(10),
     fHillas(0), fMatrix(0), fSkipHistTime(kFALSE), fSkipHistTheta(kFALSE),
@@ -295,4 +294,7 @@
     if (!fSigma)
         return kFALSE;
+    fBin = (MParameterI*)const_cast<MParList*>(pl)->FindCreateObj("MParameterI", "Bin");
+    if (!fBin)
+        return kFALSE;
 
     //fExcess = (MParameterD*)const_cast<MParList*>(pl)->FindCreateObj("MParameterD", "MExcess");
@@ -440,4 +442,22 @@
 }
 
+void MHAlpha::SetBin(Int_t ibin)
+{
+    // Is this necessary?
+    // Could be speed up up searching for it only once.
+    const Float_t max     = fFit.GetSignalIntegralMax();
+    const Int_t bin0      = fHist.GetZaxis()->FindFixBin(max);
+
+    const Int_t nbinsx    = fHist.GetNbinsX();
+    const Int_t nbinsy    = fHist.GetNbinsY();
+    const Int_t nxy       = (nbinsx+2)*(nbinsy+2);
+
+    const Int_t binz      = ibin/nxy;
+
+    const Bool_t issignal = binz>0 && binz<bin0;
+
+    fBin->SetVal(issignal ? binz : -binz);
+}
+
 // --------------------------------------------------------------------------
 //
@@ -479,5 +499,6 @@
 
     // Fill histograms
-    fHist.Fill(theta, energy, TMath::Abs(alpha), w);
+    const Int_t ibin = fHist.Fill(theta, energy, TMath::Abs(alpha), w);
+    SetBin(ibin);
 
     if (!fSkipHistTime)
@@ -769,5 +790,5 @@
 void MHAlpha::DrawAll(Bool_t newc)
 {
-    if (newc && !fDisplay)
+    if (!newc && !fDisplay)
         return;
 
@@ -843,5 +864,5 @@
         {
             *fLog << dbg << "Bin " << i << ": sigmaexc=" << fit.GetSignificanceExc() << " omega=" << fit.GetGausSigma() << " events=" << fit.GetEventsExcess() << " scale=" << fit.GetScaleFactor() << endl;
-            fit.PaintResult();
+            fit.DrawResult();
         }
         /*
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 7777)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 7778)
@@ -20,4 +20,5 @@
 class MParList;
 class MParameterD;
+class MParameterI;
 class MHillas;
 class MHMatrix;
@@ -46,4 +47,5 @@
     MParameterD   *fSigma;      //!
     MParameterD   *fEnergy;     //!
+    MParameterI   *fBin;        //!
     MPointingPos  *fPointPos;   //!
 
@@ -73,4 +75,6 @@
     void InitAlphaTime(const MTime &t);
     void FinalAlphaTime(MBinning &bins);
+
+    void SetBin(Int_t bin);
 
     void PaintText(Double_t val, Double_t error) const;
