Index: trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc	(revision 8636)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc	(revision 8643)
@@ -145,5 +145,5 @@
     rf.SetLogStream(fLog);
     rf.SetFileName(out);
-    rf.SetDebug(fDebug);
+    rf.SetDebug(fDebug>1);
     rf.SetNameOutput("Disp");
 
@@ -251,5 +251,5 @@
     hist.GetAlphaFitter().Print("result");
 
-    if (!WriteDisplay(out))
+    if (!WriteDisplay(out, "UPDATE"))
         return kFALSE;
 
Index: trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc	(revision 8636)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc	(revision 8643)
@@ -139,5 +139,5 @@
     rf.SetLogStream(fLog);
     rf.SetFileName(out);
-    rf.SetDebug(fDebug);
+    rf.SetDebug(fDebug>1);
     rf.SetNameOutput("MEnergyEst");
 
@@ -193,5 +193,5 @@
         return kFALSE;
 
-    if (!WriteDisplay(out))
+    if (!WriteDisplay(out, "UPDATE"))
         return kFALSE;
 
Index: trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc	(revision 8636)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc	(revision 8643)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2005-2006
+!   Copyright: MAGIC Software Development, 2005-2007
 !
 !
@@ -28,4 +28,15 @@
 //
 // Base class for classes training a random forest
+//
+// The order when reading a file is:
+//   1) Execution of PreTasks  (set by user)
+//   2) Execution of PreCuts   (set by user)
+//   3) Selector               (calculated from number of requested events)
+//   4) Splitter               (if sample is split automatically in test/train)
+//   5) PostTasks              (set by user)
+//
+// The split into Pre- and PostTasks is done for speed reason. So, if
+// you calculate a vlue which is not needed for your PreCuts, you can
+// calculate it afterwards, which will speed up execution.
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -45,5 +56,5 @@
 
 using namespace std;
-
+/*
 //------------------------------------------------------------------------
 //
@@ -120,2 +131,3 @@
     return kTRUE;
 }
+*/
Index: trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h	(revision 8636)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h	(revision 8643)
@@ -2,6 +2,6 @@
 #define MARS_MJTrainRanForest
 
-#ifndef MARS_MJob
-#include "MJob.h"
+#ifndef MARS_MJOptimizeBase
+#include "MJOptimizeBase.h"
 #endif
 
@@ -9,30 +9,13 @@
 class MFilter;
 
-class MJTrainRanForest : public MJob
+class MJTrainRanForest : public MJOptimizeBase
 {
 protected:
-    Bool_t fDebug;
-    Bool_t fEnableWeights;
-
-    TList fRules;
-
-    TList fPreCuts;
-    TList fTrainCuts;
-    TList fTestCuts;
-    TList fPreTasks;
-    TList fPostTasks;
-
     UShort_t fNumTrees;
     UShort_t fNdSize;
     UShort_t fNumTry;
 
-    Bool_t WriteDisplay(const char *fname) const;
-
-    void AddCut(TList &l, const char *rule);
-    void AddPar(TList &l, const char *rule, const char *name);
-    void Add(TList &l, MTask *f);
-
 public:
-    MJTrainRanForest() : fDebug(kFALSE), fEnableWeights(kFALSE)
+    MJTrainRanForest()
     {
         fNumTrees = 100; //100
@@ -41,31 +24,7 @@
     }
 
-    void AddPreTask(MTask *t)                    { Add(fPreTasks,  t); }
-    void AddPreTask(const char *rule,
-                    const char *name="MWeight")  { AddPar(fPreTasks, rule, name); }
-
-    void AddPostTask(MTask *t)                   { Add(fPostTasks, t); }
-    void AddPostTask(const char *rule,
-                     const char *name="MWeight") { AddPar(fPostTasks, rule, name); }
-
-    void SetDebug(Bool_t b=kTRUE)      { fDebug = b; }
-
-    void SetWeights(const char *rule)  { if (fEnableWeights) return; fEnableWeights=kTRUE; AddPostTask(rule); }
-    void SetWeights(MTask *t)          { if (fEnableWeights) return; fEnableWeights=kTRUE; AddPostTask(t);    }
-
-    void AddPreCut(const char *rule)   { AddCut(fPreCuts, rule); }
-    void AddPreCut(MFilter *f)         { Add(fPreCuts, (MTask*)(f)); }
-
-    void AddTrainCut(const char *rule) { AddCut(fTrainCuts, rule); }
-    void AddTrainCut(MFilter *f)       { Add(fTrainCuts, (MTask*)(f)); }
-
-    void AddTestCut(const char *rule)  { AddCut(fTestCuts, rule); }
-    void AddTestCut(MFilter *f)        { Add(fTestCuts, (MTask*)(f)); }
-
     void SetNumTrees(UShort_t n=100)   { fNumTrees = n; }
     void SetNdSize(UShort_t n=5)       { fNdSize   = n; }
     void SetNumTry(UShort_t n=0)       { fNumTry   = n; }
-
-    Int_t AddParameter(const char *rule);
 
     ClassDef(MJTrainRanForest, 0)//Base class for Random Forest training classes
Index: trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc	(revision 8636)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainSeparation.cc	(revision 8643)
@@ -802,5 +802,5 @@
     rf.SetNumObsoleteVariables(1);
     rf.SetLastDataColumnHasWeights(fEnableWeights[kTrainOn] || fEnableWeights[kTrainOff]);
-    rf.SetDebug(fDebug);
+    rf.SetDebug(fDebug>1);
     rf.SetDisplay(fDisplay);
     rf.SetLogStream(fLog);
@@ -1039,5 +1039,5 @@
 
     // Write the display
-    if (!WriteDisplay(out))
+    if (!WriteDisplay(out, "UPDATE"))
         return kFALSE;
 
Index: trunk/MagicSoft/Mars/mjtrain/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/Makefile	(revision 8636)
+++ trunk/MagicSoft/Mars/mjtrain/Makefile	(revision 8643)
@@ -22,5 +22,5 @@
            -I../manalysis -I../mfilter -I../mjobs -I../mtools \
            -I../mranforest -I../mhflux -I../mmc -I../mhist -I../mpointing \
-           -I../mimage
+           -I../mimage -I../mjoptim
 
 SRCFILES = MJTrainRanForest.cc \
