Index: trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc	(revision 7678)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.cc	(revision 7697)
@@ -35,7 +35,8 @@
 #include "MLogManip.h"
 
+#include "MF.h"
+#include "MParameterCalc.h"
+
 #include "MStatusDisplay.h"
-
-#include "MF.h"
 
 ClassImp(MJTrainRanForest);
@@ -45,6 +46,6 @@
 //------------------------------------------------------------------------
 //
-// Add a cut which is used to fill the matrix, eg "MMcEvt.fOartId<1.5"
-// (The rule is applied, nit inverted: The matrix is filled with
+// Add a cut which is used to fill the matrix, eg "MMcEvt.fPartId<1.5"
+// (The rule is applied, not inverted: The matrix is filled with
 // the events fullfilling the condition)
 //
@@ -52,14 +53,30 @@
 {
     MFilter *f = new MF(rule);
-    f->SetBit(kCanDelete);
-    AddCut(l, f);
+    f->SetBit(kCanDelete); //FIXME!!!! Why does not any other list delete it???
+    Add(l, f);
 }
 
 //------------------------------------------------------------------------
 //
-// Add a cut which is used to fill the matrix. If kCanDelete is set
+// Add an additional parameter (MParameterCalc), eg "0.5", "MWeight"
+// The default container name is "MWeight"
+//
+void MJTrainRanForest::AddPar(TList &l, const char *rule, const char *pname)
+{
+    TString tname(pname);
+    tname += "Calc";
+
+    MParameterCalc *par = new MParameterCalc(rule, tname);
+    par->SetNameParameter(pname);
+//    par->SetBit(kCanDelete);  //FIXME!!!! MTaskList is deleting it
+    Add(l, par);
+}
+
+//------------------------------------------------------------------------
+//
+// Add a task/cut which is used to fill the matrix. If kCanDelete is set
 // MJOptimize takes the ownership.
 //
-void MJTrainRanForest::AddCut(TList &l, MFilter *f)
+void MJTrainRanForest::Add(TList &l, MTask *f)
 {
     l.Add(f);
Index: trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h
===================================================================
--- trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h	(revision 7678)
+++ trunk/MagicSoft/Mars/mjtrain/MJTrainRanForest.h	(revision 7697)
@@ -6,4 +6,5 @@
 #endif
 
+class MTask;
 class MFilter;
 
@@ -12,4 +13,5 @@
 protected:
     Bool_t fDebug;
+    Bool_t fEnableWeights;
 
     TList fRules;
@@ -18,4 +20,6 @@
     TList fTrainCuts;
     TList fTestCuts;
+    TList fPreTasks;
+    TList fPostTasks;
 
     UShort_t fNumTrees;
@@ -26,8 +30,9 @@
 
     void AddCut(TList &l, const char *rule);
-    void AddCut(TList &l, MFilter *f);
+    void AddPar(TList &l, const char *rule, const char *name);
+    void Add(TList &l, MTask *f);
 
 public:
-    MJTrainRanForest() : fDebug(kFALSE)
+    MJTrainRanForest() : fDebug(kFALSE), fEnableWeights(kFALSE)
     {
         fNumTrees = 100; //100
@@ -36,18 +41,29 @@
     }
 
-    void SetDebug(Bool_t b=kTRUE) { fDebug = b; }
+    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)         { AddCut(fPreCuts, f); }
+    void AddPreCut(MFilter *f)         { Add(fPreCuts, (MTask*)(f)); }
 
     void AddTrainCut(const char *rule) { AddCut(fTrainCuts, rule); }
-    void AddTrainCut(MFilter *f)       { AddCut(fTrainCuts, f); }
+    void AddTrainCut(MFilter *f)       { Add(fTrainCuts, (MTask*)(f)); }
 
     void AddTestCut(const char *rule)  { AddCut(fTestCuts, rule); }
-    void AddTestCut(MFilter *f)        { AddCut(fTestCuts, f); }
+    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; }
+    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);
