Index: trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 713)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 715)
@@ -1,8 +1,3 @@
 #ifndef __CINT__
 
-#include <TClonesArray.h>
-
-#include "MParContainer.h"
-#include "MCamNeighbor.h"
-
 #endif // __CINT__
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 713)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 715)
@@ -8,7 +8,6 @@
 
 #include "MLog.h"
-#include "MCamNeighbor.h"
-#include "MCamDisplay.h"
 #include "MHexagon.h"
+#include "MCerPhotPix.h"
 
 ClassImp(MCerPhotEvt)
@@ -29,7 +28,4 @@
   fPixels->Clear();
 }
-
-#include "MGeomCamMagic.h"
-#include "MGeomCamCT1.h"
 
 void MCerPhotEvt::Draw(Option_t* option) 
@@ -79,152 +75,4 @@
         (*this)[il].Print();
 }
-
-/*
-void MCerPhotEvt::CleanLevel1()
-{
-    //
-    //  This method looks for all pixels with an entry (photons)
-    //  that is three times bigger than the noise of the pixel
-    //
-
-    const Int_t entries = fPixels->GetEntries();
-
-    //
-    // check the number of all pixels against the noise level and
-    // set them to 'unused' state if necessary
-    //
-    for (Int_t il=0; il<entries; il++ )
-    {
-        MCerPhotPix &pix = (*this)[il];
-
-        const Float_t entry = pix.GetNumPhotons();
-        const Float_t noise = pix.GetErrorPhot();
-
-        if (entry < 3 * noise )
-            pix.SetPixelUnused();
-    }
-}
-
-void MCerPhotEvt::CleanLevel2()
-{
-    //
-    //  check if the  survived pixel have a neighbor, that also
-    //  survived
-    //
-
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t il=0; il<entries; il++)
-    {
-        //
-        // get entry il from list
-        //
-        MCerPhotPix &pix = (*this)[il];
-
-        //
-        // check if pixel is in use, if not goto next pixel in list
-        //
-        if (!pix.IsPixelUsed())
-            continue;
-
-        //
-        // get pixel id of this entry
-        //
-        const Int_t id = pix.GetPixId() ;
-
-        //
-        // count number of next neighbors of this pixel which
-        // state is 'used'
-        //
-        Int_t itest = 0 ;
-        for (Int_t in=0 ; in < 6; in++ )
-        {
-            const Int_t id2 = fNN.GetNN(id, in) ;
-
-            if (id2 < 0)
-                continue;
-
-            if (IsPixelUsed(id2))
-                itest++ ;
-        }
-
-        //
-        // check if no next neighbor has the state 'used'
-        // set this pixel to 'unused', too.
-        //
-        if (itest==0)
-            pix.SetPixelUnused();
-    }
-
-    //
-    // now we declare all pixels that survive as CorePixels
-    //
-    for (Int_t il=0; il<entries; il++)
-    {
-        MCerPhotPix &pix = (*this)[il];
-
-        if (pix.IsPixelUsed())
-            pix.SetCorePixel();
-    }
-
-} 
-
-void MCerPhotEvt::CleanLevel3()
-{
-    //
-    //   Look for the boundary pixels around the core pixels
-    //   if a pixel has more than 2.5 sigma, and a core neigbor
-    //   it is declared as used.
-    //
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t il=0; il<entries; il++)
-    {
-        //
-        // get pixel as entry il from list
-        //
-        MCerPhotPix &pix = (*this)[il];
-
-        //
-        // if pixel is a core pixel go to the next pixel
-        //
-        if (pix.IsCorePixel())
-            continue;
-
-        //
-        // check the num of photons against the noise level
-        //
-        const Float_t entry = pix.GetNumPhotons();
-        const Float_t noise = pix.GetErrorPhot();
-
-        if (entry <= 2.5 * noise )
-            continue;
-
-        //
-        // get pixel id of this entry
-        //
-        const Int_t id = pix.GetPixId();
-
-        //
-        // check if the pixel's next neighbor is a core pixel.
-        // if it is a core pixel set pixel state to: used.
-        //
-        for (Int_t in=0; in<6 ; in++)
-        {
-            const Int_t id2 = fNN.GetNN(id, in);
-
-            if (id2 <0)
-                continue;
-
-            if (!IsPixelCore(id2))
-                continue;
-
-            pix.SetPixelUsed();
-
-            break ;
-        }
-    }
-}
-*/
 
 Bool_t MCerPhotEvt::IsPixelExisting(Int_t id)
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 713)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 715)
@@ -11,7 +11,4 @@
 #include "MParContainer.h"
 #endif
-#ifndef MCAMNEIGHBOR_H
-#include "MCamNeighbor.h"
-#endif
 
 class MCerPhotPix;
@@ -20,9 +17,6 @@
 {
 private:
-
-    UInt_t         fNumPixels;
+    UInt_t        fNumPixels;
     TClonesArray *fPixels;
-
-    MCamNeighbor  fNN;   //! the class with the information about neighbors
 
 public:
Index: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 713)
+++ trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 715)
@@ -5,7 +5,7 @@
 
 #include "MParList.h"
+#include "MGeomCam.h"
 #include "MCerPhotPix.h"
 #include "MCerPhotEvt.h"
-#include "MCamNeighbor.h"
 
 ClassImp(MImgCleanStd)
@@ -34,7 +34,7 @@
     // set them to 'unused' state if necessary
     //
-    for (Int_t il=0; il<entries; il++ )
-    {
-        MCerPhotPix &pix = (*fEvt)[il];
+    for (Int_t i=0; i<entries; i++ )
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
 
         const Float_t entry = pix.GetNumPhotons();
@@ -55,10 +55,10 @@
     const Int_t entries = fEvt->GetNumPixels();
 
-    for (Int_t il=0; il<entries; il++)
+    for (Int_t i=0; i<entries; i++)
     {
         //
         // get entry il from list
         //
-        MCerPhotPix &pix = (*fEvt)[il];
+        MCerPhotPix &pix = (*fEvt)[i];
 
         //
@@ -71,5 +71,5 @@
         // get pixel id of this entry
         //
-        const Int_t id = pix.GetPixId() ;
+        const Int_t id = pix.GetPixId();
 
         //
@@ -77,8 +77,11 @@
         // state is 'used'
         //
-        Int_t itest = 0 ;
-        for (Int_t in=0 ; in < 6; in++ )
+        MGeomPix   &gpix  = (*fCam)[id];
+        const Int_t nnmax = gpix.GetNumNeighbors();
+
+        Int_t cnt = 0;
+        for (Int_t j=0; j<nnmax; j++)
         {
-            const Int_t id2 = fNN.GetNN(id, in) ;
+            const Int_t id2 = gpix.GetNeighbor(j); //GetNN(id, in) ;
 
             if (id2 < 0)
@@ -86,5 +89,5 @@
 
             if (fEvt->IsPixelUsed(id2))
-                itest++ ;
+                cnt++;
         }
 
@@ -93,5 +96,5 @@
         // set this pixel to 'unused', too.
         //
-        if (itest==0)
+        if (cnt==0)
             pix.SetPixelUnused();
     }
@@ -100,7 +103,7 @@
     // now we declare all pixels that survive as CorePixels
     //
-    for (Int_t il=0; il<entries; il++)
-    {
-        MCerPhotPix &pix = (*fEvt)[il];
+    for (Int_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
 
         if (pix.IsPixelUsed())
@@ -119,10 +122,10 @@
     const Int_t entries = fEvt->GetNumPixels();
 
-    for (Int_t il=0; il<entries; il++)
+    for (Int_t i=0; i<entries; i++)
     {
         //
         // get pixel as entry il from list
         //
-        MCerPhotPix &pix = (*fEvt)[il];
+        MCerPhotPix &pix = (*fEvt)[i];
 
         //
@@ -150,7 +153,10 @@
         // if it is a core pixel set pixel state to: used.
         //
-        for (Int_t in=0; in<6 ; in++)
+        MGeomPix   &gpix  = (*fCam)[id];
+        const Int_t nnmax = gpix.GetNumNeighbors();
+
+        for (Int_t j=0; j<nnmax; j++)
         {
-            const Int_t id2 = fNN.GetNN(id, in);
+            const Int_t id2 = gpix.GetNeighbor(j);
 
             if (id2 <0)
@@ -173,10 +179,19 @@
     //  if not create one and add them to the list
     //
+    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
     fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
-    if (fEvt)
-        return kTRUE;
-
-    *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
-    return kFALSE;
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
 }
     
Index: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 713)
+++ trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 715)
@@ -8,8 +8,6 @@
 #include "MTask.h"
 #endif
-#ifndef MCAMNEIGHBOR_H
-#include "MCamNeighbor.h"
-#endif
 
+class MGeomCam;
 class MCerPhotEvt;
 
@@ -17,6 +15,5 @@
 {
 private:
-    MCamNeighbor  fNN;   //! the class with the information about neighbors
-
+    MGeomCam    *fCam;
     MCerPhotEvt *fEvt;
 
