Index: trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 603)
+++ trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 653)
@@ -8,7 +8,6 @@
 #pragma link C++ class MCerPhotEvt; 
 
-#pragma link C++ class MReadCT1Ascii; 
-
-
+#pragma link C++ class MCT1ReadAscii;
+#pragma link C++ class MCT1Pedestals;
 
 #endif
Index: trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc	(revision 653)
+++ trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc	(revision 653)
@@ -0,0 +1,132 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCT1ReadAscii                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MCT1ReadAscii.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+#include "MCT1Pedestals.h"
+
+ClassImp(MCT1ReadAscii)
+
+MCT1ReadAscii::MCT1ReadAscii(const char *fname,
+			     const char *name, 
+			     const char *title)
+{
+    *fName  = name  ? name  : "MCT1ReadAscii";
+    *fTitle = title ? title : "Task to loop over events in CT1 ascii file";
+
+    //
+    // remember file name for opening the file in the preprocessor
+    //
+    fFileName = fname;
+}
+
+Bool_t MCT1ReadAscii::PreProcess(MParList *pList)
+{
+    //
+    // Preprocessing
+    //
+
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    fIn = new ifstream(fFileName);
+    if (!fIn->is_open())
+    {
+        *fLog << "Error: MCT1ReadAscii::PreProcess: Cannot open file." << endl;
+        return kFALSE;
+    }
+
+    //
+    //  look for the MCerPhotEvt class in the plist
+    //
+    fNphot = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fNphot)
+    {
+        *fLog << "MRawCT1Ascii::PreProcess - WARNING: MCerPhotEvt not found... creating." << endl;
+        fNphot = new MCerPhotEvt;
+        pList->AddToList(fNphot);
+    }
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fPedest = (MCT1Pedestals*)pList->FindObject("MCT1Pedestals");
+    if (!fPedest)
+    {
+        *fLog << "MRawCT1Ascii::PreProcess - WARNING: MCT1Pedestals not found... creating." << endl;
+        fPedest = new MCT1Pedestals;
+        pList->AddToList(fPedest);
+    }
+
+    return kTRUE;
+}
+
+Bool_t MCT1ReadAscii::Process()
+{
+    //
+    // read in a dummy number (event number)
+    //
+    Int_t dummyI;
+    *fIn >> dummyI;
+
+    if (fIn->eof())
+    {
+        *fLog << "MRawCT1Ascii::Process - Error: EOF reached." << endl;
+        return kFALSE;
+    }
+
+    //
+    // if the first number is negativ this is a pedestal line:
+    // read in pedestals
+    //
+    if (dummyI < 0)
+        fPedest->AsciiRead(*fIn);
+
+    //
+    // five unsused numbers
+    //
+    *fIn >> dummyI;
+    *fIn >> dummyI;
+    *fIn >> dummyI;
+    *fIn >> dummyI;
+
+    //
+    // clear the list of cerphot-events
+    //
+    fNphot->Clear();
+
+    //
+    // read in the number of cerenkov photons and add the 'new' pixel
+    // too the list with it's id, number of photons and error
+    //
+    for (Int_t i = 0; i<127; i++ )
+    {
+        Float_t dummyF;
+
+        *fIn >> dummyF;
+
+        if (dummyF > 0.0)
+            fNphot->AddPixel(i, dummyF, (*fPedest)[i]);
+    }
+
+    return kTRUE;
+}
+
+Bool_t MCT1ReadAscii::PostProcess()
+{
+    //
+    // close and delete the input stream
+    //
+    delete fIn;
+
+    return kTRUE;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h	(revision 653)
+++ trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.h	(revision 653)
@@ -0,0 +1,32 @@
+#ifndef MCT1READASCII_H
+#define MCT1READASCII_H
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MCerPhotEvt;
+class MCT1Pedestals;
+
+class MCT1ReadAscii : public MTask
+{
+private:
+    TString        fFileName;    //! the file name of the string
+    ifstream      *fIn;          //! the inputfile
+    MCerPhotEvt   *fNphot;       //! the data container for all data.
+    MCT1Pedestals *fPedest;      //! ct1 pedestals
+
+public:
+    MCT1ReadAscii(const char *filename,
+                  const char *name=NULL,
+                  const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MCT1ReadAscii, 1)	// Reads the CT1 data file
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 603)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 653)
@@ -2,62 +2,18 @@
 
 #include <math.h>
+#include <fstream.h>
+
+#include <TCanvas.h>
 #include <TClonesArray.h>
-#include <TCanvas.h>
-
-#include "MCamGeom.h"
+
+#include "MLog.h"
+#include "MGeomCam.h"
 #include "MCamNeighbor.h"
 #include "MCamDisplay.h"
 #include "MHexagon.h"
 
-ClassImp(MCerPhotPix)
 ClassImp(MCerPhotEvt)
 
-MCerPhotPix::MCerPhotPix(Int_t pix, Float_t phot  , Float_t errphot ) 
-{ 
-  //  default constructor
-  fPixId    = pix ; 
-  fIsUsed   = kTRUE ; 
-  fIsCore   = kFALSE ; 
-  fPhot     = phot ; 
-  fErrPhot  = errphot ; 
-} 
-
-void MCerPhotPix::SetPixelContent(Int_t pix, Float_t phot  , Float_t errphot)
-{
-  fPixId    = pix ; 
-  fIsUsed   = kTRUE ; 
-  fIsUsed   = kFALSE ; 
-  fPhot     = phot ; 
-  fErrPhot  = errphot ; 
-}
-
-void MCerPhotPix::Print() 
-{ 
-  //   information about a pixel
-  cout << "MCerPhotPix: Pixel: "<< fPixId ; 
-  
-  if ( fIsUsed == kTRUE )
-    cout << "   Used " ; 
-  else 
-    if ( fIsUsed == kFALSE )
-      cout << " UnUsed " ;
-
-  if ( fIsCore == kTRUE )
-    cout << "   Core " ; 
-  else 
-    if ( fIsCore == kFALSE )
-      cout << "        " ;
-
-  cout << "  Nphot= " << fPhot
-       << "  Error(Nphot) = " << fErrPhot
-       << endl ; 
-}
-
-// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-
-MCerPhotEvt::MCerPhotEvt(const char *name, const char *title ) 
+MCerPhotEvt::MCerPhotEvt(const char *name, const char *title ) : fType(0), fNbPixels(0)
 {
   //   the default constructor 
@@ -67,12 +23,10 @@
   *fTitle = name  ? name  : "(Number of Photon)-Event Information";
   
-  fType = 0 ; 
-  fNbPixels = 0 ; 
-  
   fPixels = new TClonesArray ("MCerPhotPix", 577) ;
-  
-  fNN = new MCamNeighbor() ; 
-
-  fPixels->Clear() ; 
+
+  //
+  // FIXME: is this really necessary?
+  //
+  fPixels->Clear();
 }
 
@@ -84,258 +38,283 @@
   MCamDisplay *disp = new MCamDisplay(fType)  ; 
   
-  disp->Draw( this ) ; 
-  
-  //  disp->Draw() ; 
-
-}
-
-
-
+  disp->DrawPhotNum(this) ;
+}
 
 Int_t MCerPhotEvt::GetNbPixels() 
 {
-  return fNbPixels ; 
+  return fNbPixels;
 } 
 
 void MCerPhotEvt::AddPixel(Int_t id, Float_t nph, Float_t err)
 {
-  TClonesArray &caP = *fPixels ;
-  new ( caP[fNbPixels++] ) MCerPhotPix( id, nph, err ) ;
-}
-
-void MCerPhotEvt::Clear() 
-{
-  fNbPixels = 0 ; 
-  fPixels->Clear() ; 
-}
-
-void MCerPhotEvt::Print() 
-{
-  cout << "MCerPhotEvt::Print()"  
-       << "Number of Pixels: " << fNbPixels
-       << "(" << fPixels->GetEntries() << ")" 
-       << endl ; 
-
-  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
-    {
-      ((MCerPhotPix *) fPixels->At(il))->Print() ; 
-    }
+    //
+    // add a new pixel to the list and increase the number
+    // of valid pixels in the list by one
+    //
+    (*fPixels)[fNbPixels++] = new MCerPhotPix( id, nph, err);
+}
+
+void MCerPhotEvt::Clear(Option_t *)
+{
+    //
+    // reset counter and delete netries in list.
+    //
+    fNbPixels = 0 ;
+    fPixels->Clear() ;
+}
+
+void MCerPhotEvt::Print(Option_t *)
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    *fLog << "MCerPhotEvt::Print()" << endl
+        << "Number of Pixels: " << fNbPixels
+        << "(" << entries << ")"
+        << endl ;
+
+    for (Int_t il=0; il<entries; il++ )
+        (*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
-  
-  Float_t entry, noise ; 
-  
-  // first look for pixels above some noise level 
-  
-  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
-    {
-      entry = ((MCerPhotPix *) fPixels->At(il))->GetPhotons() ; 
-      noise = ((MCerPhotPix *) fPixels->At(il))->GetErrorPhot() ; 
-      
-      if (entry < 3 * noise ) 
-	((MCerPhotPix *) fPixels->At(il))->SetPixelUnused() ; 
-	
-    }
-} 
+{
+    //
+    //  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
-  
-  Int_t id, id2 ; 
-  Int_t itest ;
- 
-  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
-    {
-      if ( ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE )
-	{ 
-	  id = ((MCerPhotPix *) fPixels->At(il))->GetPixId() ; 
-	  
-	  itest = 0 ; 
-	  for (Int_t in=0 ; in < 6 ; in++ ) { 
-	     
-	    id2 = fNN->GetNN(id, in ) ; 
-	    
-	    if (id2 >=0 ) { 
-	      if ( PixelIsUsed(id2) == kTRUE ) 
-		itest++ ; 
-	    }   
-	  } 
-	  
-	  // 
-	  //   check if no neighbor, then set unused 
-	  //
-	  if ( itest == 0 ) 
-	    { 
-	      ((MCerPhotPix *) fPixels->At(il))->SetPixelUnused() ; 
-	    }
-
-	} 
+    //
+    //  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)
+{
+    //
+    // Checks if in the pixel list is an entry with pixel id
+    //
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t il=0; il<entries; il++)
+    {
+        if (id == (*this)[il].GetPixId())
+            return kTRUE ;
+    }
+
+    return kFALSE ;
+} 
+
+Bool_t MCerPhotEvt::IsPixelUsed(Int_t id)
+{
+    //
+    //   Checks if in the pixel list is an entry with pixel id
+    //
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t il=0; il<entries; il++ )
+    {
+        MCerPhotPix &pix = (*this)[il];
+
+        if (id == pix.GetPixId() && pix.IsPixelUsed())
+            return kTRUE ;
+    }
+
+    return kFALSE ;
+} 
+
+Bool_t MCerPhotEvt::IsPixelCore(Int_t id)
+{
+    //
+    //   Checks if in the pixel list is an entry with pixel id
+    //
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t il=0; il<entries; il++ )
+    {
+        MCerPhotPix &pix = (*this)[il];
+
+        if ( id == pix.GetPixId() && pix.IsCorePixel())
+            return kTRUE ;
     } 
-  
-  // now we declare all pixels that survive as CorePixels
-  
-  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
-    {
-      if ( ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE )
-	{ 
-	  ((MCerPhotPix *) fPixels->At(il))->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. 
-  
-  Float_t entry, noise ; 
-  Int_t   id, id2 ; 
-  for (Int_t il=0; il<fPixels->GetEntries(); il++ ) 
-    {
-      if ( ((MCerPhotPix *) fPixels->At(il))->IsCorePixel() == kFALSE )
-	{  
-	  entry = ((MCerPhotPix *) fPixels->At(il))->GetPhotons() ; 
-	  noise = ((MCerPhotPix *) fPixels->At(il))->GetErrorPhot() ; 
-      
-	  if (entry > 2.5 * noise ) { 
-	    id = ((MCerPhotPix *) fPixels->At(il))->GetPixId()  ; 
-	    for (Int_t in=0 ; in < 6 ; in++ )
-	      { 
-		id2 = fNN->GetNN(id, in ) ; 
-		if (id2 >=0 ) 
-		  { 
-		    if ( PixelIsCore(id2) == kTRUE ) { 
-		      ((MCerPhotPix *) fPixels->At(il))->SetPixelUsed() ; 
-		      break ; 
-		    } 
-		  } 
-	      } 
-	  } 
-	} 
-    } 
-} 
-
-
-
-
-Bool_t MCerPhotEvt::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 == ((MCerPhotPix *) fPixels->At(il))->GetPixId() ) { 
-	
-	// cout << " PixelExist " << il ; 
-	return kTRUE ; 
-      } 
-    } 
-
-  return kFALSE ; 
-
-} 
-
-Bool_t MCerPhotEvt::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 == ((MCerPhotPix *) fPixels->At(il))->GetPixId() && 
-	   ((MCerPhotPix *) fPixels->At(il))->IsPixelUsed() == kTRUE ) { 
-	
-	// cout << " PixelIsUsed  " << il ; 
-	return kTRUE ; 
-      } 
-    } 
-
-  return kFALSE ; 
-
-} 
-
-Bool_t MCerPhotEvt::PixelIsCore(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 == ((MCerPhotPix *) fPixels->At(il))->GetPixId() && 
-	   ((MCerPhotPix *) fPixels->At(il))->IsCorePixel() == kTRUE ) { 
-	
-	return kTRUE ; 
-      } 
-    } 
-
-  return kFALSE ; 
-
-} 
-
-Int_t MCerPhotEvt::GetPixelId(Int_t i ) 
-{ 
-  return ( ( (MCerPhotPix *) fPixels->At(i))->GetPixId() ) ; 
-} 
-
-Bool_t  MCerPhotEvt::IsPixelUsed(Int_t i ) 
-{
-  return ( ( (MCerPhotPix *) fPixels->At(i))->IsPixelUsed() ) ;
-}
- 
-Float_t MCerPhotEvt::GetPhotons(Int_t i ) 
-{ 
-  return ( ( (MCerPhotPix *) fPixels->At(i))->GetPhotons() ) ; 
-}
- 
-Float_t MCerPhotEvt::GetErrorPhot(Int_t i ) 
-{ 
-  return ( ( (MCerPhotPix *) fPixels->At(i))->GetErrorPhot() ) ; 
-} 
-
-
-Float_t MCerPhotEvt::GetMinimumPhoton() 
-{ 
-  if ( fNbPixels <= 0 ) 
-    return -5. ; 
-  
-  Float_t minWert ; 
-  minWert = ((MCerPhotPix *) fPixels->At(0))->GetPhotons() ; 
-
-  Float_t testWert ; 
-
-  for ( Int_t i =0 ; i<fNbPixels ; i++ ) { 
-    testWert = ((MCerPhotPix *) fPixels->At(i))->GetPhotons() ; 
-    
-    if ( minWert >= testWert ) 
-      minWert = testWert ; 
-  }
-
-  return  minWert ;
-} 
-
-Float_t MCerPhotEvt::GetMaximumPhoton() 
-{ 
-  if ( fNbPixels <= 0 ) 
-    return 50. ; 
-  
-  Float_t maxWert ; 
-  maxWert = ((MCerPhotPix *) fPixels->At(0))->GetPhotons() ; 
-
-  Float_t testWert ; 
-
-  for ( Int_t i =0 ; i<fNbPixels ; i++ ) { 
-    testWert = ((MCerPhotPix *) fPixels->At(i))->GetPhotons() ; 
-    
-    if ( maxWert <= testWert ) 
-      maxWert = testWert ; 
-  }
-
-  return  maxWert ;
-} 
-
+
+    return kFALSE ;
+} 
+
+Float_t MCerPhotEvt::GetMinNumPhotons()
+{
+    //
+    // get the minimum number of photons of all valid pixels in the list
+    //
+    if (fNbPixels <= 0)
+        return -5. ;
+
+    Float_t minval = (*this)[0].GetNumPhotons();
+
+    Float_t testval;
+    for (Int_t i=1 ; i<fNbPixels; i++ )
+    {
+        testval = (*this)[i].GetNumPhotons();
+
+        if (testval < minval)
+            minval = testval;
+    }
+
+    return minval;
+}
+
+Float_t MCerPhotEvt::GetMaxNumPhotons()
+{
+    //
+    // get the maximum number of photons of all valid pixels in the list
+    //
+    if (fNbPixels <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetNumPhotons();
+
+    Float_t testval;
+    for (Int_t i=1; i<fNbPixels; i++)
+    {
+        testval = (*this)[i].GetNumPhotons();
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 603)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 653)
@@ -1,96 +1,32 @@
-#ifndef MNPHOTEVENT_H
-#define MNPHOTEVENT_H
+#ifndef MCERPHOTEVT_H
+#define MCERPHOTEVT_H
 
+#ifndef MAGIC_h
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include "TClonesArray.h"
+#endif
 #ifndef MPARCONTAINER_H
 #include "MParContainer.h"
 #endif
+#ifndef MCAMNEIGHBOR_H
+#include "MCamNeighbor.h"
+#endif
 
-#include <iostream>
-#include <TROOT.h>
-class TClonesArray ; 
-class TObjArray ; 
-class MCamNeighbor ; 
-
-class MCerPhotPix : public TObject
-{
- private:
-  
-  Int_t    fPixId     ;  //   the pixel Id
-  Bool_t   fIsUsed    ;  //   the pixel is used for calculations --> kTRUE
-  Bool_t   fIsCore    ;  //   the pixel is a Core pixel          --> kTRUE
-  Float_t  fPhot      ;  //   The number of Cerenkov photons 
-  Float_t  fErrPhot   ;  //   the error of fPhot
- 
- public:
-  
-  MCerPhotPix(Int_t pix = -9999, Float_t phot=0. , Float_t errphot=0.) ; 
-
-  void Print() ; 
-  
-  Int_t GetPixId() 
-    {
-      return fPixId ; 
-    }
-  
-  Float_t GetPhotons()
-    {
-      return fPhot ; 
-    }
-  
-  Float_t GetErrorPhot()
-    {
-      return fErrPhot ; 
-    }
-  
-  void SetPixelContent(Int_t pix , Float_t phot , Float_t errphot ) ; 
-
-  Bool_t IsPixelUsed() 
-    { 
-      return fIsUsed ; 
-    }  
-  
-  void SetPixelUnused() 
-    { 
-      fIsUsed = kFALSE ; 
-    }  
-  
-  void SetPixelUsed() 
-    { 
-      fIsUsed = kTRUE ; 
-    }  
-  
-  void SetCorePixel() 
-    { 
-      fIsCore = kTRUE ; 
-    } 
-
-  Bool_t IsCorePixel() 
-    { 
-      return fIsCore ; 
-    }  
-  
-  
-  ClassDef(MCerPhotPix, 1)  // Cerenkov Photons class for the pixel
-} ; 
-
-
-// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+class MCerPhotPix;
 
 class MCerPhotEvt : public MParContainer
 {
- private: 
+private:
 
-  Int_t            fType ;       // 
-  Int_t            fNbPixels ;   // 
-  TClonesArray     *fPixels   ;  //
+    Int_t         fType;
+    Int_t         fNbPixels;
+    TClonesArray *fPixels;
 
+    MCamNeighbor  fNN;   //! the class with the information about neighbors
 
-  MCamNeighbor     *fNN  ;   //!   the class with the information about neighbors
-  
- public:
-  
-  MCerPhotEvt(const char *name=NULL, const char *title=NULL) ; 
+public:
+  MCerPhotEvt(const char *name=NULL, const char *title=NULL) ;
 
   void Draw(Option_t* option = "" ) ; 
@@ -100,7 +36,7 @@
   void AddPixel(Int_t id, Float_t nph, Float_t err );
 
-  void Clear() ; 
+  void Clear(Option_t *opt=NULL) ;
 
-  void Print() ; 
+  void Print(Option_t *opt=NULL) ;
 
   void CleanLevel1() ; 
@@ -108,16 +44,13 @@
   void CleanLevel3() ; 
   
-  Bool_t PixelExist( Int_t id ) ; 
-  Bool_t PixelIsUsed( Int_t id ) ; 
-  Bool_t PixelIsCore( Int_t id ) ; 
+  Bool_t  IsPixelExisting( Int_t id ) ;
+  Bool_t  IsPixelUsed    ( Int_t id ) ;
+  Bool_t  IsPixelCore    ( 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 ) ; 
-  
-  Float_t GetMinimumPhoton()  ;  
-  Float_t GetMaximumPhoton()  ; 
- 
+  Float_t GetMinNumPhotons();
+  Float_t GetMaxNumPhotons();
+
+  MCerPhotPix &operator[](int i) { return *(MCerPhotPix*)(fPixels->At(i)); }
+
   ClassDef(MCerPhotEvt, 1)    // class for Nphotons Events
 }; 
@@ -125,3 +58,2 @@
 #endif
 
-
Index: trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.cc	(revision 603)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MReadCT1Ascii                                                           //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-
-#include "MReadCT1Ascii.h"
-
-
-#include <stdio.h>
-#include <iostream.h>
-#include <fstream.h>
-
-#include "MParList.h"
-#include "MCerPhotEvt.h"
-
-ClassImp(MReadCT1Ascii)
-
-MReadCT1Ascii::MReadCT1Ascii(const char *fname,
-			     const char *name, 
-			     const char *title)
-{
-    *fName  = name  ? name  : "MReadCT1Ascii";
-    *fTitle = title ? title : "Task to loop over events in CT1 ascii file";
-
-    // open the input stream
-
-    fFileName = fname;
-
-    // set the pedestals to default values 
-    
-    for (Int_t i = 0; i<127; i++ )
-      {
-	
-	fPedest[i] = 1.5  ; 
-      } 
-    
-}
-
-Bool_t MReadCT1Ascii::PreProcess(MParList *pList)
-{
-  // Preprocessing 
-
-  //  open the file cout << fFileName << endl ; 
-  
-  fInputfile = fopen( fFileName, "r" ) ; 
- 
-  if ( fInputfile == 0 ) 
-    return kFALSE ; 
-  
-  //  look for the MCerPhotEvt class in the plist
-
-    
-  fNphot = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
-  
-  if (!fNphot )
-    {
-      cout << "MRawCT1Ascii::PreProcess - WARNING: MCerPhotEvt not found... exit" << endl;
-      return kFALSE ; 
-    }
-
-  return kTRUE;
-}
-
-Bool_t MReadCT1Ascii::Process()
-{
-  fNphot->Clear() ; 
-  
-  Int_t   dummyI ; 
-  Float_t dummyF ; 
-
-  //    read in the first five numbers 
-
-  fscanf ( fInputfile, "%d", &dummyI ) ; 
-  if ( feof ( fInputfile ) != 0 ) 
-    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 ) ; 
-  fscanf ( fInputfile, "%d", &dummyI ) ; 
-  fscanf ( fInputfile, "%d", &dummyI ) ; 
-
-  //    read in the next 127 numbers as the pixels
-
-  for (Int_t i = 0; i<127; i++ )
-    {
-      fscanf ( fInputfile, "%f", &dummyF ) ;
-      
-      if ( dummyF > 0.0 ) { 
-	fNphot->AddPixel(i, dummyF, fPedest[i] ) ; 
-      } 
-      
-    }
-
-  return kTRUE;
-}
-
-Bool_t MReadCT1Ascii::PostProcess()
-{
-  fclose( fInputfile ) ;   
-  return kTRUE;
-}
-
-
-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 603)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#ifndef MREADCT1ASCII_H
-#define MREADCT1ASCII_H
-
-#ifndef MTASK_H
-#include "MTask.h"
-#endif
-
-class MCerPhotEvt ; 
-
-class MReadCT1Ascii : public MTask
-{
- private:
-  TString fFileName;  //! the file name of the string
-
-  FILE*   fInputfile ; //! the inputfile 
-
-  MCerPhotEvt *fNphot ; //! the data container for all data. 
-
-  Float_t fPedest[127] ; //!
-
- public:
-  MReadCT1Ascii(const char *filename, 
-		const char *name=NULL, 
-		const char *title=NULL);
-  
-  Bool_t PreProcess(MParList *pList);
-  Bool_t Process();
-  Bool_t PostProcess();
-  
-  void   ReadPedestal() ; 
-
-  ClassDef(MReadCT1Ascii, 1)	// Reads the CT1 data file
-};
-
-#endif
-
