Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2957)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2958)
@@ -4,4 +4,33 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/01/29: Thomas Bretz
+
+   * manalysis/MArrivalTime.h, manalysis/MCameraData.h,
+     manalysis/MCerPhotEvt.h, manalysis/MExtractSignalCam.h,
+     manalysis/MPedPhotCam.h, manalysis/MPedestalCam.h,
+     mcalib/MCalibrationCam.h, mcamera/MCameraDC.h,
+     mraw/MRawEvtData.h, mreflector/MRflEvtData.h:
+     - split derivement into MParContainer and MCamEvent
+
+   * manalysis/MExtractSignalCam.[h,cc]:
+     - removed obsolete MExtractSignal::ReInit
+     - added -> to fArray
+
+   * mbase/MParList.h:
+     - added a new bit kIsProcessing
+     
+   * mbase/MTaskList.cc:
+     - fixed the handling of kDoNotReset and the bahaviour of
+       SetReadyToSave, such that it is possible to write all
+       headers 
+
+   * mfileio/MWriteFile.cc:
+     - added ReInit which also calls CheckAndWrite
+     
+   * mgui/MCamEvent.h:
+     - does not derive from MParContainer anymore
+
+
+
  2004/01/29: Markus Gaug
 
Index: trunk/MagicSoft/Mars/manalysis/MArrivalTime.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MArrivalTime.h	(revision 2958)
@@ -2,4 +2,7 @@
 #define MARS_MArrivalTime
 
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 #ifndef MARS_MCamEvent
 #include "MCamEvent.h"
@@ -15,5 +18,5 @@
 class MRawEvtData;
 
-class MArrivalTime : public MCamEvent
+class MArrivalTime : public MParContainer, public MCamEvent
 {
  private:
Index: trunk/MagicSoft/Mars/manalysis/MCameraData.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCameraData.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MCameraData.h	(revision 2958)
@@ -7,4 +7,7 @@
 #ifndef ROOT_TArrayC
 #include <TArrayC.h>
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
 #endif
 #ifndef MARS_MCamEvent
@@ -17,5 +20,5 @@
 class MPedPhotCam;
 
-class MCameraData : public MCamEvent
+class MCameraData : public MParContainer, public MCamEvent
 {
 private:
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 2958)
@@ -18,5 +18,5 @@
 class MCerPhotPix;
 
-class MCerPhotEvt : public MCamEvent
+class MCerPhotEvt : public MParContainer, public MCamEvent
 {
 private:
Index: trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2958)
@@ -36,5 +36,4 @@
 
 #include "MParList.h"
-#include "MGeomCam.h"
 
 #include "MRawEvtData.h"
@@ -125,22 +124,4 @@
         return kFALSE;
     
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// The ReInit searches for the following input containers:
-//  - MRawRunHeader
-//
-Bool_t MExtractSignal::ReInit(MParList *pList )
-{
-    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
-    if (!cam)
-    {
-        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
-        return kFALSE;
-    }
-
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/manalysis/MExtractSignal.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractSignal.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MExtractSignal.h	(revision 2958)
@@ -29,17 +29,17 @@
     static const Byte_t fgLast;
 
-    MPedestalCam             *fPedestals;    // Pedestals of all pixels in the camera
-    MExtractedSignalCam      *fSignals;      // Extracted signal of all pixels in the camera
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
 
-    MRawEvtData              *fRawEvt;       // raw event data (time slices)
-    MRawRunHeader            *fRunHeader;    // RunHeader information
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
 
-    MArrivalTime             *fArrivalTime;  // Arrival Time of FADC sample
+    MArrivalTime        *fArrivalTime;  // Arrival Time of FADC sample
   
-    Byte_t fHiGainFirst;
-    Byte_t fLoGainFirst;
+    Byte_t  fHiGainFirst;
+    Byte_t  fLoGainFirst;
 
-    Byte_t fNumHiGainSamples;
-    Byte_t fNumLoGainSamples;
+    Byte_t  fNumHiGainSamples;
+    Byte_t  fNumLoGainSamples;
 
     Float_t fSqrtHiGainSamples;
@@ -48,5 +48,4 @@
     Byte_t  fSaturationLimit;
 
-    Bool_t ReInit(MParList *pList);
     Int_t  PreProcess(MParList *pList);
     Int_t  Process();
Index: trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MExtractedSignalCam.h	(revision 2958)
@@ -1,4 +1,8 @@
 #ifndef MARS_MExtractedSignalCam
 #define MARS_MExtractedSignalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 
 #ifndef MARS_MCamEvent
@@ -9,8 +13,8 @@
 class MExtractedSignalPix;
 
-class MExtractedSignalCam : public MCamEvent
+class MExtractedSignalCam : public MParContainer, public MCamEvent
 {
 private:
-    TClonesArray *fArray; // FIXME: Change TClonesArray away from a pointer?
+    TClonesArray *fArray; //-> FIXME: Change TClonesArray away from a pointer?
 
     Byte_t fFirstUsedSliceHiGain;
Index: trunk/MagicSoft/Mars/manalysis/MPedPhotCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedPhotCam.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MPedPhotCam.h	(revision 2958)
@@ -2,4 +2,7 @@
 #define MARS_MPedPhotCam
 
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 #ifndef MARS_MCamEvent
 #include "MCamEvent.h"
@@ -11,5 +14,5 @@
 class MPedPhotPix;
 
-class MPedPhotCam : public MCamEvent
+class MPedPhotCam : public MParContainer, public MCamEvent
 {
 private:
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 2957)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 2958)
@@ -2,4 +2,7 @@
 #define MARS_MPedestalCam
 
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 #ifndef MARS_MCamEvent
 #include "MCamEvent.h"
@@ -11,5 +14,5 @@
 class MPedestalPix;
 
-class MPedestalCam : public MCamEvent
+class MPedestalCam : public MParContainer, public MCamEvent
 {
 private:
@@ -21,8 +24,9 @@
 
     void Clear(Option_t *o="");
-    void InitUseHists();
     
     void InitSize(const UInt_t i);
     Int_t GetSize() const;
+
+    void InitUseHists();
 
     MPedestalPix &operator[](Int_t i);
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 2957)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 2958)
@@ -36,5 +36,5 @@
 
 public:
-    enum { kDoNotReset = BIT(17) };
+    enum { kDoNotReset = BIT(17), kIsProcessing = BIT(18) };
 
     MParList(const char *name=NULL, const char *title=NULL);
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2957)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2958)
@@ -308,4 +308,15 @@
     *fLog << all << "Reinit... " << flush;
 
+    if (!pList)
+        pList = fParList;
+
+    //
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = pList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+        pList->SetBit(MParList::kDoNotReset);
+
     //
     //  create the Iterator over the tasklist
@@ -314,4 +325,5 @@
 
     MTask *task=NULL;
+
     //
     // loop over all tasks for reinitialization
@@ -321,5 +333,5 @@
         *fLog << all << task->GetName() << "... " << flush;
 
-        if (!task->ReInit(pList?pList:fParList))
+        if (!task->ReInit(pList/*?pList:fParList*/))
         {
             *fLog << err << "ERROR - ReInit of Task '" << task->GetDescriptor() << "' failed." << endl;
@@ -329,4 +341,13 @@
 
     *fLog << all << endl;
+
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        pList->SetReadyToSave(kFALSE);
+        pList->ResetBit(MParList::kDoNotReset);
+    }
 
     return kTRUE;
@@ -366,5 +387,11 @@
     fParList = pList;
 
-    fTasksProcess.Clear();
+    //
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+        fParList->SetBit(MParList::kDoNotReset);
 
     //
@@ -406,9 +433,18 @@
     *fLog << all << endl;
 
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kDoNotReset);
+    }
+
+    //
+    // loop over all tasks to fill fTasksProcess
+    //
     Next.Reset();
-
-    //
-    // loop over all tasks for preproccesing
-    //
+    fTasksProcess.Clear();
     while ((task=(MTask*)Next()))
         if (task->OverwritesProcess())
@@ -441,10 +477,9 @@
     // running as a task in another tasklist.
     //
-    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    const Bool_t noreset = fParList->TestBit(MParList::kIsProcessing);
     if (!noreset)
     {
-        fParList->SetReadyToSave(kFALSE);
+        fParList->SetBit(MParList::kIsProcessing);
         fParList->Reset();
-        fParList->SetBit(MParList::kDoNotReset);
     }
 
@@ -514,5 +549,8 @@
 
     if (!noreset)
-        fParList->ResetBit(MParList::kDoNotReset);
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kIsProcessing);
+    }
 
     return rc;
@@ -535,12 +573,13 @@
 
     //
-    // Reset the ReadyToSave flag.
-    // Reset all containers.
-    //
-    // FIXME: To run a tasklist as a single task in another tasklist we
-    //        have to make sure, that the Parameter list isn't reset.
-    //
-    fParList->SetReadyToSave(kFALSE);
-    fParList->Reset();
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+    {
+        fParList->SetBit(MParList::kDoNotReset);
+        fParList->Reset();
+    }
 
     //
@@ -566,4 +605,13 @@
 
     *fLog << all << endl;
+
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kDoNotReset);
+    }
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h	(revision 2957)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h	(revision 2958)
@@ -2,4 +2,7 @@
 #define MARS_MCalibrationCam
 
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 #ifndef MARS_MCamEvent
 #include "MCamEvent.h"
@@ -14,5 +17,5 @@
 class MCalibrationPINDiode;
 
-class MCalibrationCam : public MCamEvent
+class MCalibrationCam : public MParContainer, public MCamEvent
 {
 private:
Index: trunk/MagicSoft/Mars/mcamera/MCameraDC.h
===================================================================
--- trunk/MagicSoft/Mars/mcamera/MCameraDC.h	(revision 2957)
+++ trunk/MagicSoft/Mars/mcamera/MCameraDC.h	(revision 2958)
@@ -2,4 +2,7 @@
 #define MARS_MCameraDC
 
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 #ifndef MARS_MCamEvent
 #include "MCamEvent.h"
@@ -10,5 +13,5 @@
 #endif
 
-class MCameraDC : public MCamEvent
+class MCameraDC : public MParContainer, public MCamEvent
 {
 private:
@@ -30,5 +33,5 @@
     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
     {
-        val = (*this)[idx];
+        val = fArray[idx];
         return val>0;
     }
Index: trunk/MagicSoft/Mars/mfileio/MWriteFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 2957)
+++ trunk/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 2958)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -24,15 +24,14 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MWriteFile                                                              //
-//                                                                         //
-// This is a base class for writing tasks. If you want to implement        //
-// writing out parameter containers in a new file format, this is a good   //
-// starting point.                                                         //
-// The class defines a generalized interface between writing out data in   //
-// an eventloop and your file format.                                      //
-//                                                                         //
+//
+// MWriteFile
+//
+// This is a base class for writing tasks. If you want to implement
+// writing out parameter containers in a new file format, this is a good
+// starting point.
+// The class defines a generalized interface between writing out data in
+// an eventloop and your file format.
+//
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MWriteFile.h"
 
@@ -86,6 +85,17 @@
 // --------------------------------------------------------------------------
 //
-// Checks if the HasChanged flag of the output container is set. If it is set
-// the container should be written to the output.
+// Checks if the SetReadyToSave flag of the output container is set. If it
+// is set the container should be written to the output.
+//
+Bool_t MWriteFile::ReInit(MParList *pList)
+{
+    CheckAndWrite();
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the SetReadyToSave flag of the output container is set. If it is
+// set the container should be written to the output.
 //
 Int_t MWriteFile::Process()
@@ -97,6 +107,6 @@
 // --------------------------------------------------------------------------
 //
-// Checks if the HasChanged flag of the output container is set. If it is set
-// the container should be written to the output.
+// Checks if the SetReadyToSave flag of the output container is set. If it is
+// set the container should be written to the output.
 //
 Int_t MWriteFile::PostProcess()
@@ -108,3 +118,2 @@
     return kTRUE;
 }
-
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 2957)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 2958)
@@ -2,11 +2,11 @@
 #define MARS_MCamEvent
 
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
+#ifndef ROOT_TROOT
+#include <TROOT.h>
 #endif
 
 class MGeomCam;
 
-class MCamEvent : public MParContainer
+class MCamEvent
 {
 public:
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 2957)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 2958)
@@ -2,4 +2,7 @@
 #define MARS_MRawEvtData
 
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 #ifndef MARS_MCamEvent
 #include "MCamEvent.h"
@@ -17,5 +20,5 @@
 class MArrayB;
 
-class MRawEvtData : public MCamEvent
+class MRawEvtData : public MParContainer, public MCamEvent
 {
     friend class MRawEvtPixelIter;
@@ -83,5 +86,5 @@
         ;
 
-    ClassDef(MRawEvtData, 3) //Container to store the raw Event Data
+    ClassDef(MRawEvtData, 4) //Container to store the raw Event Data
 };
 
Index: trunk/MagicSoft/Mars/mreflector/MRflEvtData.h
===================================================================
--- trunk/MagicSoft/Mars/mreflector/MRflEvtData.h	(revision 2957)
+++ trunk/MagicSoft/Mars/mreflector/MRflEvtData.h	(revision 2958)
@@ -1,4 +1,8 @@
 #ifndef MARS_MRflEvtData
 #define MARS_MRflEvtData
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
 
 #ifndef MARS_MCamEvent
@@ -12,5 +16,5 @@
 class MRflSinglePhoton;
 
-class MRflEvtData : public MCamEvent
+class MRflEvtData : public MParContainer, public MCamEvent
 {
     TClonesArray fList;
