DataSetInfo.h

Go to the documentation of this file.
00001 // // @(#)root/tmva $Id: DataSetInfo.h 37097 2010-11-30 12:28:05Z 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  : DataSetInfo                                                           *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Contains all the data information                                         *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland              *
00015  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - DESY, Germany                  *
00016  *                                                                                *
00017  * Copyright (c) 2008:                                                            *
00018  *      CERN, Switzerland                                                         *
00019  *      MPI-K Heidelberg, Germany                                                 *
00020  *      DESY Hamburg, Germany                                                     *
00021  *                                                                                *
00022  * Redistribution and use in source and binary forms, with or without             *
00023  * modification, are permitted according to the terms listed in LICENSE           *
00024  * (http://tmva.sourceforge.net/LICENSE)                                          *
00025  **********************************************************************************/
00026 
00027 #ifndef ROOT_TMVA_DataSetInfo
00028 #define ROOT_TMVA_DataSetInfo
00029 
00030 //////////////////////////////////////////////////////////////////////////
00031 //                                                                      //
00032 // DataSetInfo                                                          //
00033 //                                                                      //
00034 // Class that contains all the data information                         //
00035 //                                                                      //
00036 //////////////////////////////////////////////////////////////////////////
00037 
00038 #include <iosfwd>
00039 
00040 #ifndef ROOT_TObject
00041 #include "TObject.h"
00042 #endif
00043 #ifndef ROOT_TString
00044 #include "TString.h"
00045 #endif
00046 #ifndef ROOT_TTree
00047 #include "TTree.h"
00048 #endif
00049 #ifndef ROOT_TCut
00050 #include "TCut.h"
00051 #endif
00052 #ifndef ROOT_TMatrixDfwd
00053 #include "TMatrixDfwd.h"
00054 #endif
00055 
00056 #ifndef ROOT_TMVA_Types
00057 #include "TMVA/Types.h"
00058 #endif
00059 #ifndef ROOT_TMVA_VariableInfo
00060 #include "TMVA/VariableInfo.h"
00061 #endif
00062 #ifndef ROOT_TMVA_ClassInfo
00063 #include "TMVA/ClassInfo.h"
00064 #endif
00065 #ifndef ROOT_TMVA_Event
00066 #include "TMVA/Event.h"
00067 #endif
00068 
00069 class TH2;
00070 
00071 namespace TMVA {
00072 
00073    class DataSet;
00074    class VariableTransformBase;
00075    class MsgLogger;
00076    class DataSetManager;
00077 
00078    class DataSetInfo : public TObject {
00079 
00080    public:
00081 
00082       DataSetInfo(const TString& name = "Default");
00083       virtual ~DataSetInfo();
00084 
00085       virtual const char* GetName() const { return fName.Data(); }
00086 
00087       // the data set
00088       void        ClearDataSet() const;
00089       DataSet*    GetDataSet() const;
00090 
00091       // ---
00092       // the variable data
00093       // ---
00094       VariableInfo&     AddVariable( const TString& expression, const TString& title = "", const TString& unit = "", 
00095                                      Double_t min = 0, Double_t max = 0, char varType='F', 
00096                                      Bool_t normalized = kTRUE, void* external = 0 );
00097       VariableInfo&     AddVariable( const VariableInfo& varInfo );
00098 
00099       VariableInfo&     AddTarget  ( const TString& expression, const TString& title, const TString& unit, 
00100                                      Double_t min, Double_t max, Bool_t normalized = kTRUE, void* external = 0 );
00101       VariableInfo&     AddTarget  ( const VariableInfo& varInfo );
00102 
00103       VariableInfo&     AddSpectator ( const TString& expression, const TString& title, const TString& unit, 
00104                                        Double_t min, Double_t max, char type = 'F', Bool_t normalized = kTRUE, void* external = 0 );
00105       VariableInfo&     AddSpectator ( const VariableInfo& varInfo );
00106 
00107       ClassInfo*        AddClass   ( const TString& className );
00108 
00109       // accessors
00110 
00111       // general
00112       std::vector<VariableInfo>&       GetVariableInfos()         { return fVariables; }
00113       const std::vector<VariableInfo>& GetVariableInfos() const   { return fVariables; }
00114       VariableInfo&                    GetVariableInfo( Int_t i ) { return fVariables.at(i); }
00115       const VariableInfo&              GetVariableInfo( Int_t i ) const { return fVariables.at(i); }
00116 
00117       std::vector<VariableInfo>&       GetTargetInfos()         { return fTargets; }
00118       const std::vector<VariableInfo>& GetTargetInfos() const   { return fTargets; }
00119       VariableInfo&                    GetTargetInfo( Int_t i ) { return fTargets.at(i); }
00120       const VariableInfo&              GetTargetInfo( Int_t i ) const { return fTargets.at(i); }
00121 
00122       std::vector<VariableInfo>&       GetSpectatorInfos()         { return fSpectators; }
00123       const std::vector<VariableInfo>& GetSpectatorInfos() const   { return fSpectators; }
00124       VariableInfo&                    GetSpectatorInfo( Int_t i ) { return fSpectators.at(i); }
00125       const VariableInfo&              GetSpectatorInfo( Int_t i ) const { return fSpectators.at(i); }
00126 
00127 
00128       UInt_t                           GetNVariables()    const { return fVariables.size(); }
00129       UInt_t                           GetNTargets()      const { return fTargets.size(); }
00130       UInt_t                           GetNSpectators(bool all=kTRUE)   const;
00131 
00132       const TString&                   GetNormalization() const { return fNormalization; }
00133       void                             SetNormalization( const TString& norm )   { fNormalization = norm; }
00134 
00135       // classification information
00136       Int_t              GetClassNameMaxLength() const;
00137       ClassInfo*         GetClassInfo( Int_t clNum ) const;
00138       ClassInfo*         GetClassInfo( const TString& name ) const;
00139       void               PrintClasses() const;
00140       UInt_t             GetNClasses() const { return fClasses.size(); }
00141       Bool_t             IsSignal( const Event* ev ) const;
00142       std::vector<Float_t>* GetTargetsForMulticlass( const Event* ev );
00143 
00144       // by variable
00145       Int_t              FindVarIndex( const TString& )      const;
00146 
00147       // weights
00148       const TString      GetWeightExpression(Int_t i)      const { return GetClassInfo(i)->GetWeight(); }
00149       void               SetWeightExpression( const TString& exp, const TString& className = "" );
00150 
00151       // cuts
00152       const TCut&        GetCut (Int_t i)                         const { return GetClassInfo(i)->GetCut(); }
00153       const TCut&        GetCut ( const TString& className )      const { return GetClassInfo(className)->GetCut(); }
00154       void               SetCut ( const TCut& cut, const TString& className );
00155       void               AddCut ( const TCut& cut, const TString& className );
00156       Bool_t             HasCuts() const;
00157 
00158       std::vector<TString> GetListOfVariables() const;
00159 
00160       // correlation matrix 
00161       const TMatrixD*    CorrelationMatrix     ( const TString& className ) const;
00162       void               SetCorrelationMatrix  ( const TString& className, TMatrixD* matrix );
00163       void               PrintCorrelationMatrix( const TString& className );
00164       TH2*               CreateCorrelationMatrixHist( const TMatrixD* m,
00165                                                       const TString& hName,
00166                                                       const TString& hTitle ) const;
00167 
00168       // options
00169       void               SetSplitOptions(const TString& so) { fSplitOptions = so; fNeedsRebuilding = kTRUE; }
00170       const TString&     GetSplitOptions() const { return fSplitOptions; }
00171 
00172       // root dir
00173       void               SetRootDir(TDirectory* d) { fOwnRootDir = d; }
00174       TDirectory*        GetRootDir() const { return fOwnRootDir; }
00175 
00176       void               SetMsgType( EMsgType t ) const;
00177 
00178    private:
00179 
00180       TMVA::DataSetManager*            fDataSetManager; // DSMTEST
00181       void                       SetDataSetManager( DataSetManager* dsm ) { fDataSetManager = dsm; } // DSMTEST
00182       friend class DataSetManager;  // DSMTEST (datasetmanager test)
00183 
00184       DataSetInfo( const DataSetInfo& ) : TObject() {}
00185 
00186       void PrintCorrelationMatrix( TTree* theTree );
00187 
00188       TString                    fName;              //! name of the dataset info object
00189 
00190       mutable DataSet*           fDataSet;           //! dataset, owned by this datasetinfo object
00191       mutable Bool_t             fNeedsRebuilding;   //! flag if rebuilding of dataset is needed (after change of cuts, vars, etc.)
00192 
00193       // expressions/formulas
00194       std::vector<VariableInfo>  fVariables;         //! list of variable expressions/internal names
00195       std::vector<VariableInfo>  fTargets;           //! list of targets expressions/internal names
00196       std::vector<VariableInfo>  fSpectators;          //! list of spectators expressions/internal names
00197 
00198       // the classes
00199       mutable std::vector<ClassInfo*> fClasses;      //! name and other infos of the classes
00200 
00201       TString                    fNormalization;     //!
00202       TString                    fSplitOptions;      //!
00203       
00204       TDirectory*                fOwnRootDir;        //! ROOT output dir
00205       Bool_t                     fVerbose;           //! Verbosity
00206 
00207       UInt_t                     fSignalClass;       //! index of the class with the name signal
00208 
00209       std::vector<Float_t>*      fTargetsForMulticlass;       //! all targets 0 except the one with index==classNumber
00210       
00211       mutable MsgLogger*         fLogger;            //! message logger
00212       MsgLogger& Log() const { return *fLogger; }
00213 
00214 
00215    };
00216 }
00217 
00218 #endif

Generated on Tue Jul 5 14:27:26 2011 for ROOT_528-00b_version by  doxygen 1.5.1