Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 665)
+++ trunk/MagicSoft/Mars/Changelog	(revision 666)
@@ -1,4 +1,4 @@
                                                                   -*-*- END -*-*-
- 2000/03/01: Thomas Bretz
+ 2000/03/02: Thomas Bretz
 
  * manalysis/Makefile, mdatacheck/Makefile, meventdisp/Makefile,
@@ -6,6 +6,22 @@
    new
    
- * mdatacheck/MFillAdcSpect.[h,cc]: 
-   changed high and low to hi and lo
+ * mbase/MParList.[cc,h]: 
+   Added FindCreateObj member function
+ 
+ * mbase/MReadTree.cc: 
+   changed to use FindCreateObj
+
+ * mdatacheck/MDumpEvtHeader.cc: 
+   removed fPixelIter from member list, changed cout to *fLog
+   
+ * mdatacheck/MFillAdcSpect.cc
+   removed fPixelIter from member list, changed cout to *fLog,
+   changed to use FindCreateObj, changed high and low to hi and lo
+   
+ * mdatacheck/MShowSpect.cc
+   changed cout to *fLog
+   
+ * mraw/MRawFileRead.cc:
+   changed to use FindCreateObj
    
  * mdatacheck/MGDisplayAdc.[h,cc]: 
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 665)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 666)
@@ -22,5 +22,5 @@
   void Print(Option_t *opt = NULL) ;
              
-  Int_t GetPixId() const        { return fPixId ;    }
+  Int_t   GetPixId() const      { return fPixId ;    }
   Float_t GetNumPhotons() const { return fPhot ;     }
   Float_t GetErrorPhot() const  { return fErrPhot ;  }
@@ -32,5 +32,5 @@
   void   SetPixelUsed()         { fIsUsed = kTRUE ;  }
 
-  void SetCorePixel()           { fIsCore = kTRUE ;  }
+  void   SetCorePixel()         { fIsCore = kTRUE ;  }
   Bool_t IsCorePixel() const    { return fIsCore ;   }
 
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 665)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 666)
@@ -18,4 +18,5 @@
 
 #include <TNamed.h>
+#include <TClass.h>
 
 #include "MLog.h"
@@ -111,4 +112,48 @@
 }
 
+MParContainer *MParList::FindCreateObj(const char *name)
+{
+    //
+    //  Find an object in the list.
+    //  'name' is the name of the object you are searching for.
+    //  If the object doesn't exist we try to create one from the
+    //  dictionary. If this isn't possible NULL is returned
+    //
+    MParContainer *pcont = (MParContainer*)FindObject(name);
+
+    if (pcont)
+        return pcont;
+
+    //
+    // if object is not existing in the list try to create one
+    //
+    *fLog << "MParList::CreateObject - Warning: '" << name << "' not found... creating." << endl;
+
+    //
+    // try to get class from root environment
+    //
+    TClass *cls = gROOT->GetClass(name);
+
+    if (!cls)
+    {
+        //
+        // if class is not existing in the root environment
+        //
+        *fLog << "MParList::CreateObject - Warning: Class '" << name << "' not existing in dictionary." << endl;
+        return NULL;
+    }
+
+    //
+    // create the container and add it to the list
+    //
+    pcont = (MParContainer*)cls->New();
+    AddToList(pcont);
+
+    //
+    //  Find an object in the list.
+    //  'name' is the name of the object you are searching for.
+    //
+    return pcont;
+}
 
 void MParList::Print(Option_t *t)
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 665)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 666)
@@ -40,5 +40,6 @@
     void SetLogStream(MLog *log);
 
-    TObject *FindObject(const char *name) const;
+    TObject       *FindObject(const char *name) const;
+    MParContainer *FindCreateObj(const char *name);
 
     void Print(Option_t *t = NULL);
Index: trunk/MagicSoft/Mars/mbase/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 665)
+++ trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 666)
@@ -101,34 +101,14 @@
         // check if object is existing in the list
         //
-        MParContainer *pcont = (MParContainer*)pList->FindObject(name);
+        MParContainer *pcont = pList->FindCreateObj(name);
 
         if (!pcont)
         {
             //
-            // if object is not existing in the list try to create one
+            // if class is not existing in the (root) environment
+            // we cannot proceed reading this branch
             //
-            *fLog << "MReadTree::PreProcess - WARNING: '" << name << "' not found... creating." << endl;
-
-            //
-            // try to get class from root environment
-            //
-            TClass *cls = gROOT->GetClass(name);
-
-            if (!cls)
-            {
-                //
-                // if class is not existing in the root environment
-                // we cannot proceed reading this branch
-                //
-                *fLog << "MReadTree::PreProcess - Warning: Class '" << name << "' not existing in dictionary. Branch skipped." << endl;
-                continue;
-            }
-
-            //
-            // create the container and add it to the list
-            //
-            pcont = (MParContainer*)cls->New();
-            *fLog << pcont << endl;
-            pList->AddToList(pcont);
+            *fLog << "MReadTree::PreProcess - Warning: Class '" << name << "' not existing in dictionary. Branch skipped." << endl;
+            continue;
         }
 
Index: trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 665)
+++ trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 666)
@@ -7,4 +7,7 @@
 #pragma link C++ class MShowSpect;
 #pragma link C++ class MHistosAdc;
+#pragma link C++ class MFillAdcSpect;
+
+#pragma link C++ class MDumpEvtHeader;
 
 #endif
Index: trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 665)
+++ trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 666)
@@ -1,53 +1,44 @@
 #include "MDumpEvtHeader.h"
 
-#include <iostream.h>
-
+#include "MLog.h"
+#include "MLogManip.h"
 #include "MParList.h"
 #include "MRawEvtHeader.h"
 #include "MRawEvtPixelIter.h"
 
-//ClassImp(MDumpEvtHeader)
+ClassImp(MDumpEvtHeader)
 
 Bool_t MDumpEvtHeader::PreProcess (MParList *pList)
 {
-  fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
-  if (!fRawEvtHeader)
+    fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+    if (!fRawEvtHeader)
     {
-      cout << "MRawFileRead::PreProcess - WARNING: MRawEvtHeader not found... creating." << endl;
-      return kFALSE ; 
-    }
-  
-  fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
-  
-  if (!fRawEvtData)
-    {
-      cout << "MRawFileRead::PreProcess - WARNING: MRawEvtData not found... creating." << endl;
-      return kFALSE ; 
+        *fLog << dbginf << " Error: MRawEvtHeader not found... exit." << endl;
+        return kFALSE ;
     }
 
-  fPixelIter = new MRawEvtPixelIter( fRawEvtData );
-  
-  return kTRUE ; 
+    fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvtData)
+    {
+        *fLog << dbginf << " Error: MRawEvtData not found... exit." << endl;
+        return kFALSE ;
+    }
 
+    return kTRUE ;
 } 
 
-    
 Bool_t MDumpEvtHeader::Process()
 {
   fRawEvtHeader->Print() ; 
 
-  //fRawEvtData->Print() ; 
+  MRawEvtPixelIter pixel( fRawEvtData );
 
-  fPixelIter->Reset() ; 
+  while ( pixel.Next() )
+  {
+      *fLog << " " << pixel.GetPixelId() ;
+  }
 
-  while ( fPixelIter->Next() )
-    { 
-      cout << " " << fPixelIter->GetPixelId() ; 
-      
-    } 
-
-  cout << endl ; 
+  *fLog << endl ;
   
   return kTRUE;
-
 } 
Index: trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 665)
+++ trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 666)
@@ -12,5 +12,4 @@
 class MRawEvtHeader;
 class MRawEvtData;
-class MRawEvtPixelIter;
 class MParList;
 
@@ -21,15 +20,11 @@
   MRawEvtData      *fRawEvtData;
 
-  MRawEvtPixelIter *fPixelIter ; 
-
- public:   
-  MDumpEvtHeader () { 
-    fRawEvtHeader = NULL ; 
-  } ; 
+ public:
+  MDumpEvtHeader () : fRawEvtHeader(NULL) { } ;
 
   Bool_t PreProcess(MParList *pList);
   Bool_t Process() ;
   
-  //  ClassDef(MDumpEvtHeader, 1)	// Task to read the raw data binary file
+  ClassDef(MDumpEvtHeader, 1)	// Class to dump the pixel ids of a raw evt to the screen
 
 };
Index: trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc	(revision 665)
+++ trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.cc	(revision 666)
@@ -1,6 +1,6 @@
 #include "MFillAdcSpect.h"
 
-#include <iostream.h>
-
+#include "MLog.h"
+#include "MLogManip.h"
 #include "MParList.h"
 #include "MHistosAdc.h"
@@ -8,16 +8,11 @@
 #include "MRawEvtPixelIter.h"
 
-//ClassImp(MFillAdcSpect)
+ClassImp(MFillAdcSpect)
 
-MFillAdcSpect::MFillAdcSpect (const char *name, const char *title)
+    MFillAdcSpect::MFillAdcSpect (const char *name, const char *title) : fRawEvtData(NULL)
 {
   *fName  = name  ? name  : "MFillAdcSpect";
   *fTitle = title ? title : "Task to fill the adc spectra with  raw data";
-  
-  fRawEvtData   = NULL ; 
-  fPixelIter    = NULL ; 
 }
-
-
 
 Bool_t MFillAdcSpect::PreProcess (MParList *pList)
@@ -25,20 +20,14 @@
   // connect the raw data with this task
   
-  fHistos = (MHistosAdc*)pList->FindObject("MHistosAdc");
-  if (!fHistos) 
-    {
-        cout << "MRawFileRead::PreProcess - WARNING: MHistosAdc not found... creating." << endl;
-        fHistos = new MHistosAdc;
-        pList->AddToList(fHistos);
-    }
+  fHistos = (MHistosAdc*)pList->FindCreateObj("MHistosAdc");
+  if (!fHistos)
+      return kFALSE;
 
-  fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  fRawEvtData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
   if (!fRawEvtData)
-    {
-        cout << "MRawFileRead::PreProcess - WARNING: MRawEvtData not found... exit." << endl;
-        return kFALSE;
-    }
-
-  fPixelIter = new MRawEvtPixelIter( fRawEvtData );
+  {
+      *fLog << dbginf << " Error: MRawEvtData not found... exit." << endl;
+      return kFALSE ;
+  }
 
   return kTRUE ; 
@@ -46,10 +35,9 @@
 } 
 
-    
 Bool_t MFillAdcSpect::Process()
 {
   //  loop over the pixels and fill the values in the histograms
   
-  fPixelIter->Reset() ; 
+  MRawEvtPixelIter pixel(fRawEvtData);
 
   const Int_t nhisamples = fRawEvtData->GetNumHiGainSamples() ;
@@ -58,16 +46,16 @@
   //  cout << "HighSamples " << iHighSamples ;
 
-  while ( fPixelIter->Next() )
+  while ( pixel.Next() )
     { 
       for (Int_t i=0 ; i<nhisamples ; i++ )
 	{ 
-	  fHistos->FillAdcHistHi ( fPixelIter->GetPixelId(),
-				     fPixelIter->GetHiGainFadcSamples()[i] );
+	  fHistos->FillAdcHistHi ( pixel.GetPixelId(),
+                                   pixel.GetHiGainFadcSamples()[i] );
 	}
 
       for (Int_t i=0 ; i<nlosamples ; i++ )
 	{ 
-	  fHistos->FillAdcHistLo ( fPixelIter->GetPixelId(),
-				    fPixelIter->GetLoGainFadcSamples()[i] );
+	  fHistos->FillAdcHistLo ( pixel.GetPixelId(),
+				   pixel.GetLoGainFadcSamples()[i] );
 	}
     } 
Index: trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h	(revision 665)
+++ trunk/MagicSoft/Mars/mdatacheck/MFillAdcSpect.h	(revision 666)
@@ -13,10 +13,8 @@
 class MHistosAdc;
 class MRawEvtData;
-class MRawEvtPixelIter;
 
 class MFillAdcSpect : public MTask {
  private:
   MRawEvtData      *fRawEvtData;
-  MRawEvtPixelIter *fPixelIter ; 
 
   MHistosAdc       *fHistos ; 
@@ -28,5 +26,5 @@
   Bool_t Process() ;
   
-  //  ClassDef(MFillAdcSpect, 1)	// Task to read the raw data binary file
+  ClassDef(MFillAdcSpect, 1)	// Task to fill a MHistosAdc Container with data
 
 };
Index: trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 665)
+++ trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 666)
@@ -1,6 +1,6 @@
 #include "MShowSpect.h"
 
-#include <iostream.h>
-
+#include "MLog.h"
+#include "MLogManip.h"
 #include "MParList.h"      // MParList
 #include "MGDisplayAdc.h"  // MGDisplayAdc
@@ -36,6 +36,6 @@
   if (!fHists)
     {
-      cout << "ERROR: MShowSpect::PreProc(): " << fHistName << " not found!" << endl;
-      return kFALSE;
+        *fLog << dbginf << " Error: MHistosAdc '" << fHistName << "' not found!" << endl;
+        return kFALSE;
     }
   
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 665)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 666)
@@ -84,43 +84,23 @@
     //  if not create one and add them to the list
     //
-    fRawRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    fRawRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader");
     if (!fRawRunHeader)
-    {
-        *fLog << "MRawFileRead::PreProcess - WARNING: MRawRunHeader not found... creating." << endl;
-        fRawRunHeader = new MRawRunHeader;
-        pList->AddToList(fRawRunHeader);
-    }
+        return kFALSE;
 
-    fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+    fRawEvtHeader = (MRawEvtHeader*)pList->FindCreateObj("MRawEvtHeader");
     if (!fRawEvtHeader)
-    {
-        *fLog << "MRawFileRead::PreProcess - WARNING: MRawEvtHeader not found... creating." << endl;
-        fRawEvtHeader = new MRawEvtHeader;
-        pList->AddToList(fRawEvtHeader);
-    }
+        return kFALSE;
 
-    fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    fRawEvtData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
     if (!fRawEvtData)
-    {
-        *fLog << "MRawFileRead::PreProcess - WARNING: MRawEvtData not found... creating." << endl;
-        fRawEvtData = new MRawEvtData;
-        pList->AddToList(fRawEvtData);
-    }
+        return kFALSE;
 
-    fRawCrateArray = (MRawCrateArray*)pList->FindObject("MRawCrateArray");
+    fRawCrateArray = (MRawCrateArray*)pList->FindCreateObj("MRawCrateArray");
     if (!fRawCrateArray)
-    {
-        *fLog << "MRawFileRead::PreProcess - WARNING: MRawCrateArray not found... creating." << endl;
-        fRawCrateArray = new MRawCrateArray;
-        pList->AddToList(fRawCrateArray);
-    }
+        return kFALSE;
 
-    fRawEvtTime = (MTime*)pList->FindObject("MRawEvtTime");
+    fRawEvtTime = (MTime*)pList->FindCreateObj("MRawEvtTime");
     if (!fRawEvtTime)
-    {
-        *fLog << "MRawFileRead::PreProcess - WARNING: MRawEvtTime not found... creating." << endl;
-        fRawEvtTime = new MTime("MRawEvtTime");
-        pList->AddToList(fRawEvtTime);
-    }
+        return kTRUE;
 
     //
