Logo ROOT  
Reference Guide
DataSetManager.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : DataSetManager *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation (see header for description) *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
17  * *
18  * Copyright (c) 2006: *
19  * CERN, Switzerland *
20  * MPI-K Heidelberg, Germany *
21  * *
22  * Redistribution and use in source and binary forms, with or without *
23  * modification, are permitted according to the terms listed in LICENSE *
24  * (http://tmva.sourceforge.net/LICENSE) *
25  **********************************************************************************/
26 
27 /*! \class TMVA::DataSetManager
28 \ingroup TMVA
29 
30 Class that contains all the data information.
31 
32 */
33 
34 #include <vector>
35 #include <iostream>
36 using std::endl;
37 
38 #include "TMVA/DataSetManager.h"
39 #include "TMVA/DataSetFactory.h"
40 #include "TMVA/DataSet.h"
41 #include "TMVA/DataSetInfo.h"
42 #include "TMVA/MsgLogger.h"
43 
44 #include "TMVA/Types.h"
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// constructor
48 
50  : fDatasetFactory(0),
51  fDataInput(&dataInput),
52  fDataSetInfoCollection(),
53  fLogger( new MsgLogger("DataSetManager", kINFO) )
54 {
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// constructor
59 
61 : fDatasetFactory(0),
62 fDataInput(0),
63 fDataSetInfoCollection(),
64 fLogger( new MsgLogger("DataSetManager", kINFO) )
65 {
66 }
67 
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// destructor
71 /// fDataSetInfoCollection.SetOwner(); // DSMTEST --> created a segfault because the DataSetInfo-objects got deleted twice
72 
74 {
75  if(fDatasetFactory) delete fDatasetFactory;
76 
77  delete fLogger;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Creates the singleton dataset
82 
84 {
85  DataSetInfo* dsi = GetDataSetInfo( dsiName );
86  if (!dsi) Log() << kFATAL << "DataSetInfo object '" << dsiName << "' not found" << Endl;
87  if (!fDataInput ) Log() << kFATAL << "DataInputHandler object 'fDataInput' not found" << Endl;
88 
89  // factory to create dataset from datasetinfo and datainput
90  if(!fDatasetFactory) { fDatasetFactory =new DataSetFactory(); }
91  return fDatasetFactory->CreateDataSet( *dsi, *fDataInput );
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// returns datasetinfo object for given name
96 
98 {
99  return (DataSetInfo*)fDataSetInfoCollection.FindObject( dsiName );
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// stores a copy of the dataset info object
104 
106 {
107  dsi.SetDataSetManager( this ); // DSMTEST
108 
109  DataSetInfo * dsiInList = GetDataSetInfo(dsi.GetName());
110  if (dsiInList!=0) return *dsiInList;
111  fDataSetInfoCollection.Add( const_cast<DataSetInfo*>(&dsi) );
112  return dsi;
113 }
DataSetManager.h
TMVA::DataInputHandler
Class that contains all the data information.
Definition: DataInputHandler.h:78
DataSetInfo.h
TMath::Log
Double_t Log(Double_t x)
Definition: TMath.h:760
TMVA::DataSetManager::AddDataSetInfo
DataSetInfo & AddDataSetInfo(DataSetInfo &dsi)
stores a copy of the dataset info object
Definition: DataSetManager.cxx:105
TMVA::DataSetFactory
Class that contains all the data information.
Definition: DataSetFactory.h:174
TString
Basic string class.
Definition: TString.h:136
TMVA::DataSetManager::~DataSetManager
~DataSetManager()
destructor fDataSetInfoCollection.SetOwner(); // DSMTEST --> created a segfault because the DataSetIn...
Definition: DataSetManager.cxx:73
TMVA::DataSetInfo
Class that contains all the data information.
Definition: DataSetInfo.h:62
MsgLogger.h
TMVA::DataSetManager::GetDataSetInfo
DataSetInfo * GetDataSetInfo(const TString &dsiName)
returns datasetinfo object for given name
Definition: DataSetManager.cxx:97
TMVA::DataSet
Class that contains all the data information.
Definition: DataSet.h:58
TObject::FindObject
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:323
TMVA::DataSetInfo::SetDataSetManager
void SetDataSetManager(DataSetManager *dsm)
Definition: DataSetInfo.h:198
Types.h
TMVA::Endl
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
DataSetFactory.h
TMVA::DataSetManager::CreateDataSet
DataSet * CreateDataSet(const TString &dsiName)
Creates the singleton dataset.
Definition: DataSetManager.cxx:83
TMVA::MsgLogger
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
TMVA::DataSetInfo::GetName
virtual const char * GetName() const
Returns name of object.
Definition: DataSetInfo.h:71
TMVA::DataSetManager::DataSetManager
DataSetManager()
constructor
Definition: DataSetManager.cxx:60
DataSet.h