Index: trunk/MagicSoft/Cosy/caos/Ring.cc
===================================================================
--- trunk/MagicSoft/Cosy/caos/Ring.cc	(revision 4892)
+++ trunk/MagicSoft/Cosy/caos/Ring.cc	(revision 7296)
@@ -20,13 +20,29 @@
 bool Ring::CalcCenter(const Leds &leds, Int_t i, Int_t j, Int_t k)
 {
+    if (leds.At(i)==NULL)
+    {
+        cout << "Ring::CalcCenter: Led i=" << i << " is NULL." << endl;
+        return kFALSE;
+    }
+    if (leds.At(j)==NULL)
+    {
+        cout << "Ring::CalcCenter: Led j=" << j << " is NULL." << endl;
+        return kFALSE;
+    }
+    if (leds.At(k)==NULL)
+    {
+        cout << "Ring::CalcCenter: Led k=" << k << " is NULL." << endl;
+        return kFALSE;
+    }
+
     Double_t h1 = leds(i).GetY()- leds(j).GetY();
 
     if (h1==0)
     {
-        Swap(&j, &k);
+        Swap(j, k);
         h1 = leds(i).GetY()- leds(j).GetY();
         if (h1==0)
         {
-            cout << "h1==0" <<endl;
+            cout << "Ring::CalcCenter: h1==0" <<endl;
             return kFALSE;
         }
@@ -37,9 +53,9 @@
     if (h2==0)
     {
-        Swap(&i, &j);
+        Swap(i, j);
         h2 = leds(j).GetY() - leds(k).GetY();
         if (h2==0)
         {
-            cout << "h2==0" << endl;
+            cout << "Ring::CalcCenter: h2==0" << endl;
             return kFALSE;
         }
@@ -54,5 +70,5 @@
     if (m2-m1==0)
     {
-        cout << "All three points in a row! (m2-m1==0)" << endl;
+        cout << "Ring::CalcCenter: All three points in a row! (m2-m1==0)" << endl;
         return kFALSE;
     }
