Index: trunk/MagicSoft/Mars/mranforest/MRanForest.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForest.cc	(revision 8203)
+++ trunk/MagicSoft/Mars/mranforest/MRanForest.cc	(revision 8644)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MRanForest.cc,v 1.26 2006-11-02 08:57:00 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MRanForest.cc,v 1.27 2007-07-24 13:35:39 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -124,5 +124,4 @@
 
     fNTimesOutBag = rf.fNTimesOutBag;
-
 }
 
@@ -435,6 +434,6 @@
     // initialize running output
 
-    float minfloat=fHadTrue[TMath::LocMin(fHadTrue.GetSize(),fHadTrue.GetArray())];
-    Bool_t calcResolution=(minfloat>0.001);
+    float minfloat=TMath::MinElement(fHadTrue.GetSize(),fHadTrue.GetArray());
+    Bool_t calcResolution=(minfloat>FLT_MIN);
 
     if (fTreeNo==1)
@@ -443,7 +442,7 @@
 
         if(calcResolution)
-            *fLog << "TreeNum BagSize NumNodes TestSize res/% (from oob-data -> overest. of error)" << endl;
+            *fLog << "TreeNum BagSize NumNodes TestSize  Bias/%   var/%   res/% (from oob-data)" << endl;
         else
-            *fLog << "TreeNum BagSize NumNodes TestSize rms/% (from oob-data -> overest. of error)" << endl;
+            *fLog << "TreeNum BagSize NumNodes TestSize  Bias/au  var/au  rms/au (from oob-data)" << endl;
                      //        12345678901234567890123456789012345678901234567890
     }
@@ -498,14 +497,29 @@
                        jinbag,winbag,nclass);
 
-    //-------------------------------------------------------------------
-    // error-estimates from out-of-bag data (oob data):
-    //
-    // For a single tree the events not(!) contained in the bootstrap
-    // sample of this tree can be used to obtain estimates for the
-    // classification error of this tree.
-    // If you take a certain event, it is contained in the oob-data of
-    // 1/3 of the trees (see comment to ModifyData). This means that the
-    // classification error determined from oob-data is underestimated,
-    // but can still be taken as upper limit.
+    const Double_t ferr = EstimateError(jinbag, calcResolution);
+
+    fRanTree->SetError(ferr);
+
+    // adding tree to forest
+    AddTree();
+
+    return fTreeNo<fNumTrees;
+}
+
+//-------------------------------------------------------------------
+// error-estimates from out-of-bag data (oob data):
+//
+// For a single tree the events not(!) contained in the bootstrap
+// sample of this tree can be used to obtain estimates for the
+// classification error of this tree.
+// If you take a certain event, it is contained in the oob-data of
+// 1/3 of the trees (see comment to ModifyData). This means that the
+// classification error determined from oob-data is underestimated,
+// but can still be taken as upper limit.
+//
+Double_t MRanForest::EstimateError(const MArrayI &jinbag, Bool_t calcResolution)
+{
+    const Int_t numdata = GetNumData();
+
     Int_t ninbag = 0;
     for (Int_t ievt=0;ievt<numdata;ievt++)
@@ -522,18 +536,33 @@
 
     Int_t n=0;
-    Float_t ferr=0;
-
-    for (Int_t ievt=0;ievt<numdata;ievt++)
-    {
-        if(fNTimesOutBag[ievt]!=0)
-        {
-            float val = fHadEst[ievt]/float(fNTimesOutBag[ievt])-fHadTrue[ievt];
-            if(calcResolution) val/=fHadTrue[ievt];
-
-            ferr += val*val;
-            n++;
-        }
-    }
-    ferr = TMath::Sqrt(ferr/n);
+
+    Double_t sum=0;
+    Double_t sq =0;
+    for (Int_t i=0; i<numdata; i++)
+    {
+        if (fNTimesOutBag[i]==0)
+            continue;
+
+        const Float_t hadest = fHadEst[i]/fNTimesOutBag[i];
+
+        const Float_t val = calcResolution ?
+            hadest/fHadTrue[i] - 1 : hadest - fHadTrue[i];
+
+        sum += val;
+        sq  += val*val;
+        n++;
+    }
+
+    if (calcResolution)
+    {
+        sum *= 100;
+        sq  *= 10000;
+    }
+
+    sum /= n;
+    sq  /= n;
+
+    const Double_t var  = TMath::Sqrt(sq-sum*sum);
+    const Double_t ferr = TMath::Sqrt(sq);
 
     //-------------------------------------------------------------------
@@ -543,13 +572,10 @@
     *fLog << setw(9) << fRanTree->GetNumEndNodes();
     *fLog << Form("  %9.1f", 100.*n/numdata);
-    *fLog << Form("%18.2f", ferr*100.);
+    *fLog << Form(" %7.2f", sum);
+    *fLog << Form(" %7.2f", var);
+    *fLog << Form(" %7.2f", ferr);
     *fLog << endl;
 
-    fRanTree->SetError(ferr);
-
-    // adding tree to forest
-    AddTree();
-
-    return fTreeNo<fNumTrees;
+    return ferr;
 }
 
Index: trunk/MagicSoft/Mars/mranforest/MRanForest.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForest.h	(revision 8203)
+++ trunk/MagicSoft/Mars/mranforest/MRanForest.h	(revision 8644)
@@ -74,4 +74,6 @@
     Double_t fUserVal;     // A user value describing this tree (eg E-mc)
 
+    Double_t EstimateError(const MArrayI &jinbag, Bool_t calcResolution);
+
 protected:
     // create and modify (->due to bagging) fDataSort
Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 8203)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 8644)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.25 2006-11-02 08:57:00 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.26 2007-07-24 13:35:39 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -229,5 +229,5 @@
         tlist.AddToList(&fillh);
 
-        MEvtLoop evtloop;
+        MEvtLoop evtloop(fName);
         evtloop.SetParList(&plist);
         evtloop.SetDisplay(fDisplay);
