Index: trunk/MagicSoft/Cosy/caos/Led.cc
===================================================================
--- trunk/MagicSoft/Cosy/caos/Led.cc	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Led.cc	(revision 2278)
@@ -2,4 +2,6 @@
 
 #include <iostream.h>
+
+#include <TROOT.h>
 #include <TMath.h>
 
@@ -16,7 +18,7 @@
 {
     cout << "Led: ";
-    cout << "x="   << fX   << "+-" << fDx   << ", ";
-    cout << "y="   << fY   << "+-" << fDy   << ", ";
-    cout << "phi=" << fPhi << "+-" << fDphi << ", ";
+    cout << "x="   << Form("%5.1f", fX)   << "+-" << fDx   << ", ";
+    cout << "y="   << Form("%5.1f", fY)   << "+-" << fDy   << ", ";
+    cout << "phi=" << Form("%6.1f", fPhi) << "+-" << fDphi << ", ";
     cout << "mag=" << fMag << endl;
 }
Index: trunk/MagicSoft/Cosy/caos/Led.h
===================================================================
--- trunk/MagicSoft/Cosy/caos/Led.h	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Led.h	(revision 2278)
@@ -23,5 +23,5 @@
 public:
     Led(Double_t x=0, Double_t y=0, Double_t dx=0, Double_t dy=0, Double_t mag=0) :
-        fX(x), fY(y), fDx(dx), fDy(dy), fMag(mag)
+        fX(x), fY(y), fPhi(0), fDx(dx), fDy(dy), fDphi(-1), fMag(mag)
     {
     }
@@ -48,5 +48,7 @@
     Double_t GetMag() const  { return fMag; }
 
-        Bool_t IsSortable() const { return kTRUE; }
+    void AddOffset(Double_t dx, Double_t dy) { fX+=dx; fY+=dy; }
+
+    Bool_t IsSortable() const { return kTRUE; }
 
     void CalcPhi(const Ring &ring);
Index: trunk/MagicSoft/Cosy/caos/Leds.cc
===================================================================
--- trunk/MagicSoft/Cosy/caos/Leds.cc	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Leds.cc	(revision 2278)
@@ -12,4 +12,9 @@
 }
 
+void Leds::Add(Double_t x, Double_t y, Double_t dx, Double_t dy, Double_t mag)
+{
+    Set(GetEntriesFast(), x, y, dx, dy, mag);
+}
+
 void Leds::Print(Option_t *o=NULL) const
 {
Index: trunk/MagicSoft/Cosy/caos/Leds.h
===================================================================
--- trunk/MagicSoft/Cosy/caos/Leds.h	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Leds.h	(revision 2278)
@@ -19,5 +19,6 @@
     //
 
-    void Set(Int_t i, Double_t x, Double_t y, Double_t dx, Double_t dy, Double_t mag);
+    void Set(Int_t i, Double_t x, Double_t y, Double_t dx=0, Double_t dy=0, Double_t mag=0);
+    void Add(Double_t x, Double_t y, Double_t dx=0, Double_t dy=0, Double_t mag=0);
 
     //nst Led &GetLed(int i) const { return *(Led*)( (*this)[i] ); }
Index: trunk/MagicSoft/Cosy/caos/Ring.cc
===================================================================
--- trunk/MagicSoft/Cosy/caos/Ring.cc	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Ring.cc	(revision 2278)
@@ -9,4 +9,10 @@
 
 ClassImp(Ring);
+
+Ring::Ring() :
+    fX(0), fY(0), fR(0), fPhi(0), fDx(-1), fDy(-1), fDr(-1), fDphi(-1)
+{
+}
+
 
 bool Ring::CalcCenter(const Leds &leds, Int_t i, Int_t j, Int_t k)
@@ -53,5 +59,5 @@
     fY = ((m2*(leds(i).GetY() + leds(j).GetY()) +m1*m2*(leds(k).GetX() - leds(i).GetX())-m1*(leds(j).GetY() + leds(k).GetY()))/(m2-m1)/2);
 
-    fR = sqrt(sqr(fX-leds(i).GetX())+sqr(fY-leds(i).GetY()));
+    fR = hypot(fX-leds(i).GetX(), fY-leds(i).GetY());
 
     return kTRUE;
@@ -101,7 +107,7 @@
     }
 
-    fDx=sqrt(fDx)/(n-1);
-    fDy=sqrt(fDy)/(n-1);
-    fDr=sqrt(fDr)/(n-1);
+    fDx=sqrt(fDx)/n;
+    fDy=sqrt(fDy)/n;
+    fDr=sqrt(fDr)/n;
 }
 
@@ -109,8 +115,8 @@
 {
     cout << "Ring: ";
-    cout << "x="   << fX   << "+-" << fDx   << ", ";
-    cout << "y="   << fY   << "+-" << fDy   << ", ";
-    cout << "r="   << fR   << "+-" << fDr   << ", ";
-    cout << "phi=" << fPhi << "+-" << fDphi << endl;
+    cout << "x="   << Form("%5.1f", fX) << "+-" << Form("%.1f", fDx) << ", ";
+    cout << "y="   << Form("%5.1f", fY) << "+-" << Form("%.1f", fDy) << ", ";
+    cout << "r="   << Form("%5.1f", fR) << "+-" << Form("%.1f", fDr) << ", ";
+    cout << "phi=" << fPhi              << "+-" << fDphi << endl;
 }
 
Index: trunk/MagicSoft/Cosy/caos/Ring.h
===================================================================
--- trunk/MagicSoft/Cosy/caos/Ring.h	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Ring.h	(revision 2278)
@@ -32,4 +32,5 @@
 
 public:
+    Ring();
 
     Double_t GetX() const   { return fX; }
Index: trunk/MagicSoft/Cosy/caos/Rings.cc
===================================================================
--- trunk/MagicSoft/Cosy/caos/Rings.cc	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Rings.cc	(revision 2278)
@@ -8,9 +8,12 @@
 ClassImp(Rings);
 
-void Rings::CalcCenters(const Leds &leds)
+void Rings::CalcCenters(const Leds &leds, Float_t min, Float_t max)
 {
     Clear();
 
     int nPoints = leds.GetEntries();
+
+    if (nPoints<5)
+        return;
 
     int n=0;
@@ -27,4 +30,13 @@
                 }
 
+                //
+                //filter and remove rings with too big or too small radius
+                //
+                if ((min>=0&&ring.GetR()<min) || (max>=0&&ring.GetR()>max))
+                {
+                    RemoveAt(n);
+                    continue;
+                }
+
                 n++;
             }
@@ -33,7 +45,7 @@
 }
 
-void Rings::CalcRings(Leds &leds)
+void Rings::CalcRings(Leds &leds, Float_t min, Float_t max)
 {
-    CalcCenters(leds);
+    CalcCenters(leds, min, max);
 
     fCenter.InterpolCenters(*this);
@@ -51,6 +63,9 @@
 {
     cout << "Number of Rings: " << GetEntries() << endl;
-    TClonesArray::Print();
-    cout << "Center: " << endl;
-    fCenter.Print();
+    if (GetEntriesFast()>0)
+    {
+        TClonesArray::Print();
+        cout << "Center: " << endl;
+        fCenter.Print();
+    }
 }
Index: trunk/MagicSoft/Cosy/caos/Rings.h
===================================================================
--- trunk/MagicSoft/Cosy/caos/Rings.h	(revision 1882)
+++ trunk/MagicSoft/Cosy/caos/Rings.h	(revision 2278)
@@ -17,10 +17,10 @@
     Ring fCenter;
 
-    void CalcCenters(const Leds &leds);
+    void CalcCenters(const Leds &leds, Float_t min, Float_t max);
 
 public:
     Rings() : TClonesArray("Ring", 1) {}
 
-    void CalcRings(Leds &leds);
+    void CalcRings(Leds &leds, Float_t min=-1, Float_t max=-1);
 
     void Print(Option_t *o=NULL) const;
