Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Fredrik Tegenfeldt, Helge Voss
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : Config                                                                *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      GLobal configuration settings (singleton)                                 *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Andreas Hoecker    <Andreas.Hocker@cern.ch>     - CERN, Switzerland       *
0015  *      Joerg Stelzer      <Joerg.Stelzer@cern.ch>      - CERN, Switzerland       *
0016  *      Fredrik Tegenfeldt <Fredrik.Tegenfeldt@cern.ch> - Iowa State U., USA      *
0017  *      Helge Voss         <Helge.Voss@cern.ch>         - MPI-K Heidelberg, GER   *
0018  *                                                                                *
0019  * Copyright (c) 2006:                                                            *
0020  *      CERN, Switzerland                                                         *
0021  *      Iowa State U., USA                                                        *
0022  *      MPI-K Heidelberg, Germany                                                 *
0023  *                                                                                *
0024  * Redistribution and use in source and binary forms, with or without             *
0025  * modification, are permitted according to the terms listed in LICENSE           *
0026  * (http://mva.sourceforge.net/license.txt)                                       *
0027  **********************************************************************************/
0028 
0029 #ifndef ROOT_TMVA_Config
0030 #define ROOT_TMVA_Config
0031 
0032 //////////////////////////////////////////////////////////////////////////
0033 //                                                                      //
0034 // Config                                                               //
0035 //                                                                      //
0036 // Singleton class for global configuration settings used by TMVA       //
0037 //                                                                      //
0038 //////////////////////////////////////////////////////////////////////////
0039 #include <atomic>
0040 #include "Rtypes.h"
0041 #include "TString.h"
0042 
0043 #include "Executor.h"
0044 
0045 namespace TMVA {
0046 
0047    class MsgLogger;
0048 
0049    class Config {
0050    protected:
0051 
0052       Executor fExecutor;   // Executor for multi-thread or serial execution
0053 
0054    public:
0055 
0056       static Config& Instance();
0057       static void    DestroyInstance();
0058 
0059       Bool_t UseColor() const { return fUseColoredConsole; }
0060       void   SetUseColor( Bool_t uc ) { fUseColoredConsole = uc; }
0061 
0062       Bool_t IsSilent() const { return fSilent; }
0063       void   SetSilent( Bool_t s ) { fSilent = s; }
0064 
0065       Bool_t WriteOptionsReference() const { return fWriteOptionsReference; }
0066       void   SetWriteOptionsReference( Bool_t w ) { fWriteOptionsReference = w; }
0067 
0068       Bool_t DrawProgressBar() const { return fDrawProgressBar; }
0069       void   SetDrawProgressBar( Bool_t d ) { fDrawProgressBar = d; }
0070       UInt_t GetNCpu() { return fExecutor.GetPoolSize(); }
0071 
0072       UInt_t GetNumWorkers() const { return fNWorkers; }
0073       void   SetNumWorkers(UInt_t n) { fNWorkers = n; }
0074 
0075 #ifdef R__USE_IMT
0076       ROOT::TThreadExecutor &GetMultiThreadExecutor() { return *(fExecutor.GetMultiThreadExecutor()); }
0077 //      ROOT::TSequentialExecutor &GetSeqExecutor() { return *fSeqfPool; }
0078 #endif
0079       /// Get executor class for multi-thread usage
0080       /// In case when  MT is not enabled will return a serial executor
0081       Executor & GetThreadExecutor() { return fExecutor; }
0082 
0083       /// Enable MT in TMVA (by default is on when ROOT::EnableImplicitMT() is set
0084       void EnableMT(int numthreads = 0) { fExecutor = Executor(numthreads); }
0085 
0086       /// Force disabling MT running and release the thread pool by using instead seriaql execution
0087       void DisableMT() {  fExecutor = Executor(1); }
0088 
0089       ///Check if IMT is enabled
0090       Bool_t IsMTEnabled() const { return  fExecutor.GetPoolSize() > 1; }
0091 
0092    public:
0093 
0094       class VariablePlotting;
0095       class IONames;
0096 
0097       VariablePlotting& GetVariablePlotting() { return fVariablePlotting; }
0098       IONames&          GetIONames()          { return fIONames; }
0099 
0100       // publicly accessible global settings
0101       class VariablePlotting {
0102          // data collection class to configure plotting of variables
0103       public:
0104 
0105          Float_t fTimesRMS;
0106          Int_t   fNbins1D;
0107          Int_t   fNbins2D;
0108          Int_t   fMaxNumOfAllowedVariables;
0109          Int_t   fMaxNumOfAllowedVariablesForScatterPlots;
0110          Int_t   fNbinsMVAoutput;
0111          Int_t   fNbinsXOfROCCurve;
0112          Bool_t  fUsePaperStyle;   // set to get eps output
0113          enum { kPNG = 0, kGIF = 1, kPDF = 2, kEPS = 3 };
0114          Int_t fPlotFormat; // (0: png , 1: gif, 2: pdf, 3: eps)
0115 
0116       } fVariablePlotting; // Customisable plotting properties
0117 
0118       // for file names and similar
0119       class IONames {
0120 
0121       public:
0122          // this is name of weight file directory
0123          TString fWeightFileDirPrefix;
0124          TString fWeightFileDir;
0125          TString fWeightFileExtension;
0126          TString fOptionsReferenceFileDir;
0127       } fIONames; // Customisable weight file properties
0128 
0129 
0130    private:
0131 
0132       // private constructor
0133       Config();
0134       Config( const Config& );
0135       Config& operator=( const Config&);
0136       virtual ~Config();
0137       static std::atomic<Config*> fgConfigPtr;
0138    private:
0139 
0140       std::atomic<Bool_t> fDrawProgressBar;       ///< draw progress bar to indicate training evolution
0141       std::atomic<UInt_t> fNWorkers;              ///< Default number of workers for multi-process jobs
0142       std::atomic<Bool_t> fUseColoredConsole;     ///< coloured standard output
0143       std::atomic<Bool_t> fSilent;                ///< no output at all
0144       std::atomic<Bool_t> fWriteOptionsReference; ///< if set true: Configurable objects write file with option reference
0145       mutable MsgLogger* fLogger;                 ///<! message logger
0146       MsgLogger& Log() const { return *fLogger; }
0147 
0148       ClassDef(Config,0); // Singleton class for global configuration settings
0149    };
0150 
0151    // global accessor
0152    Config& gConfig();
0153 }
0154 
0155 #endif