Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
VariablePCATransform.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : VariablePCATransform *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Principal value composition of input variables *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Peter Speckmayer <Peter.Speckmayer@cern.ch> - CERN, Switzerland *
16  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
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_VariablePCATransform
30 #define ROOT_TMVA_VariablePCATransform
31 
32 //////////////////////////////////////////////////////////////////////////
33 // //
34 // VariablePCATransform //
35 // //
36 // Linear interpolation class //
37 // //
38 //////////////////////////////////////////////////////////////////////////
39 
40 #include "TPrincipal.h"
41 
43 
44 namespace TMVA {
45 
46  class VariablePCATransform : public VariableTransformBase {
47 
48  public:
49 
50  VariablePCATransform( DataSetInfo& dsi );
51  virtual ~VariablePCATransform( void );
52 
53  void Initialize();
54  Bool_t PrepareTransformation (const std::vector<Event*>&);
55 
56  virtual const Event* Transform(const Event* const, Int_t cls ) const;
57  virtual const Event* InverseTransform(const Event* const, Int_t cls ) const;
58 
59  void WriteTransformationToStream ( std::ostream& ) const;
60  void ReadTransformationFromStream( std::istream&, const TString& );
61 
62  virtual void AttachXMLTo(void* parent);
63  virtual void ReadFromXML( void* trfnode );
64 
65  // writer of function code
66  virtual void MakeFunction( std::ostream& fout, const TString& fncName, Int_t part, UInt_t trCounter, Int_t cls );
67 
68  private:
69 
70  void CalculatePrincipalComponents( const std::vector< Event*>& );
71  void X2P( std::vector<Float_t>&, const std::vector<Float_t>&, Int_t cls ) const;
72  void P2X( std::vector<Float_t>&, const std::vector<Float_t>&, Int_t cls ) const;
73 
74  // store relevant parts of PCA locally
75  std::vector<TVectorD*> fMeanValues; // mean values
76  std::vector<TMatrixD*> fEigenVectors; // eigenvectors
77 
78  ClassDef(VariablePCATransform,0); // Variable transformation: Principal Value Composition
79  };
80 
81 } // namespace TMVA
82 
83 #endif
84