Logo ROOT   6.08/07
Reference Guide
TransformationHandler.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Jan Therhaag, Eckhard von Toerne
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : TransformationHandler *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Contains all the data information *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland *
16  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
17  * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
18  * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
19  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
20  * *
21  * Copyright (c) 2005-2011: *
22  * CERN, Switzerland *
23  * MPI-K Heidelberg, Germany *
24  * U. of Bonn, Germany *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
31 #ifndef ROOT_TMVA_TransformationHandler
32 #define ROOT_TMVA_TransformationHandler
33 
34 //////////////////////////////////////////////////////////////////////////
35 // //
36 // TransformationHandler //
37 // //
38 // Class that contains all the data information //
39 // //
40 //////////////////////////////////////////////////////////////////////////
41 
42 #ifndef ROOT_TList
43 #include "TList.h"
44 #endif
45 #ifndef ROOT_TString
46 #include "TString.h"
47 #endif
48 
49 #ifndef ROOT_TMVA_DataSetInfo
50 #include "TMVA/DataSetInfo.h"
51 #endif
52 
53 namespace TMVA {
54 
55  class Event;
56  class DataSet;
57  class Ranking;
58  class VariableTransformBase;
59  class MsgLogger;
60 
62  public:
63 
64  struct VariableStat {
69  };
70 
71  TransformationHandler( DataSetInfo&, const TString& callerName );
73 
74  TString GetName() const;
75  TString GetVariableAxisTitle( const VariableInfo& info ) const;
76 
77  const Event* Transform(const Event*) const;
78  const Event* InverseTransform(const Event*, Bool_t suppressIfNoTargets=true ) const;
79 
80  // overrides the reference classes of all added transformations. Handle with care!!!
82 
84  const TList& GetTransformationList() const { return fTransformations; }
86  const std::vector<Event*>* CalcTransformations( const std::vector<Event*>&, Bool_t createNewVector = kFALSE );
87 
88  void CalcStats( const std::vector<Event*>& events );
89  void AddStats ( Int_t k, UInt_t ivar, Double_t mean, Double_t rms, Double_t min, Double_t max );
90  Double_t GetMean ( Int_t ivar, Int_t cls = -1 ) const;
91  Double_t GetRMS ( Int_t ivar, Int_t cls = -1 ) const;
92  Double_t GetMin ( Int_t ivar, Int_t cls = -1 ) const;
93  Double_t GetMax ( Int_t ivar, Int_t cls = -1 ) const;
94 
95  void WriteToStream ( std::ostream& o ) const;
96  void AddXMLTo ( void* parent=0 ) const;
97  void ReadFromStream( std::istream& istr );
98  void ReadFromXML ( void* trfsnode );
99 
100  // writer of function code
101  void MakeFunction(std::ostream& fout, const TString& fncName, Int_t part) const;
102 
103  // variable ranking
104  void PrintVariableRanking() const;
105 
106  // provides string vector giving explicit transformation (only last transform at present -> later show full chain)
107  std::vector<TString>* GetTransformationStringsOfLastTransform() const;
108  const char* GetNameOfLastTransform() const;
109 
110  // modify caller name for output
111  void SetCallerName( const TString& name );
112  const TString& GetCallerName() const { return fCallerName; }
113 
114  // setting file dir for histograms
115  TDirectory* GetRootDir() const { return fRootBaseDir; }
116  void SetRootDir( TDirectory *d ) { fRootBaseDir = d; }
117 
118  void PlotVariables( const std::vector<Event*>& events, TDirectory* theDirectory = 0 );
119 
120  private:
121 
122  // std::vector<TMVA::Event*>* TransformCollection( VariableTransformBase* trf,
123  // Int_t cls,
124  // std::vector<TMVA::Event*>* events,
125  // Bool_t replace ) const;
126 
127  const TMVA::VariableInfo& Variable(UInt_t ivar) const { return fDataSetInfo.GetVariableInfos().at(ivar); }
128  const TMVA::VariableInfo& Target (UInt_t itgt) const { return fDataSetInfo.GetTargetInfos()[itgt]; }
129 
131 
132  DataSetInfo& fDataSetInfo; // pointer to the datasetinfo
133  TList fTransformations; //! list of transformations
134  std::vector< Int_t > fTransformationsReferenceClasses; //! reference classes for the transformations
135  std::vector<std::vector<TMVA::TransformationHandler::VariableStat> > fVariableStats; // first the variables, then the targets
136 
137  Int_t fNumC; // number of categories (#classes +1)
138 
139  std::vector<Ranking*> fRanking; //! ranking object
140  TDirectory* fRootBaseDir; //! if set put input var hists
141  TString fCallerName; //! name of the caller for output
142  mutable MsgLogger* fLogger; //! message logger
143  MsgLogger& Log() const { return *fLogger; }
144  };
145 }
146 
147 #endif
Double_t GetRMS(Int_t ivar, Int_t cls=-1) const
std::vector< std::vector< TMVA::TransformationHandler::VariableStat > > fVariableStats
reference classes for the transformations
std::vector< Ranking * > fRanking
const TString & GetCallerName() const
TDirectory * fRootBaseDir
ranking object
TransformationHandler(DataSetInfo &, const TString &callerName)
constructor
const TList & GetTransformationList() const
void PlotVariables(const std::vector< Event *> &events, TDirectory *theDirectory=0)
create histograms from the input variables
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
const Event * Transform(const Event *) const
the transformation
void ReadFromStream(std::istream &istr)
VariableTransformBase* trf = ((VariableTransformBase*)GetTransformationList().Last()); trf->ReadTrans...
void SetTransformationReferenceClass(Int_t cls)
overrides the setting for all classes! (this is put in basically for the likelihood-method) be carefu...
void AddXMLTo(void *parent=0) const
XML node describing the transformation return;.
TString GetVariableAxisTitle(const VariableInfo &info) const
incorporates transformation type into title axis (usually for histograms)
void SetCallerName(const TString &name)
Double_t GetMean(Int_t ivar, Int_t cls=-1) const
std::vector< Int_t > fTransformationsReferenceClasses
list of transformations
std::vector< VariableInfo > & GetTargetInfos()
Definition: DataSetInfo.h:117
const std::vector< Event * > * CalcTransformations(const std::vector< Event *> &, Bool_t createNewVector=kFALSE)
computation of transformation
A doubly linked list.
Definition: TList.h:47
void AddStats(Int_t k, UInt_t ivar, Double_t mean, Double_t rms, Double_t min, Double_t max)
unsigned int UInt_t
Definition: RtypesCore.h:42
const Event * InverseTransform(const Event *, Bool_t suppressIfNoTargets=true) const
void MakeFunction(std::ostream &fout, const TString &fncName, Int_t part) const
create transformation function
const char * GetNameOfLastTransform() const
returns string for transformation
TString fCallerName
if set put input var hists
void WriteToStream(std::ostream &o) const
write transformatino to stream
double Double_t
Definition: RtypesCore.h:55
Double_t GetMax(Int_t ivar, Int_t cls=-1) const
Describe directory structure in memory.
Definition: TDirectory.h:44
TString GetName() const
return transformation name
void PrintVariableRanking() const
prints ranking of input variables
MsgLogger & Log() const
message logger
Abstract ClassifierFactory template that handles arbitrary types.
const TMVA::VariableInfo & Variable(UInt_t ivar) const
MsgLogger * fLogger
name of the caller for output
virtual Int_t GetSize() const
Definition: TCollection.h:95
std::vector< TString > * GetTransformationStringsOfLastTransform() const
returns string for transformation
void CalcStats(const std::vector< Event *> &events)
const TMVA::VariableInfo & Target(UInt_t itgt) const
DataSet * GetDataSet() const
returns data set
std::vector< VariableInfo > & GetVariableInfos()
Definition: DataSetInfo.h:112
char name[80]
Definition: TGX11.cxx:109
VariableTransformBase * AddTransformation(VariableTransformBase *, Int_t cls)
Double_t GetMin(Int_t ivar, Int_t cls=-1) const