Index: trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 596)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 597)
@@ -5,4 +5,5 @@
 
 #include "MParContainer.h"
+#include "MCamNeighbor.h"
 
 #endif // __CINT__
Index: trunk/MagicSoft/Mars/manalysis/MNphotEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MNphotEvent.cc	(revision 596)
+++ trunk/MagicSoft/Mars/manalysis/MNphotEvent.cc	(revision 597)
@@ -6,4 +6,5 @@
 
 #include "MCamGeom.h"
+#include "MCamNeighbor.h"
 #include "MCamDisplay.h"
 #include "MHexagon.h"
@@ -16,4 +17,5 @@
   //  default constructor
   fPixId    = pix ; 
+  fIsUsed   = kTRUE ; 
   fPhot     = phot ; 
   fErrPhot  = errphot ; 
@@ -23,4 +25,5 @@
 {
   fPixId    = pix ; 
+  fIsUsed   = kTRUE ; 
   fPhot     = phot ; 
   fErrPhot  = errphot ; 
@@ -30,6 +33,13 @@
 { 
   //   information about a pixel
-  cout << "MNphotPix: Pixel: "<< fPixId 
-       << "  Nphot= " << fPhot
+  cout << "MNphotPix: Pixel: "<< fPixId ; 
+  
+  if ( fIsUsed == kTRUE )
+    cout << "   Used " ; 
+  else 
+    if ( fIsUsed == kFALSE )
+      cout << " UnUsed " ;
+
+  cout << "  Nphot= " << fPhot
        << "  Error(Nphot) = " << fErrPhot
        << endl ; 
@@ -54,4 +64,6 @@
   fPixels = new TClonesArray ("MNphotPix", 577) ;
   
+  fNN = new MCamNeighbor() ; 
+
   fPixels->Clear() ; 
 }
@@ -59,5 +71,5 @@
 void MNphotEvent::Draw(Option_t* option) 
 {
-  //
+  //   FIXME!!!
   // 
   
@@ -102,5 +114,88 @@
     }
 }
-  
+
+void MNphotEvent::CleanLevel1()
+{ 
+  //  This method looks for all pixels with an entry (photons) 
+  //  that is three times bigger than the noise of the pixel
+  
+  Float_t entry, noise ; 
+  
+  // first look for pixels above some noise level 
+  
+  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
+    {
+      entry = ((MNphotPix *) fPixels->At(il))->GetPhotons() ; 
+      noise =  3 * ((MNphotPix *) fPixels->At(il))->GetErrorPhot() ; 
+      
+      if (entry < 3 * noise ) 
+	((MNphotPix *) fPixels->At(il))->SetPixelUnused() ; 
+	
+    }
+} 
+
+void MNphotEvent::CleanLevel2()
+{
+  //  check if the  survived pixel have a neighbor, that also 
+  //  survived
+  
+  Int_t id, id2 ; 
+  Int_t itest ;
+ 
+  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
+    {
+      if ( ((MNphotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE )
+	{ 
+	  id = ((MNphotPix *) fPixels->At(il))->GetPixId() ; 
+	  
+	  itest = 0 ; 
+	  for (Int_t in=0 ; in < 6 ; in++ ) { 
+	     
+	    id2 = fNN->GetNN(id, in ) ; 
+	    
+	    if ( PixelIsUsed(id2) == kTRUE ) 
+	      cout << " hulibu " << id << "/" << id2 << endl ;  
+	    
+	    
+	  } 
+	} 
+    } 
+} 
+
+Bool_t MNphotEvent::PixelExist(Int_t id ) 
+{ 
+  //   Checks if in the pixel list is an entry with pixel id
+  
+  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
+    {
+      if ( id == ((MNphotPix *) fPixels->At(il))->GetPixId() ) { 
+	
+	cout << " PixelExist " << il ; 
+	return kTRUE ; 
+      } 
+    } 
+
+  return kFALSE ; 
+
+} 
+
+Bool_t MNphotEvent::PixelIsUsed(Int_t id ) 
+{ 
+  //   Checks if in the pixel list is an entry with pixel id
+  
+  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
+    {
+      if ( id == ((MNphotPix *) fPixels->At(il))->GetPixId() && 
+	   ((MNphotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) { 
+	
+	cout << " PixelIsUsed  " << il ; 
+	return kTRUE ; 
+      } 
+    } 
+
+  return kFALSE ; 
+
+} 
+
 Int_t MNphotEvent::GetPixelId(Int_t i ) 
 { 
@@ -108,4 +203,9 @@
 } 
 
+Bool_t  MNphotEvent::IsPixelUsed(Int_t i ) 
+{
+  return ( ( (MNphotPix *) fPixels->At(i))->IsPixelUsed() ) ;
+}
+ 
 Float_t MNphotEvent::GetPhotons(Int_t i ) 
 { 
Index: trunk/MagicSoft/Mars/manalysis/MNphotEvent.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MNphotEvent.h	(revision 596)
+++ trunk/MagicSoft/Mars/manalysis/MNphotEvent.h	(revision 597)
@@ -10,4 +10,5 @@
 class TClonesArray ; 
 class TObjArray ; 
+class MCamNeighbor ; 
 
 class MNphotPix : public TObject
@@ -16,7 +17,8 @@
   
   Int_t    fPixId     ;  //   the pixel Id
+  Bool_t   fIsUsed    ;  //   the pixel is used for calculations --> kTRUE
   Float_t  fPhot      ;  //   The number of Cerenkov photons 
   Float_t  fErrPhot   ;  //   the error of fPhot
-
+ 
  public:
   
@@ -42,4 +44,21 @@
   void SetPixelContent(Int_t pix , Float_t phot , Float_t errphot ) ; 
 
+  Bool_t IsPixelUsed() 
+    { 
+      return fIsUsed ; 
+    }  
+  
+  void SetPixelUnused() 
+    { 
+      fIsUsed = kFALSE ; 
+    }  
+  
+  void SetPixelUsed() 
+    { 
+      fIsUsed = kTRUE ; 
+    }  
+  
+  
+  
   ClassDef(MNphotPix, 1)  // Cerenkov Photons class for the pixel
 } ; 
@@ -57,4 +76,7 @@
   Int_t            fNbPixels ;   // 
   TClonesArray     *fPixels   ;  //
+
+
+  MCamNeighbor     *fNN  ;   //!   the class with the information about neighbors
   
  public:
@@ -72,5 +94,12 @@
   void Print() ; 
 
+  void CleanLevel1() ; 
+  void CleanLevel2() ; 
+  
+  Bool_t PixelExist( Int_t id ) ; 
+  Bool_t PixelIsUsed( Int_t id ) ; 
+ 
   Int_t GetPixelId(Int_t i ) ; 
+  Bool_t  IsPixelUsed(Int_t i ) ;
   Float_t GetPhotons(Int_t i ) ; 
   Float_t GetErrorPhot(Int_t i ) ; 
@@ -80,5 +109,5 @@
  
   ClassDef(MNphotEvent, 1)    // class for Nphotons Events
-};
+}; 
 
 #endif
Index: trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.cc	(revision 596)
+++ trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.cc	(revision 597)
@@ -27,4 +27,13 @@
 
     fFileName = fname;
+
+    // set the pedestals to default values 
+    
+    for (Int_t i = 0; i<127; i++ )
+      {
+	
+	fPedest[i] = 1.5  ; 
+      } 
+    
 }
 
@@ -67,4 +76,9 @@
     return kFALSE ; 
 
+  // if the first number is negativ this is the pedestal line
+  
+  if (dummyI < 0 )
+    ReadPedestal() ; 
+
   fscanf ( fInputfile, "%d", &dummyI ) ; 
   fscanf ( fInputfile, "%d", &dummyI ) ; 
@@ -78,7 +92,6 @@
       fscanf ( fInputfile, "%f", &dummyF ) ;
       
-      
       if ( dummyF > 0.0 ) { 
-	fNphot->AddPixel(i, dummyF, sqrt(dummyF) ) ; 
+	fNphot->AddPixel(i, dummyF, fPedest[i] ) ; 
       } 
       
@@ -94,2 +107,32 @@
 }
 
+
+void MReadCT1Ascii::ReadPedestal() 
+{ 
+  cout << " Read in the Pedestals " << endl ; 
+  Int_t   dummyI ; 
+  Float_t dummyF ; 
+  
+  // the next for values are for dummy 
+  fscanf ( fInputfile, "%d", &dummyI ) ; 
+  fscanf ( fInputfile, "%d", &dummyI ) ; 
+  fscanf ( fInputfile, "%d", &dummyI ) ; 
+  fscanf ( fInputfile, "%d", &dummyI ) ; 
+
+  //    read in the next 127 numbers as the pedestals
+
+  for (Int_t i = 0; i<127; i++ )
+    {
+      fscanf ( fInputfile, "%f", &dummyF ) ;
+      
+      if ( dummyF > 0.0 ) { 
+	fPedest[i] = dummyF ; 
+      } 
+      
+    }
+
+  fscanf ( fInputfile, "%d", &dummyI ) ; 
+
+
+} 
+
Index: trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.h	(revision 596)
+++ trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.h	(revision 597)
@@ -17,4 +17,6 @@
   MNphotEvent *fNphot ; //! the data container for all data. 
 
+  Float_t fPedest[127] ; //!
+
  public:
   MReadCT1Ascii(const char *filename, 
@@ -26,6 +28,9 @@
   Bool_t PostProcess();
   
+  void   ReadPedestal() ; 
+
   ClassDef(MReadCT1Ascii, 1)	// Reads the CT1 data file
 };
-    
+
 #endif
+
