Logo ROOT   6.08/07
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 #include <vector>
28 #include <iostream>
29 using std::endl;
30 
31 #ifndef ROOT_TMVA_DataSetManager
32 #include "TMVA/DataSetManager.h"
33 #endif
34 #ifndef ROOT_TMVA_DataSetFactory
35 #include "TMVA/DataSetFactory.h"
36 #endif
37 #ifndef ROOT_TMVA_DataSet
38 #include "TMVA/DataSet.h"
39 #endif
40 #ifndef ROOT_TMVA_DataSetInfo
41 #include "TMVA/DataSetInfo.h"
42 #endif
43 #ifndef ROOT_TMVA_MsgLogger
44 #include "TMVA/MsgLogger.h"
45 #endif
46 
47 #include "TMVA/Types.h"
48 
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// constructor
52 
54  : fDatasetFactory(0),
55  fDataInput(&dataInput),
56  fDataSetInfoCollection(),
57  fLogger( new MsgLogger("DataSetManager", kINFO) )
58 {
59 }
60 
62 : fDatasetFactory(0),
63 fDataInput(0),
65 fLogger( new MsgLogger("DataSetManager", kINFO) )
66 {
67 }
68 
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// destructor
72 /// fDataSetInfoCollection.SetOwner(); // DSMTEST --> created a segfault because the DataSetInfo-objects got deleted twice
73 
75 {
77 
78  delete fLogger;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Creates the singleton dataset
83 
85 {
86  DataSetInfo* dsi = GetDataSetInfo( dsiName );
87  if (!dsi) Log() << kFATAL << "DataSetInfo object '" << dsiName << "' not found" << Endl;
88  if (!fDataInput ) Log() << kFATAL << "DataInputHandler object 'fDataInput' not found" << Endl;
89 
90  // factory to create dataset from datasetinfo and datainput
92  return fDatasetFactory->CreateDataSet( *dsi, *fDataInput );
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// returns datasetinfo object for given name
97 
99 {
100  return (DataSetInfo*)fDataSetInfoCollection.FindObject( dsiName );
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// stores a copy of the dataset info object
105 
107 {
108  dsi.SetDataSetManager( this ); // DSMTEST
109 
110  DataSetInfo * dsiInList = GetDataSetInfo(dsi.GetName());
111  if (dsiInList!=0) return *dsiInList;
112  fDataSetInfoCollection.Add( const_cast<DataSetInfo*>(&dsi) );
113  return dsi;
114 }
DataSetInfo * GetDataSetInfo(const TString &dsiName)
returns datasetinfo object for given name
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
DataInputHandler * fDataInput
DataSet * CreateDataSet(const TString &dsiName)
Creates the singleton dataset.
Basic string class.
Definition: TString.h:137
void SetDataSetManager(DataSetManager *dsm)
Definition: DataSetInfo.h:197
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
DataSet * CreateDataSet(DataSetInfo &, DataInputHandler &)
steering the creation of a new dataset
DataSetInfo & AddDataSetInfo(DataSetInfo &dsi)
stores a copy of the dataset info object
MsgLogger & Log() const
message logger
TMVA::DataSetFactory * fDatasetFactory
virtual const char * GetName() const
Returns name of object.
Definition: DataSetInfo.h:85
virtual void Add(TObject *obj)
Definition: TList.h:81
~DataSetManager()
destructor fDataSetInfoCollection.SetOwner(); // DSMTEST –> created a segfault because the DataSetIn...