Logo ROOT   6.14/05
Reference Guide
DistSamplerOptions.cxx
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta Fri Aug 15 2008
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2008 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
12 
13 #include "Math/GenAlgoOptions.h"
14 
15 
16 #include <iomanip>
17 
18 namespace ROOT {
19 
20 
21 namespace Math {
22 
23  namespace Sampler {
24  static std::string gDefaultSampler = "Unuran";
25  static std::string gDefaultAlgorithm1D = "auto";
26  static std::string gDefaultAlgorithmND = "vnrou";
27  static int gDefaultPrintLevel = 0;
28  }
29 
30 
32  // set the default minimizer type and algorithm
33  if (type) Sampler::gDefaultSampler = std::string(type);
34 }
36  // set the default minimizer type and algorithm
37  if (algo) Sampler::gDefaultAlgorithm1D = std::string(algo);
38 }
40  // set the default minimizer type and algorithm
41  if (algo) Sampler::gDefaultAlgorithmND = std::string(algo);
42 }
44  // set the default printing level
46 }
47 
51 
53 {
54  // return default minimizer
55  // if is "" (no default is set) read from etc/system.rootrc
56  // use form /etc/ ??
57 
59 }
60 
61 
63  fLevel( Sampler::gDefaultPrintLevel),
64  fExtraOptions(0)
65 {
66  // constructor using the default options
67 
69 
70  if (dim == 1)
72  else if (dim >1)
74  else
75  // not specified - keep null string
76  fAlgoType = std::string();
77 
78  // check if extra options exists (copy them if needed)
79  if (!fExtraOptions) {
80  IOptions * gopts = FindDefault( fSamplerType.c_str() );
81  if (gopts) fExtraOptions = gopts->Clone();
82  }
83 }
84 
85 
87  // copy constructor
88  (*this) = opt;
89 }
90 
92  // assignment operator
93  if (this == &opt) return *this; // self assignment
94  fLevel = opt.fLevel;
96  fAlgoType = opt.fAlgoType;
97 
98  if (fExtraOptions) delete fExtraOptions;
99  fExtraOptions = 0;
100  if (opt.fExtraOptions) fExtraOptions = (opt.fExtraOptions)->Clone();
101  return *this;
102 }
103 
105  if (fExtraOptions) delete fExtraOptions;
106 }
107 
109  // set extra options (clone the passed one)
110  if (fExtraOptions) delete fExtraOptions;
111  fExtraOptions = opt.Clone();
112 }
113 
114 void DistSamplerOptions::Print(std::ostream & os) const {
115  //print all the options
116  os << std::setw(25) << "DistSampler Type" << " : " << std::setw(15) << fSamplerType << std::endl;
117  os << std::setw(25) << "DistSampler Algorithm" << " : " << std::setw(15) << fAlgoType << std::endl;
118  os << std::setw(25) << "Print Level" << " : " << std::setw(15) << fLevel << std::endl;
119 
120  if (ExtraOptions()) {
121  os << fSamplerType << " specific options :" << std::endl;
122  ExtraOptions()->Print(os);
123  }
124 }
125 
127  // create default extra options for the given algorithm type
128  return GenAlgoOptions::Default(name);
129 }
130 
132  // find extra options for the given algorithm type
133  return GenAlgoOptions::FindDefault(name);
134 }
135 
136 void DistSamplerOptions::PrintDefault(const char * name, std::ostream & os) {
137  //print default options
138  os << "Default DistSampler options " << std::endl;
139  os << std::setw(25) << "Default Type" << " : " << std::setw(15) << DistSamplerOptions::DefaultSampler() << std::endl;
140  os << std::setw(25) << "Default Algorithm 1D" << " : " << std::setw(15) << DistSamplerOptions::DefaultAlgorithm1D() << std::endl;
141  os << std::setw(25) << "Default Algorithm ND" << " : " << std::setw(15) << DistSamplerOptions::DefaultAlgorithmND() << std::endl;
142  os << std::setw(25) << "Default Print Level" << " : " << std::setw(15) << DistSamplerOptions::DefaultPrintLevel() << std::endl;
143  IOptions * opt = FindDefault(name);
144  if (opt) {
145  os << "Specific default options for " << name << std::endl;
146  opt->Print(os);
147  }
148 }
149 
150 
151 
152 
153 } // end namespace Math
154 
155 } // end namespace ROOT
156 
static ROOT::Math::IOptions * FindDefault(const char *name)
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
static void SetDefaultAlgorithmND(const char *algo)
virtual void Print(std::ostream &=std::cout) const
print options
Definition: IOptions.h:98
static void SetDefaultSampler(const char *type)
static void SetDefaultPrintLevel(int level)
static std::string gDefaultAlgorithm1D
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
static const std::string & DefaultAlgorithmND()
static void PrintDefault(const char *name, std::ostream &os=std::cout)
print all the default options for the name given
DistSampler options class.
static std::string gDefaultSampler
virtual IOptions * Clone() const =0
static ROOT::Math::IOptions & Default(const char *name)
retrieve extra options - if not existing create a IOptions
DistSamplerOptions & operator=(const DistSamplerOptions &opt)
assignment operators
int type
Definition: TGX11.cxx:120
static const std::string & DefaultSampler()
static void SetDefaultAlgorithm1D(const char *algo)
static std::string gDefaultAlgorithmND
Namespace for new Math classes and functions.
static IOptions & Default(const char *algoname)
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:30
ROOT::Math::IOptions * fExtraOptions
IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
static IOptions * FindDefault(const char *algoname)
static const std::string & DefaultAlgorithm1D()
char name[80]
Definition: TGX11.cxx:109
void Print(std::ostream &os=std::cout) const
print all the options