Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1854)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1859)
@@ -42,4 +42,7 @@
 #pragma link C++ class MHHadronness+;
 
+#pragma link C++ class MHRanForest+;
+#pragma link C++ class MHRanForestGini+;
+
 #pragma link C++ class MHMcRate+;
 #pragma link C++ class MHMcDifRate+;
Index: trunk/MagicSoft/Mars/mhist/MHRanForest.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHRanForest.cc	(revision 1859)
+++ trunk/MagicSoft/Mars/mhist/MHRanForest.cc	(revision 1859)
@@ -0,0 +1,219 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHRanForest
+//
+// This histogram shows the evolution of the standard deviation 
+// of est. hadronness as the number of trees increases. 
+// It helps you to find out how many trees are really needed in g/h-sep.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHRanForest.h"
+
+#include <TPad.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MRanForest.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHRanForest);
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms, nbins is the number of bins used for the evaluation.
+// The default is 100 bins.
+//
+MHRanForest::MHRanForest(Int_t nbins, const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHRanForest";
+    fTitle = title ? title : "Histogram showing Standard deviation of estimated hadronness";
+
+    fGraphSigma = new TGraph;
+    fGraphSigma->SetTitle("Evolution of Standard deviation of estimated hadronness in tree combination");
+    fGraphSigma->SetMaximum(1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHRanForest::~MHRanForest()
+{
+    delete fGraphSigma;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup Filling of the histograms. It needs:
+//  MMcEvt and MRanForest
+//
+Bool_t MHRanForest::SetupFill(const MParList *plist)
+{
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanForest = (MRanForest*)plist->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSigma.Set(fRanForest->GetNumTrees());
+    fNumEvent=0;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MHRanForest::Fill(const MParContainer *par)
+{
+    fNumEvent++;
+    Double_t hest=0;
+    Double_t htrue=fMcEvt->GetPartId()==kGAMMA ? 0. : 1.;
+
+    Int_t ntrees=fRanForest->GetNumTrees();
+
+    for (Int_t i=0;i<ntrees;i++)
+    {
+        for(Int_t j=0;j<=i;j++)
+            hest+=fRanForest->GetTreeHad(j);
+
+        hest/=Double_t(i+1);
+        fSigma[i]+=(htrue-hest)*(htrue-hest);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Finalize the histogram:
+// calculate standard deviation and set histogram max and min
+//
+Bool_t MHRanForest::Finalize()
+{
+    Int_t n = fSigma.GetSize();
+
+    fGraphSigma->Set(n);
+
+    Stat_t max=0.;
+    Stat_t min=0.;
+    for (Int_t i=0; i<n; i++)
+    {
+        Stat_t ip = i+1.;
+	fSigma[i] = TMath::Sqrt(fSigma[i]/Stat_t(fNumEvent));
+        Stat_t ig = fSigma[i];
+        max=TMath::Max(max,ig);
+        min=TMath::Min(min,ig);
+        fGraphSigma->SetPoint(i,ip,ig);
+    }
+    fGraphSigma->SetMaximum(1.05*max);
+    fGraphSigma->SetMinimum(0.95*min);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram
+//
+TObject *MHRanForest::DrawClone(Option_t *opt) const
+{
+    if (fGraphSigma->GetN()==0)
+        return NULL;
+
+    TCanvas &c = *MakeDefCanvas("RanForest", fTitle);
+    gROOT->SetSelectedPad(NULL);
+
+    gStyle->SetOptStat(10);
+    TGraph &g = (TGraph&)*fGraphSigma->DrawClone("AL");
+    g.SetBit(kCanDelete);
+    gPad->Modified();
+    gPad->Update();
+    if (g.GetHistogram())
+    {
+        g.GetXaxis()->SetRangeUser(0, fNumEvent);
+        g.GetXaxis()->SetTitle("Number of Trees");
+        g.GetYaxis()->SetTitle("Standard deviation of estimated hadronness");
+        g.SetMarkerStyle(kFullDotlarge);
+        g.Draw("P");
+
+    }
+    gPad->SetGrid();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw histogram. (For the Meaning see class description)
+//
+void MHRanForest::Draw(Option_t *)
+{
+   if (fGraphSigma->GetN()==0)
+        return;
+
+   if (!gPad)
+        MakeDefCanvas("RanForest", fTitle);
+
+    gStyle->SetOptStat(10);
+    fGraphSigma->Draw("ALP");
+    gPad->Modified();
+    gPad->Update();
+    if (fGraphSigma->GetHistogram())
+    {
+        fGraphSigma->GetXaxis()->SetRangeUser(0, 1);
+        fGraphSigma->GetXaxis()->SetTitle("Number of Trees");
+        fGraphSigma->GetYaxis()->SetTitle("Standard deviation of estimated hadronness");
+
+        fGraphSigma->SetMarkerStyle(kFullDotSmall);
+        fGraphSigma->Draw("P");
+        gPad->Modified();
+        gPad->Update();
+    }    
+}
+void MHRanForest::Print(Option_t *) const
+{
+    return;
+}
Index: trunk/MagicSoft/Mars/mhist/MHRanForest.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHRanForest.h	(revision 1859)
+++ trunk/MagicSoft/Mars/mhist/MHRanForest.h	(revision 1859)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHRanForest
+#define MARS_MHRanForest
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef TArrayF
+#include "TArrayF.h"
+#endif
+
+class TH1D;
+class TGraph;
+class MParList;
+class MMcEvt;
+class MRanForest;
+
+class MHRanForest : public MH
+{
+private:
+    const MMcEvt *fMcEvt;
+    const MRanForest *fRanForest;
+
+    TArrayF fSigma;
+    Int_t fNumEvent;
+    TGraph *fGraphSigma;
+
+public:
+    MHRanForest(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
+    ~MHRanForest();
+
+    TGraph *GetGrphSigma() const  { return fGraphSigma; }
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
+
+    void Print(Option_t *option="") const;
+
+    void Draw(Option_t *opt="");
+    TObject *DrawClone(Option_t *opt="") const;
+
+    ClassDef(MHRanForest, 1) // Histogram showing variance of estimated Hadronness
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mhist/MHRanForestGini.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHRanForestGini.cc	(revision 1859)
+++ trunk/MagicSoft/Mars/mhist/MHRanForestGini.cc	(revision 1859)
@@ -0,0 +1,207 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHRanForest
+//
+// This histogram shows a measure of variable importance (mean decrease in
+// Gini-index)
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHRanForestGini.h"
+
+#include <TPad.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MRanForest.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHRanForestGini);
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms, nbins is the number of bins used for the evaluation.
+// The default is 100 bins.
+//
+MHRanForestGini::MHRanForestGini(Int_t nbins, const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHRanForestGini";
+    fTitle = title ? title : "Measure of importance of Random Forest-input parameters";
+
+    fGraphGini = new TGraph;
+    fGraphGini->SetTitle("Importance of RF-input parameters measured by mean Gini decrease");
+    fGraphGini->SetMaximum(1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHRanForestGini::~MHRanForestGini()
+{
+    delete fGraphGini;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup Filling of the histograms. It needs:
+//  MMcEvt and MRanForest
+//
+Bool_t MHRanForestGini::SetupFill(const MParList *plist)
+{
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanForest = (MRanForest*)plist->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGini.Set(fRanForest->GetNumDim());
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the RanForest from a MRanForest container into the corresponding
+// histogram dependant on the particle id.
+//
+//
+Bool_t MHRanForestGini::Fill(const MParContainer *par)
+{
+    for (Int_t i=0;i<fRanForest->GetNumDim();i++)
+        fGini[i]+=fRanForest->GetGiniDec(i);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MHRanForestGini::Finalize()
+{
+    Int_t n = fGini.GetSize();
+
+    fGraphGini->Set(n);
+
+    Stat_t max=0.;
+    Stat_t min=0.;
+    for (Int_t i=0; i<n; i++)
+    {
+        Stat_t ip = i+1.;
+        fGini[i]/=Stat_t(fRanForest->GetNumTrees());
+        fGini[i]/=Stat_t(fRanForest->GetNumData());
+        Stat_t ig = fGini[i];
+        max=TMath::Max(max,ig);
+        min=TMath::Min(min,ig);
+        fGraphGini->SetPoint(i,ip,ig);
+    }
+    fGraphGini->SetMaximum(1.05*max);
+    fGraphGini->SetMinimum(0.95*min);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram (For the Meaning see class description)
+//
+TObject *MHRanForestGini::DrawClone(Option_t *opt) const
+{
+    if (fGraphGini->GetN()==0)
+        return NULL;
+
+    TCanvas &c = *MakeDefCanvas("RanForestGini", fTitle);
+    gROOT->SetSelectedPad(NULL);
+
+    gStyle->SetOptStat(10);
+    TGraph &g = (TGraph&)*fGraphGini->DrawClone("AL");
+    g.SetBit(kCanDelete);
+    gPad->Modified();
+    gPad->Update();
+    if (g.GetHistogram())
+    {
+        g.GetXaxis()->SetRangeUser(0, fRanForest->GetNumTrees());
+        g.GetXaxis()->SetTitle("No. of RF-input parameter parameter");
+        g.GetYaxis()->SetTitle("Mean decrease in Gini-index [a.u.]");
+        g.SetMarkerStyle(kFullDotlarge);
+        g.Draw("P");
+
+    }
+    gPad->SetGrid();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw histogram. (For the Meaning see class description)
+//
+void MHRanForestGini::Draw(Option_t *)
+{
+   if (fGraphGini->GetN()==0)
+        return;
+
+   if (!gPad)
+        MakeDefCanvas("RanForest", fTitle);
+
+    gStyle->SetOptStat(10);
+    fGraphGini->Draw("ALP");
+    gPad->Modified();
+    gPad->Update();
+    if (fGraphGini->GetHistogram())
+    {
+        fGraphGini->GetXaxis()->SetRangeUser(0, 1);
+        fGraphGini->GetXaxis()->SetTitle("No. of parameter");
+        fGraphGini->GetYaxis()->SetTitle("Mean decrease in Gini-index [a.u.]");
+
+        fGraphGini->SetMarkerStyle(kFullDotSmall);
+        fGraphGini->Draw("P");
+        gPad->Modified();
+        gPad->Update();
+    }
+}
+void MHRanForestGini::Print(Option_t *) const
+{
+    return;
+}
Index: trunk/MagicSoft/Mars/mhist/MHRanForestGini.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHRanForestGini.h	(revision 1859)
+++ trunk/MagicSoft/Mars/mhist/MHRanForestGini.h	(revision 1859)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHRanForestGini
+#define MARS_MHRanForestGini
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef TArrayF
+#include "TArrayF.h"
+#endif
+
+class TH1D;
+class TGraph;
+class MParList;
+class MMcEvt;
+class MRanForest;
+
+class MHRanForestGini : public MH
+{
+private:
+    const MMcEvt *fMcEvt;
+    const MRanForest *fRanForest;
+
+    TArrayF fGini;
+    TGraph *fGraphGini;
+
+public:
+    MHRanForestGini(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
+    ~MHRanForestGini();
+
+    TGraph *GetGrphGini() const  { return fGraphGini; }
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
+
+    void Print(Option_t *option="") const;
+
+    void Draw(Option_t *opt="");
+    TObject *DrawClone(Option_t *opt="") const;
+
+    ClassDef(MHRanForestGini, 1)
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 1854)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 1859)
@@ -52,4 +52,6 @@
            MHCompProb.cc \
            MHHadronness.cc \
+	   MHRanForest.cc \
+	   MHRanForestGini.cc \
            MHMcEnergy.cc \
            MHMcEfficiency.cc \
