Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RndmGenerators.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_RNDMGENGENERATORS_H
2 #define GAUDIKERNEL_RNDMGENGENERATORS_H
3 
4 // STL include files
5 #include <vector>
6 
7 // Framework include files
8 #include "GaudiKernel/IRndmGen.h"
9 #include "GaudiKernel/SmartIF.h"
10 
11 // Forward declarations
12 class IRndmGen;
13 class IRndmGenSvc;
14 
15 namespace Rndm {
16 
17  template <class TYPE> class Generator;
18 
22  protected:
24  friend class Generator<Gauss>;
26  double m_mean;
28  double m_sigma;
29  public:
31  Gauss(double m, double s)
32  : IRndmGen::Param(IID_IRndmGauss), m_mean(m), m_sigma(s) { }
34  ~Gauss() override = default;
36  double mean() const { return m_mean; }
38  double sigma() const { return m_sigma; }
40  static const InterfaceID& typeID() { return IID_IRndmGauss; }
42  Gauss* clone() const override { return new Gauss(m_mean, m_sigma); }
43  };
44 
48  protected:
50  double m_mean;
51  public:
53  Exponential(double m)
54  : IRndmGen::Param(IID_IRndmExponential), m_mean(m) { }
56  ~Exponential() override = default;
58  double mean() const { return m_mean; }
60  static const InterfaceID& typeID() { return IID_IRndmExponential; }
62  Exponential* clone() const override { return new Exponential(m_mean); }
63  };
64 
67  class GAUDI_API Chi2: public IRndmGen::Param {
68  friend class Generator<Chi2>;
69  protected:
71  long m_nDOF;
72  public:
74  Chi2(long n_dof) : IRndmGen::Param(IID_IRndmChi2), m_nDOF(n_dof) { }
76  ~Chi2() override = default;
78  long nDOF() const { return m_nDOF; }
80  static const InterfaceID& typeID() { return IID_IRndmChi2; }
82  Chi2* clone() const override { return new Chi2(m_nDOF); }
83  };
84 
88  friend class Generator<BreitWigner>;
89  protected:
91  double m_mean, m_gamma;
92  public:
94  BreitWigner(double m, double g)
95  : IRndmGen::Param(IID_IRndmBreitWigner), m_mean(m), m_gamma(g) { }
97  ~BreitWigner() override = default;
99  double mean() const { return m_mean; }
101  double gamma() const { return m_gamma; }
103  static const InterfaceID& typeID() { return IID_IRndmBreitWigner; }
105  BreitWigner* clone() const override { return new BreitWigner(m_mean, m_gamma); }
106  };
107 
111  friend class Generator<Landau>;
112  protected:
114  double m_mean, m_sigma;
115  public:
117  Landau(double m, double s)
118  : IRndmGen::Param(IID_IRndmLandau), m_mean(m), m_sigma(s) { }
120  ~Landau() override = default;
122  double mean() const { return m_mean; }
124  double sigma() const { return m_sigma; }
126  static const InterfaceID& typeID() { return IID_IRndmLandau; }
128  Landau* clone() const override { return new Landau(m_mean, m_sigma); }
129  };
130 
136  protected:
138  double m_mean, m_gamma, m_cut;
139  public:
141  BreitWignerCutOff(double m, double g, double c)
142  : IRndmGen::Param(IID_IRndmBreitWignerCutOff),
143  m_mean(m),
144  m_gamma(g),
145  m_cut(c) { }
147  ~BreitWignerCutOff() override = default;
149  double mean() const { return m_mean; }
151  double gamma() const { return m_gamma; }
153  double cutOff() const { return m_cut; }
155  static const InterfaceID& typeID() { return IID_IRndmBreitWignerCutOff;}
157  BreitWignerCutOff* clone() const override{ return new BreitWignerCutOff(m_mean, m_gamma, m_cut); }
158  };
159 
163  friend class Generator<StudentT>;
164  protected:
166  double m_aValue;
167  public:
169  StudentT(double a) : IRndmGen::Param(IID_IRndmStudentT), m_aValue(a) { }
171  ~StudentT() override = default;
173  double aValue() const { return m_aValue; }
175  static const InterfaceID& typeID() { return IID_IRndmStudentT; }
177  StudentT* clone() const override { return new StudentT(m_aValue);}
178  };
179 
183  friend class Generator<Gamma>;
184  protected:
186  double m_kValue;
188  double m_lambda;
189  public:
191  Gamma(double k, double l)
192  : IRndmGen::Param(IID_IRndmGamma), m_kValue(k), m_lambda(l) { }
194  ~Gamma() override = default;
196  double kValue() const { return m_kValue; }
198  double lambda() const { return m_lambda; }
200  static const InterfaceID& typeID() { return IID_IRndmGamma; }
202  Gamma* clone() const override { return new Gamma(m_kValue, m_lambda); }
203  };
204 
209  friend class Generator<Poisson>;
210  protected:
212  double m_mean;
213  public:
215  Poisson(double m) : IRndmGen::Param(IID_IRndmPoisson), m_mean(m) { }
217  ~Poisson() override = default;
219  double mean() const { return m_mean; }
221  static const InterfaceID& typeID() { return IID_IRndmPoisson; }
223  Poisson* clone() const override { return new Poisson(m_mean); }
224  };
225 
230  protected:
232  long m_nEvent;
235  public:
237  Binomial(long n, double p)
238  : IRndmGen::Param(IID_IRndmBinomial), m_nEvent(n), m_probability(p) { }
240  ~Binomial() override = default;
242  long nEvent() const { return m_nEvent; }
244  double probability() const { return m_probability; }
246  static const InterfaceID& typeID() { return IID_IRndmBinomial; }
248  Binomial* clone() const override { return new Binomial(m_nEvent, m_probability); }
249  };
250 
255  protected:
257  double m_minimum;
259  double m_maximum;
260  public:
262  Flat(double mi, double ma)
263  : IRndmGen::Param(IID_IRndmFlat), m_minimum(mi), m_maximum(ma) { }
265  ~Flat() override = default;
267  double minimum() const { return m_minimum; }
269  double maximum() const { return m_maximum; }
271  static const InterfaceID& typeID() { return IID_IRndmFlat; }
273  Flat* clone() const override { return new Flat(m_minimum, m_maximum); }
274  };
275 
278  class GAUDI_API Bit: public IRndmGen::Param {
279  public:
281  Bit() : IRndmGen::Param(IID_IRndmBit) { }
283  ~Bit() override = default;
285  static const InterfaceID& typeID() { return IID_IRndmBit; }
287  Bit* clone() const override { return new Bit(); }
288  };
289 
307  protected:
312  public:
314  DefinedPdf(const std::vector<double>& pdf, long intpol)
315  : IRndmGen::Param(IID_IRndmDefinedPdf),
316  m_pdf(pdf),
317  m_interpolation(intpol) { }
319  ~DefinedPdf() override = default;
321  std::vector<double>& pdf() { return m_pdf; }
323  long interpolation() const { return m_interpolation; }
325  static const InterfaceID& typeID() { return IID_IRndmDefinedPdf; }
327  DefinedPdf* clone() const override { return new DefinedPdf(m_pdf,m_interpolation); }
328  };
329 
333  protected:
335  double m_cut;
337  double m_sigma;
338  public:
340  GaussianTail(double a, double s)
341  : IRndmGen::Param(IID_IRndmGaussianTail), m_cut(a), m_sigma(s) { }
343  ~GaussianTail() override = default;
345  double cut() const { return m_cut; }
347  double sigma() const { return m_sigma; }
349  static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
351  GaussianTail* clone() const override { return new GaussianTail(m_cut, m_sigma); }
352  };
353 
354 
371  protected:
374  public:
376  Numbers() = default;
378  Numbers(const Numbers& ) = default;
380  Numbers(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par);
382  virtual ~Numbers();
384  virtual StatusCode initialize(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par);
385 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
386  Numbers(IRndmGenSvc* svc, const IRndmGen::Param& par);
389  virtual StatusCode initialize(IRndmGenSvc* svc, const IRndmGen::Param& par);
390 #endif
391  virtual StatusCode finalize();
394  operator bool () const {
395  return m_generator;
396  }
398  double operator() () {
399  return this->shoot();
400  }
402  double pop() {
403  return this->shoot();
404  }
406  double shoot() {
407  return m_generator ? m_generator->shoot()
408  : -1;
409  }
412  return m_generator ? m_generator->shootArray(array, num, start)
414  }
415  };
416 }
417 #endif // GAUDIKERNEL_RNDMGENGENERATORS_H
Binomial * clone() const override
Clone parameters.
Gamma * clone() const override
Clone parameters.
StudentT * clone() const override
Clone parameters.
virtual double shoot() const =0
Single shot returning single random number according to specified distribution.
long nDOF() const
Access mean value of the distribution.
static const InterfaceID & typeID()
Identifier for factory.
Parameters for the bit value generation: returns values 0 and 1.
double m_mean
Mean, Gamma and cut off parameter of the Breit-Wigner distribution.
static const InterfaceID & typeID()
Identifier for factory.
GaussianTail(double a, double s)
Standard Constructor.
double m_kValue
k Value
double m_minimum
Lower boundary for random numbers.
static const InterfaceID & typeID()
Identifier for factory.
double mean() const
Access mean value of the distribution.
Parameters for the Poisson distributed random number generation with a given mean.
Exponential * clone() const override
Clone parameters.
double mean() const
Access mean value of the distribution.
Definition of a interface for a generic random number generators.
Definition: IRndmGen.h:35
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
double m_probability
And the probability for having success.
static const InterfaceID & typeID()
Identifier for factory.
double m_sigma
Sigma of the Gauss ditribution.
static const InterfaceID & typeID()
Identifier for factory.
Parameters for the Gauss random number generation.
Gauss(double m, double s)
Standard Constructor.
Bit * clone() const override
Clone parameters.
Flat(double mi, double ma)
Standard Constructor.
double mean() const
Access mean value of the distribution.
double shoot()
Pop a new number from the buffer.
double lambda() const
Access Lambda parameter.
long m_nEvent
Number of events the binomial destribution corresponds to.
double m_mean
Mean value of the exponential distribution.
BreitWigner(double m, double g)
Standard Constructor.
long nEvent() const
Access number of events.
long interpolation() const
Access interpolation type.
Landau(double m, double s)
Standard Constructor.
Flat * clone() const override
Clone parameters.
double m_mean
Mean value of the Poisson distribution.
Random number accessor This small class encapsulates the use of the random number generator...
Interface ID class.
Definition: IInterface.h:30
Bit()
Standard Constructor.
double probability() const
Access number of events.
Poisson * clone() const override
Clone parameters.
DefinedPdf(const std::vector< double > &pdf, long intpol)
Standard Constructor.
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
double m_cut
Cut on the Gaussian tail distribution.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
constexpr double m
Definition: SystemOfUnits.h:93
static const InterfaceID & typeID()
Identifier for factory.
Parameters for the flat random number generation within boundaries [minimum, maximum].
double m_maximum
Upper boundary for random numbers.
std::vector< double > m_pdf
Vector containing probability distribution function.
static const InterfaceID & typeID()
Identifier for factory.
StudentT(double a)
Standard Constructor.
double cutOff() const
Access width of the distribution.
start
Definition: IOTest.py:88
static const InterfaceID & typeID()
Identifier for factory.
double m_mean
Mean of the Gauss distribution.
long m_interpolation
Interpolation type.
static const InterfaceID & typeID()
Identifier for factory.
double maximum() const
Access upper edge.
Parameters for the StudentT distributed random number generation.
double m_lambda
Lambda parameter.
static const InterfaceID & typeID()
Identifier for factory.
dictionary l
Definition: gaudirun.py:421
Parameters for the Binomial distributed random number generation.
StatusCode shootArray(std::vector< double > &array, long num, long start=0)
Pop a new number from the buffer.
double kValue() const
Access K parameter.
double sigma() const
Access width of the distribution.
Parameters for the Landau distributed random number generation.
BreitWigner * clone() const override
Clone parameters.
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Parameters for the Chi2 distributed random number generation.
double pop()
Pop a new number from the buffer.
double m_sigma
Sigma of the Gauss distribution.
Landau * clone() const override
Clone parameters.
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
static const InterfaceID & typeID()
Identifier for factory.
Parameters for the BreitWigner distributed random number generation with cut off;.
double sigma() const
Access width of the distribution.
double mean() const
Access mean value of the distribution.
Parameters for the Gamma distributed random number generation.
dictionary g
Definition: gaudirun.py:420
string s
Definition: gaudirun.py:245
BreitWignerCutOff(double m, double g, double c)
Standard Constructor.
static const InterfaceID & typeID()
Identifier for factory.
Gamma(double k, double l)
Standard Constructor.
BreitWignerCutOff * clone() const override
Clone parameters.
double gamma() const
Access width of the distribution.
virtual StatusCode shootArray(std::vector< double > &array, long howmany, long start=0) const =0
Multiple shots returning vector with random number according to specified distribution.
Binomial(long n, double p)
Standard Constructor.
double m_aValue
StudentT distribution parameter.
Gauss * clone() const override
Clone parameters.
Chi2(long n_dof)
Standard Constructor.
double aValue() const
Access A parameter.
double cut() const
Access cut value of the distribution.
double mean() const
Access mean value of the distribution.
Parameters for the Gaussian tail number generation.
Generate a random number Generator following generally distributed random values, given a user-define...
Parameters for the Gauss random number generation.
#define GAUDI_API
Definition: Kernel.h:107
Chi2 * clone() const override
Clone parameters.
double minimum() const
Access lower edge.
DefinedPdf * clone() const override
Clone parameters.
long m_nDOF
Number of degrees of freedom.
double mean() const
Access mean value of the distribution.
Parameters for the BreitWigner distributed random number generation.
Poisson(double m)
Standard Constructor.
static const InterfaceID & typeID()
Identifier for factory.
double gamma() const
Access width of the distribution.
double m_mean
Mean and Gamma parameter of the Breit-Wigner distribution.
GaussianTail * clone() const override
Clone parameters.
double sigma() const
Access sigma of the distribution.
Exponential(double m)
Standard Constructor.
std::vector< double > & pdf()
Access pdf.
static const InterfaceID & typeID()
Identifier for factory.