Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 2279)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 2280)
@@ -1,3 +1,30 @@
                                                                   -*-*- END -*-*-
+ 2003/07/16 - Thomas Bretz (La Palma)
+
+   * bending_magic.txt:
+     - new bending correction. Calculated from new stars and
+       recalculated old ones (old positions where wrong due
+       to a bug in the observatory coordinates)
+       
+   * catalog/Slalib.[h,cc]:
+     - fixed a bug in the Hms2Deg and Dms2Deg (negative hours, degs
+       where treated incorrect!)
+     - added many new conversion functions
+     
+   * devdrv/macs.[h,cc]:
+     - commented SetHome
+     
+   * gui/MGCosy.[h,cc]:
+     - implemented button to write prepos
+     - implemented star list
+     
+   * gui/MGSkyPosition.cc:
+     - changed calculation of h,m,s etc to new Slalib functions
+     
+   * main/MCaos.cc:
+     - changed detection limit from 4.0 to 3.0
+
+
+     
  2003/07/15 - Thomas Bretz (La Palma)
 
Index: /trunk/MagicSoft/Cosy/bending_magic.txt
===================================================================
--- /trunk/MagicSoft/Cosy/bending_magic.txt	(revision 2279)
+++ /trunk/MagicSoft/Cosy/bending_magic.txt	(revision 2280)
@@ -1,10 +1,10 @@
-MAGIC1 2003/07/15 13:28:46.783326
+MAGIC1 2003/07/16 16:15:09.783074
 S   00   000000   000000  0000000
- IA     141.81712 -1
- IE     -9.0736584 -1
+ IA     501.79683 -1
+ IE     -9.0710418 -1
  CA     0 -1
- NPAE   0.14617499 -1
+ NPAE   0.14889374 -1
  AN     0 -1
- AW     -1.5469003 -1
+ AW     -1.5600339 -1
  NRX    0 -1
  NRY    0 -1
Index: /trunk/MagicSoft/Cosy/catalog/Slalib.cc
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/Slalib.cc	(revision 2279)
+++ /trunk/MagicSoft/Cosy/catalog/Slalib.cc	(revision 2280)
@@ -16,4 +16,16 @@
 Slalib::~Slalib()
 {
+}
+
+Double_t Slalib::Trunc(Double_t val)
+{
+    /* dint(A) - truncate to nearest whole number towards zero (double) */
+    return val<0 ? TMath::Ceil(val) : TMath::Floor(val);
+}
+
+Double_t Slalib::Round(Double_t val)
+{
+    /* dnint(A) - round to nearest whole number (double) */
+    return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5);
 }
 
@@ -45,2 +57,141 @@
     return ZdAz(kPiDiv2-alt, az);
 }
+
+Double_t Slalib::Hms2Sec(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    const Double_t rc = TMath::Sign((60.0 * (60.0 * (Double_t)TMath::Abs(deg) + (Double_t)min) + sec), (Double_t)deg);
+    return sgn=='-' ? -rc : rc;
+}
+
+Double_t Slalib::Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    /* pi/(180*3600):  arcseconds to radians */
+#define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
+    return Hms2Sec(deg, min, sec, sgn)*DAS2R;
+}
+
+Double_t Slalib::Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
+{
+    /* pi/(12*3600):  seconds of time to radians */
+#define DS2R 7.2722052166430399038487115353692196393452995355905e-5
+    return Hms2Sec(hor, min, sec, sgn)*DS2R;
+}
+
+Double_t Slalib::Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(deg, min, sec, sgn)/3600.;
+}
+
+Double_t Slalib::Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(hor, min, sec, sgn)/240.;
+}
+
+Double_t Slalib::Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(deg, min, sec, sgn)/15.;
+}
+
+Double_t Slalib::Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(hor, min, sec, sgn)/3600.;
+}
+
+void Slalib::Day2Hms(Double_t day, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec)
+{
+    /* Handle sign */
+    sgn = day<0?'-':'+';
+
+    /* Round interval and express in smallest units required */
+    Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds
+
+    /* Separate into fields */
+    const Double_t ah = Trunc(a/3600.);
+    a -= ah * 3600.;
+    const Double_t am = Trunc(a/60.);
+    a -= am * 60.;
+    const Double_t as = Trunc(a);
+
+    /* Return results */
+    hor = (UShort_t)ah;
+    min = (UShort_t)am;
+    sec = (UShort_t)as;
+}
+
+void Slalib::Rad2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(rad/(TMath::Pi()*2), sgn, deg, min, sec);
+}
+
+void Slalib::Rad2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Rad2Hms(rad*15, sgn, deg, min, sec);
+}
+
+void Slalib::Deg2Dms(Double_t d, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(d/24, sgn, deg, min, sec);
+}
+
+void Slalib::Deg2Hms(Double_t d, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Rad2Hms(d/360, sgn, deg, min, sec);
+}
+
+void Slalib::Hor2Dms(Double_t h, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(h*15/24, sgn, deg, min, sec);
+}
+
+void Slalib::Hor2Hms(Double_t h, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(h/24, sgn, deg, min, sec);
+}
+
+void Slalib::Day2Hm(Double_t day, Char_t &sgn, UShort_t &hor, Double_t &min)
+{
+    /* Handle sign */
+    sgn = day<0?'-':'+';
+
+    /* Round interval and express in smallest units required */
+    Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds
+
+    /* Separate into fields */
+    const Double_t ah = Trunc(a/3600.);
+    a -= ah * 3600.;
+
+    /* Return results */
+    hor = (UShort_t)ah;
+    min = a/60.;
+}
+
+void Slalib::Rad2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(rad/(TMath::Pi()*2), sgn, deg, min);
+}
+
+void Slalib::Rad2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Rad2Hm(rad*15, sgn, deg, min);
+}
+
+void Slalib::Deg2Dm(Double_t d, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(d/24, sgn, deg, min);
+}
+
+void Slalib::Deg2Hm(Double_t d, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Rad2Hm(d/360, sgn, deg, min);
+}
+
+void Slalib::Hor2Dm(Double_t h, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(h*15/24, sgn, deg, min);
+}
+
+void Slalib::Hor2Hm(Double_t h, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(h/24, sgn, deg, min);
+}
+
Index: /trunk/MagicSoft/Cosy/catalog/Slalib.h
===================================================================
--- /trunk/MagicSoft/Cosy/catalog/Slalib.h	(revision 2279)
+++ /trunk/MagicSoft/Cosy/catalog/Slalib.h	(revision 2280)
@@ -13,21 +13,34 @@
     double fAlpha;
 
+    static Double_t Round(Double_t val);
+    static Double_t Trunc(Double_t val);
+
 public:
     Slalib(MObservatory::LocationName_t key);
     virtual ~Slalib();
 
-    static Double_t Dms2Rad(Int_t deg, UInt_t min, Double_t sec)
-    {
-        /* pi/(180*3600):  arcseconds to radians */
-#define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
-        return DAS2R * (60.0 * (60.0 * (Double_t)deg + (Double_t)min) + sec);
-    }
+    static Double_t Hms2Sec(Int_t deg, UInt_t min, Double_t sec, char sgn='+');
+    static Double_t Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
 
-    static Double_t Hms2Rad(Int_t hor, UInt_t min, Double_t sec)
-    {
-        /* pi/(12*3600):  seconds of time to radians */
-#define DS2R 7.2722052166430399038487115353692196393452995355905e-5
-        return DS2R * (60.0 * (60.0 * (Double_t)hor + (Double_t)min) + sec);
-    }
+    static void Day2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Rad2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Rad2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Deg2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Deg2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Hor2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Hor2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+
+    static void Day2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Rad2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Rad2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Deg2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Deg2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Hor2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Hor2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
 
     virtual void SetMjd(double mjd);
Index: /trunk/MagicSoft/Cosy/devdrv/macs.cc
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 2279)
+++ /trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 2280)
@@ -362,5 +362,5 @@
     WaitForSdo(0x2002);
 }
-
+/*
 void Macs::SetHome(LWORDS_t pos, WORD_t maxtime)
 {
@@ -384,5 +384,5 @@
     StartHostGuarding();
 }
-
+*/
 void Macs::SetVelocity(LWORD_t vel)
 {
Index: /trunk/MagicSoft/Cosy/devdrv/macs.h
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 2279)
+++ /trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 2280)
@@ -80,5 +80,5 @@
     void ReqVelRes();
     void ReqRes();
-    void SetHome(LWORDS_t pos=0, WORD_t maxtime=25);
+    //void SetHome(LWORDS_t pos=0, WORD_t maxtime=25);
     void SetAcceleration(LWORD_t acc);
     void SetDeceleration(LWORD_t dec);
Index: /trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 2279)
+++ /trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 2280)
@@ -1,8 +1,10 @@
 #include "MGCosy.h"
 
+#include <iomanip.h>
 #include <iostream.h>
 
 #include "msgqueue.h"
 #include "coord.h"
+#include "slalib.h"
 
 #include <TROOT.h>
@@ -64,4 +66,6 @@
     kCB_PredefPos,
     kCB_StarList,
+    kPB_SavePreDef,
+    kPB_SaveStar,
 
     // kLog
@@ -323,12 +327,14 @@
     while (1)
     {
+        Double_t zd, az;
+        fin >> zd >> az;
+
         TString str;
-        Double_t zd, az;
-        fin >> str >> zd >> az;
+        str.ReadLine(fin);
         if (!fin)
             break;
+
         box->AddEntry(str, i++);
-
-        fStarList.Add(zd, az);
+        fPreDefList.Add(zd, az);
     }
 }
@@ -336,11 +342,10 @@
 void MGCosy::CreateStarList(TGCompositeFrame *tf1)
 {
-    /*
     TGComboBox *box = new TGComboBox(tf1, kCB_StarList);
-    box->Resize(120, 20);
+    box->Resize(170, 20);
     box->Associate(this);
 
     TGLayoutHints *lay = new TGLayoutHints(kLHintsLeft|kLHintsTop,
-                                           27, 0, 200, 0);
+                                           27, 0, 70, 0);
     tf1->AddFrame(box, lay);
 
@@ -358,7 +363,9 @@
     while (1)
     {
-        TString str;
         Int_t h, m, s, d, am, as;
         fin >> h >> m >> s >> d >> am >> as;
+
+        TString str;
+        str.ReadLine(fin);
         if (!fin)
             break;
@@ -366,7 +373,6 @@
         box->AddEntry(str, i++);
 
-        fStarList.Add(zd, az);
-        }
-        */
+        fStarList.Add(Slalib::Hms2Hor(h, m, s), Slalib::Dms2Deg(d, am, as));
+    }
 }
 
@@ -513,5 +519,26 @@
     fList->Add(but);
 
+    but = new TGTextButton(tf4, "TPoint", kPB_TPOINT);
+    but->Resize(50, 25);
+    but->Move(176/*231*/, 213);
+    but->SetToolTipText("Trigger writing a tpoint coordinate pair.");
+    but->Associate(this);
+    fList->Add(but);
+
 #ifdef EXPERT
+    but= new TGTextButton(tf1, "New Position",  kPB_SavePreDef);
+    but->Resize(80, 25);
+    but->Move(165, 197);
+    but->SetToolTipText("Save new predefined position.");
+    but->Associate(this);
+    fList->Add(but);
+
+    but= new TGTextButton(tf4, "New", kPB_SaveStar);
+    but->Resize(60, 23);
+    but->Move(211, 69);
+    but->SetToolTipText("Save new Source position.");
+    but->Associate(this);
+    fList->Add(but);
+
     but = new TGTextButton(tf5, "Display", kPB_DISPLAY1);
     but->Resize(80, 25);
@@ -528,13 +555,4 @@
     fList->Add(but);
 
-    /*
-    but = new TGTextButton(tf4, "Calib SE", kPB_CALIBSE);
-    but->Resize(80, 25);
-    but->Move(160, 197);
-    but->SetToolTipText("Set SE to given coordinates.");
-    but->Associate(this);
-    fList->Add(but);
-    */
-#ifdef EXPERT
     but = new TGTextButton(tf4, "Load", kPB_LoadBending);
     but->Resize(50, 25);
@@ -548,12 +566,4 @@
     but->Move(206, 185);
     but->SetToolTipText("Reset bending correction (coefficients=0)");
-    but->Associate(this);
-    fList->Add(but);
-#endif EXPERT
-
-    but = new TGTextButton(tf4, "TPoint", kPB_TPOINT);
-    but->Resize(50, 25);
-    but->Move(176/*231*/, 213);
-    but->SetToolTipText("Trigger writing a tpoint coordinate pair.");
     but->Associate(this);
     fList->Add(but);
@@ -893,16 +903,21 @@
     char text[64];
 
-    rd.Ra(rd.Ra()  * 24/2/TMath::Pi());
-    rd.Dec(rd.Dec()*360/2/TMath::Pi());
-
-    radec.Ra(radec.Ra()  * 24/2/TMath::Pi());
-    radec.Dec(radec.Dec()*360/2/TMath::Pi());
+    UShort_t h, d;
+    Double_t hm, dm;
+    Char_t   sh, sd;
+
+    // Calculate Display values
+    Slalib::Rad2Hm(rd.Ra(),  sh, h, hm);
+    Slalib::Rad2Dm(rd.Dec(), sd, d, dm);
+
+    rd.Ra(rd.Ra()  * 12/TMath::Pi());
+    rd.Dec(rd.Dec()*180/TMath::Pi());
 
     RaDec test = rd*600;
-
     if (rai!=(int)test.Ra())
     {
         rai = (int)test.Ra();
-        sprintf(text, "%c%dh %.1fm", rd.Ra()<0?'-':'+', abs((int)rd.Ra()), 0.1*(abs((int)test.Ra())%600));
+        //sprintf(text, "%c%dh %.1fm", rd.Ra()<0?'-':'+', abs((int)rd.Ra()), 0.1*(abs((int)test.Ra())%600));
+        sprintf(text, "%c%dh %.1fm", sh, h, hm);
         fRaEst->SetText(new TGString(text));
     }
@@ -910,8 +925,12 @@
     {
         deci = (int)test.Dec();
-        sprintf(text, "%c%dd %.1fm", rd.Dec()<0?'-':'+' , abs((int)rd.Dec()), 0.1*(abs((int)test.Dec())%600));
+        //sprintf(text, "%c%dd %.1fm", rd.Dec()<0?'-':'+' , abs((int)rd.Dec()), 0.1*(abs((int)test.Dec())%600));
+        sprintf(text, "%c%dh %.1fm", sd, d, dm);
         fDecEst->SetText(new TGString(text));
     }
 
+    // Align RaDec
+    radec.Ra(radec.Ra()  * 12/TMath::Pi());
+    radec.Dec(radec.Dec()*180/TMath::Pi());
     if (radec.Dec()>90|| radec.Dec()<-90)
     {
@@ -921,10 +940,14 @@
     radec.Ra(fmod((radec.Ra()+48), 24));
 
+    // Calculate display values
+    Slalib::Hor2Hm(radec.Ra(),  sh, h, hm);
+    Slalib::Deg2Dm(radec.Dec(), sd, d, dm);
+
     test = radec*600;
-
     if (ras!=(int)test.Ra())
     {
         ras = (int)test.Ra();
-        sprintf(text, "%c%dh %.1fm", radec.Ra()<0?'-':'+', abs((int)radec.Ra()), 0.1*(abs((int)test.Ra())%600));
+        //sprintf(text, "%c%dh %.1fm", radec.Ra()<0?'-':'+', abs((int)radec.Ra()), 0.1*(abs((int)test.Ra())%600));
+        sprintf(text, "%c%dh %.1fm", sh, h, hm);
         fRaSoll->SetText(new TGString(text));
     }
@@ -932,5 +955,6 @@
     {
         decs = (int)test.Dec();
-        sprintf(text, "%c%dd %.1fm", radec.Dec()<0?'-':'+' , abs((int)radec.Dec()), 0.1*(abs((int)test.Dec())%600));
+        //sprintf(text, "%c%dd %.1fm", radec.Dec()<0?'-':'+' , abs((int)radec.Dec()), 0.1*(abs((int)test.Dec())%600));
+        sprintf(text, "%c%dh %.1fm", sd, d, dm);
         fDecSoll->SetText(new TGString(text));
     }
@@ -1265,10 +1289,20 @@
         {
         case kCM_COMBOBOX:
-            if (mp1==kCB_PredefPos)
+            switch (mp1)
             {
-                MStar *pos = fStarList[mp2];
-                if (!pos)
+            case kCB_PredefPos:
+                {
+                    MStar *pos = fPreDefList[mp2];
+                    if (pos)
+                        fCZdAz->SetCoordinates(ZdAz(pos->GetX(), pos->GetY()));
                     return kTRUE;
-                fCZdAz->SetCoordinates(ZdAz(pos->GetX(), pos->GetY()));
+                }
+            case kCB_StarList:
+                {
+                    MStar *pos = fStarList[mp2];
+                    if (pos)
+                        fCCalib->SetCoordinates(RaDec(pos->GetX(), pos->GetY()));
+                    return kTRUE;
+                }
             }
             return kTRUE;
@@ -1333,4 +1367,29 @@
                     XY xy = fCRaDec->GetCoordinates();
                     fQueue->Proc(WM_CALCALTAZ, &xy);
+                }
+                return kTRUE;
+
+            case kPB_SavePreDef:
+                {
+                    ofstream fout("prepos.txt", ios::app);
+                    XY za = fCZdAz->GetCoordinates();
+                    fout << setprecision(7) << za.X() << " \t" << za.Y();
+                    fout << " New Position" << endl;
+                }
+                return kTRUE;
+            case kPB_SaveStar:
+                {
+                    ofstream fout("stars.txt", ios::app);
+                    XY za = fCCalib->GetCoordinates();
+
+                    UShort_t d, m, s;
+                    Char_t sgn;
+                    Slalib::Deg2Dms(za.X(), sgn, d, m, s);
+                    if (sgn=='-') fout << sgn;
+                    fout << d << " " << m << " " << s << " \t";
+                    Slalib::Deg2Dms(za.Y(), sgn, d, m, s);
+                    if (sgn=='-') fout << sgn;
+                    fout << d << " " << m << " " << s << " \t";
+                    fout << " New Star/Source" << endl;
                 }
                 return kTRUE;
Index: /trunk/MagicSoft/Cosy/gui/MGCosy.h
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 2279)
+++ /trunk/MagicSoft/Cosy/gui/MGCosy.h	(revision 2280)
@@ -65,4 +65,5 @@
     TGLabel       *fMjd;
 
+    MStarList     fPreDefList;
     MStarList     fStarList;
 
Index: /trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 2279)
+++ /trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc	(revision 2280)
@@ -318,11 +318,8 @@
     SetLin2(x+dy, y-dx, x-dy, y+dx);
 
-    //if (zd<80)
-    //{
-        for(int i=0; i<3; i++)
-            SetDot(fDot[i], radec, i-3);
-        for(int i=3; i<6; i++)
-            SetDot(fDot[i], radec, i-2);
-    //}
+    for(int i=0; i<3; i++)
+        SetDot(fDot[i], radec, i-3);
+    for(int i=3; i<6; i++)
+        SetDot(fDot[i], radec, i-2);
 
     SetModified();
@@ -334,11 +331,12 @@
     static int Y = ~0;
 
-    int xd = (int)/*floor*/(x);
-    int yd = (int)/*floor*/(y);
-    x *= 60.;
-    y *= 60.;
-
-    int fx = (int)/*floor*/(x*10.);
-    int fy = (int)/*floor*/(y*10.);
+    UShort_t xd, yd;
+    Char_t   sx, sy;
+    Double_t xm, ym;
+    Slalib::Deg2Dm(x, sx, xd, xm);
+    Slalib::Deg2Dm(y, sy, yd, ym);
+
+    const int fx = (int)(x*600);
+    const int fy = (int)(y*600);
 
     if (X==fx && Y==fy)
@@ -348,12 +346,9 @@
     Y = fy;
 
-    float xm = fmod(fabs(x), 60.);
-    float ym = fmod(fabs(y), 60.);
-
     char txt[100];
-    sprintf(txt, "Zd=%s%d\xb0%02.1f'", x<0?"-":"", abs(xd), xm);
+    sprintf(txt, "Zd=%s%d\xb0%02.1f'", sx=='-'?"-":"", xd, xm);
     fText1->SetText(fText1->GetX(), fText1->GetY(), txt);
 
-    sprintf(txt, "Az=%s%d\xb0%02.1f'", y<0?"-":"", abs(yd), ym);
+    sprintf(txt, "Az=%s%d\xb0%02.1f'", sy=='-'?"-":"", yd, ym);
     fText2->SetText(fText2->GetX(), fText2->GetY(), txt);
 
Index: /trunk/MagicSoft/Cosy/main/MCaos.cc
===================================================================
--- /trunk/MagicSoft/Cosy/main/MCaos.cc	(revision 2279)
+++ /trunk/MagicSoft/Cosy/main/MCaos.cc	(revision 2280)
@@ -312,5 +312,5 @@
 
     //          img  width height radius sigma
-    FilterLed f(img, 768, 576, 50, 4.0);
+    FilterLed f(img, 768, 576, 50, 3.0);
 
     Int_t first=0;
@@ -343,5 +343,5 @@
 
     Rings rings;
-    rings.CalcRings(leds, 274-10, 274+10);
+    rings.CalcRings(leds, 266, 272);
 
     const Ring &center = rings.GetCenter();
