Index: trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 959)
@@ -31,4 +31,6 @@
 #pragma link C++ class MInputStreamID;
 
+#pragma link C++ class MClone;
+
 #pragma link C++ class MReadTree;
 #pragma link C++ class MWriteFile;
Index: trunk/MagicSoft/Mars/mbase/MClone.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 959)
+++ trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 959)
@@ -0,0 +1,126 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  07/2001 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MClone.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MClone);
+
+// --------------------------------------------------------------------------
+//
+// Initializes name and title of the object. It is called by all
+// constructors.
+//
+void MClone::Init(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MClone";
+    *fTitle = title ? title : "Task to clone a parameter container for later usage";
+
+    fClone        = NULL;
+    fParContainer = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+MClone::MClone(const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainerName = par;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+MClone::MClone(const MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainer = par;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MClone::~MClone()
+{
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks the parameter list for the existance of the parameter container. If
+// the name of it was given in the constructor. It checks also for the
+// existance of the histogram container in the parameter list if a name was
+// given. If it is not available it tried to create a histogram container
+// with the same type as the given object name.
+//
+Bool_t MClone::PreProcess(MParList *pList)
+{
+    if (!fParContainer)
+    {
+        fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+        if (!fParContainer)
+        {
+            *fLog << dbginf << fParContainerName << " not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
+}
+
+void MClone::Clear(Option_t *)
+{
+    if (!fClone)
+        return;
+
+    delete fClone;
+    fClone = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills the data from the parameter conatiner into the histogram container
+//
+Bool_t MClone::Process()
+{
+    Clear();
+
+    fClone = fParContainer->Clone();
+
+    return kTRUE;
+} 
+
Index: trunk/MagicSoft/Mars/mbase/MClone.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.h	(revision 959)
+++ trunk/MagicSoft/Mars/mbase/MClone.h	(revision 959)
@@ -0,0 +1,40 @@
+#ifndef MCLONE_H
+#define MCLONE_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MClone : public MTask
+{
+private:
+    const MParContainer *fParContainer;
+    TString fParContainerName;
+
+    TObject* fClone;
+
+    void Init(const char *name, const char *title);
+
+public:
+    MClone(const char *par,          const char *name=NULL, const char *title=NULL);
+    MClone(const MParContainer *par, const char *name=NULL, const char *title=NULL);
+    ~MClone();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    TObject *GetClone() const { return fClone; }
+
+    void Clear(Option_t *opt=NULL);
+
+    ClassDef(MClone, 0) // Task to fill the Hillas parameters into histograms
+};
+    
+#endif
+
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 959)
@@ -81,4 +81,16 @@
 MEvtLoop::~MEvtLoop()
 {
+    if (TestBit(kIsOwner) && fParList)
+        delete fParList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  if you set the Eventloop as owner the destructor of the given parameter
+//  list is calles by the destructor of MEvtLoop, otherwise not.
+//
+inline void MEvtLoop::SetOwner(Bool_t enable=kTRUE)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
 }
 
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 959)
@@ -27,9 +27,14 @@
     MTaskList *fTaskList;
 
+    enum { kIsOwner = BIT(14) };
+
 public:
     MEvtLoop();
     virtual ~MEvtLoop();
 
-    void SetParList(MParList *p)  { fParList = p; }
+    void SetParList(MParList *p)        { fParList = p; }
+    MParList *GetParList() const        { return fParList; }
+
+    void SetOwner(Bool_t enable=kTRUE);
 
     Bool_t PreProcess(const char *tlist="MTaskList");
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 959)
@@ -81,4 +81,25 @@
 // --------------------------------------------------------------------------
 //
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+MParList::~MParList()
+{
+    if (TestBit(kIsOwner))
+        fContainer.SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+inline void MParList::SetOwner(Bool_t enable=kTRUE)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+// --------------------------------------------------------------------------
+//
 //  Set the logging streamer of the parameter list and all contained
 //  parameter containers
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 959)
@@ -32,11 +32,11 @@
     static TString GetObjectName(const char *classname, const char *objname);
 
+    enum { kIsOwner = BIT(14) };
+
 public:
     MParList(const char *name=NULL, const char *title=NULL);
     MParList(MParList &ts);
 
-    ~MParList()
-    {
-    }
+    ~MParList();
 
     Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL);
@@ -57,4 +57,6 @@
     void SetReadyToSave(Bool_t flag=kTRUE);
 
+    void SetOwner(Bool_t enable=kTRUE);
+
     void Print(Option_t *t = NULL);
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 959)
@@ -80,4 +80,26 @@
 // --------------------------------------------------------------------------
 //
+//  If the 'IsOwner' bit is set (via SetOwner()) all tasks are deleted
+//  by the destructor
+//
+MTaskList::~MTaskList()
+{
+    if (TestBit(kIsOwner))
+        fTasks.SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+inline void MTaskList::SetOwner(Bool_t enable=kTRUE)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+
+// --------------------------------------------------------------------------
+//
 //  Set the logging stream for the all tasks in the list and the tasklist
 //  itself.
@@ -169,4 +191,23 @@
 // --------------------------------------------------------------------------
 //
+//  Find an object in the list.
+//  'name' is the name of the object you are searching for.
+//
+TObject *MTaskList::FindObject(const char *name) const
+{
+    return fTasks.FindObject(name);
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the object is in the list or not
+//
+TObject *MTaskList::FindObject(TObject *obj) const
+{
+    return fTasks.FindObject(obj);
+}
+
+// --------------------------------------------------------------------------
+//
 // do pre processing (before eventloop) of all tasks in the task-list
 //
@@ -187,5 +228,5 @@
     // loop over all tasks for preproccesing
     //
-    while ( (task=(MTask*)Next()) )
+    while ((task=(MTask*)Next()))
     {
         *fLog << task->GetName() << "... " << flush;
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 959)
@@ -27,12 +27,18 @@
     MParList      *fParList;
 
+    enum { kIsOwner = BIT(14) };
+
 public:
     MTaskList(const char *name=NULL, const char *title=NULL);
+    MTaskList(MTaskList &ts);
 
-    MTaskList(MTaskList &ts);
+    ~MTaskList();
 
     void SetLogStream(MLog *log);
 
     Bool_t AddToList(MTask *task, const char *tType="All", MTask *where = NULL);
+
+    TObject *FindObject(const char *name) const;
+    TObject *FindObject(TObject *obj) const;
 
     Bool_t PreProcess(MParList *pList);
@@ -41,4 +47,5 @@
 
     void Print(Option_t *opt = "");
+    void SetOwner(Bool_t enable=kTRUE);
 
     ClassDef(MTaskList, 0)	//collection of tasks to be performed in the eventloop
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 949)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 959)
@@ -49,4 +49,5 @@
            MLog.cc \
            MHtml.cc \
+           MClone.cc \
            MLogManip.cc
 
