Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : MethodHMatrix                                                         *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      H-Matrix method, which is implemented as a simple comparison of           *
0012  *      chi-squared estimators for signal and background, taking into account     *
0013  *      the linear correlations between the input variables.                      *
0014  *      Method is (also) used by D0 Collaboration (FNAL) for electron             *
0015  *      identification; for more information, see, eg,                            *
0016  *      http://www-d0.fnal.gov/d0dist/dist/packages/tau_hmchisq/devel/doc/        *
0017  *                                                                                *
0018  * Authors (alphabetical):                                                        *
0019  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
0020  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
0021  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
0022  *                                                                                *
0023  * Copyright (c) 2005:                                                            *
0024  *      CERN, Switzerland                                                         *
0025  *      U. of Victoria, Canada                                                    *
0026  *      MPI-K Heidelberg, Germany                                                 *
0027  *                                                                                *
0028  * Redistribution and use in source and binary forms, with or without             *
0029  * modification, are permitted according to the terms listed in LICENSE           *
0030  * (see tmva/doc/LICENSE)                                          *
0031  **********************************************************************************/
0032 
0033 #ifndef ROOT_TMVA_MethodHMatrix
0034 #define ROOT_TMVA_MethodHMatrix
0035 
0036 //////////////////////////////////////////////////////////////////////////
0037 //                                                                      //
0038 // MethodHMatrix                                                        //
0039 //                                                                      //
0040 // H-Matrix method, which is implemented as a simple comparison of      //
0041 // chi-squared estimators for signal and background, taking into        //
0042 // account the linear correlations between the input variables          //
0043 //                                                                      //
0044 //////////////////////////////////////////////////////////////////////////
0045 
0046 #include "TMVA/MethodBase.h"
0047 #include "TMatrixDfwd.h"
0048 #include "TVectorD.h"
0049 
0050 namespace TMVA {
0051 
0052    class MethodHMatrix : public MethodBase {
0053 
0054    public:
0055 
0056       MethodHMatrix( const TString& jobName,
0057                      const TString& methodTitle,
0058                      DataSetInfo& theData,
0059                      const TString& theOption = "");
0060 
0061       MethodHMatrix( DataSetInfo& theData,
0062                      const TString& theWeightFile);
0063 
0064       virtual ~MethodHMatrix();
0065 
0066       virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
0067 
0068       // training method
0069       void Train();
0070 
0071       using MethodBase::ReadWeightsFromStream;
0072 
0073       // write weights to file
0074       void AddWeightsXMLTo( void* parent ) const;
0075 
0076       // read weights from file
0077       void ReadWeightsFromStream( std::istream& istr );
0078       void ReadWeightsFromXML( void* wghtnode );
0079       // calculate the MVA value
0080       Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0081 
0082       // ranking of input variables
0083       const Ranking* CreateRanking() { return nullptr; }
0084 
0085    protected:
0086 
0087       // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
0088       void MakeClassSpecific( std::ostream&, const TString& ) const;
0089 
0090       // get help message text
0091       void GetHelpMessage() const;
0092 
0093    private:
0094 
0095       // the option handling methods
0096       void DeclareOptions();
0097       void ProcessOptions();
0098 
0099       // returns chi2 estimator for given type (signal or background)
0100       Double_t GetChi2( Types::ESBType );
0101 
0102       // compute correlation matrices
0103       void     ComputeCovariance( Bool_t, TMatrixD* );
0104 
0105       // arrays of input evt vs. variable
0106       TMatrixD* fInvHMatrixS; ///< inverse H-matrix (signal)
0107       TMatrixD* fInvHMatrixB; ///< inverse H-matrix (background)
0108       TVectorD* fVecMeanS;    ///< vector of mean values (signal)
0109       TVectorD* fVecMeanB;    ///< vector of mean values (background)
0110 
0111       // default initialisation method called by all constructors
0112       void Init();
0113 
0114       ClassDef(MethodHMatrix,0); // H-Matrix method, a simple comparison of chi-squared estimators for signal and background
0115    };
0116 
0117 } // namespace TMVA
0118 
0119 #endif