| The Gaudi Framework v32r1 (f65d50dc)

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>
18 class Generator;
19
22 class GAUDI_API Gauss : public IRndmGen::Param {
23 protected:
25 friend class Generator<Gauss>;
27 double m_mean;
29 double m_sigma;
30
31 public:
33 Gauss( double m, double s ) : IRndmGen::Param( IID_IRndmGauss ), m_mean( m ), m_sigma( s ) {}
35 double mean() const { return m_mean; }
37 double sigma() const { return m_sigma; }
39 static const InterfaceID& typeID() { return IID_IRndmGauss; }
41 Gauss* clone() const override { return new Gauss( m_mean, m_sigma ); }
42 };
43
46 class GAUDI_API Exponential : public IRndmGen::Param {
47 protected:
49 double m_mean;
50
51 public:
53 Exponential( double m ) : IRndmGen::Param( IID_IRndmExponential ), m_mean( m ) {}
55 double mean() const { return m_mean; }
57 static const InterfaceID& typeID() { return IID_IRndmExponential; }
59 Exponential* clone() const override { return new Exponential( m_mean ); }
60 };
61
64 class GAUDI_API Chi2 : public IRndmGen::Param {
65 friend class Generator<Chi2>;
66
67 protected:
69 long m_nDOF;
70
71 public:
73 Chi2( long n_dof ) : IRndmGen::Param( IID_IRndmChi2 ), m_nDOF( n_dof ) {}
75 long nDOF() const { return m_nDOF; }
77 static const InterfaceID& typeID() { return IID_IRndmChi2; }
79 Chi2* clone() const override { return new Chi2( m_nDOF ); }
80 };
81
84 class GAUDI_API BreitWigner : public IRndmGen::Param {
85 friend class Generator<BreitWigner>;
86
87 protected:
89 double m_mean, m_gamma;
90
91 public:
93 BreitWigner( double m, double g ) : IRndmGen::Param( IID_IRndmBreitWigner ), m_mean( m ), m_gamma( g ) {}
95 double mean() const { return m_mean; }
97 double gamma() const { return m_gamma; }
99 static const InterfaceID& typeID() { return IID_IRndmBreitWigner; }
101 BreitWigner* clone() const override { return new BreitWigner( m_mean, m_gamma ); }
102 };
103
106 class GAUDI_API Landau : public IRndmGen::Param {
107 friend class Generator<Landau>;
108
109 protected:
111 double m_mean, m_sigma;
112
113 public:
115 Landau( double m, double s ) : IRndmGen::Param( IID_IRndmLandau ), m_mean( m ), m_sigma( s ) {}
117 double mean() const { return m_mean; }
119 double sigma() const { return m_sigma; }
121 static const InterfaceID& typeID() { return IID_IRndmLandau; }
123 Landau* clone() const override { return new Landau( m_mean, m_sigma ); }
124 };
125
129 class GAUDI_API BreitWignerCutOff : public IRndmGen::Param {
130 friend class Generator<BreitWignerCutOff>;
131
132 protected:
134 double m_mean, m_gamma, m_cut;
135
136 public:
138 BreitWignerCutOff( double m, double g, double c )
139 : IRndmGen::Param( IID_IRndmBreitWignerCutOff ), m_mean( m ), m_gamma( g ), m_cut( c ) {}
141 double mean() const { return m_mean; }
143 double gamma() const { return m_gamma; }
145 double cutOff() const { return m_cut; }
147 static const InterfaceID& typeID() { return IID_IRndmBreitWignerCutOff; }
149 BreitWignerCutOff* clone() const override { return new BreitWignerCutOff( m_mean, m_gamma, m_cut ); }
150 };
151
154 class GAUDI_API StudentT : public IRndmGen::Param {
155 friend class Generator<StudentT>;
156
157 protected:
159 double m_aValue;
160
161 public:
163 StudentT( double a ) : IRndmGen::Param( IID_IRndmStudentT ), m_aValue( a ) {}
165 double aValue() const { return m_aValue; }
167 static const InterfaceID& typeID() { return IID_IRndmStudentT; }
169 StudentT* clone() const override { return new StudentT( m_aValue ); }
170 };
171
174 class GAUDI_API Gamma : public IRndmGen::Param {
175 friend class Generator<Gamma>;
176
177 protected:
179 double m_kValue;
181 double m_lambda;
182
183 public:
185 Gamma( double k, double l ) : IRndmGen::Param( IID_IRndmGamma ), m_kValue( k ), m_lambda( l ) {}
187 double kValue() const { return m_kValue; }
189 double lambda() const { return m_lambda; }
191 static const InterfaceID& typeID() { return IID_IRndmGamma; }
193 Gamma* clone() const override { return new Gamma( m_kValue, m_lambda ); }
194 };
195
199 class GAUDI_API Poisson : public IRndmGen::Param {
200 friend class Generator<Poisson>;
201
202 protected:
204 double m_mean;
205
206 public:
208 Poisson( double m ) : IRndmGen::Param( IID_IRndmPoisson ), m_mean( m ) {}
210 double mean() const { return m_mean; }
212 static const InterfaceID& typeID() { return IID_IRndmPoisson; }
214 Poisson* clone() const override { return new Poisson( m_mean ); }
215 };
216
220 class GAUDI_API Binomial : public IRndmGen::Param {
221 protected:
223 long m_nEvent;
225 double m_probability;
226
227 public:
229 Binomial( long n, double p ) : IRndmGen::Param( IID_IRndmBinomial ), m_nEvent( n ), m_probability( p ) {}
231 long nEvent() const { return m_nEvent; }
233 double probability() const { return m_probability; }
235 static const InterfaceID& typeID() { return IID_IRndmBinomial; }
237 Binomial* clone() const override { return new Binomial( m_nEvent, m_probability ); }
238 };
239
243 class GAUDI_API Flat : public IRndmGen::Param {
244 protected:
246 double m_minimum;
248 double m_maximum;
249
250 public:
252 Flat( double mi, double ma ) : IRndmGen::Param( IID_IRndmFlat ), m_minimum( mi ), m_maximum( ma ) {}
254 double minimum() const { return m_minimum; }
256 double maximum() const { return m_maximum; }
258 static const InterfaceID& typeID() { return IID_IRndmFlat; }
260 Flat* clone() const override { return new Flat( m_minimum, m_maximum ); }
261 };
262
265 class GAUDI_API Bit : public IRndmGen::Param {
266 public:
268 Bit() : IRndmGen::Param( IID_IRndmBit ) {}
270 static const InterfaceID& typeID() { return IID_IRndmBit; }
272 Bit* clone() const override { return new Bit(); }
273 };
274
291 class GAUDI_API DefinedPdf : public IRndmGen::Param {
292 protected:
294 std::vector<double> m_pdf;
296 long m_interpolation;
297
298 public:
300 DefinedPdf( const std::vector<double>& pdf, long intpol )
301 : IRndmGen::Param( IID_IRndmDefinedPdf ), m_pdf( pdf ), m_interpolation( intpol ) {}
303 std::vector<double>& pdf() { return m_pdf; }
305 long interpolation() const { return m_interpolation; }
307 static const InterfaceID& typeID() { return IID_IRndmDefinedPdf; }
309 DefinedPdf* clone() const override { return new DefinedPdf( m_pdf, m_interpolation ); }
310 };
311
314 class GAUDI_API GaussianTail : public IRndmGen::Param {
315 protected:
317 double m_cut;
319 double m_sigma;
320
321 public:
323 GaussianTail( double a, double s ) : IRndmGen::Param( IID_IRndmGaussianTail ), m_cut( a ), m_sigma( s ) {}
325 double cut() const { return m_cut; }
327 double sigma() const { return m_sigma; }
329 static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
331 GaussianTail* clone() const override { return new GaussianTail( m_cut, m_sigma ); }
332 };
333
349 class GAUDI_API Numbers {
350 protected:
352 SmartIF<IRndmGen> m_generator;
353
354 public:
356 Numbers() = default;
358 Numbers( const Numbers& ) = default;
360 Numbers( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par );
362 virtual ~Numbers();
364 virtual StatusCode initialize( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par );
365 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
366 Numbers( IRndmGenSvc* svc, const IRndmGen::Param& par );
369 virtual StatusCode initialize( IRndmGenSvc* svc, const IRndmGen::Param& par );
370 #endif
371 virtual StatusCode finalize();
374 operator bool() const { return m_generator; }
376 double operator()() { return this->shoot(); }
378 double pop() { return this->shoot(); }
380 double shoot() { return m_generator ? m_generator->shoot() : -1; }
382 StatusCode shootArray( std::vector<double>& array, long num, long start = 0 ) {
383 return m_generator ? m_generator->shootArray( array, num, start ) : StatusCode::FAILURE;
384 }
385 };
386 } // namespace Rndm
387 #endif // GAUDIKERNEL_RNDMGENGENERATORS_H
Rndm::GaussianTail::cut
double cut() const
Access cut value of the distribution.
Definition: RndmGenerators.h:325
Rndm::Gamma::lambda
double lambda() const
Access Lambda parameter.
Definition: RndmGenerators.h:189
SmartIF< IRndmGen >
Rndm::Chi2::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:77
Rndm::Bit
Parameters for the bit value generation: returns values 0 and 1.
Definition: RndmGenerators.h:265
Rndm::BreitWignerCutOff::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:141
Rndm::BreitWignerCutOff::m_mean
double m_mean
Mean, Gamma and cut off parameter of the Breit-Wigner distribution.
Definition: RndmGenerators.h:134
gaudirun.c
c
Definition: gaudirun.py:487
Rndm::Exponential::clone
Exponential * clone() const override
Clone parameters.
Definition: RndmGenerators.h:59
Rndm::Landau::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:121
Rndm::GaussianTail::GaussianTail
GaussianTail(double a, double s)
Standard Constructor.
Definition: RndmGenerators.h:323
Rndm::Gamma::m_kValue
double m_kValue
k Value
Definition: RndmGenerators.h:179
Rndm::Gamma::kValue
double kValue() const
Access K parameter.
Definition: RndmGenerators.h:187
Rndm::Flat::m_minimum
double m_minimum
Lower boundary for random numbers.
Definition: RndmGenerators.h:246
Rndm::BreitWignerCutOff::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:147
Rndm::Poisson
Parameters for the Poisson distributed random number generation with a given mean.
Definition: RndmGenerators.h:199
Rndm
Definition: RndmGenerators.h:15
IRndmGen
Definition of a interface for a generic random number generators.
Definition: IRndmGen.h:34
Rndm::Exponential::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:55
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:352
Rndm::Binomial::m_probability
double m_probability
And the probability for having success.
Definition: RndmGenerators.h:225
Rndm::Flat::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:258
IRndmGen.h
Rndm::Numbers::operator()
double operator()()
Operator () for the use within STL.
Definition: RndmGenerators.h:376
Rndm::GaussianTail::m_sigma
double m_sigma
Sigma of the Gauss ditribution.
Definition: RndmGenerators.h:319
Rndm::BreitWigner::clone
BreitWigner * clone() const override
Clone parameters.
Definition: RndmGenerators.h:101
Rndm::StudentT::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:167
Rndm::GaussianTail::clone
GaussianTail * clone() const override
Clone parameters.
Definition: RndmGenerators.h:331
Rndm::Gauss
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:22
Rndm::Gauss::Gauss
Gauss(double m, double s)
Standard Constructor.
Definition: RndmGenerators.h:33
Rndm::BreitWignerCutOff::cutOff
double cutOff() const
Access width of the distribution.
Definition: RndmGenerators.h:145
Rndm::Landau::clone
Landau * clone() const override
Clone parameters.
Definition: RndmGenerators.h:123
Rndm::Flat::Flat
Flat(double mi, double ma)
Standard Constructor.
Definition: RndmGenerators.h:252
IOTest.start
def start
Definition: IOTest.py:97
Rndm::Numbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: RndmGenerators.h:380
Rndm::Binomial::m_nEvent
long m_nEvent
Number of events the binomial destribution corresponds to.
Definition: RndmGenerators.h:223
Rndm::Exponential::m_mean
double m_mean
Mean value of the exponential distribution.
Definition: RndmGenerators.h:49
Rndm::Gauss::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:35
Rndm::BreitWigner::BreitWigner
BreitWigner(double m, double g)
Standard Constructor.
Definition: RndmGenerators.h:93
Rndm::Binomial::probability
double probability() const
Access number of events.
Definition: RndmGenerators.h:233
Rndm::Landau::Landau
Landau(double m, double s)
Standard Constructor.
Definition: RndmGenerators.h:115
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
Rndm::Chi2::nDOF
long nDOF() const
Access mean value of the distribution.
Definition: RndmGenerators.h:75
Rndm::Poisson::m_mean
double m_mean
Mean value of the Poisson distribution.
Definition: RndmGenerators.h:204
Rndm::Numbers
Random number accessor This small class encapsulates the use of the random number generator.
Definition: RndmGenerators.h:349
InterfaceID
Interface ID class.
Definition: IInterface.h:29
Rndm::BreitWignerCutOff::gamma
double gamma() const
Access width of the distribution.
Definition: RndmGenerators.h:143
Rndm::Bit::Bit
Bit()
Standard Constructor.
Definition: RndmGenerators.h:268
Rndm::Landau::m_sigma
double m_sigma
Definition: RndmGenerators.h:111
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
Rndm::Chi2::clone
Chi2 * clone() const override
Clone parameters.
Definition: RndmGenerators.h:79
Rndm::DefinedPdf::DefinedPdf
DefinedPdf(const std::vector< double > &pdf, long intpol)
Standard Constructor.
Definition: RndmGenerators.h:300
IRndmGenSvc
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
Rndm::GaussianTail::m_cut
double m_cut
Cut on the Gaussian tail distribution.
Definition: RndmGenerators.h:317
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Rndm::BreitWigner::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:95
IRndmGen::Param
Definition: IRndmGen.h:39
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
Rndm::Flat::minimum
double minimum() const
Access lower edge.
Definition: RndmGenerators.h:254
Rndm::Gauss::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:39
Rndm::Flat
Parameters for the flat random number generation within boundaries [minimum, maximum].
Definition: RndmGenerators.h:243
Rndm::Flat::m_maximum
double m_maximum
Upper boundary for random numbers.
Definition: RndmGenerators.h:248
SmartIF.h
Rndm::DefinedPdf::m_pdf
std::vector< double > m_pdf
Vector containing probability distribution function.
Definition: RndmGenerators.h:294
Rndm::Gamma::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:191
Rndm::DefinedPdf::interpolation
long interpolation() const
Access interpolation type.
Definition: RndmGenerators.h:305
Rndm::StudentT::StudentT
StudentT(double a)
Standard Constructor.
Definition: RndmGenerators.h:163
Rndm::StudentT::clone
StudentT * clone() const override
Clone parameters.
Definition: RndmGenerators.h:169
Rndm::BreitWigner::gamma
double gamma() const
Access width of the distribution.
Definition: RndmGenerators.h:97
Rndm::BreitWigner::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:99
Rndm::Gauss::m_mean
double m_mean
Mean of the Gauss distribution.
Definition: RndmGenerators.h:27
Rndm::DefinedPdf::m_interpolation
long m_interpolation
Interpolation type.
Definition: RndmGenerators.h:296
Rndm::Binomial::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:235
Rndm::Gauss::clone
Gauss * clone() const override
Clone parameters.
Definition: RndmGenerators.h:41
Rndm::StudentT
Parameters for the StudentT distributed random number generation.
Definition: RndmGenerators.h:154
Rndm::Gamma::m_lambda
double m_lambda
Lambda parameter.
Definition: RndmGenerators.h:181
Rndm::DefinedPdf::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:307
Rndm::Flat::clone
Flat * clone() const override
Clone parameters.
Definition: RndmGenerators.h:260
gaudirun.l
dictionary l
Definition: gaudirun.py:521
Rndm::Binomial
Parameters for the Binomial distributed random number generation.
Definition: RndmGenerators.h:220
Rndm::StudentT::aValue
double aValue() const
Access A parameter.
Definition: RndmGenerators.h:165
Rndm::Numbers::shootArray
StatusCode shootArray(std::vector< double > &array, long num, long start=0)
Pop a new number from the buffer.
Definition: RndmGenerators.h:382
IRndmGen::shoot
virtual double shoot() const =0
Single shot returning single random number according to specified distribution.
Rndm::Landau
Parameters for the Landau distributed random number generation.
Definition: RndmGenerators.h:106
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:27
Rndm::Chi2
Parameters for the Chi2 distributed random number generation.
Definition: RndmGenerators.h:64
std::vector< double >
Rndm::Numbers::pop
double pop()
Pop a new number from the buffer.
Definition: RndmGenerators.h:378
Rndm::Binomial::clone
Binomial * clone() const override
Clone parameters.
Definition: RndmGenerators.h:237
Rndm::Gauss::m_sigma
double m_sigma
Sigma of the Gauss distribution.
Definition: RndmGenerators.h:29
Rndm::GaussianTail::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:329
Rndm::BreitWignerCutOff
Parameters for the BreitWigner distributed random number generation with cut off;.
Definition: RndmGenerators.h:129
Rndm::Flat::maximum
double maximum() const
Access upper edge.
Definition: RndmGenerators.h:256
IRndmGen::shootArray
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.
Rndm::Landau::sigma
double sigma() const
Access width of the distribution.
Definition: RndmGenerators.h:119
Rndm::Gamma
Parameters for the Gamma distributed random number generation.
Definition: RndmGenerators.h:174
Rndm::Gauss::sigma
double sigma() const
Access width of the distribution.
Definition: RndmGenerators.h:37
Rndm::BreitWignerCutOff::clone
BreitWignerCutOff * clone() const override
Clone parameters.
Definition: RndmGenerators.h:149
Rndm::Generator
Definition: RndmGenerators.h:18
Rndm::Binomial::nEvent
long nEvent() const
Access number of events.
Definition: RndmGenerators.h:231
Rndm::Poisson::clone
Poisson * clone() const override
Clone parameters.
Definition: RndmGenerators.h:214
gaudirun.g
dictionary g
Definition: gaudirun.py:520
gaudirun.s
string s
Definition: gaudirun.py:316
Rndm::BreitWignerCutOff::BreitWignerCutOff
BreitWignerCutOff(double m, double g, double c)
Standard Constructor.
Definition: RndmGenerators.h:138
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Rndm::Exponential::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:57
Rndm::Gamma::clone
Gamma * clone() const override
Clone parameters.
Definition: RndmGenerators.h:193
Rndm::Gamma::Gamma
Gamma(double k, double l)
Standard Constructor.
Definition: RndmGenerators.h:185
Rndm::Binomial::Binomial
Binomial(long n, double p)
Standard Constructor.
Definition: RndmGenerators.h:229
Rndm::StudentT::m_aValue
double m_aValue
StudentT distribution parameter.
Definition: RndmGenerators.h:159
Rndm::GaussianTail::sigma
double sigma() const
Access sigma of the distribution.
Definition: RndmGenerators.h:327
Rndm::Chi2::Chi2
Chi2(long n_dof)
Standard Constructor.
Definition: RndmGenerators.h:73
Rndm::Landau::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:117
Rndm::GaussianTail
Parameters for the Gaussian tail number generation.
Definition: RndmGenerators.h:314
Rndm::DefinedPdf
Generate a random number Generator following generally distributed random values, given a user-define...
Definition: RndmGenerators.h:291
Rndm::Exponential
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:46
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
Rndm::Bit::clone
Bit * clone() const override
Clone parameters.
Definition: RndmGenerators.h:272
Rndm::DefinedPdf::clone
DefinedPdf * clone() const override
Clone parameters.
Definition: RndmGenerators.h:309
Rndm::Chi2::m_nDOF
long m_nDOF
Number of degrees of freedom.
Definition: RndmGenerators.h:69
Rndm::Poisson::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:210
Rndm::BreitWigner
Parameters for the BreitWigner distributed random number generation.
Definition: RndmGenerators.h:84
Rndm::Poisson::Poisson
Poisson(double m)
Standard Constructor.
Definition: RndmGenerators.h:208
Rndm::Bit::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:270
Rndm::BreitWigner::m_mean
double m_mean
Mean and Gamma parameter of the Breit-Wigner distribution.
Definition: RndmGenerators.h:89
Rndm::Exponential::Exponential
Exponential(double m)
Standard Constructor.
Definition: RndmGenerators.h:53
Rndm::DefinedPdf::pdf
std::vector< double > & pdf()
Access pdf.
Definition: RndmGenerators.h:303
Rndm::Poisson::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:212