Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2329)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2330)
@@ -1,3 +1,11 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/09/12: Thomas Bretz
+ 
+   * mimage/MHillasSrc.cc:
+     - fixed the NaN-problem in the calculation of Alpha. More 
+       information can be found in the comments there.
+
+
 
  2003/09/10: Thomas Bretz
Index: /trunk/MagicSoft/Mars/mimage/MHillasSrc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHillasSrc.cc	(revision 2329)
+++ /trunk/MagicSoft/Mars/mimage/MHillasSrc.cc	(revision 2330)
@@ -125,9 +125,19 @@
     // *OLD* const Double_t arg = (sy-tand*sx) / (dist*sqrt(tand*tand+1));
     // *OLD* fAlpha = asin(arg)*kRad2Deg;
-
+    //
     const Double_t arg1 = cd*sy-sd*sx;          // [mm]
     const Double_t arg2 = cd*sx+sd*sy;          // [mm]
 
-    fAlpha         = asin(arg1/dist)*kRad2Deg;  // [deg]
+    //
+    // Due to numerical uncertanties in the calculation of the
+    // square root (dist) and arg1 it can happen (in less than 1e-5 cases)
+    // that the absolute value of arg exceeds 1. Because this uncertainty
+    // results in an Delta Alpha which is still less than 1e-3 we don't care
+    // about this uncertainty in general and simply set values which exceed
+    // to 1 saving its sign.
+    //
+    const Double_t arg = arg1/dist;
+    fAlpha = TMath::Abs(arg)>1 ? TMath::Sign(90., arg) : asin(arg)*kRad2Deg;  // [deg]
+
     fCosDeltaAlpha = arg2/dist;                 // [1]
     fDist          = dist;                      // [mm]
