Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
VariableIdentityTransform.cxx
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 : VariableIdentityTransform *
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) 2005: *
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 /*! \class TMVA::VariableIdentityTransform
28 \ingroup TMVA
29 Linear interpolation class
30 */
31 
33 
34 #include "TMVA/Event.h"
35 #include "TMVA/MsgLogger.h"
36 #include "TMVA/SVEvent.h"
37 #include "TMVA/Types.h"
39 
40 #include "Rtypes.h"
41 #include "TString.h"
42 
43 #include <iostream>
44 
45 namespace TMVA {
46  class DataSetInfo;
47 }
48 
49 ClassImp(TMVA::VariableIdentityTransform);
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// constructor
53 
54 TMVA::VariableIdentityTransform::VariableIdentityTransform( DataSetInfo& dsi )
55 : VariableTransformBase( dsi, Types::kIdentity, "Id" )
56 {
57 }
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// nothing to initialize
61 
62 void TMVA::VariableIdentityTransform::Initialize()
63 {
64 }
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// the identity does not need to be prepared, only calculate the normalization
68 
69 Bool_t TMVA::VariableIdentityTransform::PrepareTransformation (const std::vector<Event*>& events)
70 {
71  Initialize();
72 
73  if (!IsEnabled() || IsCreated()) return kTRUE;
74 
75  Log() << kDEBUG << "Preparing the Identity transformation..." << Endl;
76 
77  if( fGet.size() < events[0]->GetNVariables() )
78  Log() << kFATAL << "Identity transform does not allow for a selection of input variables. Please remove the variable selection option and put only 'I'." << Endl;
79 
80  SetNVariables(events[0]->GetNVariables());
81 
82  SetCreated( kTRUE );
83 
84  return kTRUE;
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// identity transformation to write to XML
89 ///Log() << kFATAL << "Please implement writing of transformation as XML" << Endl;
90 
91 void TMVA::VariableIdentityTransform::AttachXMLTo( void* )
92 {
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// reding the identity transformation from XML
97 
98 void TMVA::VariableIdentityTransform::ReadFromXML( void* )
99 {
100  return;
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// identity transform returns same event
105 
106 const TMVA::Event* TMVA::VariableIdentityTransform::Transform (const TMVA::Event* const ev, Int_t ) const
107 {
108  return ev;
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// creates C++ code fragment of the identity transform for inclusion in standalone C++ class
113 
114 void TMVA::VariableIdentityTransform::MakeFunction( std::ostream& fout, const TString& fncName,
115  Int_t , UInt_t trCounter, Int_t )
116 {
117  fout << "inline void " << fncName << "::InitTransform_Identity_" << trCounter << "() {}" << std::endl;
118  fout << std::endl;
119  fout << "inline void " << fncName << "::Transform_Identity_" << trCounter << "(const std::vector<double> &, int) const {}" << std::endl;
120 }