Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TFoamSampler.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Fri Sep 22 15:06:47 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10// Header file for class TFoamSampler
11
12#ifndef ROOT_TFoamSampler
13#define ROOT_TFoamSampler
14
15
16#include "Math/DistSampler.h"
17
18
19namespace ROOT {
20
21 namespace Fit {
22
23 class DataRange;
24 class BinData;
25 class UnBinData;
26 }
27
28 namespace Math {
29 }
30}
31
32class TFoamIntegrand;
33
34
35class TRandom;
36class TF1;
37class TFoam;
38
40
41public:
42
43 /// default constructor
45
46
47 /// virtual destructor
48 virtual ~TFoamSampler();
49
50
51 using DistSampler::SetFunction;
52
53 /// set the parent function distribution to use for random sampling (one dim case)
55 fFunc1D = &func;
56 SetFunction<const ROOT::Math::IGenFunction>(func, 1);
57 }
58
59 /// set the Function using a TF1 pointer
60 void SetFunction(TF1 * pdf);
61
62
63 /**
64 initialize the generators with the default options
65 */
66 bool Init(const char * = "");
67
68 /**
69 initialize the generators with the given options
70 */
71 bool Init(const ROOT::Math::DistSamplerOptions & opt );
72
73 /**
74 Set the random engine to be used
75 Needs to be called before Init to have effect
76 */
77 void SetRandom(TRandom * r);
78
79 /**
80 Set the random seed for the TRandom instances used by the sampler
81 classes
82 Needs to be called before Init to have effect
83 */
84 void SetSeed(unsigned int seed);
85
86
87 /**
88 Get the random engine used by the sampler
89 */
91
92
93 /**
94 sample one event in multi-dimension by filling the given array
95 return false if sampling failed
96 */
97 bool Sample(double * x);
98
99 /**
100 sample one bin given an estimated of the pdf in the bin
101 (this can be function value at the center or its integral in the bin
102 divided by the bin width)
103 By default do not do random sample, just return the function values
104 */
105 bool SampleBin(double prob, double & value, double *error = 0);
106
107
108
109protected:
110
111
112private:
113
114// bool fOneDim; // flag to indicate if the function is 1 dimension
115// bool fHasMode; // flag to indicate if a mode is set
116// bool fHasArea; // flag to indicate if a area is set
117// double fMode; // mode of dist
118// double fArea; // area of dist
119 const ROOT::Math::IGenFunction * fFunc1D; // 1D function pointer
120 TFoam * fFoam; // foam engine class
121 TFoamIntegrand * fFoamDist; // foam distribution interface
122
123 //ClassDef(TFoamSampler,1) //Distribution sampler class based on FOAM
124
125};
126
127
128
129#endif /* ROOT_TFoamSampler */
ROOT::R::TRInterface & r
Definition Object.C:4
DistSampler options class.
Interface class for generic sampling of a distribution, i.e.
Definition DistSampler.h:57
const double * Sample()
sample one event and rerturning array x with coordinates
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition IFunction.h:135
1-Dim function class
Definition TF1.h:213
Abstract class representing n-dimensional real positive integrand function.
class implementing the ROOT::Math::DistSampler interface using FOAM for sampling arbitrary distributi...
const ROOT::Math::IGenFunction * fFunc1D
void SetSeed(unsigned int seed)
Set the random seed for the TRandom instances used by the sampler classes Needs to be called before I...
TFoamSampler()
default constructor
bool SampleBin(double prob, double &value, double *error=0)
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or ...
void SetRandom(TRandom *r)
Set the random engine to be used Needs to be called before Init to have effect.
TFoamIntegrand * fFoamDist
bool Init(const char *="")
initialize the generators with the default options
virtual ~TFoamSampler()
virtual destructor
void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
TRandom * GetRandom()
Get the random engine used by the sampler.
TFoam is the main class of the multi-dimensional general purpose Monte Carlo event generator (integra...
Definition TFoam.h:21
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Double_t x[n]
Definition legend1.C:17
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition HFitImpl.cxx:133
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...