Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7220)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7221)
@@ -21,5 +21,13 @@
                                                  -*-*- END OF LINE -*-*-
 
- 2005/07/22 Daniela Dorner
+ 2005/07/26 Thomas Bretz
+
+   * mhflux/MHDisp.cc:
+     - improved scaling for significance plot, so that significances
+     similar to the ThetaSq plot come out
+
+
+
+ 2005/07/25 Daniela Dorner
 
    * datacenter/macros/fillstar.C, setupdb.C:
Index: /trunk/MagicSoft/Mars/mhflux/MHDisp.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHDisp.cc	(revision 7220)
+++ /trunk/MagicSoft/Mars/mhflux/MHDisp.cc	(revision 7221)
@@ -403,7 +403,7 @@
             if (rmax<TMath::Hypot(px, py))
                 h2.SetBinContent(bin, 0);
-            else
-                if (h2.GetBinContent(bin)==0)
-                    h2.SetBinContent(bin, 1e-10);
+            //else
+            //    if (h2.GetBinContent(bin)==0)
+            //        h2.SetBinContent(bin, 1e-10);
         }
 }
@@ -418,28 +418,44 @@
     const TAxis &axey = *s.GetYaxis();
 
+    const Int_t nx = axex.GetNbins();
+    const Int_t ny = axey.GetNbins();
+
     const Int_t n = TMath::Nint(0.2/axex.GetBinWidth(1));
 
-    for (int x=1+n; x<=axex.GetNbins()-n; x++)
-        for (int y=1+n; y<=axey.GetNbins()-n; y++)
-        {
-            Double_t sig=0;
-            Double_t bg =0;
-
-            for (int dx=-n; dx<=n; dx++)
-                for (int dy=-n; dy<=n; dy++)
-                {
-                    if (TMath::Hypot((float)dx, (float)dy)>n)
-                        continue;
-
-                    const Int_t  bin = s.GetBin(x+dx,y+dy);
-
-                    sig += h1.GetBinContent(bin);
-                    bg  += h2.GetBinContent(bin);
-                }
-
-            const Double_t S = sig>0 ? MMath::SignificanceLiMaSigned(sig, bg, TMath::Abs(scale)) : 0;
-
-            const Int_t bin = s.GetBin(x,y);
-            s.SetBinContent(bin, S);
+    const Double_t sc = h2.GetEntries()/fHistOff->GetEntries();
+
+    for (int x=1; x<=nx; x++)
+        for (int y=1; y<=ny; y++)
+        {
+            Double_t S=0;
+
+            // Only calculate significances for pixels far enough
+            // from the border to get all expected pixels.
+            if (TMath::Hypot((float)x-0.5*nx, (float)y-0.5*ny)<0.5*axex.GetNbins()-n)
+            {
+                Double_t sig=0;
+                Double_t bg =0;
+
+                // Integral a region of n pixels around x/y
+                for (int dx=-n; dx<=n; dx++)
+                    for (int dy=-n; dy<=n; dy++)
+                    {
+                        if (TMath::Hypot((float)dx, (float)dy)>n)
+                            continue;
+
+                        const Int_t  bin = s.GetBin(x+dx,y+dy);
+
+                        sig += h1.GetBinContent(bin);
+                        bg  += h2.GetBinContent(bin);
+                    }
+
+                // Scale such, that the statistical error corresponds to
+                // the amount of off-data used to determin the background
+                // model, not to the background itself. This gives
+                // significances as calculated from the theta-sq plot.
+                S = sig>0 ? MMath::SignificanceLiMaSigned(sig, bg*scale/sc, sc) : 0;
+            }
+
+            s.SetBinContent(x, y, S);
         }
 }
@@ -456,7 +472,8 @@
     hrc->Reset();
 
+    //const_cast<TH2&>(h).SetMaximum();
     const Double_t max = h.GetMaximum();
 
-    MBinning(50, -max*1.1, max*1.1).Apply(*hrc);
+    MBinning(51, -max*1.1, max*1.1).Apply(*hrc);
 
     for (int x=1; x<=h.GetXaxis()->GetNbins(); x++)
@@ -525,5 +542,5 @@
         {
             hx->SetContour(99);
-            MakeSignificance(*hx, *h1, fHistBg, scale);
+            MakeSignificance(*hx, *h1, fHistBg, TMath::Abs(scale));
             MakeDot(*hx);
             MakeSymmetric(hx);
