Index: trunk/MagicSoft/Mars/mranforest/MRanForest.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForest.cc	(revision 7419)
+++ trunk/MagicSoft/Mars/mranforest/MRanForest.cc	(revision 7420)
@@ -62,5 +62,7 @@
 // Default constructor.
 //
-MRanForest::MRanForest(const char *name, const char *title) : fClassify(1), fNumTrees(100), fNumTry(0), fNdSize(1), fRanTree(NULL), fUserVal(-1)
+MRanForest::MRanForest(const char *name, const char *title)
+    : fClassify(kTRUE), fNumTrees(100), fNumTry(0), fNdSize(1),
+    fRanTree(NULL), fRules(NULL), fMatrix(NULL), fUserVal(-1)
 {
     fName  = name  ? name  : "MRanForest";
@@ -125,4 +127,8 @@
 {
     delete fForest;
+    if (fMatrix)
+        delete fMatrix;
+    if (fRules)
+        delete fRules;
 }
 
@@ -152,9 +158,5 @@
 void MRanForest::SetWeights(const TArrayF &weights)
 {
-    const int n=weights.GetSize();
-    fWeight.Set(n);
     fWeight=weights;
-
-    return;
 }
 
@@ -175,6 +177,4 @@
     //for(int i=0;i<n;i++)
     //    *fLog<<inf<<" "<<i<<") "<<fGrid[i]<<endl;
-
-    return;
 }
 
@@ -227,23 +227,4 @@
 }
 
-/*
-Bool_t MRanForest::PreProcess(MParList *plist)
-{
-    if (!fRules)
-    {
-        *fLog << err << dbginf << "MDataArray with rules not initialized... aborting." << endl;
-        return kFALSE;
-    }
-
-    if (!fRules->PreProcess(plist))
-    {
-        *fLog << err << dbginf << "PreProcessing of MDataArray failed... aborting." << endl;
-        return kFALSE;
-    }
-
-    return kTRUE;
-}
-*/
-
 Double_t MRanForest::CalcHadroness()
 {
@@ -285,4 +266,6 @@
     // access matrix, copy last column (target) preliminarily
     // into fHadTrue
+    if (fMatrix)
+        delete fMatrix;
     fMatrix = new TMatrix(mat->GetM());
 
@@ -337,4 +320,6 @@
     }
 
+    if (fRules)
+        delete fRules;
     fRules = new MDataArray();
     fRules->Reset();
Index: trunk/MagicSoft/Mars/mranforest/MRanForest.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForest.h	(revision 7419)
+++ trunk/MagicSoft/Mars/mranforest/MRanForest.h	(revision 7420)
@@ -30,5 +30,5 @@
 {
 private:
-    Int_t fClassify;
+    Bool_t fClassify;
 
     Int_t fNumTrees;       // Number of trees
@@ -83,5 +83,5 @@
     void SetNdSize(Int_t n);
 
-    void SetClassify(Int_t n){ fClassify=n; }
+    void SetClassify(Bool_t n){ fClassify=n; }
     void PrepareClasses();
 
Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 7419)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 7420)
@@ -79,4 +79,15 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// ver=0: One yes/no-classification forest is trained for each bin.
+//        the yes/no classification is done using the grid
+// ver=1: One classification forest is trained. The last column contains a
+//        value which is turned into a classifier by rf itself using the grid
+// ver=2: One classification forest is trained. The last column already contains
+//        the classifier
+// ver=3: A regression forest is trained. The last column contains the
+//        classifier
+//
 Int_t MRanForestCalc::Train(const MHMatrix &matrixtrain, const TArrayD &grid, Int_t ver)
 {
@@ -117,5 +128,5 @@
 
     MDataArray rules(usedrules);
-    rules.AddEntry(ver<2?"Classification":dcol[ncols-1].GetRule());
+    rules.AddEntry(ver<3?"Classification":dcol[ncols-1].GetRule());
 
     // prepare matrix for current energy bin
@@ -133,5 +144,5 @@
         switch (ver)
         {
-        case 0: // Replace Energy Grid by classification
+        case 0: // Replace last column by a classification
             {
                 Int_t irows=0;
@@ -158,6 +169,7 @@
             break;
 
-        case 1: // Use Energy as classifier
+        case 1: // Use last column as classifier or for regression
         case 2:
+        case 3:
             for (Int_t j=0; j<nrows; j++)
                 mat(j, ncols-nobs) = matrixtrain.GetM()(j,ncols-1);
@@ -176,5 +188,5 @@
         rf.SetNumTry(fNumTry);
         rf.SetNdSize(fNdSize);
-        rf.SetClassify(ver<2 ? 1 : 0);
+        rf.SetClassify(ver<3 ? kTRUE : kFALSE);
         if (ver==1)
             rf.SetGrid(grid);
Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 7419)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 7420)
@@ -65,5 +65,5 @@
 
     // Train Interface
-    Int_t Train(const MHMatrix &n, const TArrayD &grid, Int_t ver=2);
+    Int_t Train(const MHMatrix &n, const TArrayD &grid, Int_t ver);
 
 public:
@@ -87,9 +87,17 @@
     Int_t TrainMultiRF(const MHMatrix &n, const TArrayD &grid)
     {
+        // One yes/no-classification forest is trained for each bin
         return Train(n, grid, 0);
     }
     Int_t TrainSingleRF(const MHMatrix &n, const TArrayD &grid=TArrayD())
     {
+        // w/o Grid: Last Column contains classifier
+        // w/  Grid: Last Column will be converted by grid into classifier
         return Train(n, grid, grid.GetSize()==0 ? 2 : 1);
+    }
+    Int_t TrainRegression(const MHMatrix &n)
+    {
+        // Use last column for regression
+        return Train(n, TArrayD(), 3);
     }
 
Index: trunk/MagicSoft/Mars/mranforest/MRanTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanTree.cc	(revision 7419)
+++ trunk/MagicSoft/Mars/mranforest/MRanTree.cc	(revision 7420)
@@ -49,5 +49,5 @@
 // Default constructor.
 //
-MRanTree::MRanTree(const char *name, const char *title):fClassify(1),fNdSize(0), fNumTry(3)
+MRanTree::MRanTree(const char *name, const char *title):fClassify(kTRUE),fNdSize(0), fNumTry(3)
 {
 
Index: trunk/MagicSoft/Mars/mranforest/MRanTree.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanTree.h	(revision 7419)
+++ trunk/MagicSoft/Mars/mranforest/MRanTree.h	(revision 7420)
@@ -22,5 +22,6 @@
 {
 private:
-    Int_t fClassify;
+    Bool_t fClassify;
+
     Int_t fNdSize;
     Int_t fNumTry;
@@ -88,5 +89,5 @@
     Float_t GetGiniDec(Int_t i)  const { return fGiniDec.At(i); }
 
-    void SetClassify(Int_t n){ fClassify=n; }
+    void SetClassify(Bool_t n){ fClassify=n; }
 
     // functions used in tree growing process
