// @(#)root/tmva $Id$ // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss /********************************************************************************** * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * * Package: TMVA * * Class : Results * * Web : http://tmva.sourceforge.net * * * * Description: * * Implementation (see header for description) * * * * Authors (alphabetical): * * Andreas Hoecker - CERN, Switzerland * * Peter Speckmayer - CERN, Switzerland * * Joerg Stelzer - CERN, Switzerland * * Helge Voss - MPI-K Heidelberg, Germany * * * * Copyright (c) 2006: * * CERN, Switzerland * * MPI-K Heidelberg, Germany * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * * (http://tmva.sourceforge.net/LICENSE) * **********************************************************************************/ #include #include "TH1.h" #include "TH2.h" #include "TGraph.h" #include "TMVA/Results.h" #include "TMVA/MsgLogger.h" //_______________________________________________________________________ TMVA::Results::Results( const DataSetInfo* dsi, TString resultsName ) : fTreeType(Types::kTraining), fDsi(dsi), fStorage( new TList() ), fHistAlias( new std::map ), fLogger( new MsgLogger(Form("Results%s",resultsName.Data()), kINFO) ) { // constructor fStorage->SetOwner(); } //_______________________________________________________________________ TMVA::Results::~Results() { // destructor // delete result-histograms delete fStorage; delete fHistAlias; delete fLogger; } //_______________________________________________________________________ void TMVA::Results::Store( TObject* obj, const char* alias ) { TListIter l(fStorage); // check if object is already in list while (void* p = (void*)l()) { if(p==obj) *fLogger << kFATAL << "Histogram pointer " << p << " already exists in results storage" << Endl; } TString as(obj->GetName()); if (alias!=0) as=TString(alias); if (fHistAlias->find(as) != fHistAlias->end()) { // alias exists *fLogger << kFATAL << "Alias " << as << " already exists in results storage" << Endl; } if( obj->InheritsFrom(TH1::Class()) ) { ((TH1*)obj)->SetDirectory(0); } fStorage->Add( obj ); fHistAlias->insert(std::pair(as,obj)); } //_______________________________________________________________________ TObject* TMVA::Results::GetObject(const TString & alias) const { std::map::iterator it = fHistAlias->find(alias); if (it != fHistAlias->end()) return it->second; // alias does not exist return 0; } Bool_t TMVA::Results::DoesExist(const TString & alias) const { TObject* test = GetObject(alias); return test; } //_______________________________________________________________________ TH1* TMVA::Results::GetHist(const TString & alias) const { TH1* out=dynamic_cast(GetObject(alias)); if (!out) Log() <(GetObject(alias)); if (!out) Log() <Delete(); fHistAlias->clear(); }