/usr/include/root/TMVA/VariableTransformBase.h is in libroot-tmva-dev 5.34.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | // @(#)root/tmva $Id$
// Author: Andreas Hoecker, Peter Speckmayer,Joerg Stelzer, Helge Voss
/**********************************************************************************
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
* Package: TMVA *
* Class : VariableTransformBase *
* Web : http://tmva.sourceforge.net *
* *
* Description: *
* Pre-transformation of input variables (base class) *
* *
* Authors (alphabetical): *
* Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
* Peter Speckmayer <Peter.Speckmayer@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 *
* U. of Victoria, Canada *
* 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) *
**********************************************************************************/
#ifndef ROOT_TMVA_VariableTransformBase
#define ROOT_TMVA_VariableTransformBase
//////////////////////////////////////////////////////////////////////////
// //
// VariableTransformBase //
// //
// Linear interpolation class //
// //
//////////////////////////////////////////////////////////////////////////
#include <vector>
#ifndef ROOT_TH1
#include "TH1.h"
#endif
#ifndef ROOT_TDirectory
#include "TDirectory.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TMVA_Types
#include "TMVA/Types.h"
#endif
#ifndef ROOT_TMVA_Event
#include "TMVA/Event.h"
#endif
#ifndef ROOT_TMVA_VariableInfo
#include "TMVA/VariableInfo.h"
#endif
#ifndef ROOT_TMVA_DataSetInfo
#include "TMVA/DataSetInfo.h"
#endif
namespace TMVA {
class VariableTransformBase : public TObject {
public:
typedef std::vector<std::pair<Char_t,UInt_t> > VectorOfCharAndInt;
typedef VectorOfCharAndInt::iterator ItVarTypeIdx;
typedef VectorOfCharAndInt::const_iterator ItVarTypeIdxConst;
VariableTransformBase( DataSetInfo& dsi, Types::EVariableTransform tf, const TString& trfName );
virtual ~VariableTransformBase( void );
virtual void Initialize() = 0;
virtual Bool_t PrepareTransformation (const std::vector<Event*>& ) = 0;
virtual const Event* Transform ( const Event* const, Int_t cls ) const = 0;
virtual const Event* InverseTransform( const Event* const, Int_t cls ) const = 0;
// accessors
void SetEnabled ( Bool_t e ) { fEnabled = e; }
void SetNormalise( Bool_t n ) { fNormalise = n; }
Bool_t IsEnabled() const { return fEnabled; }
Bool_t IsCreated() const { return fCreated; }
Bool_t IsNormalised() const { return fNormalise; }
// variable selection
virtual void SelectInput( const TString& inputVariables, Bool_t putIntoVariables = kFALSE );
virtual Bool_t GetInput ( const Event* event, std::vector<Float_t>& input, std::vector<Char_t>& mask, Bool_t backTransform = kFALSE ) const;
virtual void SetOutput( Event* event, std::vector<Float_t>& output, std::vector<Char_t>& mask, const Event* oldEvent = 0, Bool_t backTransform = kFALSE ) const;
virtual void CountVariableTypes( UInt_t& nvars, UInt_t& ntgts, UInt_t& nspcts ) const;
void ToggleInputSortOrder( Bool_t sortOrder ) { fSortGet = sortOrder; }
void SetOutputDataSetInfo( DataSetInfo* outputDsi ) { fDsiOutput = outputDsi; }
void SetUseSignalTransform( Bool_t e=kTRUE) { fUseSignalTransform = e; }
Bool_t UseSignalTransform() const { return fUseSignalTransform; }
virtual const char* GetName() const { return fTransformName.Data(); }
TString GetShortName() const { TString a(fTransformName); a.ReplaceAll("Transform",""); return a; }
virtual void WriteTransformationToStream ( std::ostream& o ) const = 0;
virtual void ReadTransformationFromStream( std::istream& istr, const TString& classname="" ) = 0;
virtual void AttachXMLTo(void* parent) = 0;
virtual void ReadFromXML( void* trfnode ) = 0;
Types::EVariableTransform GetVariableTransform() const { return fVariableTransform; }
// writer of function code
virtual void MakeFunction( std::ostream& fout, const TString& fncName, Int_t part,
UInt_t trCounter, Int_t cls ) = 0;
// provides string vector giving explicit transformation
virtual std::vector<TString>* GetTransformationStrings( Int_t cls ) const;
virtual void PrintTransformation( std::ostream & ) {}
const std::vector<TMVA::VariableInfo>& Variables() const { return fVariables; }
const std::vector<TMVA::VariableInfo>& Targets() const { return fTargets; }
const std::vector<TMVA::VariableInfo>& Spectators() const { return fSpectators; }
MsgLogger& Log() const { return *fLogger; }
void SetTMVAVersion(TMVAVersion_t v) { fTMVAVersion = v; }
protected:
void CalcNorm( const std::vector<const Event*>& );
void SetCreated( Bool_t c = kTRUE ) { fCreated = c; }
void SetNVariables( UInt_t i ) { fNVars = i; }
void SetName( const TString& c ) { fTransformName = c; }
UInt_t GetNVariables() const { return fDsi.GetNVariables(); }
UInt_t GetNTargets() const { return fDsi.GetNTargets(); }
UInt_t GetNSpectators() const { return fDsi.GetNSpectators(); }
DataSetInfo& fDsi;
DataSetInfo* fDsiOutput;
std::vector<TMVA::VariableInfo>& Variables() { return fVariables; }
std::vector<TMVA::VariableInfo>& Targets() { return fTargets; }
std::vector<TMVA::VariableInfo>& Spectators() { return fSpectators; }
Int_t GetNClasses() const { return fDsi.GetNClasses(); }
mutable Event* fTransformedEvent; // holds the current transformed event
mutable Event* fBackTransformedEvent; // holds the current back-transformed event
// variable selection
VectorOfCharAndInt fGet; // get variables/targets/spectators
VectorOfCharAndInt fPut; // put variables/targets/spectators
private:
Types::EVariableTransform fVariableTransform; // Decorrelation, PCA, etc.
void UpdateNorm( Int_t ivar, Double_t x );
Bool_t fUseSignalTransform; // true if transformation bases on signal data
Bool_t fEnabled; // has been enabled
Bool_t fCreated; // has been created
Bool_t fNormalise; // normalise input variables
UInt_t fNVars; // number of variables
TString fTransformName; // name of transformation
std::vector<TMVA::VariableInfo> fVariables; // event variables [saved to weight file]
std::vector<TMVA::VariableInfo> fTargets; // event targets [saved to weight file --> TODO ]
std::vector<TMVA::VariableInfo> fSpectators; // event spectators [saved to weight file --> TODO ]
mutable Bool_t fVariableTypesAreCounted; // true if variable types have been counted already
mutable UInt_t fNVariables; // number of variables to be transformed
mutable UInt_t fNTargets; // number of targets to be transformed
mutable UInt_t fNSpectators; // number of spectators to be transformed
Bool_t fSortGet; // if true, sort the variables into the order as defined by the user at the var definition
// if false, sort the variables according to the order given for the var transformation
protected:
TMVAVersion_t fTMVAVersion;
mutable MsgLogger* fLogger; //! message logger
ClassDef(VariableTransformBase,0) // Base class for variable transformations
};
} // namespace TMVA
#endif
|