// @(#)root/tmva $Id: VariableTransformBase.h 21630 2008-01-10 19:40:44Z brun $ // Author: Andreas Hoecker, 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 - CERN, Switzerland * * Joerg Stelzer - CERN, Switzerland * * Helge Voss - 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 // // // ////////////////////////////////////////////////////////////////////////// #include #include "TTree.h" #include "TH1.h" #include "TDirectory.h" #include "TString.h" #ifndef ROOT_TMVA_Event #include "TMVA/Event.h" #endif #ifndef ROOT_TMVA_VariableInfo #include "TMVA/VariableInfo.h" #endif #ifndef ROOT_TMVA_MsgLogger #include "TMVA/MsgLogger.h" #endif namespace TMVA { class Ranking; class VariableTransformBase : public TObject { public: VariableTransformBase( std::vector&, Types::EVariableTransform tf ); virtual ~VariableTransformBase( void ); virtual void ApplyTransformation( Types::ESBType type = Types::kMaxSBType ) const = 0; virtual Bool_t PrepareTransformation( TTree* inputTree ) = 0; void PlotVariables( TTree* theTree ); // 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; } void CreateEvent() const; virtual TMVA::Event& GetEvent() const { if (fEvent==0) CreateEvent(); return *fEvent; } TMVA::Event& GetEventRaw() const { if (fEventRaw==0) fEventRaw = new TMVA::Event(fVariables); return *fEventRaw; } // provides string vector describing explicit transformation virtual std::vector* GetTransformationStrings( Types::ESBType type = Types::kMaxSBType ) const = 0; void SetUseSignalTransform( Bool_t e=kTRUE) { fUseSignalTransform = e; } virtual const char* GetName() const { return fTransformName; } UInt_t GetNVariables() const { return fVariables.size(); } void SetRootOutputBaseDir(TDirectory * dir) { fOutputBaseDir = dir; } Bool_t ReadEvent( TTree* tr, UInt_t evidx, Types::ESBType type ) const; const std::vector& Variables() const { return fVariables; } const VariableInfo& Variable(Int_t ivar) const { return fVariables[ivar]; } VariableInfo& Variable(Int_t ivar) { return fVariables[ivar]; } const VariableInfo& Variable(const TString& var) const { return fVariables[FindVar(var)]; } VariableInfo& Variable(const TString& var) { return fVariables[FindVar(var)]; } Int_t FindVar(const TString& var) const { // don't use in loops, it is slow for (UInt_t ivar=0; ivar fVariables; // event variables [saved to weight file] mutable TTree* fCurrentTree; // pointer to tree mutable Size_t fCurrentEvtIdx; // current event index TDirectory* fOutputBaseDir; // directory Ranking* fRanking; // ranking object protected: mutable MsgLogger fLogger; // message logger ClassDef(VariableTransformBase,0) // Base class for variable transformations }; } // namespace TMVA #endif