Index: trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 5429)
+++ trunk/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 6338)
@@ -53,4 +53,5 @@
 
 #include <TClass.h>     // IsA()->New()
+#include <TArrayI.h>    // TArrayI
 #include <TVector2.h>   // TVector2
 
@@ -69,5 +70,5 @@
 //
 MGeomCam::MGeomCam()
-    : fNumPixels(0), fCamDist(0), fConvMm2Deg(0), fMaxRadius(1), fMinRadius(1)
+    : fNumPixels(0), fCamDist(0), fConvMm2Deg(0), /*fPixels(1000),*/ fMaxRadius(1), fMinRadius(1)
 {
     fName  = "MGeomCam";
@@ -302,5 +303,8 @@
         MGeomCam *cam = new MGeomCam(fNumPixels, fCamDist);
         for (UInt_t i=0; i<fNumPixels; i++)
-            (*this)[i].Copy((*cam)[i]);
+        {
+            //if (fPixels.UncheckedAt(i))
+                (*this)[i].Copy((*cam)[i]);
+        }
         cam->InitGeometry();
         return cam;
@@ -335,24 +339,67 @@
 }
 
-/*
-void MGeomCam::Streamer(TBuffer &R__b)
-{
-   // Stream an object of class MGeomCam.
-
-    if (R__b.IsReading())
-    {
-        MGeomCam::Class()->ReadBuffer(R__b, this);
-
-        UInt_t R__s, R__c;
-        Version_t R__v = b.ReadVersion(&R__s, &R__c);
-        if (R__v > 2) {
-            MGeomCam::Class()->ReadBuffer(b, this, R__v, R__s, R__c);
-
-        Version_t v = MGeomCam::Class()->GetClassVersion();
-   }
-   else
-   {
-       MGeomCam::Class()->WriteBuffer(R__b, this);
-   }
-}
-*/
+// --------------------------------------------------------------------------
+//
+// Add all indices to arr of all neighbors around pix in a radius r.
+// The center pixel is also returned.
+//
+void MGeomCam::GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const
+{
+    arr.Set(GetNumPixels());
+
+    Int_t n = 0;
+
+    for (unsigned int i=0; i<GetNumPixels(); i++)
+    {
+        if (r>TMath::Hypot(pix.GetX()-(*this)[i].GetX(), pix.GetY()-(*this)[i].GetY()))
+            arr[n++] = i;
+    }
+
+    arr.Set(n);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add all indices to arr of all neighbors around idx in a radius r.
+// The center pixel is also returned.
+//
+void MGeomCam::GetNeighbors(TArrayI &arr, UInt_t idx, Float_t r) const
+{
+    if (idx>=GetNumPixels())
+    {
+        arr.Set(0);
+        return;
+    }
+
+
+    const MGeomPix &pix = (*this)[idx];
+    GetNeighbors(arr, pix, r);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add all pixels to list of all neighbors around pix in a radius r.
+// The center pixel is also returned.
+//
+void MGeomCam::GetNeighbors(TList &arr, const MGeomPix &pix, Float_t r) const
+{
+    for (unsigned int i=0; i<GetNumPixels(); i++)
+    {
+        if (r>TMath::Hypot(pix.GetX()-(*this)[i].GetX(), pix.GetY()-(*this)[i].GetY()))
+            arr.Add(fPixels.UncheckedAt(i));
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Add all pixels to list of all neighbors around idx in a radius r.
+// The center pixel is also returned.
+//
+void MGeomCam::GetNeighbors(TList &arr, UInt_t idx, Float_t r) const
+{
+    if (idx>=GetNumPixels())
+        return;
+
+    const MGeomPix &pix = (*this)[idx];
+    GetNeighbors(arr, pix, r);
+}
Index: trunk/MagicSoft/Mars/mgeom/MGeomCam.h
===================================================================
--- trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 5429)
+++ trunk/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 6338)
@@ -13,4 +13,5 @@
 
 class TVector2;
+class TArrayI;
 class MGeomPix;
 
@@ -84,4 +85,9 @@
     }
 
+    void GetNeighbors(TArrayI &arr, UInt_t idx,          Float_t r) const;
+    void GetNeighbors(TList &arr,   UInt_t idx,          Float_t r) const;
+    void GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const;
+    void GetNeighbors(TList &arr,   const MGeomPix &pix, Float_t r) const;
+
     virtual void Print(Option_t *opt=NULL)   const;
 
