Results.cxx

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: Results.cxx 36966 2010-11-26 09:50:13Z evt $
00002 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : Results                                                             *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Implementation (see header for description)                               *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
00015  *      Peter Speckmayer <Peter.Speckmayer@cern.ch>  - CERN, Switzerland          *
00016  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
00017  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
00018  *                                                                                *
00019  * Copyright (c) 2006:                                                            *
00020  *      CERN, Switzerland                                                         *
00021  *      MPI-K Heidelberg, Germany                                                 *
00022  *                                                                                *
00023  * Redistribution and use in source and binary forms, with or without             *
00024  * modification, are permitted according to the terms listed in LICENSE           *
00025  * (http://tmva.sourceforge.net/LICENSE)                                          *
00026  **********************************************************************************/
00027 
00028 #include <vector>
00029 
00030 #include "TH1.h"
00031 
00032 #include "TMVA/Results.h"
00033 #include "TMVA/MsgLogger.h"
00034 
00035 //_______________________________________________________________________
00036 TMVA::Results::Results( const DataSetInfo* dsi ) 
00037    : fTreeType(Types::kTraining),
00038      fDsi(dsi),
00039      fStorage( new TList() ),
00040      fHistAlias( new std::map<TString, TObject*> ),
00041      fLogger( new MsgLogger("Results", kINFO) )
00042 {
00043    // constructor
00044    fStorage->SetOwner();
00045 }
00046 
00047 //_______________________________________________________________________
00048 TMVA::Results::~Results() 
00049 {
00050    // destructor
00051 
00052    // delete result-histograms
00053    delete fStorage;
00054    delete fHistAlias;
00055    delete fLogger;
00056 }
00057 
00058 //_______________________________________________________________________
00059 void TMVA::Results::Store( TObject* obj, const char* alias )
00060 {
00061    TListIter l(fStorage);
00062    // check if object is already in list
00063    while (void* p = (void*)l()) {
00064       if(p==obj)
00065          *fLogger << kFATAL << "Histogram pointer " << p << " already exists in results storage" << Endl;
00066    }
00067 
00068    TString as(obj->GetName());
00069    if (alias!=0) as=TString(alias);
00070    if (fHistAlias->find(as) != fHistAlias->end()) {
00071       // alias exists
00072       *fLogger << kFATAL << "Alias " << as << " already exists in results storage" << Endl;
00073    }
00074    if( obj->InheritsFrom(TH1::Class()) ) {
00075       ((TH1*)obj)->SetDirectory(0);
00076    }
00077    fStorage->Add( obj );
00078    fHistAlias->insert(std::pair<TString, TObject*>(as,obj));
00079 }
00080 
00081 //_______________________________________________________________________
00082 TObject* TMVA::Results::GetObject(const TString & alias) const 
00083 {
00084    std::map<TString, TObject*>::iterator it = fHistAlias->find(alias);
00085 
00086    if (it != fHistAlias->end()) return it->second;
00087 
00088    // alias does not exist
00089    return 0;
00090 }
00091 
00092 
00093 //_______________________________________________________________________
00094 TH1* TMVA::Results::GetHist(const TString & alias) const 
00095 {
00096    return (TH1*)GetObject(alias);
00097 }
00098 
00099 
00100 //_______________________________________________________________________
00101 void TMVA::Results::Delete()
00102 {
00103    // delete all stored histograms
00104 
00105    fStorage->Delete();
00106    fHistAlias->clear();
00107 }

Generated on Tue Jul 5 15:25:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1