Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:00

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss,Or Cohen
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : MethodCompositeBase                                                   *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Virtual base class for all MVA method                                     *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
0015  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
0016  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
0017  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
0018  *      Or Cohen        <orcohenor@gmail.com>    - Weizmann Inst., Israel         *
0019  *                                                                                *
0020  * Copyright (c) 2005:                                                            *
0021  *      CERN, Switzerland                                                         *
0022  *      U. of Victoria, Canada                                                    *
0023  *      MPI-K Heidelberg, Germany                                                 *
0024  *      LAPP, Annecy, France                                                      *
0025  *                                                                                *
0026  * Redistribution and use in source and binary forms, with or without             *
0027  * modification, are permitted according to the terms listed in LICENSE           *
0028  * (see tmva/doc/LICENSE)                                          *
0029  **********************************************************************************/
0030 
0031 #ifndef ROOT_TMVA_MethodCompositeBase
0032 #define ROOT_TMVA_MethodCompositeBase
0033 
0034 //////////////////////////////////////////////////////////////////////////
0035 //                                                                      //
0036 // MethodCompositeBase                                                  //
0037 //                                                                      //
0038 // Virtual base class for combining several TMVA method                 //
0039 //                                                                      //
0040 //////////////////////////////////////////////////////////////////////////
0041 
0042 #include <iosfwd>
0043 #include <vector>
0044 
0045 #include "TMVA/MethodBase.h"
0046 
0047 namespace TMVA {
0048    class IMethod;
0049 
0050    class MethodCompositeBase : public MethodBase {
0051 
0052    public :
0053       MethodCompositeBase( const TString& jobName,
0054                            Types::EMVA methodType,
0055                            const TString& methodTitle,
0056                            DataSetInfo& theData,
0057                            const TString& theOption = "" );
0058 
0059 
0060       MethodCompositeBase( Types::EMVA methodType,
0061                            DataSetInfo& dsi,
0062                            const TString& weightFile );
0063 
0064       using MethodBase::ReadWeightsFromStream;
0065 
0066       // write weights to file
0067       void AddWeightsXMLTo( void* parent ) const;
0068       void ReadWeightsFromXML( void* wghtnode );
0069 
0070       // calculate the MVA value combining all classifiers according to their fMethodWeight
0071       Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0072 
0073       using MethodBase::GetMvaValue;
0074 
0075       // read weights from file
0076       void ReadWeightsFromStream( std::istream& istr );
0077 
0078       // performs classifier training
0079       virtual void Train() = 0;
0080 
0081       // create ranking
0082       virtual const Ranking* CreateRanking() = 0;
0083 
0084       virtual ~MethodCompositeBase( void );
0085 
0086    protected:
0087 
0088       void DeclareOptions() = 0;
0089       void ProcessOptions() = 0;
0090 
0091       IMethod* GetMethod( const TString& title ) const;  ///< accessor by name
0092 
0093       IMethod* GetMethod( const Int_t index ) const;  ///< accessor by index in vector
0094 
0095       //the index of the classifier currently boosted
0096       UInt_t             fCurrentMethodIdx;
0097       MethodBase*        fCurrentMethod;
0098       UInt_t GetCurrentMethodIndex() { return fCurrentMethodIdx; }
0099 
0100       IMethod* GetLastMethod() { return fMethods.back(); }
0101 
0102       IMethod* GetPreviousMethod() { return (fCurrentMethodIdx>0)?fMethods[fCurrentMethodIdx-1]:nullptr; }
0103 
0104       MethodBase* GetCurrentMethod(){ return fCurrentMethod;}
0105       MethodBase* GetCurrentMethod(UInt_t idx){return dynamic_cast<MethodBase*>(fMethods.at(idx)); }
0106 
0107 
0108 
0109       std::vector<IMethod*>      fMethods;          ///< vector of all classifiers
0110 
0111       //the weight of every classifier used in the GetMVA method
0112       std::vector<Double_t>      fMethodWeight;
0113 
0114       ClassDef(MethodCompositeBase,0);
0115 
0116    };
0117 }
0118 
0119 #endif
0120