MethodBase.h

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: MethodBase.h 36966 2010-11-26 09:50:13Z evt $
00002 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Kai Voss
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : MethodBase                                                            *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Virtual base class for all MVA method                                     *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
00015  *      Peter Speckmayer <peter.speckmayer@cern.ch>  - CERN, Switzerland          *
00016  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
00017  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
00018  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
00019  *                                                                                *
00020  * Copyright (c) 2005:                                                            *
00021  *      CERN, Switzerland                                                         *
00022  *      U. of Victoria, Canada                                                    *
00023  *      MPI-K Heidelberg, Germany                                                 *
00024  *      LAPP, Annecy, France                                                      *
00025  *                                                                                *
00026  * Redistribution and use in source and binary forms, with or without             *
00027  * modification, are permitted according to the terms listed in LICENSE           *
00028  * (http://tmva.sourceforge.net/LICENSE)                                          *
00029  **********************************************************************************/
00030 
00031 #ifndef ROOT_TMVA_MethodBase
00032 #define ROOT_TMVA_MethodBase
00033 
00034 //////////////////////////////////////////////////////////////////////////
00035 //                                                                      //
00036 // MethodBase                                                           //
00037 //                                                                      //
00038 // Virtual base class for all TMVA method                               //
00039 //                                                                      //
00040 //////////////////////////////////////////////////////////////////////////
00041 
00042 #include <iosfwd>
00043 #include <vector>
00044 #include <map>
00045 #include "assert.h"
00046 
00047 #ifndef ROOT_TString
00048 #include "TString.h"
00049 #endif
00050 
00051 #ifndef ROOT_TMVA_IMethod
00052 #include "TMVA/IMethod.h"
00053 #endif
00054 #ifndef ROOT_TMVA_Configurable
00055 #include "TMVA/Configurable.h"
00056 #endif
00057 #ifndef ROOT_TMVA_Types
00058 #include "TMVA/Types.h"
00059 #endif
00060 #ifndef ROOT_TMVA_DataSet
00061 #include "TMVA/DataSet.h"
00062 #endif
00063 #ifndef ROOT_TMVA_Event
00064 #include "TMVA/Event.h"
00065 #endif
00066 #ifndef ROOT_TMVA_TransformationHandler
00067 #include "TMVA/TransformationHandler.h"
00068 #endif
00069 #ifndef ROOT_TMVA_OptimizeConfigParameters
00070 #include "TMVA/OptimizeConfigParameters.h"
00071 #endif
00072 
00073 class TGraph;
00074 class TTree;
00075 class TDirectory;
00076 class TSpline;
00077 
00078 namespace TMVA {
00079 
00080    class Ranking;
00081    class PDF;
00082    class TSpline1;
00083    class MethodCuts;
00084    class MethodBoost;
00085    class DataSetInfo;
00086 
00087    class MethodBase : virtual public IMethod, public Configurable {
00088 
00089    public:
00090 
00091       enum EWeightFileType { kROOT=0, kTEXT };
00092 
00093       // default constructur
00094       MethodBase( const TString& jobName,
00095                   Types::EMVA methodType,
00096                   const TString& methodTitle,
00097                   DataSetInfo& dsi,
00098                   const TString& theOption = "",
00099                   TDirectory* theBaseDir = 0 );
00100 
00101       // constructor used for Testing + Application of the MVA, only (no training),
00102       // using given weight file
00103       MethodBase( Types::EMVA methodType,
00104                   DataSetInfo& dsi,
00105                   const TString& weightFile,
00106                   TDirectory* theBaseDir = 0 );
00107 
00108       // default destructur
00109       virtual ~MethodBase();
00110 
00111       // declaration, processing and checking of configuration options
00112       void             SetupMethod();
00113       void             ProcessSetup();
00114       virtual void     CheckSetup(); // may be overwritten by derived classes
00115 
00116       // ---------- main training and testing methods ------------------------------
00117 
00118       // prepare tree branch with the method's discriminating variable
00119       void             AddOutput( Types::ETreeType type, Types::EAnalysisType analysisType );
00120 
00121       // performs classifier training
00122       // calls methods Train() implemented by derived classes
00123       void             TrainMethod();
00124 
00125       // optimize tuning parameters
00126       virtual std::map<TString,Double_t> OptimizeTuningParameters(TString fomType="ROCIntegral", TString fitType="FitGA");
00127       virtual void SetTuneParameters(std::map<TString,Double_t> tuneParameters);
00128 
00129       virtual void     Train() = 0;
00130 
00131       // store and retrieve time used for training
00132       void             SetTrainTime( Double_t trainTime ) { fTrainTime = trainTime; }
00133       Double_t         GetTrainTime() const { return fTrainTime; }
00134 
00135       // store and retrieve time used for testing
00136       void             SetTestTime ( Double_t testTime ) { fTestTime = testTime; }
00137       Double_t         GetTestTime () const { return fTestTime; }
00138 
00139       // performs classifier testing
00140       virtual void     TestClassification();
00141 
00142       // performs multiclass classifier testing
00143       virtual void     TestMulticlass();
00144 
00145       // performs regression testing
00146       virtual void     TestRegression( Double_t& bias, Double_t& biasT,
00147                                        Double_t& dev,  Double_t& devT,
00148                                        Double_t& rms,  Double_t& rmsT,
00149                                        Double_t& mInf, Double_t& mInfT, // mutual information
00150                                        Double_t& corr,
00151                                        Types::ETreeType type );
00152 
00153       // options treatment
00154       virtual void     Init()           = 0;
00155       virtual void     DeclareOptions() = 0;
00156       virtual void     ProcessOptions() = 0;
00157       virtual void     DeclareCompatibilityOptions(); // declaration of past options
00158 
00159       // reset the Method --> As if it was not yet trained, just instantiated
00160       //      virtual void     Reset()          = 0;
00161       //for the moment, I provide a dummy (that would not work) default, just to make
00162       // compilation/running w/o parameter optimisation still possible
00163       virtual void     Reset(){return;}
00164 
00165       // classifier response:
00166       // some methods may return a per-event error estimate
00167       // error calculation is skipped if err==0
00168       virtual Double_t GetMvaValue( Double_t* errLower = 0, Double_t* errUpper = 0) = 0;
00169 
00170       // signal/background classification response
00171       Double_t GetMvaValue( const TMVA::Event* const ev, Double_t* err = 0, Double_t* errUpper = 0 );
00172 
00173    protected:
00174       // helper function to set errors to -1
00175       void NoErrorCalc(Double_t* const err, Double_t* const errUpper);
00176 
00177    public:
00178       // regression response
00179       virtual const std::vector<Float_t>& GetRegressionValues() {
00180          std::vector<Float_t>* ptr = new std::vector<Float_t>(0);
00181          return (*ptr);
00182       }
00183 
00184       // multiclass classification response
00185       virtual const std::vector<Float_t>& GetMulticlassValues() {
00186          std::vector<Float_t>* ptr = new std::vector<Float_t>(0);
00187          return (*ptr);
00188       }
00189 
00190       // probability of classifier response (mvaval) to be signal (requires "CreateMvaPdf" option set)
00191       virtual Double_t GetProba( Double_t mvaVal, Double_t ap_sig );
00192 
00193       // Rarity of classifier response (signal or background (default) is uniform in [0,1])
00194       virtual Double_t GetRarity( Double_t mvaVal, Types::ESBType reftype = Types::kBackground ) const;
00195 
00196       // create ranking
00197       virtual const Ranking* CreateRanking() = 0;
00198 
00199       // perfrom extra actions during the boosting at different stages
00200       virtual Bool_t   MonitorBoost(MethodBoost* /*booster*/) {return kFALSE;};
00201 
00202       // make ROOT-independent C++ class
00203       virtual void     MakeClass( const TString& classFileName = TString("") ) const;
00204 
00205       // print help message
00206       void             PrintHelpMessage() const;
00207 
00208       //
00209       // streamer methods for training information (creates "weight" files) --------
00210       //
00211    public:
00212       void WriteStateToFile     () const;
00213       void ReadStateFromFile    ();
00214 
00215    protected:
00216       // the actual "weights"
00217       virtual void AddWeightsXMLTo      ( void* parent ) const = 0;
00218       virtual void ReadWeightsFromXML   ( void* wghtnode ) = 0;
00219       virtual void ReadWeightsFromStream( std::istream& ) = 0;       // backward compatibility
00220       virtual void ReadWeightsFromStream( TFile& ) {}                // backward compatibility
00221 
00222    private:
00223       friend class MethodCategory;
00224       friend class MethodCommittee;
00225       friend class MethodCompositeBase;
00226       void WriteStateToXML      ( void* parent ) const;
00227       void ReadStateFromXML     ( void* parent );
00228       void WriteStateToStream   ( std::ostream& tf ) const;   // needed for MakeClass
00229       void WriteVarsToStream    ( std::ostream& tf, const TString& prefix = "" ) const;  // needed for MakeClass
00230 
00231 
00232    public: // these two need to be public, they are used to read in-memory weight-files
00233       void ReadStateFromStream  ( std::istream& tf );         // backward compatibility
00234       void ReadStateFromStream  ( TFile&        rf );         // backward compatibility
00235       void ReadStateFromXMLString( const char* xmlstr );      // for reading from memory
00236 
00237    private:
00238       // the variable information
00239       void AddVarsXMLTo         ( void* parent  ) const;
00240       void AddSpectatorsXMLTo   ( void* parent  ) const;
00241       void AddTargetsXMLTo      ( void* parent  ) const;
00242       void AddClassesXMLTo      ( void* parent  ) const;
00243       void ReadVariablesFromXML ( void* varnode );
00244       void ReadSpectatorsFromXML( void* specnode);
00245       void ReadTargetsFromXML   ( void* tarnode );
00246       void ReadClassesFromXML   ( void* clsnode );
00247       void ReadVarsFromStream   ( std::istream& istr );       // backward compatibility
00248 
00249    public:
00250       // ---------------------------------------------------------------------------
00251 
00252       // write evaluation histograms into target file
00253       virtual void     WriteEvaluationHistosToFile(Types::ETreeType treetype);
00254 
00255       // write classifier-specific monitoring information to target file
00256       virtual void     WriteMonitoringHistosToFile() const;
00257 
00258       // ---------- public evaluation methods --------------------------------------
00259 
00260       // individual initialistion for testing of each method
00261       // overload this one for individual initialisation of the testing,
00262       // it is then called automatically within the global "TestInit"
00263 
00264       // variables (and private menber functions) for the Evaluation:
00265       // get the effiency. It fills a histogram for efficiency/vs/bkg
00266       // and returns the one value fo the efficiency demanded for 
00267       // in the TString argument. (Watch the string format)
00268       virtual Double_t GetEfficiency( const TString&, Types::ETreeType, Double_t& err );
00269       virtual Double_t GetTrainingEfficiency(const TString& );
00270       virtual std::vector<Float_t> GetMulticlassEfficiency( std::vector<std::vector<Float_t> >& purity );
00271       virtual std::vector<Float_t> GetMulticlassTrainingEfficiency(std::vector<std::vector<Float_t> >& purity );
00272       virtual Double_t GetSignificance() const;
00273       virtual Double_t GetROCIntegral(PDF *pdfS=0, PDF *pdfB=0) const;
00274       virtual Double_t GetMaximumSignificance( Double_t SignalEvents, Double_t BackgroundEvents, 
00275                                                Double_t& optimal_significance_value  ) const;
00276       virtual Double_t GetSeparation( TH1*, TH1* ) const;
00277       virtual Double_t GetSeparation( PDF* pdfS = 0, PDF* pdfB = 0 ) const;
00278 
00279       virtual void GetRegressionDeviation(UInt_t tgtNum, Types::ETreeType type, Double_t& stddev,Double_t& stddev90Percent ) const;
00280       // ---------- public accessors -----------------------------------------------
00281 
00282       // classifier naming (a lot of names ... aren't they ;-)
00283       const TString&   GetJobName       () const { return fJobName; }
00284       const TString&   GetMethodName    () const { return fMethodName; }
00285       TString          GetMethodTypeName() const { return Types::Instance().GetMethodName(fMethodType); }
00286       Types::EMVA      GetMethodType    () const { return fMethodType; }
00287       const char*      GetName          () const { return fMethodName.Data(); }
00288       const TString&   GetTestvarName   () const { return fTestvar; }
00289       const TString    GetProbaName     () const { return fTestvar + "_Proba"; }
00290       TString          GetWeightFileName() const;
00291 
00292       // build classifier name in Test tree
00293       // MVA prefix (e.g., "TMVA_")
00294       void             SetTestvarName  ( const TString & v="" ) { fTestvar = (v=="") ? ("MVA_" + GetMethodName()) : v; }
00295 
00296       // number of input variable used by classifier
00297       UInt_t           GetNvar()       const { return DataInfo().GetNVariables(); }
00298       UInt_t           GetNVariables() const { return DataInfo().GetNVariables(); }
00299       UInt_t           GetNTargets()   const { return DataInfo().GetNTargets(); };
00300 
00301       // internal names and expressions of input variables
00302       const TString&   GetInputVar  ( Int_t i ) const { return DataInfo().GetVariableInfo(i).GetInternalName(); }
00303       const TString&   GetInputLabel( Int_t i ) const { return DataInfo().GetVariableInfo(i).GetLabel(); }
00304       const TString&   GetInputTitle( Int_t i ) const { return DataInfo().GetVariableInfo(i).GetTitle(); }
00305 
00306       // normalisation and limit accessors
00307       Double_t         GetMean( Int_t ivar ) const { return GetTransformationHandler().GetMean(ivar); }
00308       Double_t         GetRMS ( Int_t ivar ) const { return GetTransformationHandler().GetRMS(ivar); }
00309       Double_t         GetXmin( Int_t ivar ) const { return GetTransformationHandler().GetMin(ivar); }
00310       Double_t         GetXmax( Int_t ivar ) const { return GetTransformationHandler().GetMax(ivar); }
00311 
00312       // sets the minimum requirement on the MVA output to declare an event signal-like
00313       Double_t         GetSignalReferenceCut() const { return fSignalReferenceCut; }
00314 
00315       // sets the minimum requirement on the MVA output to declare an event signal-like
00316       void             SetSignalReferenceCut( Double_t cut ) { fSignalReferenceCut = cut; }
00317 
00318       // pointers to ROOT directories
00319       TDirectory*      BaseDir()       const;
00320       TDirectory*      MethodBaseDir() const;
00321       void             SetMethodDir ( TDirectory* methodDir ) { fBaseDir = fMethodBaseDir  = methodDir; }
00322       void             SetBaseDir( TDirectory* methodDir ){ fBaseDir = methodDir; }
00323       void             SetMethodBaseDir( TDirectory* methodDir ){ fMethodBaseDir = methodDir; }
00324 
00325       // the TMVA version can be obtained and checked using
00326       //    if (GetTrainingTMVAVersionCode()>TMVA_VERSION(3,7,2)) {...}
00327       // or
00328       //    if (GetTrainingROOTVersionCode()>ROOT_VERSION(5,15,5)) {...}
00329       UInt_t           GetTrainingTMVAVersionCode()   const { return fTMVATrainingVersion; }
00330       UInt_t           GetTrainingROOTVersionCode()   const { return fROOTTrainingVersion; }
00331       TString          GetTrainingTMVAVersionString() const;
00332       TString          GetTrainingROOTVersionString() const;
00333 
00334       TransformationHandler&        GetTransformationHandler() { return fTransformation; }
00335       const TransformationHandler&  GetTransformationHandler() const { return fTransformation; }
00336 
00337       // ---------- event accessors ------------------------------------------------
00338 
00339       // returns reference to data set
00340       DataSetInfo&     DataInfo() const { return fDataSetInfo; }
00341 
00342       mutable const Event*   fTmpEvent; //! temporary event when testing on a different DataSet than the own one
00343 
00344       // event reference and update
00345       UInt_t           GetNEvents      () const { return Data()->GetNEvents(); }
00346       const Event*     GetEvent        () const;
00347       const Event*     GetEvent        ( const TMVA::Event* ev ) const;
00348       const Event*     GetEvent        ( Long64_t ievt ) const;
00349       const Event*     GetEvent        ( Long64_t ievt , Types::ETreeType type ) const;
00350       const Event*     GetTrainingEvent( Long64_t ievt ) const;
00351       const Event*     GetTestingEvent ( Long64_t ievt ) const;
00352       const std::vector<TMVA::Event*>& GetEventCollection( Types::ETreeType type );
00353 
00354       // ---------- public auxiliary methods ---------------------------------------
00355 
00356       // this method is used to decide whether an event is signal- or background-like
00357       // the reference cut "xC" is taken to be where
00358       // Int_[-oo,xC] { PDF_S(x) dx } = Int_[xC,+oo] { PDF_B(x) dx }
00359       virtual Bool_t        IsSignalLike() { return GetMvaValue() > GetSignalReferenceCut() ? kTRUE : kFALSE; }
00360 
00361       DataSet* Data() const { return DataInfo().GetDataSet(); }
00362 
00363       Bool_t                HasMVAPdfs() const { return fHasMVAPdfs; }
00364       virtual void          SetAnalysisType( Types::EAnalysisType type ) { fAnalysisType = type; }
00365       Types::EAnalysisType  GetAnalysisType() const { return fAnalysisType; }
00366       Bool_t                DoRegression() const { return fAnalysisType == Types::kRegression; }
00367       Bool_t                DoMulticlass() const { return fAnalysisType == Types::kMulticlass; }
00368 
00369       // setter method for suppressing writing to XML and writing of standalone classes
00370       void                  DisableWriting(Bool_t setter){ fDisableWriting = setter; }
00371 
00372    protected:
00373 
00374       // ---------- protected acccessors -------------------------------------------
00375 
00376       //TDirectory*  LocalTDir() const { return Data().LocalRootDir(); }
00377 
00378       // weight file name and directory (given by global config variable)
00379       void             SetWeightFileName( TString );
00380 
00381       const TString&   GetWeightFileDir() const { return fFileDir; }
00382       void             SetWeightFileDir( TString fileDir );
00383 
00384       // are input variables normalised ?
00385       Bool_t           IsNormalised() const { return fNormalise; }
00386       void             SetNormalised( Bool_t norm ) { fNormalise = norm; }
00387 
00388       // set number of input variables (only used by MethodCuts, could perhaps be removed)
00389       //      void SetNvar( Int_t n ) { fNvar = n; }
00390 
00391       // verbose and help flags
00392       Bool_t           Verbose() const { return fVerbose; }
00393       Bool_t           Help   () const { return fHelp; }
00394 
00395       // ---------- protected event and tree accessors -----------------------------
00396 
00397       // names of input variables (if the original names are expressions, they are 
00398       // transformed into regexps)
00399       const TString&   GetInternalVarName( Int_t ivar ) const { return (*fInputVars)[ivar]; }
00400       const TString&   GetOriginalVarName( Int_t ivar ) const { return DataInfo().GetVariableInfo(ivar).GetExpression(); }
00401 
00402       Bool_t           HasTrainingTree() const { return Data()->GetNTrainingEvents() != 0; }
00403 
00404       // ---------- protected auxiliary methods ------------------------------------
00405 
00406    protected:
00407 
00408       // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
00409       virtual void     MakeClassSpecific( std::ostream&, const TString& = "" ) const {}
00410 
00411       // header and auxiliary classes
00412       virtual void     MakeClassSpecificHeader( std::ostream&, const TString& = "" ) const {}
00413 
00414       // static pointer to this object - required for ROOT finder (to be solved differently)
00415       static MethodBase* GetThisBase();
00416 
00417       // some basic statistical analysis
00418       void Statistics( Types::ETreeType treeType, const TString& theVarName,
00419                        Double_t&, Double_t&, Double_t&, 
00420                        Double_t&, Double_t&, Double_t& );
00421 
00422       // if TRUE, write weights only to text files 
00423       Bool_t           TxtWeightsOnly() const { return kTRUE; }
00424 
00425    protected:
00426       
00427       // access to event information that needs method-specific information
00428       
00429       Float_t GetTWeight( const Event* ev ) const { 
00430          return (fIgnoreNegWeightsInTraining && (ev->GetWeight() < 0)) ? 0. : ev->GetWeight(); 
00431       }
00432 
00433       Bool_t           IsConstructedFromWeightFile() const { return fConstructedFromWeightFile; }
00434 
00435    public:
00436       virtual void SetCurrentEvent( Long64_t ievt ) const {
00437          Data()->SetCurrentEvent(ievt);
00438       }
00439 
00440 
00441    private:
00442 
00443       // ---------- private definitions --------------------------------------------
00444       // Initialisation
00445       void             InitBase();
00446       void             DeclareBaseOptions();
00447       void             ProcessBaseOptions();
00448 
00449       // used in efficiency computation
00450       enum ECutOrientation { kNegative = -1, kPositive = +1 };
00451       ECutOrientation  GetCutOrientation() const { return fCutOrientation; }
00452 
00453       // ---------- private acccessors ---------------------------------------------
00454 
00455       // reset required for RootFinder
00456       void             ResetThisBase();
00457 
00458       // ---------- private auxiliary methods --------------------------------------
00459 
00460       // PDFs for classifier response (required to compute signal probability and Rarity)
00461       void             CreateMVAPdfs();
00462 
00463       // for root finder 
00464       static Double_t  IGetEffForRoot( Double_t );  // interface
00465       Double_t         GetEffForRoot ( Double_t );  // implementation
00466 
00467       // used for file parsing
00468       Bool_t           GetLine( std::istream& fin, char * buf );
00469       
00470       // fill test tree with classification or regression results
00471       virtual void     AddClassifierOutput    ( Types::ETreeType type );
00472       virtual void     AddClassifierOutputProb( Types::ETreeType type );
00473       virtual void     AddRegressionOutput    ( Types::ETreeType type );
00474       virtual void     AddMulticlassOutput    ( Types::ETreeType type );
00475 
00476    private:
00477 
00478       void             AddInfoItem( void* gi, const TString& name, const TString& value) const;
00479       void             CreateVariableTransforms(const TString& trafoDefinition );
00480 
00481 
00482       // ========== class members ==================================================
00483 
00484    protected:
00485 
00486       // direct accessors
00487       Ranking*              fRanking;              // pointer to ranking object (created by derived classifiers)
00488       std::vector<TString>* fInputVars;            // vector of input variables used in MVA
00489 
00490       // histogram binning
00491       Int_t                 fNbins;                // number of bins in representative histograms
00492       Int_t                 fNbinsH;               // number of bins in evaluation histograms
00493 
00494       Types::EAnalysisType  fAnalysisType;         // method-mode : true --> regression, false --> classification
00495 
00496       std::vector<Float_t>* fRegressionReturnVal;  // holds the return-values for the regression
00497       std::vector<Float_t>* fMulticlassReturnVal;  // holds the return-values for the multiclass classification
00498 
00499    private:
00500 
00501       // MethodCuts redefines some of the evaluation variables and histograms -> must access private members
00502       friend class MethodCuts; 
00503 
00504       Bool_t           fDisableWriting;       //! set to true in order to suppress writing to XML
00505 
00506       // data sets
00507       DataSetInfo&     fDataSetInfo;         //! the data set information (sometimes needed)
00508 
00509       Double_t         fSignalReferenceCut;  // minimum requirement on the MVA output to declare an event signal-like
00510       Types::ESBType   fVariableTransformType;  // this is the event type (sig or bgd) assumed for variable transform
00511 
00512       // naming and versioning
00513       TString          fJobName;             // name of job -> user defined, appears in weight files
00514       TString          fMethodName;          // name of the method (set in derived class)
00515       Types::EMVA      fMethodType;          // type of method (set in derived class)      
00516       TString          fTestvar;             // variable used in evaluation, etc (mostly the MVA)
00517       UInt_t           fTMVATrainingVersion; // TMVA version used for training
00518       UInt_t           fROOTTrainingVersion; // ROOT version used for training
00519       Bool_t           fConstructedFromWeightFile; // is it obtained from weight file? 
00520 
00521       // Directory structure: fMethodBaseDir/fBaseDir
00522       // where the first directory name is defined by the method type
00523       // and the second is user supplied (the title given in Factory::BookMethod())
00524       TDirectory*      fBaseDir;             // base directory for the instance, needed to know where to jump back from localDir
00525       mutable TDirectory* fMethodBaseDir;    // base directory for the method
00526 
00527       TString          fParentDir;           // method parent name, like booster name
00528 
00529       TString          fFileDir;             // unix sub-directory for weight files (default: "weights")
00530       TString          fWeightFile;          // weight file name
00531 
00532    private:
00533 
00534       TH1*             fEffS;                // efficiency histogram for rootfinder
00535 
00536       PDF*             fDefaultPDF;          // default PDF definitions
00537       PDF*             fMVAPdfS;             // signal MVA PDF
00538       PDF*             fMVAPdfB;             // background MVA PDF
00539 
00540       PDF*             fSplS;                // PDFs of MVA distribution (signal)
00541       PDF*             fSplB;                // PDFs of MVA distribution (background)
00542       TSpline*         fSpleffBvsS;          // splines for signal eff. versus background eff.
00543 
00544       PDF*             fSplTrainS;           // PDFs of training MVA distribution (signal)
00545       PDF*             fSplTrainB;           // PDFs of training MVA distribution (background)
00546       TSpline*         fSplTrainEffBvsS;     // splines for training signal eff. versus background eff.
00547 
00548    private:
00549 
00550       // basic statistics quantities of MVA
00551       Double_t         fMeanS;               // mean (signal)
00552       Double_t         fMeanB;               // mean (background)
00553       Double_t         fRmsS;                // RMS (signal)
00554       Double_t         fRmsB;                // RMS (background)
00555       Double_t         fXmin;                // minimum (signal and background)
00556       Double_t         fXmax;                // maximum (signal and background)
00557 
00558       // variable preprocessing
00559       TString          fVarTransformString;          // labels variable transform method
00560 
00561       TransformationHandler fTransformation;         // the list of transformations
00562 
00563 
00564       // help and verbosity
00565       Bool_t           fVerbose;               // verbose flag
00566       TString          fVerbosityLevelString;  // verbosity level (user input string)
00567       EMsgType         fVerbosityLevel;        // verbosity level
00568       Bool_t           fHelp;                  // help flag
00569       Bool_t           fHasMVAPdfs;            // MVA Pdfs are created for this classifier
00570 
00571       Bool_t           fIgnoreNegWeightsInTraining;// If true, events with negative weights are not used in training
00572 
00573    protected:
00574 
00575       Bool_t           IgnoreEventsWithNegWeightsInTraining() const { return fIgnoreNegWeightsInTraining; }
00576 
00577       // for signal/background
00578       UInt_t           fSignalClass;           // index of the Signal-class
00579       UInt_t           fBackgroundClass;       // index of the Background-class
00580 
00581    private:
00582 
00583       // timing variables
00584       Double_t         fTrainTime;             // for timing measurements
00585       Double_t         fTestTime;              // for timing measurements
00586 
00587       // orientation of cut: depends on signal and background mean values
00588       ECutOrientation  fCutOrientation;      // +1 if Sig>Bkg, -1 otherwise
00589 
00590       // for root finder
00591       TSpline1*        fSplRefS;             // helper splines for RootFinder (signal)
00592       TSpline1*        fSplRefB;             // helper splines for RootFinder (background)
00593 
00594       TSpline1*        fSplTrainRefS;        // helper splines for RootFinder (signal)
00595       TSpline1*        fSplTrainRefB;        // helper splines for RootFinder (background)
00596 
00597       mutable std::vector<const std::vector<TMVA::Event*>*> fEventCollections; // if the method needs the complete event-collection, the transformed event coll. ist stored here.
00598 
00599    public:
00600       Bool_t           fSetupCompleted;      // is method setup
00601 
00602    private:
00603 
00604       // this carrier
00605       static MethodBase* fgThisBase;         // this pointer
00606 
00607 
00608       // ===== depreciated options, kept for backward compatibility  =====
00609    private:
00610 
00611       Bool_t           fNormalise;                   // normalise input variables
00612       Bool_t           fUseDecorr;                   // synonymous for decorrelation
00613       TString          fVariableTransformTypeString; // labels variable transform type
00614       Bool_t           fTxtWeightsOnly;              // if TRUE, write weights only to text files 
00615       Int_t            fNbinsMVAPdf;                 // number of bins used in histogram that creates PDF
00616       Int_t            fNsmoothMVAPdf;               // number of times a histogram is smoothed before creating the PDF
00617 
00618    protected:
00619 
00620       ClassDef(MethodBase,0)  // Virtual base class for all TMVA method
00621 
00622    };
00623 } // namespace TMVA
00624 
00625 
00626 
00627 
00628 
00629 
00630 
00631 // ========== INLINE FUNCTIONS =========================================================
00632 
00633 
00634 //_______________________________________________________________________
00635 inline const TMVA::Event* TMVA::MethodBase::GetEvent( const TMVA::Event* ev ) const 
00636 {
00637    return GetTransformationHandler().Transform(ev);
00638 }
00639 
00640 inline const TMVA::Event* TMVA::MethodBase::GetEvent() const 
00641 {
00642    if(fTmpEvent)
00643       return GetTransformationHandler().Transform(fTmpEvent);
00644    else
00645       return GetTransformationHandler().Transform(Data()->GetEvent());
00646 }
00647 
00648 inline const TMVA::Event* TMVA::MethodBase::GetEvent( Long64_t ievt ) const 
00649 {
00650    assert(fTmpEvent==0);
00651    return GetTransformationHandler().Transform(Data()->GetEvent(ievt));
00652 }
00653 
00654 inline const TMVA::Event* TMVA::MethodBase::GetEvent( Long64_t ievt, Types::ETreeType type ) const 
00655 {
00656    assert(fTmpEvent==0);
00657    return GetTransformationHandler().Transform(Data()->GetEvent(ievt, type));
00658 }
00659 
00660 inline const TMVA::Event* TMVA::MethodBase::GetTrainingEvent( Long64_t ievt ) const 
00661 {
00662    assert(fTmpEvent==0);
00663    return GetEvent(ievt, Types::kTraining);
00664 }
00665 
00666 inline const TMVA::Event* TMVA::MethodBase::GetTestingEvent( Long64_t ievt ) const 
00667 {
00668    assert(fTmpEvent==0);
00669    return GetEvent(ievt, Types::kTesting);
00670 }
00671 
00672 #endif

Generated on Tue Jul 5 14:27:30 2011 for ROOT_528-00b_version by  doxygen 1.5.1