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 ~TFoamSampler() override;
49
50
51 using DistSampler::SetFunction;
52
53 /// set the parent function distribution to use for random sampling (one dim case)
54 void SetFunction(const ROOT::Math::IGenFunction & func) override {
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 * = "") override;
67
68 /**
69 initialize the generators with the given options
70 */
71 bool Init(const ROOT::Math::DistSamplerOptions & opt ) override;
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) override;
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) override;
85
86
87 /**
88 Get the random engine used by the sampler
89 */
90 TRandom * GetRandom() override;
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) override;
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 = nullptr) override;
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 //ClassDefOverride(TFoamSampler,1) //Distribution sampler class based on FOAM
124
125};
126
127
128
129#endif /* ROOT_TFoamSampler */
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
DistSampler options class.
Interface class for generic sampling of a distribution, i.e.
Definition DistSampler.h:57
const double * Sample()
Sample one event and return an array x with sample coordinates values.
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...
void SetFunction(const ROOT::Math::IGenFunction &func) override
set the parent function distribution to use for random sampling (one dim case)
const ROOT::Math::IGenFunction * fFunc1D
bool Init(const char *="") override
initialize the generators with the default options
void SetSeed(unsigned int seed) override
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=nullptr) override
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or ...
TFoamIntegrand * fFoamDist
TRandom * GetRandom() override
Get the random engine used by the sampler.
~TFoamSampler() override
virtual destructor
void SetRandom(TRandom *r) override
Set the random engine to be used Needs to be called before Init to have effect.
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.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.