The Gaudi Framework  v30r3 (a5ef0a68)
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 
18  template <class TYPE>
19  class Generator;
20 
24  {
25  protected:
27  friend class Generator<Gauss>;
29  double m_mean;
31  double m_sigma;
32 
33  public:
35  Gauss( double m, double s ) : IRndmGen::Param( IID_IRndmGauss ), m_mean( m ), m_sigma( s ) {}
37  double mean() const { return m_mean; }
39  double sigma() const { return m_sigma; }
41  static const InterfaceID& typeID() { return IID_IRndmGauss; }
43  Gauss* clone() const override { return new Gauss( m_mean, m_sigma ); }
44  };
45 
49  {
50  protected:
52  double m_mean;
53 
54  public:
56  Exponential( double m ) : IRndmGen::Param( IID_IRndmExponential ), m_mean( m ) {}
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 
68  {
69  friend class Generator<Chi2>;
70 
71  protected:
73  long m_nDOF;
74 
75  public:
77  Chi2( long n_dof ) : IRndmGen::Param( IID_IRndmChi2 ), m_nDOF( n_dof ) {}
79  long nDOF() const { return m_nDOF; }
81  static const InterfaceID& typeID() { return IID_IRndmChi2; }
83  Chi2* clone() const override { return new Chi2( m_nDOF ); }
84  };
85 
89  {
90  friend class Generator<BreitWigner>;
91 
92  protected:
94  double m_mean, m_gamma;
95 
96  public:
98  BreitWigner( double m, double g ) : IRndmGen::Param( IID_IRndmBreitWigner ), m_mean( m ), m_gamma( g ) {}
100  double mean() const { return m_mean; }
102  double gamma() const { return m_gamma; }
104  static const InterfaceID& typeID() { return IID_IRndmBreitWigner; }
106  BreitWigner* clone() const override { return new BreitWigner( m_mean, m_gamma ); }
107  };
108 
112  {
113  friend class Generator<Landau>;
114 
115  protected:
117  double m_mean, m_sigma;
118 
119  public:
121  Landau( double m, double s ) : IRndmGen::Param( IID_IRndmLandau ), m_mean( m ), m_sigma( s ) {}
123  double mean() const { return m_mean; }
125  double sigma() const { return m_sigma; }
127  static const InterfaceID& typeID() { return IID_IRndmLandau; }
129  Landau* clone() const override { return new Landau( m_mean, m_sigma ); }
130  };
131 
136  {
138 
139  protected:
141  double m_mean, m_gamma, m_cut;
142 
143  public:
145  BreitWignerCutOff( double m, double g, double c )
146  : IRndmGen::Param( IID_IRndmBreitWignerCutOff ), m_mean( m ), m_gamma( g ), m_cut( c )
147  {
148  }
150  double mean() const { return m_mean; }
152  double gamma() const { return m_gamma; }
154  double cutOff() const { return m_cut; }
156  static const InterfaceID& typeID() { return IID_IRndmBreitWignerCutOff; }
158  BreitWignerCutOff* clone() const override { return new BreitWignerCutOff( m_mean, m_gamma, m_cut ); }
159  };
160 
164  {
165  friend class Generator<StudentT>;
166 
167  protected:
169  double m_aValue;
170 
171  public:
173  StudentT( double a ) : IRndmGen::Param( IID_IRndmStudentT ), m_aValue( a ) {}
175  double aValue() const { return m_aValue; }
177  static const InterfaceID& typeID() { return IID_IRndmStudentT; }
179  StudentT* clone() const override { return new StudentT( m_aValue ); }
180  };
181 
185  {
186  friend class Generator<Gamma>;
187 
188  protected:
190  double m_kValue;
192  double m_lambda;
193 
194  public:
196  Gamma( double k, double l ) : IRndmGen::Param( IID_IRndmGamma ), m_kValue( k ), m_lambda( l ) {}
198  double kValue() const { return m_kValue; }
200  double lambda() const { return m_lambda; }
202  static const InterfaceID& typeID() { return IID_IRndmGamma; }
204  Gamma* clone() const override { return new Gamma( m_kValue, m_lambda ); }
205  };
206 
211  {
212  friend class Generator<Poisson>;
213 
214  protected:
216  double m_mean;
217 
218  public:
220  Poisson( double m ) : IRndmGen::Param( IID_IRndmPoisson ), m_mean( m ) {}
222  double mean() const { return m_mean; }
224  static const InterfaceID& typeID() { return IID_IRndmPoisson; }
226  Poisson* clone() const override { return new Poisson( m_mean ); }
227  };
228 
233  {
234  protected:
236  long m_nEvent;
239 
240  public:
242  Binomial( long n, double p ) : IRndmGen::Param( IID_IRndmBinomial ), m_nEvent( n ), m_probability( p ) {}
244  long nEvent() const { return m_nEvent; }
246  double probability() const { return m_probability; }
248  static const InterfaceID& typeID() { return IID_IRndmBinomial; }
250  Binomial* clone() const override { return new Binomial( m_nEvent, m_probability ); }
251  };
252 
257  {
258  protected:
260  double m_minimum;
262  double m_maximum;
263 
264  public:
266  Flat( double mi, double ma ) : IRndmGen::Param( IID_IRndmFlat ), m_minimum( mi ), m_maximum( ma ) {}
268  double minimum() const { return m_minimum; }
270  double maximum() const { return m_maximum; }
272  static const InterfaceID& typeID() { return IID_IRndmFlat; }
274  Flat* clone() const override { return new Flat( m_minimum, m_maximum ); }
275  };
276 
280  {
281  public:
283  Bit() : IRndmGen::Param( IID_IRndmBit ) {}
285  static const InterfaceID& typeID() { return IID_IRndmBit; }
287  Bit* clone() const override { return new Bit(); }
288  };
289 
307  {
308  protected:
313 
314  public:
316  DefinedPdf( const std::vector<double>& pdf, long intpol )
317  : IRndmGen::Param( IID_IRndmDefinedPdf ), m_pdf( pdf ), m_interpolation( intpol )
318  {
319  }
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  {
334  protected:
336  double m_cut;
338  double m_sigma;
339 
340  public:
342  GaussianTail( double a, double s ) : IRndmGen::Param( IID_IRndmGaussianTail ), m_cut( a ), m_sigma( s ) {}
344  double cut() const { return m_cut; }
346  double sigma() const { return m_sigma; }
348  static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
350  GaussianTail* clone() const override { return new GaussianTail( m_cut, m_sigma ); }
351  };
352 
369  {
370  protected:
373 
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 { return m_generator; }
396  double operator()() { return this->shoot(); }
398  double pop() { return this->shoot(); }
400  double shoot() { return m_generator ? m_generator->shoot() : -1; }
403  {
404  return m_generator ? m_generator->shootArray( array, num, start ) : StatusCode::FAILURE;
405  }
406  };
407 }
408 #endif // GAUDIKERNEL_RNDMGENGENERATORS_H
Binomial * clone() const override
Clone parameters.
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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:34
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 operator()()
Operator () for the use within STL.
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:29
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:51
constexpr double m
Definition: SystemOfUnits.h:94
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:99
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:440
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.
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:439
string s
Definition: gaudirun.py:253
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:104
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.