Logo ROOT   6.08/07
Reference Guide
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 #ifndef ROOT_Math_DistSampler
17 #include "Math/DistSampler.h"
18 #endif
19 
20 
21 namespace ROOT {
22 
23  namespace Fit {
24 
25  class DataRange;
26  class BinData;
27  class UnBinData;
28  }
29 
30  namespace Math {
31  }
32 }
33 
34 class TFoamIntegrand;
35 
36 
37 class TRandom;
38 class TF1;
39 class TFoam;
40 
41 
42 //_______________________________________________________________________________
43 /**
44  TFoamSampler class
45  class implementing the ROOT::Math::DistSampler interface using FOAM
46  for sampling arbitrary distributions.
47 
48 
49 */
51 
52 public:
53 
54  /// default constructor
55  TFoamSampler();
56 
57 
58  /// virtual destructor
59  virtual ~TFoamSampler();
60 
61 
62  using DistSampler::SetFunction;
63 
64  /// set the parent function distribution to use for random sampling (one dim case)
66  fFunc1D = &func;
67  SetFunction<const ROOT::Math::IGenFunction>(func, 1);
68  }
69 
70  /// set the Function using a TF1 pointer
71  void SetFunction(TF1 * pdf);
72 
73 
74  /**
75  initialize the generators with the default options
76  */
77  bool Init(const char * = "");
78 
79  /**
80  initialize the generators with the fiven options
81  */
82  bool Init(const ROOT::Math::DistSamplerOptions & opt );
83 
84  /**
85  Set the random engine to be used
86  Needs to be called before Init to have effect
87  */
88  void SetRandom(TRandom * r);
89 
90  /**
91  Set the random seed for the TRandom instances used by the sampler
92  classes
93  Needs to be called before Init to have effect
94  */
95  void SetSeed(unsigned int seed);
96 
97 
98  /**
99  Get the random engine used by the sampler
100  */
101  TRandom * GetRandom();
102 
103 
104  /**
105  sample one event in multi-dimension by filling the given array
106  return false if sampling failed
107  */
108  bool Sample(double * x);
109 
110  /**
111  sample one bin given an estimated of the pdf in the bin
112  (this can be function value at the center or its integral in the bin
113  divided by the bin width)
114  By default do not do random sample, just return the function values
115  */
116  bool SampleBin(double prob, double & value, double *error = 0);
117 
118 
119 
120 protected:
121 
122 
123 private:
124 
125  // private member
126 // bool fOneDim; // flag to indicate if the function is 1 dimension
127 // bool fHasMode; // flag to indicate if a mode is set
128 // bool fHasArea; // flag to indicate if a area is set
129 // double fMode; // mode of dist
130 // double fArea; // area of dist
131  const ROOT::Math::IGenFunction * fFunc1D; // 1D function pointer
132  TFoam * fFoam; // foam engine class
133  TFoamIntegrand * fFoamDist; // foam distribution interface
134 
135  //ClassDef(TFoamSampler,1) //Distribution sampler class based on FOAM
136 
137 };
138 
139 
140 
141 #endif /* ROOT_TFoamSampler */
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:133
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
Definition: TFoamSampler.h:65
TFoamIntegrand * fFoamDist
Definition: TFoamSampler.h:133
Double_t x[n]
Definition: legend1.C:17
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:119
TFoam * fFoam
Definition: TFoamSampler.h:132
TRandom2 r(17)
DistSampler options class.
Interface class for generic sampling of a distribution, i.e.
Definition: DistSampler.h:61
const ROOT::Math::IGenFunction * fFunc1D
Definition: TFoamSampler.h:131
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:134
double func(double *x, double *p)
Definition: stressTF1.cxx:213
Namespace for new Math classes and functions.
1-Dim function class
Definition: TF1.h:149
Definition: TFoam.h:29
TFoamSampler class class implementing the ROOT::Math::DistSampler interface using FOAM for sampling a...
Definition: TFoamSampler.h:50