1 #include <utl/ConfigParameter.h>
3 #include <utl/VRandomSampler.h>
4 #include <utl/RandomSamplerFromPDF.h>
5 #include <utl/RandomSamplerFromCDF.h>
6 #include <utl/Branch.h>
7 #include <utl/ConsecutiveEnumFactory.h>
8 #include <utl/RandomEngine.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/TabulatedFunction.h>
26 virtual double MapRandom(
double rand)
const;
38 FixedSampler::MapRandom(
double )
51 typedef std::list<utl::ConfigParameter::Type> List;
54 ListSampler(
const C& values);
56 ListSampler(std::unique_ptr<List>& source);
58 virtual double MapRandom(
const double rand)
const;
61 std::unique_ptr<List> fValues;
62 mutable List::const_iterator fIt;
63 List::const_iterator fEnd;
68 ListSampler::ListSampler(
const C& values) :
69 fValues(new List(values.begin(), values.end()))
75 ListSampler::ListSampler(std::unique_ptr<List>& source) :
76 fValues(std::move(source))
86 fIt = fValues->begin();
87 fEnd = fValues->end();
92 ListSampler::MapRandom(
double )
96 fIt = fValues->begin();
106 const char*
const ConfigParameter::kFunctionTypeTags[] = {
"Fixed",
"PDF",
"CDF",
"ValueList" };
108 const char*
const ConfigParameter::kParametrizationTags[] =
109 {
"Formula",
"FormulaWithVariable",
"Map",
"TabulatedFunction",
"Vector",
"VectorPair" };
111 const char*
const ConfigParameter::kInterpolationTags[] = {
"Linear",
"Discrete",
"Step" };
124 const double v = configData.
GetChild(
"value").
Get<
double>();
125 fSampler.reset(
new FixedSampler(v));
131 std::unique_ptr<ListSampler::List> vs(
new ListSampler::List());
133 fSampler.reset(
new ListSampler(vs));
139 const std::string tagPar = configData.
GetChild(
"parametrization").
Get<std::string>();
142 std::string
function;
146 std::string iVarName;
147 std::map<double, double> dfMap;
149 std::vector<double> dfVect;
150 std::vector<double> xVect;
151 std::vector<double> yVect;
152 std::string interpol;
159 interpolChild.
GetData(interpol);
187 ERROR(
"Branch doesn't provide a GetData(std::map<>) method.");
Simple factory to create an enumerator for a given enumeration.
FunctionType
Type of function to be used.
static EnumType Create(const int k)
int version of the overloaded creation method.
utl::RandomEngine & fEngine
RandomEngineType & GetEngine()
std::unique_ptr< utl::VRandomSampler > fSampler
Class to hold collection (x,y) points and provide interpolation between them.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Class representing a document branch.
Wraps the random number engine used to generate distributions.
~ConfigParameter()
Explicit declaratio+defintion so as to have, when defined, also fully defined the pointed-to type of ...
void GetData(bool &b) const
Overloads of the GetData member template function.
virtual double MapRandom(const double rand) const =0
#define ERROR(message)
Macro for logging error messages.
Class to shoot random numbers given by a user-defined distribution function.