Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/mathcore:$Id$
0002 // Author: L. Moneta Fri Aug 15 2008
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2008  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 
0011 #ifndef ROOT_Math_DistSamplerOptions
0012 #define ROOT_Math_DistSamplerOptions
0013 
0014 #include <string>
0015 
0016 #include <iostream>
0017 #include "Math/IOptions.h"
0018 
0019 namespace ROOT {
0020 
0021 
0022 namespace Math {
0023 
0024 
0025 //_______________________________________________________________________________
0026 /**
0027     DistSampler options class
0028 
0029     @ingroup NumAlgo
0030 */
0031 class DistSamplerOptions {
0032 
0033 public:
0034 
0035    // static methods for setting and retrieving the default options
0036 
0037    static void SetDefaultSampler(const char * type);
0038    static void SetDefaultAlgorithm1D(const char * algo );
0039    static void SetDefaultAlgorithmND(const char * algo );
0040    static void SetDefaultPrintLevel(int level);
0041 
0042    static const std::string & DefaultSampler();
0043    static const std::string & DefaultAlgorithm1D();
0044    static const std::string & DefaultAlgorithmND();
0045    static int DefaultPrintLevel();
0046 
0047    /// retrieve extra options - if not existing create a IOptions
0048    static ROOT::Math::IOptions & Default(const char * name);
0049 
0050    // find extra options - return 0 if not existing
0051    static ROOT::Math::IOptions * FindDefault(const char * name);
0052 
0053    /// print all the default options for the name given
0054    static void PrintDefault(const char * name, std::ostream & os = std::cout);
0055 
0056 public:
0057 
0058    // constructor using the default options
0059    // pass optionally a pointer to the additional options
0060    // otherwise look if they exist for this default minimizer
0061    // and in that case they are copied in the constructed instance
0062    // constructor takes dimension since a different default algorithm
0063    // is used if the dimension is 1 or greater than 1
0064    DistSamplerOptions(int dim = 0);
0065 
0066    // destructor
0067    ~DistSamplerOptions();
0068 
0069    // copy constructor
0070    DistSamplerOptions(const DistSamplerOptions & opt);
0071 
0072    /// assignment operators
0073    DistSamplerOptions & operator=(const DistSamplerOptions & opt);
0074 
0075    /** non-static methods for  retrieving options */
0076 
0077    /// set print level
0078    int PrintLevel() const { return fLevel; }
0079 
0080    /// return extra options (NULL pointer if they are not present)
0081    IOptions * ExtraOptions() const { return fExtraOptions; }
0082 
0083    /// type of minimizer
0084    const std::string & Sampler() const { return fSamplerType; }
0085 
0086    /// type of algorithm (method)
0087    const std::string & Algorithm() const { return fAlgoType; }
0088 
0089    /// print all the options
0090    void Print(std::ostream & os = std::cout) const;
0091 
0092    /** non-static methods for setting options */
0093 
0094    /// set print level
0095    void SetPrintLevel(int level) { fLevel = level; }
0096 
0097    /// set minimizer type
0098    void SetSampler(const char * type) { fSamplerType = type; }
0099 
0100    /// set minimizer algorithm
0101    void SetAlgorithm(const char *type) { fAlgoType = type; }
0102 
0103    /// set extra options (in this case pointer is cloned)
0104    void  SetExtraOptions(const IOptions & opt);
0105 
0106    /// set a specific algorithm option
0107    template <class T>
0108    void SetAlgoOption(const char * name, T value) {
0109       if (!fExtraOptions) CreateExtraOptions();
0110       fExtraOptions->SetValue(name, value);
0111    }
0112 
0113 protected:
0114 
0115    void CreateExtraOptions();
0116 
0117 private:
0118 
0119    int fLevel;               ///< debug print level
0120    std::string fSamplerType; ///< DistSampler type (Unuran, Foam, etc...)xs
0121    std::string fAlgoType;    ///< DistSampler algorithmic specification (for Unuran only)
0122 
0123    ROOT::Math::IOptions *   fExtraOptions;  ///< extra options
0124 
0125 };
0126 
0127    } // end namespace Math
0128 
0129 } // end namespace ROOT
0130 
0131 #endif