Index: trunk/MagicSoft/Cosy/Changelog
===================================================================
--- trunk/MagicSoft/Cosy/Changelog	(revision 9557)
+++ trunk/MagicSoft/Cosy/Changelog	(revision 9558)
@@ -1,3 +1,14 @@
                                                                   -*-*- END -*-*-
+ 2010/02/26 Thomas Bretz
+
+   * main/MMoonPointing.cc:
+     - emit error messages to console/log-file
+
+   * main/MTracing.[h,cc]:
+     - propagate errors
+     - stop tracking if some calculation fails
+
+
+
  2010/02/25 Thomas Bretz
 
Index: trunk/MagicSoft/Cosy/main/MMoonPointing.cc
===================================================================
--- trunk/MagicSoft/Cosy/main/MMoonPointing.cc	(revision 9557)
+++ trunk/MagicSoft/Cosy/main/MMoonPointing.cc	(revision 9558)
@@ -60,9 +60,15 @@
 
         if (sinzd<=0)
+        {
+            gLog << warn << "WARNING - |Zd|>=90°" << endl;
             return ZdAz();
+        }
 
         const Double_t costheta = coszd*fCosOffset + sinzd*fSinOffset*fCosAngle;
-        if (costheta*costheta >= 1)
+        if (costheta >= 1)
+        {
+            gLog << warn << "WARNING - cos(Zd) > 1." << endl;
             return ZdAz();
+        }
 
         const Double_t sintheta = TMath::Sqrt(1 - costheta*costheta);
@@ -97,4 +103,5 @@
     {
         MakeZombie();
+        gLog << warn << "WARNING - Reading of " << filename << " failed." << endl;
         return;
     }
@@ -103,4 +110,5 @@
     {
         MakeZombie();
+        gLog << warn << "WARNING - Reading of TGraph2D 'cosAngle' from " << filename << " failed." << endl;
         return;
     }
@@ -109,4 +117,5 @@
     {
         MakeZombie();
+        gLog << warn << "WARNING - Reading of TGraph2D 'sinAngle' from " << filename << " failed." << endl;
         return;
     }
@@ -127,5 +136,10 @@
     const Double_t norm = TMath::Hypot(fcos, fsin);
     if (TMath::Abs(norm-1)<0.001)
+    {
+        gLog << warn << "WARNING - Local moon position Zd/Az=";
+        gLog << moon.Zd()*TMath::RadToDeg() << "/" << moon.Az()*TMath::RadToDeg();
+        gLog << " out of range of table for interpolation." << endl;
         return kFALSE;
+    }
 
     // Apply a small numerical improvement
@@ -137,5 +151,8 @@
     srcpos = calc1.Calc(moon, &sn, &cs);
     if (srcpos.Zd()==0)
+    {
+        gLog << warn << "WARNING - Calculation of moon shadow position failed." << endl;
         return kFALSE;
+    }
 
     // Calaculate Telescope pointing position:
@@ -143,5 +160,8 @@
     pointpos = calc2.Calc(srcpos);
     if (pointpos.Zd()==0)
+    {
+        gLog << warn << "WARNING - Calculation of moon shadow's wobble position failed." << endl;
         return kFALSE;
+    }
 
     return kTRUE;
Index: trunk/MagicSoft/Cosy/main/MTracking.cc
===================================================================
--- trunk/MagicSoft/Cosy/main/MTracking.cc	(revision 9557)
+++ trunk/MagicSoft/Cosy/main/MTracking.cc	(revision 9558)
@@ -218,5 +218,5 @@
 }
 
-void MTracking::UpdateSlalib(SlaPlanets &sla)
+Bool_t MTracking::UpdateSlalib(SlaPlanets &sla)
 {
     if (fTrackType<0)
@@ -240,6 +240,8 @@
 
         const ZdAz za = sla.GetZdAzRad();
-        if (moon.CalcPosition(za, srcpos, pointpos))
-            sla.Set(pointpos);
+        if (!moon.CalcPosition(za, srcpos, pointpos))
+            return kFALSE;
+
+        sla.Set(pointpos);
 
         // Ra/Dec, Zd/Az from pointpos
@@ -261,8 +263,9 @@
 }
 
-void MTracking::UpdateSlalib(Double_t dt)
+Bool_tMTracking::UpdateSlalib(Double_t dt)
 {
     fSlalib.Now(dt);
-    UpdateSlalib(fSlalib);
+    if (!UpdateSlalib(fSlalib))
+        return kFALSE;
 
     fCosy->fRaDec     = fSlalib.GetRaDecRad();
@@ -273,5 +276,5 @@
 {
     sla.SetMjd(mjd);
-    UpdateSlalib(sla);
+    return UpdateSlalib(sla);
 }
 
@@ -342,5 +345,6 @@
 {
     // Position to corrent nominal position
-    UpdateSlalib();
+    if (!UpdateSlalib())
+        return;
 
     if (!Move())
@@ -362,5 +366,9 @@
 
     // Get current nominal local position
-    UpdateSlalib();
+    if (!UpdateSlalib())
+    {
+        fCosy->StopMovement();
+        return;
+    }
 
     ZdAz pos = fSlalib.GetZdAzRad();
@@ -402,5 +410,6 @@
         // Request Target position for Now+dt
         //
-        UpdateSlalib(dt);
+        if (!UpdateSlalib(dt))
+            break;
 
         //
