Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 8646)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 8698)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.27 2007-07-26 11:13:00 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.28 2007-08-23 10:25:08 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -66,5 +66,5 @@
 
 MRanForestCalc::MRanForestCalc(const char *name, const char *title)
-    : fData(0), fRFOut(0), fTestMatrix(0),
+    : fData(0), fRFOut(0), fTestMatrix(0), fFunc("Function", "x"),
     fNumTrees(-1), fNumTry(-1), fNdSize(-1), fNumObsoleteVariables(1),
     fLastDataColumnHasWeights(kFALSE),
@@ -73,4 +73,6 @@
     fName  = name  ? name  : gsDefName.Data();
     fTitle = title ? title : gsDefTitle.Data();
+
+    gROOT->GetListOfFunctions()->Remove(&fFunc);
 
     // FIXME:
@@ -83,4 +85,13 @@
 {
     fEForests.Delete();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set a function which is applied to the output of the random forest
+//
+Bool_t MRanForestCalc::SetFunction(const char *func)
+{
+    return !fFunc.Compile(func);
 }
 
@@ -291,4 +302,7 @@
     }
 
+    if (fileRF.GetListOfKeys()->FindObject("Function"))
+        fFunc.Read("Function");
+
     return kTRUE;
 }
@@ -326,5 +340,5 @@
 }
 
-Int_t MRanForestCalc::Process()
+Double_t MRanForestCalc::Eval() const
 {
     TVector event;
@@ -338,8 +352,5 @@
     {
         MRanForest *rf = static_cast<MRanForest*>(fEForests.UncheckedAt(0));
-        fRFOut->SetVal(rf->CalcHadroness(event));
-        fRFOut->SetReadyToSave();
-
-        return kTRUE;
+        return rf->CalcHadroness(event);
     }
 
@@ -383,9 +394,7 @@
     {
     case kMean:
-        fRFOut->SetVal(pow(10, sume/sumh));
-        break;
+        return sume/sumh;
     case kMaximum:
-        fRFOut->SetVal(pow(10, maxe));
-        break;
+        return maxe;
     case kFit:
         f1.SetParameter(0, maxh);
@@ -393,8 +402,15 @@
         f1.SetParameter(2, 0.125);
         g.Fit(&f1, "Q0N");
-        fRFOut->SetVal(pow(10, f1.GetParameter(1)));
-        break;
-    }
-
+        return f1.GetParameter(1);
+    }
+
+    return 0;
+}
+
+Int_t MRanForestCalc::Process()
+{
+    const Double_t val = Eval();
+
+    fRFOut->SetVal(fFunc.Eval(val));
     fRFOut->SetReadyToSave();
 
Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 8646)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 8698)
@@ -12,4 +12,8 @@
 #ifndef ROOT_TArrayD
 #include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TF1
+#include <TF1.h>
 #endif
 
@@ -36,4 +40,5 @@
     MParameterD *fRFOut;                //! Used to store result
     MHMatrix    *fTestMatrix;           //! Test Matrix used in Process (together with MMatrixLoop)
+    TF1          fFunc;                 //! Function to apply to the result
 
     TObjArray    fEForests;             //! List of forests read or to be written
@@ -60,4 +65,5 @@
     // MRanForestCalc
     Int_t ReadForests(MParList &plist);
+    Double_t Eval() const;
 
     // MParContainer
@@ -84,4 +90,6 @@
     void SetNumTry(UShort_t n=0)     { fNumTry   = n; }
     void SetDebug(Bool_t b=kTRUE)    { fDebug    = b; }
+
+    Bool_t SetFunction(const char *name="x");
 
     void SetNumObsoleteVariables(Int_t n=1)          { fNumObsoleteVariables = n; }
