Index: trunk/MagicSoft/Mars/mhflux/MHPhi.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHPhi.cc	(revision 7250)
+++ trunk/MagicSoft/Mars/mhflux/MHPhi.cc	(revision 7251)
@@ -30,4 +30,7 @@
 // the source position.
 //
+// More detail can be found at:
+// http://www.astro.uni-wuerzburg.de/results/ringmethod/
+//
 ////////////////////////////////////////////////////////////////////////////
 #include "MHPhi.h"
@@ -60,5 +63,5 @@
 //
 MHPhi::MHPhi(const char *name, const char *title)
-: fHillas(0), fSrcPos(0), fDisp(0)
+: fHillas(0), fSrcPos(0), fDisp(0)//, fOnOffMode(kTRUE), fIsOffLoop(kFALSE)
 {
     fName  = name  ? name  : "MHPhi";
@@ -66,5 +69,5 @@
 
     // Init Graphs
-    fHPhi.SetNameTitle("Phi", "Distribution of \\Delta\\Phi");
+    fHPhi.SetNameTitle("Phi", "\\Delta\\Phi-Distribution");
 
     fHPhi.SetXTitle("\\Delta\\Phi [\\circ]");
@@ -78,5 +81,48 @@
 
     fHPhi.GetYaxis()->SetTitleOffset(1.2);
-}
+
+    /*
+    fNameParameter = "Disp";
+
+    fHist.SetNameTitle("Phi", "\\Delta\\Phi-Distribution");
+    fHist.SetZTitle("\\Delta\\Phi [\\circ]");
+    fHist.SetDirectory(NULL);
+
+    // Main histogram
+    fHistTime.SetName("Phi");
+    fHistTime.SetXTitle("\\Delta\\Phi [\\circ]");
+    fHistTime.SetDirectory(NULL);
+
+    MBinning binsa, binse, binst;
+    //binsa.SetEdges(75, 0, 1.5);
+    //binsa.SetEdges(arr);
+    binse.SetEdgesLog(15, 10, 100000);
+    binst.SetEdgesASin(67, -0.005, 0.665);
+    //binsa.Apply(fHistTime);
+
+    MH::SetBinning(&fHist, &binst, &binse, &binsa);
+     */
+}
+
+/*
+Double_t MHPhi::GetVal() const
+{
+    const Dopuble_t disp = static_cast<const MParameterD*>(fParameter)->GetVal();
+
+    const TVector2 pos = fHillas->GetMean()*fConvMm2Deg + fHillas->GetNormAxis()*disp;
+    const TVector2 src = fSrcPos->GetXY()*fConvMm2Deg;
+
+    // Calculate radial distance.
+    const Double_t d = pos.Mod() - src.Mod();
+
+    if (d<-fThetaCut*0.913 || d>fThetaCut)
+        return kTRUE;
+
+    const Double_t delta = src.DeltaPhi(pos)*TMath::RadToDeg();
+    const Double_t absd  = TMath::Abs(delta)
+
+    return fHistOff ? absd : 180-absd;
+}
+*/
 
 // --------------------------------------------------------------------------
@@ -118,4 +164,5 @@
     fThetaCut      = 0.21/1.2;
     fDistSrc       = 0.4;
+    //fIsOffLoop = !fIsOffLoop;
 
     const Double_t w  = TMath::ATan(fThetaCut/fDistSrc);
@@ -124,5 +171,20 @@
 
     MBinning(n, 0, n*sz).Apply(fHPhi);
-
+    /*
+
+    // Get Histogram binnings
+    MBinning binst, binse;
+    binst.SetEdges(fHist, 'x');
+    binse.SetEdges(fHist, 'y');
+
+    MBinning binsa(n, 0, n*sz);
+
+    // Apply binning
+    binsa.Apply(fHistTime);
+    MH::SetBinning(&fHist, &binst, &binse, &binsa);
+
+    // Remark: Binnings might be overwritten in MHAlpha::SetupFill
+    return MHAlpha::SetupFill(pl);
+     */
     return kTRUE;
 }
@@ -135,7 +197,8 @@
 Bool_t MHPhi::Fill(const MParContainer *par, const Stat_t weight)
 {
-    const TVector2 pos = fHillas->GetMean()*fConvMm2Deg - fHillas->GetNormAxis()*fDisp->GetVal();
+    const TVector2 pos = fHillas->GetMean()*fConvMm2Deg + fHillas->GetNormAxis()*fDisp->GetVal();
     const TVector2 src = fSrcPos->GetXY()*fConvMm2Deg;
 
+    // Calculate radial distance.
     const Double_t d = pos.Mod() - src.Mod();
 
@@ -146,4 +209,7 @@
 
     fHPhi.Fill(TMath::Abs(delta), weight);
+
+    // const Double_t absd = TMath::Abs(delta)
+    // fHPhi.Fill(fHistOff ? absd : 180-absd, weight);
 
     return kTRUE;
@@ -161,28 +227,44 @@
     pad->SetBorderMode(0);
 
+    AppendPad("combine");
+
     fHPhi.Draw();
 
-    AppendPad();
+    AppendPad(opt);
 }
 
 void MHPhi::Paint(Option_t *o)
 {
-    const Double_t sig = fHPhi.Integral(1, fNumBinsSignal);
-    const Double_t bg  = fHPhi.Integral(1+fNumBinsSignal, fHPhi.GetNbinsX());
-
-    const Double_t cut = fHPhi.GetBinLowEdge(fNumBinsSignal+1);
-
-    const Double_t f   = cut/(180-cut);
-
-    const Double_t S0  = MMath::SignificanceLiMaSigned(sig, bg*f);
-    const Double_t S   = MMath::SignificanceLiMaSigned(sig, bg, f);
-
-    const TString  fmt = Form("\\sigma_{L/M}=%.1f (\\sigma_{0}=%.1f)  \\Delta\\Phi<%.1f\\circ  E=%.0f  B=%.0f  f=%.2f",
-                              S, S0, cut, sig-bg*f, bg*f, f);
+    //TString opt(o);
+    //opt.ToLower();
+
+    // if (opt=="combine" && fHistOff)
+    // {
+    //    fHPhi.Add(fHist, fHistOff);
+    //    return;
+    // }
+
+    const Bool_t wobble = TString(o).Contains("anticut", TString::kIgnoreCase);
+
+    const Double_t cut  = fHPhi.GetBinLowEdge(fNumBinsSignal+1);
+
+    const Int_t maxbin  = wobble ? fHPhi.GetXaxis()->FindFixBin(180-cut)-1 : fHPhi.GetNbinsX();
+    const Double_t cut2 = wobble ? fHPhi.GetBinLowEdge(maxbin+1) : 180;
+
+    const Double_t sig  = fHPhi.Integral(1, fNumBinsSignal);
+    const Double_t bg   = fHPhi.Integral(1+fNumBinsSignal, maxbin);
+
+    const Double_t f    = cut/(cut2-cut);
+
+    const Double_t S0   = MMath::SignificanceLiMaSigned(sig, bg*f);
+    const Double_t S    = MMath::SignificanceLiMaSigned(sig, bg, f);
+
+    const TString  fmt  = Form("\\sigma_{L/M}=%.1f (\\sigma_{0}=%.1f)  \\Delta\\Phi_{on}<%.1f\\circ  \\Delta\\Phi_{off}<%.1f\\circ  E=%.0f  B=%.0f  f=%.2f",
+                               S, S0, cut, cut2, sig-bg*f, bg*f, f);
 
     const Double_t b = bg             *f/fNumBinsSignal;
     const Double_t e = TMath::Sqrt(bg)*f/fNumBinsSignal;
 
-    TLatex text(0.33, 0.94, fmt);
+    TLatex text(0.27, 0.94, fmt);
     text.SetBit(TLatex::kTextNDC);
     text.SetTextSize(0.035);
@@ -192,4 +274,6 @@
     line.SetLineColor(14);
     line.PaintLine(cut, gPad->GetUymin(), cut, gPad->GetUymax());
+    if (maxbin<fHPhi.GetNbinsX())
+        line.PaintLine(cut2, gPad->GetUymin(), cut2, gPad->GetUymax());
     line.SetLineColor(kBlue);
     line.PaintLine(0, b, cut, b);
@@ -202,4 +286,3 @@
     m.SetMarkerStyle(kFullDotMedium);
     m.PaintMarker(cut/2, b);
-
-}
+}
