Index: /trunk/MagicSoft/Cosy/tpoint/gui.C
===================================================================
--- /trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 8765)
+++ /trunk/MagicSoft/Cosy/tpoint/gui.C	(revision 8766)
@@ -29,4 +29,5 @@
 //#include "coord.h"
 
+#include "MAstro.h"
 #include "MGList.h"
 #include "MPointing.h"
@@ -60,21 +61,7 @@
     Double_t GetResidual(Double_t *err=0) const
     {
-      /*
-       TVector3 v1, v2;
-       v1.SetMagThetaPhi(1, TMath::Pi()/2-fRawEl, fRawAz);
-       v2.SetMagThetaPhi(1, TMath::Pi()/2-fStarEl, fStarAz);
-
-       return v1.Angle(v2)*TMath::RadToDeg();
-       */
-
         const Double_t del = fRawEl-fStarEl;
         const Double_t daz = fRawAz-fStarAz;
 
-        /*
-        const Double_t dphi2 = daz/2.;
-        const Double_t cos2  = cos(dphi2)*cos(dphi2);
-        const Double_t sin2  = sin(dphi2)*sin(dphi2);
-        const Double_t d = cos(del)*cos2 - cos(fRawEl+fStarEl)*sin2;
-        */
         const Double_t d  = cos(del) - cos(fRawEl)*cos(fStarEl)*(1.-cos(daz));
 
@@ -100,6 +87,10 @@
         }
 
-        const Double_t dist = acos(d);
-        return dist * TMath::RadToDeg();
+        //const Double_t dist = acos(d);
+        //return dist * TMath::RadToDeg();
+
+        return MAstro::GetDevAbs(90-fStarEl*TMath::RadToDeg(),
+                                  del*TMath::RadToDeg(),
+                                 -daz*TMath::RadToDeg());
     }
 
@@ -569,8 +560,8 @@
 
             Set &set0 = *(Set*)fCoordinates.At(i);
-    
+
             ZdAz za(set0.GetStarZdAz());
             za *=kRad2Deg;
-    
+
             //
             // Correct for offsets only
@@ -578,10 +569,10 @@
             Set set1(set0);
             set1.Adjust(b2);
-    
+
             hres1.Fill(set1.GetResidual());
-    
+
             set0.Adjust(fBending);
             hres2.Fill(set0.GetResidual());
-    
+
             Double_t dz = fmod(set0.GetDAz()+720, 360);
             if (dz>180)
@@ -590,5 +581,5 @@
             Double_t err;
             Double_t resi = set0.GetResidual(&err);
-    
+
             gdzd.SetPoint(i, za.Az(), set0.GetDZd());
             gdaz.SetPoint(i, za.Zd(), dz);
@@ -603,4 +594,10 @@
             {
                 fout << Form("%6.3f", resi) << ": " << (resi>maxres?"*":" ");
+                fout << " " << orig << endl;
+            }
+
+            if (fabs(set0.GetDZd())>0.05)
+            {
+                fout << "-> " <<Form("%6.3f", resi) << ": " << (resi>maxres?"*":" ");
                 fout << " " << orig << endl;
             }
@@ -622,5 +619,5 @@
 
         cout << "Residuals (>0.13deg) written to residuals.txt." << endl;
-    
+
         //
         // Check for overflows
@@ -629,7 +626,7 @@
         if (ov>0)
             cout << "WARNING: " << ov << " overflows (>" << maxres << ") in residuals." << endl;
-    
-    
-    
+
+
+
         cout << dec << endl;
         cout << "              Number of calls to FCN: " << minuit.fNfcn << endl;
@@ -638,7 +635,7 @@
         cout << "                           Chi^2/NDF: " << minuit.fAmin/(fOriginal.GetSize()-minuit.GetNumFreePars()) << endl;
         //cout << "Prob(?): " << TMath::Prob(fChisquare,ndf);
-    
-    
-    
+
+
+
         //
         // Print all data sets for which the backward correction is
@@ -652,17 +649,17 @@
             Set set0(*(Set*)list.At(i));
             Set &set1 = *(Set*)list.At(i);
-    
+
             set0.AdjustBack(fBending);
             set1.Adjust(fBending);
-    
+
             const Double_t res0 = set0.GetResidual();
             const Double_t res1 = set1.GetResidual();
             const Double_t diff = TMath::Abs(res0-res1);
-    
+
             hres3.Fill(res0);
-    
+
             if (diff<hres2.GetMean()*0.66)
                 continue;
-    
+
             cout << "DBack: " << setw(6) << set0.GetStarZd() << " " << setw(7) << set0.GetStarAz() << ":  ";
             cout << "ResB="<< setw(7) << res0*60 << "  ResF=" << setw(7) << res1*60 << "  |ResB-ResF|=" << setw(7) << diff*60 << " arcmin" << endl;
