ROOT  6.06/09
Reference Guide
VariableGaussTransform.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Eckhard v. Toerne
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : VariableGaussTransform *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Decorrelation of input variables *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Eckhard v. Toerne <evt@uni-bonn.de> - Uni Bonn, Germany *
17  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
18  * *
19  * Copyright (c) 2005: *
20  * CERN, Switzerland *
21  * U. of Victoria, Canada *
22  * MPI-K Heidelberg, Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://tmva.sourceforge.net/LICENSE) *
27  **********************************************************************************/
28 
29 #ifndef ROOT_TMVA_VariableGaussTransform
30 #define ROOT_TMVA_VariableGaussTransform
31 
32 #ifndef ROOT_TMVA_PDF
33 #include "TMVA/PDF.h"
34 #endif
35 
36 //////////////////////////////////////////////////////////////////////////
37 // //
38 // VariableGaussTransform //
39 // //
40 // Gaussian transformation of input variables. //
41 // //
42 //////////////////////////////////////////////////////////////////////////
43 
44 #include <vector>
45 
46 #ifndef ROOT_TH1
47 #include "TH1.h"
48 #endif
49 #ifndef ROOT_TGraph
50 #include "TGraph.h"
51 #endif
52 #ifndef ROOT_TSpline
53 #include "TSpline.h"
54 #endif
55 #ifndef ROOT_TDirectory
56 #include "TDirectory.h"
57 #endif
58 #ifndef ROOT_Event
59 #include "Event.h"
60 #endif
61 
62 #ifndef ROOT_TMVA_VariableTransformBase
64 #endif
65 
66 namespace TMVA {
67 
68  class TMVAGaussPair {
69 
70  public:
71 
72  TMVAGaussPair( Float_t f, Float_t w ): fF(f), fW(w) {}
73  Bool_t operator > ( const TMVAGaussPair &p ) const { return fF > p.fF; }
74  Bool_t operator < ( const TMVAGaussPair &p ) const { return fF < p.fF; }
75  Bool_t operator == ( const TMVAGaussPair &p ) const { return fF == p.fF; }
76  Float_t GetValue() const { return fF; }
77  Float_t GetWeight() const { return fW; }
78 
79  private:
80 
81  Float_t fF; // the float
82  Float_t fW; // the event weight
83  };
84 
85 
87 
88  public:
89 
90  VariableGaussTransform( DataSetInfo& dsi, TString strcor="" );
91  virtual ~VariableGaussTransform( void );
92 
93  void Initialize();
94  Bool_t PrepareTransformation (const std::vector<Event*>&);
95 
96  virtual const Event* Transform(const Event* const, Int_t cls ) const;
97  virtual const Event* InverseTransform(const Event* const, Int_t cls ) const;
98 
99  void WriteTransformationToStream ( std::ostream& ) const;
100  void ReadTransformationFromStream( std::istream&, const TString& );
101 
102  virtual void AttachXMLTo(void* parent);
103  virtual void ReadFromXML( void* trfnode );
104 
105  virtual void PrintTransformation( std::ostream & o );
106 
107  // writer of function code
108  virtual void MakeFunction( std::ostream& fout, const TString& fncName, Int_t part, UInt_t trCounter, Int_t cls );
109 
110  private:
111 
115  // mutable Event* fTransformedEvent;
116 
117  std::vector< std::vector< TH1F* > > fCumulativeDist; //! The Cummulative distributions
118  //std::vector< std::vector< TGraph* > > fCumulativeGraph; //! The Cummulative distributions
119  //std::vector< std::vector< TSpline3* > > fCumulativeSpline; //! The Cummulative distributions
120  std::vector< std::vector< PDF*> > fCumulativePDF; // The cumulative PDF
121 
122  void GetCumulativeDist( const std::vector<Event*>& );
123  void CleanUpCumulativeArrays(TString opt = "ALL");
124 
125  // needed for backward compatibility
126  UInt_t fElementsperbin; // av number of events stored per bin in cum dist
127  Double_t OldCumulant(Float_t x, TH1* h ) const;
128 
129  ClassDef(VariableGaussTransform,0) // Variable transformation: Gauss transformation
130  };
131 
132 } // namespace TMVA
133 
134 #endif
void GetCumulativeDist(const std::vector< Event * > &)
fill the cumulative distributions
virtual const Event * Transform(const Event *const, Int_t cls) const
apply the Gauss transformation
virtual ~VariableGaussTransform(void)
destructor
float Float_t
Definition: RtypesCore.h:53
Float_t GetWeight() const
VariableGaussTransform(DataSetInfo &dsi, TString strcor="")
TH1 * h
Definition: legend2.C:5
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t operator<(const TMVAGaussPair &p) const
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
void ReadTransformationFromStream(std::istream &, const TString &)
Read the cumulative distribution.
Bool_t operator>(const TMVAGaussPair &p) const
Bool_t PrepareTransformation(const std::vector< Event * > &)
calculate the cumulative distributions
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t OldCumulant(Float_t x, TH1 *h) const
double f(double x)
double Double_t
Definition: RtypesCore.h:55
Bool_t operator==(const TMVAGaussPair &p) const
The TH1 histogram class.
Definition: TH1.h:80
virtual void MakeFunction(std::ostream &fout, const TString &fncName, Int_t part, UInt_t trCounter, Int_t cls)
creates the transformation function
Abstract ClassifierFactory template that handles arbitrary types.
std::vector< std::vector< PDF * > > fCumulativePDF
The Cummulative distributions.
virtual void ReadFromXML(void *trfnode)
Read the transformation matrices from the xml node.
TMVAGaussPair(Float_t f, Float_t w)
void CleanUpCumulativeArrays(TString opt="ALL")
clean up of cumulative arrays
virtual void AttachXMLTo(void *parent)
create XML description of Gauss transformation
virtual const Event * InverseTransform(const Event *const, Int_t cls) const
apply the inverse Gauss or inverse uniform transformation
virtual void PrintTransformation(std::ostream &o)
prints the transformation
std::vector< std::vector< TH1F * > > fCumulativeDist
void WriteTransformationToStream(std::ostream &) const