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  *      Peter Speckmayer   <Peter.Speckmayer@cern.ch> - CERN, Switzerland         *
0017  *      Helge Voss         <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany   *
0018  *      Eckhard v. Toerne  <evt@uni-bonn.de>        - U of Bonn, Germany          *
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_MethodCategory
0032 #define ROOT_TMVA_MethodCategory
0033 
0034 //////////////////////////////////////////////////////////////////////////
0035 //                                                                      //
0036 // MethodCategory                                                       //
0037 //                                                                      //
0038 // Class for categorizing the phase space                               //
0039 //                                                                      //
0040 //////////////////////////////////////////////////////////////////////////
0041 
0042 #include <iosfwd>
0043 #include <vector>
0044 
0045 #include "TMVA/MethodBase.h"
0046 
0047 #include "TMVA/MethodCompositeBase.h"
0048 
0049 namespace TMVA {
0050 
0051    class Factory;  // DSMTEST
0052    class Reader;   // DSMTEST
0053    class MethodBoost;   // DSMTEST
0054    class DataSetManager;  // DSMTEST
0055    namespace Experimental {
0056    class Classification;
0057    }
0058    class MethodCategory : public MethodCompositeBase {
0059       friend class Experimental::Classification;
0060 
0061    public :
0062 
0063       // constructors
0064       MethodCategory( const TString& jobName,
0065                       const TString& methodTitle,
0066                       DataSetInfo& theData,
0067                       const TString& theOption = "" );
0068 
0069       MethodCategory( DataSetInfo& dsi,
0070                       const TString& theWeightFile );
0071 
0072       virtual ~MethodCategory( void );
0073 
0074       virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/ );
0075       // training and boosting all the classifiers
0076       void Train( void );
0077 
0078       // ranking of input variables
0079       const Ranking* CreateRanking();
0080 
0081       // saves the name and options string of the boosted classifier
0082       TMVA::IMethod* AddMethod(const TCut&,
0083                                const TString& theVariables,
0084                                Types::EMVA theMethod,
0085                                const TString& theTitle,
0086                                const TString& theOptions);
0087 
0088       void AddWeightsXMLTo( void* parent ) const;
0089       void ReadWeightsFromXML( void* wghtnode );
0090 
0091       Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0092 
0093       // regression response
0094       virtual const std::vector<Float_t>& GetRegressionValues();
0095 
0096       // multi class response
0097       virtual const std::vector<Float_t> &GetMulticlassValues();
0098 
0099       virtual void MakeClass( const TString& = TString("") ) const {};
0100 
0101    protected :
0102 
0103       // signal/background classification response for all current set of data
0104       virtual std::vector<Double_t> GetMvaValues(Long64_t firstEvt = 0, Long64_t lastEvt = -1, Bool_t logProgress = false);
0105 
0106    private:
0107       // initializing mostly monitoring tools of the category process
0108       void Init();
0109 
0110       // the option handling methods
0111       void DeclareOptions();
0112       void ProcessOptions();
0113 
0114       // build the cut formula for event categorization
0115       Bool_t PassesCut( const Event* ev, UInt_t methodIdx );
0116 
0117    protected:
0118 
0119       // vectors that contain the added methods and the cuts on which they are to be called
0120       std::vector<IMethod*>               fMethods;
0121       std::vector<TCut>                   fCategoryCuts;
0122       std::vector<UInt_t>                 fCategorySpecIdx;
0123       std::vector<TString>                fVars;
0124       std::vector <std::vector <UInt_t> > fVarMaps;
0125 
0126       // get help message text
0127       void GetHelpMessage() const;
0128 
0129       TMVA::DataSetInfo& CreateCategoryDSI(const TCut&, const TString&, const TString&);
0130 
0131    private:
0132 
0133       void InitCircularTree(const DataSetInfo& dsi);
0134 
0135       TTree *                    fCatTree; //! needed in conjunction with TTreeFormulas for evaluation category expressions
0136       std::vector<TTreeFormula*> fCatFormulas;
0137 
0138       DataSetManager* fDataSetManager; // DSMTEST
0139       friend class Factory; // DSMTEST
0140       friend class Reader;  // DSMTEST
0141       friend class MethodBoost;  // DSMTEST
0142 
0143       ClassDef(MethodCategory,0);
0144    };
0145 }
0146 
0147 #endif