// @(#)root/tmva $Id$
// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : VariableIdentityTransform                                             *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Implementation (see header for description)                               *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
 *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
 *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
 *                                                                                *
 * Copyright (c) 2005:                                                            *
 *      CERN, Switzerland                                                         *
 *      MPI-K Heidelberg, Germany                                                 *
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#include <iostream>

#include "TMVA/VariableIdentityTransform.h"

#ifndef ROOT_TMVA_MsgLogger
#include "TMVA/MsgLogger.h"
#endif

ClassImp(TMVA::VariableIdentityTransform)

//_______________________________________________________________________
   TMVA::VariableIdentityTransform::VariableIdentityTransform( DataSetInfo& dsi )
      : VariableTransformBase( dsi, Types::kIdentity, "Id" )
{
   // constructor
}

//_______________________________________________________________________
void TMVA::VariableIdentityTransform::Initialize()
{
   // nothing to initialize
}

//_______________________________________________________________________
Bool_t TMVA::VariableIdentityTransform::PrepareTransformation (const std::vector<Event*>& events)
{
   // the identity does not need to be prepared, only calculate the normalization
   Initialize();

   if (!IsEnabled() || IsCreated()) return kTRUE;

   Log() << kINFO << "Preparing the Identity transformation..." << Endl;

   if( fGet.size() < events[0]->GetNVariables() )
      Log() << kFATAL << "Identity transform does not allow for a selection of input variables. Please remove the variable selection option and put only 'I'." << Endl;

   SetNVariables(events[0]->GetNVariables());

   SetCreated( kTRUE );

   return kTRUE;
}

//_______________________________________________________________________
void TMVA::VariableIdentityTransform::AttachXMLTo( void* ) 
{
   // identity transformation to write to XML
   //Log() << kFATAL << "Please implement writing of transformation as XML" << Endl;
}

//_______________________________________________________________________
void TMVA::VariableIdentityTransform::ReadFromXML( void* ) 
{
   // reding the identity transformation from XML
   return;
}

//_______________________________________________________________________
const TMVA::Event* TMVA::VariableIdentityTransform::Transform (const TMVA::Event* const ev, Int_t ) const 
{
   // identity transform returns same event
   return ev;
}

//_______________________________________________________________________
void TMVA::VariableIdentityTransform::MakeFunction( std::ostream& fout, const TString& fncName, 
                                                    Int_t , UInt_t trCounter, Int_t ) 
{
   // creates C++ code fragment of the indentity transform for inclusion in standalone C++ class

   fout << "inline void " << fncName << "::InitTransform_Identity_" << trCounter << "() {}" << std::endl;
   fout << std::endl;
   fout << "inline void " << fncName << "::Transform_Identity_" << trCounter << "(const std::vector<double> &, int) const {}" << std::endl;
}
 VariableIdentityTransform.cxx:1
 VariableIdentityTransform.cxx:2
 VariableIdentityTransform.cxx:3
 VariableIdentityTransform.cxx:4
 VariableIdentityTransform.cxx:5
 VariableIdentityTransform.cxx:6
 VariableIdentityTransform.cxx:7
 VariableIdentityTransform.cxx:8
 VariableIdentityTransform.cxx:9
 VariableIdentityTransform.cxx:10
 VariableIdentityTransform.cxx:11
 VariableIdentityTransform.cxx:12
 VariableIdentityTransform.cxx:13
 VariableIdentityTransform.cxx:14
 VariableIdentityTransform.cxx:15
 VariableIdentityTransform.cxx:16
 VariableIdentityTransform.cxx:17
 VariableIdentityTransform.cxx:18
 VariableIdentityTransform.cxx:19
 VariableIdentityTransform.cxx:20
 VariableIdentityTransform.cxx:21
 VariableIdentityTransform.cxx:22
 VariableIdentityTransform.cxx:23
 VariableIdentityTransform.cxx:24
 VariableIdentityTransform.cxx:25
 VariableIdentityTransform.cxx:26
 VariableIdentityTransform.cxx:27
 VariableIdentityTransform.cxx:28
 VariableIdentityTransform.cxx:29
 VariableIdentityTransform.cxx:30
 VariableIdentityTransform.cxx:31
 VariableIdentityTransform.cxx:32
 VariableIdentityTransform.cxx:33
 VariableIdentityTransform.cxx:34
 VariableIdentityTransform.cxx:35
 VariableIdentityTransform.cxx:36
 VariableIdentityTransform.cxx:37
 VariableIdentityTransform.cxx:38
 VariableIdentityTransform.cxx:39
 VariableIdentityTransform.cxx:40
 VariableIdentityTransform.cxx:41
 VariableIdentityTransform.cxx:42
 VariableIdentityTransform.cxx:43
 VariableIdentityTransform.cxx:44
 VariableIdentityTransform.cxx:45
 VariableIdentityTransform.cxx:46
 VariableIdentityTransform.cxx:47
 VariableIdentityTransform.cxx:48
 VariableIdentityTransform.cxx:49
 VariableIdentityTransform.cxx:50
 VariableIdentityTransform.cxx:51
 VariableIdentityTransform.cxx:52
 VariableIdentityTransform.cxx:53
 VariableIdentityTransform.cxx:54
 VariableIdentityTransform.cxx:55
 VariableIdentityTransform.cxx:56
 VariableIdentityTransform.cxx:57
 VariableIdentityTransform.cxx:58
 VariableIdentityTransform.cxx:59
 VariableIdentityTransform.cxx:60
 VariableIdentityTransform.cxx:61
 VariableIdentityTransform.cxx:62
 VariableIdentityTransform.cxx:63
 VariableIdentityTransform.cxx:64
 VariableIdentityTransform.cxx:65
 VariableIdentityTransform.cxx:66
 VariableIdentityTransform.cxx:67
 VariableIdentityTransform.cxx:68
 VariableIdentityTransform.cxx:69
 VariableIdentityTransform.cxx:70
 VariableIdentityTransform.cxx:71
 VariableIdentityTransform.cxx:72
 VariableIdentityTransform.cxx:73
 VariableIdentityTransform.cxx:74
 VariableIdentityTransform.cxx:75
 VariableIdentityTransform.cxx:76
 VariableIdentityTransform.cxx:77
 VariableIdentityTransform.cxx:78
 VariableIdentityTransform.cxx:79
 VariableIdentityTransform.cxx:80
 VariableIdentityTransform.cxx:81
 VariableIdentityTransform.cxx:82
 VariableIdentityTransform.cxx:83
 VariableIdentityTransform.cxx:84
 VariableIdentityTransform.cxx:85
 VariableIdentityTransform.cxx:86
 VariableIdentityTransform.cxx:87
 VariableIdentityTransform.cxx:88
 VariableIdentityTransform.cxx:89
 VariableIdentityTransform.cxx:90
 VariableIdentityTransform.cxx:91
 VariableIdentityTransform.cxx:92
 VariableIdentityTransform.cxx:93
 VariableIdentityTransform.cxx:94
 VariableIdentityTransform.cxx:95
 VariableIdentityTransform.cxx:96
 VariableIdentityTransform.cxx:97
 VariableIdentityTransform.cxx:98
 VariableIdentityTransform.cxx:99
 VariableIdentityTransform.cxx:100