Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 653)
+++ trunk/MagicSoft/Mars/Changelog	(revision 654)
@@ -2,4 +2,28 @@
 
  2000/03/01: Thomas Bretz
+
+ * Makefile: added headers to dependencies
+ 
+ * Makefile.rules: added headers to dependencies
+ 
+ * merpp.cc: changed from pointers to objects, added compression level
+ 
+ * readraw.cc: removed unnecessary includes
+ 
+ * mbase/MArray*.*: changed all Int_t to UInt_t
+ 
+ * mbase/MLogManip.h: changed name of __DINF__ to dbginf
+ 
+ * mraw/MRawCrateData.[h,cc]: changed ifstream to istream
+ * mraw/MRawEvtHeader.[h,cc]: dito
+ * mraw/MRawRunHeader.[h,cc]: dito
+
+ * mraw/MRawEvtData.cc: changed the reading, which speeds up merpp by 
+   a factor of 10
+   
+ * mraw/MRawEvtData.h: added flag to InitArrays and DeletePixels 
+   (not yet used)
+
+ * mraw/MRawFileRead.h: removed pParList from parameter list
  
  * manalysis/AnalysisLinkDef.h
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 653)
+++ trunk/MagicSoft/Mars/Makefile	(revision 654)
@@ -54,9 +54,9 @@
 
 # Use $(CXX) -v ... for a more verbose output
-$(PROGRAMS): $(LIBRARIES) $(OBJS) MCint.o $(PROGRAMS:=.o) 
+$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o $(PROGRAMS:=.o) 
 	@echo " Linking $@ ..." 
 	$(CXX) $(CXXFLAGS) $@.o $(OBJS) $(MARS_LIB) MCint.o $(ROOTGLIBS) -o $@
 
-$(SOLIB): $(LIBRARIES) $(OBJS) MCint.o
+$(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o
 	@echo " Linking $(SOLIB) ..."
 	$(CXX) -shared $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
Index: trunk/MagicSoft/Mars/Makefile.rules
===================================================================
--- trunk/MagicSoft/Mars/Makefile.rules	(revision 653)
+++ trunk/MagicSoft/Mars/Makefile.rules	(revision 654)
@@ -4,5 +4,5 @@
         -f Makefile.depend 2> kk.kk ; cat kk.kk
 
-$(LIB): $(OBJS) $(CINT)Cint.o
+$(LIB): $(OBJS) $(HEADERS) $(CINT)Cint.o
 	@echo " - Building Library lib$(LIB) ... "
 	$(AR) $(LIB) *.o
Index: trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.cc	(revision 654)
+++ trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.cc	(revision 654)
@@ -0,0 +1,53 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCT1Pedestals                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1Pedestals.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+
+ClassImp(MCT1Pedestals)
+
+MCT1Pedestals::MCT1Pedestals(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MCT1Pedestals";
+    *fTitle = title ? title : "Storage container for CT1 Pedestals";
+
+    //
+    // set the pedestals to default values
+    //
+    for (Int_t i = 0; i<127; i++ )
+        fPedest[i] = 1.5;
+}
+
+void MCT1Pedestals::AsciiRead (ifstream &fin)
+{
+    *fLog << "MCT1Pedestals::AsciiRead: Reading Pedestals..." << endl;
+
+    Int_t   dummyI;
+    Float_t dummyF;
+
+    //
+    // skip the next 4 values
+    //
+    fin >> dummyF;
+    fin >> dummyF;
+    fin >> dummyF;
+    fin >> dummyF;
+
+    //
+    //    read in the next 127 numbers as the pedestals
+    //
+    for (Int_t i = 0; i<127; i++)
+    {
+        fin >> dummyF;
+
+        if (dummyF > 0.0)
+            fPedest[i] = dummyF;
+    }
+
+    fin >> dummyI;
+}
Index: trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.h	(revision 654)
+++ trunk/MagicSoft/Mars/manalysis/MCT1Pedestals.h	(revision 654)
@@ -0,0 +1,24 @@
+#ifndef MCT1PEDESTALS_H
+#define MCT1PEDESTALS_H
+
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+
+class MCT1Pedestals : public MParContainer
+{
+private:
+    Float_t fPedest[127]; //!
+
+public:
+    MCT1Pedestals(const char *name=NULL, const char *title=NULL);
+
+    Float_t &operator[](int i) { return fPedest[i]; }
+
+    void AsciiRead (ifstream &fin);
+
+    ClassDef(MCT1Pedestals, 1)	// Storage Container for CT1 Pedestals
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotPix.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotPix.cc	(revision 654)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotPix.cc	(revision 654)
@@ -0,0 +1,34 @@
+#include "MCerPhotPix.h"
+
+#include "MLog.h"
+
+ClassImp(MCerPhotPix)
+
+MCerPhotPix::MCerPhotPix(Int_t pix, Float_t phot, Float_t errphot ) :
+    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(Option_t *)
+{ 
+  //   information about a pixel
+    gLog << "MCerPhotPix: Pixel: "<< fPixId ;
+
+    gLog << (fIsUsed?"    Used ":"  Unused ");
+
+    gLog << (fIsCore?"  Core  ":"        ");
+
+    gLog << "  Nphot= " << fPhot
+        << "  Error(Nphot) = " << fErrPhot
+        << endl ;
+}
+
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 654)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 654)
@@ -0,0 +1,45 @@
+#ifndef MCERPHOTPIX_H
+#define MCERPHOTPIX_H
+
+#ifndef ROOT_TROOT
+#include <TROOT.h>
+#endif
+
+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 = -1, Float_t phot=0. , Float_t errphot=0.) ;
+
+  void Print(Option_t *opt = NULL) ;
+             
+  Int_t GetPixId() const        { return fPixId ;    }
+  Float_t GetNumPhotons() const { return fPhot ;     }
+  Float_t GetErrorPhot() const  { return fErrPhot ;  }
+
+  void SetPixelContent(Int_t pix, Float_t phot, Float_t errphot);
+
+  Bool_t IsPixelUsed() const    { return fIsUsed ;   }
+  void   SetPixelUnused()       { fIsUsed = kFALSE ; }
+  void   SetPixelUsed()         { fIsUsed = kTRUE ;  }
+
+  void SetCorePixel()           { fIsCore = kTRUE ;  }
+  Bool_t IsCorePixel() const    { return fIsCore ;   }
+
+  void SetNumPhotons(Float_t f) { fPhot    = f; }
+  void SetErrorPhot(Float_t f)  { fErrPhot = f; }
+  
+  ClassDef(MCerPhotPix, 1)  // Cerenkov Photons class for the pixel
+} ; 
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- trunk/MagicSoft/Mars/manalysis/Makefile	(revision 653)
+++ trunk/MagicSoft/Mars/manalysis/Makefile	(revision 654)
@@ -32,5 +32,7 @@
 
 SRCFILES = MCerPhotEvt.cc \
-	   MReadCT1Ascii.cc
+	   MCerPhotPix.cc \
+	   MCT1Pedestals.cc \
+	   MCT1ReadAscii.cc
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/mbase/MArray.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArray.h	(revision 653)
+++ trunk/MagicSoft/Mars/mbase/MArray.h	(revision 654)
@@ -21,9 +21,9 @@
 {
 protected:
-    Int_t fN; // Number of array elements
+    UInt_t fN; // Number of array elements
 
 public:
    MArray()                              { fN = 0; }
-   MArray(Int_t n)                       { fN = n; }
+   MArray(UInt_t n)                      { fN = n; }
    MArray(const MArray &a)               { fN = a.fN; }
    virtual ~MArray()                     { fN = 0; }
@@ -31,6 +31,6 @@
    MArray &operator=(const MArray &rhs)  { fN = rhs.fN; return *this; }
 
-   Int_t        GetSize() const          { return fN; }
-   virtual void Set(Int_t n) = 0;
+   UInt_t       GetSize() const          { return fN; }
+   virtual void Set(UInt_t n) = 0;
 
    ClassDef(MArray, 1)  //Abstract array base class for TObject derived Arrays
Index: trunk/MagicSoft/Mars/mbase/MArrayB.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArrayB.h	(revision 653)
+++ trunk/MagicSoft/Mars/mbase/MArrayB.h	(revision 654)
@@ -26,21 +26,22 @@
     MArrayB()
     {
-        fN = 0;
+        fN     = 0;
         fArray = NULL;
     }
 
-    MArrayB(Int_t n)
+    MArrayB(UInt_t n)
     {
-        fN = 0;
+        fN     = 0;
         fArray = NULL;
-        if (n > 0)
-            Set(n);
+
+        Set(n);
     }
 
-    MArrayB(Int_t n, Byte_t *array)
+    MArrayB(UInt_t n, Byte_t *array)
     {
         // Create TArrayC object and initialize it with values of array.
-        fN = 0;
+        fN     = 0;
         fArray = NULL;
+
         Set(n, array);
     }
@@ -53,5 +54,5 @@
     }
 
-    Int_t GetSize() const
+    UInt_t GetSize() const
     {
         return fN;
@@ -73,5 +74,5 @@
     }
 
-    void Adopt(Int_t n, Byte_t *array)
+    void Adopt(UInt_t n, Byte_t *array)
     {
         // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly
@@ -84,5 +85,5 @@
     }
 
-    void AddAt(Byte_t c, Int_t i)
+    void AddAt(Byte_t c, UInt_t i)
     {
         // Add char c at position i. Check for out of bounds.
@@ -90,5 +91,5 @@
     }
 
-    void AddAt(Byte_t *array, Int_t i, Int_t n)
+    void AddAt(Byte_t *array, UInt_t i, UInt_t n)
     {
         // Add char c at position i. Check for out of bounds.
@@ -96,5 +97,5 @@
     }
 
-    Byte_t     At(Int_t i)
+    Byte_t     At(UInt_t i)
     {
         return fArray[i];
@@ -111,5 +112,5 @@
     }
 
-    void Set(Int_t n)
+    void Set(UInt_t n)
     {
         // Set size of this array to n chars.
@@ -117,9 +118,11 @@
         // then the old array is deleted.
 
-        if (n < 0 || n==fN)
+        if (n==fN)
             return;
 
         Byte_t *temp = fArray;
-        if (n != 0)
+        if (n == 0)
+            fArray = 0;
+        else
         {
             fArray = new Byte_t[n];
@@ -132,8 +135,4 @@
             }
         }
-        else
-        {
-            fArray = 0;
-        }
 
         if (fN)
@@ -143,8 +142,8 @@
     }
 
-    void Set(Int_t n, Byte_t *array)
+    void Set(UInt_t n, Byte_t *array)
     {
         // Set size of this array to n chars and set the contents.
-        if (n < 0 || array == 0)
+        if (!array)
             return;
 
@@ -154,4 +153,5 @@
             fArray = 0;
         }
+
         fN = n;
 
@@ -165,5 +165,5 @@
     }
 
-    Byte_t &operator[](Int_t i)
+    Byte_t &operator[](UInt_t i)
     {
         return fArray[i];
Index: trunk/MagicSoft/Mars/mbase/MArrayS.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArrayS.h	(revision 653)
+++ trunk/MagicSoft/Mars/mbase/MArrayS.h	(revision 654)
@@ -25,20 +25,19 @@
     MArrayS()
     {
-        fN = 0;
+        fN     = 0;
         fArray = NULL;
     }
 
-    MArrayS(Int_t n)
+    MArrayS(UInt_t n)
     {
-        fN = 0;
+        fN     = 0;
         fArray = NULL;
-        if (n > 0)
-            Set(n);
+        Set(n);
     }
 
-    MArrayS(Int_t n, UShort_t *array)
+    MArrayS(UInt_t n, UShort_t *array)
     {
         // Create TArrayC object and initialize it with values of array.
-        fN = 0;
+        fN     = 0;
         fArray = NULL;
         Set(n, array);
@@ -52,5 +51,5 @@
     }
 
-    Int_t GetSize() const
+    UInt_t GetSize() const
     {
         return fN;
@@ -72,5 +71,5 @@
     }
 
-    void Adopt(Int_t n, UShort_t *array)
+    void Adopt(UInt_t n, UShort_t *array)
     {
         // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly
@@ -83,5 +82,5 @@
     }
 
-    void AddAt(UShort_t c, Int_t i)
+    void AddAt(UShort_t c, UInt_t i)
     {
         // Add char c at position i. Check for out of bounds.
@@ -89,5 +88,5 @@
     }
 
-    UShort_t     At(Int_t i)
+    UShort_t     At(UInt_t i)
     {
         return fArray[i];
@@ -104,5 +103,5 @@
     }
 
-    void Set(Int_t n)
+    void Set(UInt_t n)
     {
         // Set size of this array to n chars.
@@ -110,9 +109,11 @@
         // then the old array is deleted.
 
-        if (n < 0 || n==fN)
+        if (n==fN)
             return;
 
         UShort_t *temp = fArray;
-        if (n != 0)
+        if (n == 0)
+            fArray = NULL;
+        else
         {
             fArray = new UShort_t[n];
@@ -125,8 +126,4 @@
             }
         }
-        else
-        {
-            fArray = NULL;
-        }
 
         if (fN)
@@ -136,8 +133,8 @@
     }
 
-    void Set(Int_t n, UShort_t *array)
+    void Set(UInt_t n, UShort_t *array)
     {
         // Set size of this array to n chars and set the contents.
-        if (n < 0 || array == 0)
+        if (!array)
             return;
 
@@ -158,5 +155,5 @@
     }
 
-    UShort_t &operator[](Int_t i)
+    UShort_t &operator[](UInt_t i)
     {
         return fArray[i];
Index: trunk/MagicSoft/Mars/mbase/MLogManip.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLogManip.h	(revision 653)
+++ trunk/MagicSoft/Mars/mbase/MLogManip.h	(revision 654)
@@ -53,5 +53,5 @@
 //
 #ifndef __CINT__
-#define __DINF__        __FILE__ << " " << __LINE__ << ": "
+#define dbginf        __FILE__ << " " << __LINE__ << ": "
 #endif
 //
@@ -63,5 +63,5 @@
 //
 #ifndef __CINT__
-#define DEBUG(lvl)      flush << debug(lvl) << __DINF__
+#define DEBUG(lvl)    flush << debug(lvl) << dbginf
 #endif
 
Index: trunk/MagicSoft/Mars/mbase/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 653)
+++ trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 654)
@@ -43,5 +43,5 @@
 {
     //
-    // open file
+    // open file and check if file is really open
     //
     fFile = new TFile(fFileName, "READ");
@@ -54,6 +54,8 @@
     }
 
+    //
+    // try to get the tree and check if it was found
+    //
     fTree = (TTree*)fFile->Get(fTreeName);
-
     if (!fTree)
     {
@@ -63,7 +65,17 @@
     }
 
+    //
+    // get number of events in this tree
+    //
     fNumEntries = (UInt_t)fTree->GetEntries();
+
+    //
+    // set pointer to first event
+    //
     fNumEntry   = 0;
 
+    //
+    // output logging information
+    //
     *fLog << "File: '" << fFileName << "'  Tree: '" << fTreeName;
     *fLog << "' with " << fNumEntries << " Entries opened." << endl;
Index: trunk/MagicSoft/Mars/merpp.cc
===================================================================
--- trunk/MagicSoft/Mars/merpp.cc	(revision 653)
+++ trunk/MagicSoft/Mars/merpp.cc	(revision 654)
@@ -43,10 +43,17 @@
     // check for the right usage of the program
     //
-    if (argc!=3)
+    if (argc<3 || argc>4)
     {
         gLog << "Sorry the usage is:" << endl;
-        gLog << "   merpp inputfile outputfile" << endl << endl;
+        gLog << "   merpp inputfile outputfile [compression level]" << endl << endl;
         return -1;
     }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    const char *kNamein   = argv[1];
+    const char *kNameout  = argv[2];
+    const int   kComprlvl = argc==4 ? atoi(argv[3]) : 9;
 
     //
@@ -58,16 +65,16 @@
     // check whether the given files are OK.
     //
-    if (gSystem->AccessPathName(argv[1], kFileExists))
+    if (gSystem->AccessPathName(kNamein, kFileExists))
     {
-        gLog << "Sorry, the file '" << argv[1] << "' doesn't exist." << endl;
+        gLog << "Sorry, the file '" << kNamein << "' doesn't exist." << endl;
         return -1;
     }
 
-    if (!gSystem->AccessPathName(argv[2], kFileExists))
-        gLog << "Warning: The file '" << argv[2] << "' exists." << endl;
+    if (!gSystem->AccessPathName(kNameout, kFileExists))
+        gLog << "Warning: The file '" << kNameout << "' exists." << endl;
     else
-        if (!gSystem->AccessPathName(argv[2], kWritePermission))
+        if (!gSystem->AccessPathName(kNameout, kWritePermission))
         {
-            gLog << "Sorry, you don't have write permission for '" << argv[2] << "'." << endl;
+            gLog << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
             return -1;
         }
@@ -77,23 +84,23 @@
     // and an (empty) list of tasks which should be executed
     //
-    MParList *plist  = new MParList;
+    MParList plist;
 
-    MTaskList *tasks = new MTaskList;
-    plist->AddToList(tasks);
+    MTaskList tasks;
+    plist.AddToList(&tasks);
 
-    MRawRunHeader *runheader = new MRawRunHeader;
-    plist->AddToList(runheader);
+    MRawRunHeader runheader;
+    plist.AddToList(&runheader);
 
-    MRawEvtHeader *evtheader = new MRawEvtHeader;
-    plist->AddToList(evtheader);
+    MRawEvtHeader evtheader;
+    plist.AddToList(&evtheader);
 
-    MRawEvtData *evtdata = new MRawEvtData;
-    plist->AddToList(evtdata);
+    MRawEvtData evtdata;
+    plist.AddToList(&evtdata);
 
-    MRawCrateArray *cratearray = new MRawCrateArray;
-    plist->AddToList(cratearray);
+    MRawCrateArray cratearray;
+    plist.AddToList(&cratearray);
 
-    MTime *evttime = new MTime("MRawEvtTime");
-    plist->AddToList(evttime);
+    MTime evttime("MRawEvtTime");
+    plist.AddToList(&evttime);
 
     //
@@ -102,8 +109,8 @@
     // be created by MRawFileRead::PreProcess
     //
-    MRawFileRead  *reader = new MRawFileRead(argv[1]);
-    MRawFileWrite *writer = new MRawFileWrite(argv[2], "RECREATE");
-    tasks->AddToList(reader);
-    tasks->AddToList(writer);
+    MRawFileRead  reader(kNamein);
+    MRawFileWrite writer(kNameout, "RECREATE", "Title", kComprlvl);
+    tasks.AddToList(&reader);
+    tasks.AddToList(&writer);
 
     //
@@ -114,5 +121,5 @@
     MEvtLoop magic;
 
-    magic.SetParList(plist);
+    magic.SetParList(&plist);
 
     //
Index: trunk/MagicSoft/Mars/mgui/GuiLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 653)
+++ trunk/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 654)
@@ -13,11 +13,9 @@
 
 #pragma link C++ class MHexagon;
-#pragma link C++ class MPixGeom; 
-#pragma link C++ class MCamGeom;
+#pragma link C++ class MGeomPix;
+#pragma link C++ class MGeomCam;
 #pragma link C++ class MCamNeighbor;
 
 #pragma link C++ class MCamDisplay;
 
-//#pragma link C++ class MDumpEvtHeader;
-
 #endif
Index: trunk/MagicSoft/Mars/mgui/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mgui/Makefile	(revision 653)
+++ trunk/MagicSoft/Mars/mgui/Makefile	(revision 654)
@@ -58,5 +58,6 @@
 	   MGPrototyp.cc \
            MHexagon.cc \
-	   MCamGeom.cc \
+           MGeomCam.cc \
+           MGeomPix.cc \
 	   MCamNeighbor.cc \
 	   MCamDisplay.cc
Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 654)
@@ -12,5 +12,5 @@
 }
 
-void MRawCrateData::ReadEvt(ifstream& fin)
+void MRawCrateData::ReadEvt(istream& fin)
 {
     //
Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 654)
@@ -42,5 +42,5 @@
     void Print(Option_t *t=NULL);
 
-    void ReadEvt(ifstream& fin);
+    void ReadEvt(istream& fin);
 
     ClassDef(MRawCrateData, 1) //Container to store the Raw CRATE DATA
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 654)
@@ -216,5 +216,5 @@
 }
 
-void MRawEvtData::DeletePixels()
+void MRawEvtData::DeletePixels(Bool_t flag)
 {
     //
@@ -222,5 +222,5 @@
     //
     DeleteArrays();
-    InitArrays();
+    InitArrays(flag);
 }
 
@@ -233,10 +233,12 @@
 }
 
-void MRawEvtData::InitArrays()
-{
-    fHiGainPixId       = new MArrayS(0); //UShort_t[0];
-    fLoGainPixId       = new MArrayS(0); //new UShort_t[0];
-    fHiGainFadcSamples = new MArrayB(0); //new Byte_t[0];
-    fLoGainFadcSamples = new MArrayB(0); //new Byte_t[0];
+void MRawEvtData::InitArrays(Bool_t flag)
+{
+    // const int npix = !flag ? 0 : fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
+
+    fHiGainPixId       = new MArrayS(0);//npix);
+    fLoGainPixId       = new MArrayS(0);//npix); 
+    fHiGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesHiGain());
+    fLoGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesLoGain());
 }
 
@@ -248,5 +250,4 @@
     //  Add to lo gains if lflag = 1
     //
-
     MArrayS *arrpix = lflag ? fLoGainPixId       : fHiGainPixId;
     MArrayB *arrsam = lflag ? fLoGainFadcSamples : fHiGainFadcSamples;
@@ -286,37 +287,5 @@
 }
 
-/*
-void MRawEvtData::AddPixelLo(UShort_t nOfPixel, TArrayC *data, int nr, int pos)
-{
-    //
-    // add the number of the new pixel to the array as last entry
-    //
-    fLoGainPixId->AddAt(nOfPixel, nr);
-
-    //
-    // add the new slices as last entries to array
-    //
-    fLoGainFadcSamples->AddAt((Byte_t*)data->GetArray(), pos,  data->GetSize());
-}
-
-void MRawEvtData::AddPixelHi(UShort_t nOfPixel, TArrayC *data, int nr, int pos)
-{
-    // check whether we got the right number of new samples
-    // if there are no samples already stored: this is the new number of samples
-    //
-    const Byte_t ns = data->GetSize();
-
-    //
-    // add the number of the new pixel to the array as last entry
-    //
-    fHiGainPixId->AddAt(nOfPixel, nr);
-
-    //
-    // add the new slices as last entries to array
-    //
-    fHiGainFadcSamples->AddAt((Byte_t*)data->GetArray(), arrsam->GetSize()-ns, ns);
-}
-*/
-void MRawEvtData::ReadEvt(ifstream &fin)
+void MRawEvtData::ReadEvt(istream &fin)
 {
     //
@@ -327,8 +296,23 @@
     const UShort_t nhi = fRunHeader->GetNumSamplesHiGain();
 
-    TArrayC lo(nlo);
-    TArrayC hi(nhi);
-
     const UShort_t npic = fRunHeader->GetNumPixInCrate();
+
+    //
+    // Enhance array by the size which we'll read now
+    //
+    Byte_t lo[nlo];
+    Byte_t hi[nhi];
+
+    const int npixhi = fHiGainPixId->GetSize();
+    const int npixlo = fLoGainPixId->GetSize();
+
+    fHiGainPixId->Set(npixhi+npic);
+    fLoGainPixId->Set(npixlo+npic);
+
+    const int nsamhi = fHiGainFadcSamples->GetSize();
+    const int nsamlo = fLoGainFadcSamples->GetSize();
+
+    fHiGainFadcSamples->Set(nsamhi+nhi*npic);
+    fLoGainFadcSamples->Set(nsamlo+nlo*npic);
 
     for (int i=0; i<npic; i++)
@@ -339,12 +323,19 @@
         const UShort_t npix = fRunHeader->GetPixAssignment(i);
 
-        fin.read((Byte_t*)hi.GetArray(), nhi);
-        AddPixel(npix, &hi, kFALSE);
+        //
+        //  This is to fill the data of one pixel to the MRawEvtHeader Class.
+        //  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
+        //  Add to lo gains if lflag = 1
+        //
+        fin.read(hi, nhi);
+        fHiGainPixId->AddAt(npix, npixhi+i);
+        fHiGainFadcSamples->AddAt(hi, nsamhi+i*nhi, nhi);
 
         // FIXME: Not implemented in the raw files yet
         //if (IsLoGainOn(i, j))
         //{
-        fin.read((Byte_t*)lo.GetArray(), nlo);
-        AddPixel(npix, &lo, kTRUE);
+        fin.read(lo, nlo);
+        fLoGainPixId->AddAt(npix, npixlo+i);
+        fLoGainFadcSamples->AddAt(lo, nsamlo+i*nlo, nlo);
         //}
     }
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 654)
@@ -27,5 +27,5 @@
     MArrayB *fLoGainFadcSamples;  // list of lo gain samples of all pixels (ordering: see fLoGainPixId)
 
-    void InitArrays();
+    void InitArrays(Bool_t flag=kFALSE);
     void DeleteArrays();
 
@@ -47,5 +47,5 @@
     void Draw (Option_t * = NULL);
 
-    void DeletePixels();
+    void DeletePixels(Bool_t flag=kFALSE);
     void AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag=kFALSE);
 
@@ -54,5 +54,5 @@
     Byte_t GetNumPixels() const;
 
-    void ReadEvt(ifstream &fin);
+    void ReadEvt(istream &fin);
 
     ClassDef(MRawEvtData, 1) //Container to store the raw Event Data
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 654)
@@ -169,5 +169,5 @@
     *fLog << "Number of Lo Gains On: " << fNumLoGainOn << endl;
 
-    for (int i=0; i<fPixLoGainOn->GetSize(); i++)
+    for (unsigned int i=0; i<fPixLoGainOn->GetSize(); i++)
     {
         for (int j=0; j<8; j++)
@@ -194,5 +194,5 @@
 }
 
-int MRawEvtHeader::ReadEvt(ifstream &fin)
+int MRawEvtHeader::ReadEvt(istream &fin)
 {
     //
@@ -220,5 +220,5 @@
 
     fNumLoGainOn = 0;
-    for (int i=0; i<fPixLoGainOn->GetSize(); i++)
+    for (unsigned int i=0; i<fPixLoGainOn->GetSize(); i++)
         for (int j=0; j<8; j++)
             if ((*fPixLoGainOn)[i] & (1<<j))
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 654)
@@ -46,5 +46,5 @@
   UShort_t GetTrigType() const { return fTrigType; }
 
-  int ReadEvt(ifstream& fin);
+  int ReadEvt(istream& fin);
 
   ClassDef(MRawEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 654)
@@ -24,4 +24,35 @@
 ClassImp(MRawFileRead)
 
+/*
+  ----------- please don't delete ------------
+#define kBUFSZ 1024
+
+class bifstream : public istream, public streambuf
+{
+private:
+    char fBuffer[kBUFSZ]; //!
+    FILE *fd;
+
+    int sync()
+    {
+        memset(fBuffer, 0, kBUFSZ);
+        return 0; 
+    }
+    int underflow()
+    {
+        int sz=fread(fBuffer, 1, kBUFSZ, fd);
+        setg(fBuffer, fBuffer, fBuffer+kBUFSZ);
+
+        return sz==kBUFSZ ? *(unsigned char*)fBuffer : EOF;//EOF;
+    }
+public:
+    bifstream(const char *name) : istream(this)
+    {
+        fd = fopen(name, "rb");
+        setbuf(fBuffer, kBUFSZ);
+    }
+};
+*/
+
 MRawFileRead::MRawFileRead(const char *fname, const char *name, const char *title)
 {
@@ -38,10 +69,14 @@
 }
 
-Bool_t MRawFileRead::PreProcess (MParList *pList)
+MRawFileRead::~MRawFileRead()
+{
+    delete fIn;
+}
+
+Bool_t MRawFileRead::PreProcess(MParList *pList)
 {
     //
     // remember the pointer to the parameter list fur further usage
     //
-    pParList = pList;
 
     //
@@ -103,5 +138,5 @@
     return kTRUE;
 }
-    
+
 Bool_t MRawFileRead::Process()
 {
@@ -112,5 +147,4 @@
     if (!fRawEvtHeader->ReadEvt(*fIn))
         return kFALSE;
-    //fRawEvtHeader->Print();
 
     //
@@ -135,12 +169,9 @@
     {
         fRawCrateArray->GetEntry(i)->ReadEvt(*fIn);
-        //fRawCrateArray->GetEntry(i)->Print();
 
         fRawEvtData->ReadEvt(*fIn);
     }
-    //fRawEvtData->Print();
 
     return kTRUE;
-
 }
 
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 654)
@@ -18,16 +18,15 @@
 {
 private:
-    MParList *pParList;
+    MRawRunHeader  *fRawRunHeader;  // run header information container to fill from file
+    MRawEvtHeader  *fRawEvtHeader;  // event header information container to fill from file
+    MRawEvtData    *fRawEvtData;    // raw evt header infomation container to fill from file
+    MRawCrateArray *fRawCrateArray; // crate information array container to fill from file
+    MTime          *fRawEvtTime;    // raw evt time information container to fill from file
 
-    MRawRunHeader  *fRawRunHeader;
-    MRawEvtHeader  *fRawEvtHeader;
-    MRawEvtData    *fRawEvtData;
-    MRawCrateArray *fRawCrateArray;
-    MTime          *fRawEvtTime;
-
-    ifstream *fIn; //!
+    ifstream      *fIn;            //! buffered input stream (file to read from)
 
 public:
     MRawFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
+    ~MRawFileRead();
 
     Bool_t PreProcess(MParList *pList);
Index: trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc	(revision 654)
@@ -33,5 +33,5 @@
 }
 
-void MRawRunHeader::ReadEvt(ifstream& fin)
+void MRawRunHeader::ReadEvt(istream& fin)
 {
     //
@@ -87,4 +87,5 @@
     // print run header information on screen
     //
+    *fLog << endl;
     *fLog << "MagicNumber:  0x" << hex << fMagicNumber << " - " << (fMagicNumber==0xc0c0?"OK":"Wrong!") << endl;
     *fLog << "Version:      " << dec << "Format=" << fFormatVersion << "  ";
Index: trunk/MagicSoft/Mars/mraw/MRawRunHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 653)
+++ trunk/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 654)
@@ -11,4 +11,5 @@
 #endif
 
+class TBuffer;
 class ifstream;
 class MArrayS;
@@ -77,5 +78,5 @@
     void Print(Option_t *t=NULL);
 
-    void ReadEvt(ifstream& fin);
+    void ReadEvt(istream& fin);
 
     ClassDef(MRawRunHeader, 1)	// storage container for general info
Index: trunk/MagicSoft/Mars/readraw.cc
===================================================================
--- trunk/MagicSoft/Mars/readraw.cc	(revision 653)
+++ trunk/MagicSoft/Mars/readraw.cc	(revision 654)
@@ -1,4 +1,2 @@
-//#include <iostream.h>
-
 #include <TSystem.h>
 
@@ -21,6 +19,4 @@
 #include "MMcEvt.hxx" 
 #include "MMcTrig.hxx" 
-
-#include "MGMarsMain.h"
 
 /////////////////////////////////////////////////////////////////////////////
