| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
21 class GAUDI_API Gauss: public IRndmGen::Param {
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
47 class GAUDI_API Exponential: public IRndmGen::Param {
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
87 class GAUDI_API BreitWigner : public IRndmGen::Param {
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
110 class GAUDI_API Landau : public IRndmGen::Param {
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
134 class GAUDI_API BreitWignerCutOff : public IRndmGen::Param {
135 friend class Generator<BreitWignerCutOff>;
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
162 class GAUDI_API StudentT: public IRndmGen::Param {
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
182 class GAUDI_API Gamma: public IRndmGen::Param {
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
208 class GAUDI_API Poisson: public IRndmGen::Param {
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
229 class GAUDI_API Binomial: public IRndmGen::Param {
230 protected:
232 long m_nEvent;
234 double m_probability;
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
254 class GAUDI_API Flat: public IRndmGen::Param {
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
306 class GAUDI_API DefinedPdf: public IRndmGen::Param {
307 protected:
309 std::vector<double> m_pdf;
311 long m_interpolation;
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
332 class GAUDI_API GaussianTail: public IRndmGen::Param {
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
370 class GAUDI_API Numbers {
371 protected:
373 SmartIF<IRndmGen> m_generator;
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 }
411 StatusCode shootArray(std::vector<double>& array, long num, long start=0) {
412 return m_generator ? m_generator->shootArray(array, num, start)
413 : StatusCode::FAILURE;
414 }
415 };
416 }
417 #endif // GAUDIKERNEL_RNDMGENGENERATORS_H
Rndm::Binomial::clone
Binomial * clone() const override
Clone parameters.
Definition: RndmGenerators.h:248
Rndm::Gamma::clone
Gamma * clone() const override
Clone parameters.
Definition: RndmGenerators.h:202
Rndm::StudentT::clone
StudentT * clone() const override
Clone parameters.
Definition: RndmGenerators.h:177
IRndmGen::shoot
virtual double shoot() const =0
Single shot returning single random number according to specified distribution.
Rndm::Chi2::nDOF
long nDOF() const
Access mean value of the distribution.
Definition: RndmGenerators.h:78
SmartIF< IRndmGen >
Rndm::Chi2::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:80
Rndm::Bit
Parameters for the bit value generation: returns values 0 and 1.
Definition: RndmGenerators.h:278
Rndm::BreitWignerCutOff::m_mean
double m_mean
Mean, Gamma and cut off parameter of the Breit-Wigner distribution.
Definition: RndmGenerators.h:138
gaudirun.c
c
Definition: gaudirun.py:391
StatusCode::FAILURE
Definition: StatusCode.h:29
Rndm::Landau::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:126
Rndm::GaussianTail::GaussianTail
GaussianTail(double a, double s)
Standard Constructor.
Definition: RndmGenerators.h:340
Rndm::Gamma::m_kValue
double m_kValue
k Value
Definition: RndmGenerators.h:186
Rndm::Flat::m_minimum
double m_minimum
Lower boundary for random numbers.
Definition: RndmGenerators.h:257
Rndm::BreitWignerCutOff::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:155
Rndm::Gauss::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:36
Rndm::Poisson
Parameters for the Poisson distributed random number generation with a given mean.
Definition: RndmGenerators.h:208
Rndm
Definition: RndmGenerators.h:15
Rndm::Exponential::clone
Exponential * clone() const override
Clone parameters.
Definition: RndmGenerators.h:62
Rndm::Poisson::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:219
IRndmGen
Definition of a interface for a generic random number generators.
Definition: IRndmGen.h:35
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:373
Rndm::Binomial::m_probability
double m_probability
And the probability for having success.
Definition: RndmGenerators.h:234
Rndm::Flat::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:271
IRndmGen.h
Rndm::GaussianTail::m_sigma
double m_sigma
Sigma of the Gauss ditribution.
Definition: RndmGenerators.h:337
Rndm::StudentT::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:175
Rndm::Gauss
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:21
Rndm::Gauss::Gauss
Gauss(double m, double s)
Standard Constructor.
Definition: RndmGenerators.h:31
Rndm::Bit::clone
Bit * clone() const override
Clone parameters.
Definition: RndmGenerators.h:287
Rndm::Flat::Flat
Flat(double mi, double ma)
Standard Constructor.
Definition: RndmGenerators.h:262
Rndm::Exponential::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:58
Rndm::Numbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: RndmGenerators.h:406
Rndm::Gamma::lambda
double lambda() const
Access Lambda parameter.
Definition: RndmGenerators.h:198
Rndm::Binomial::m_nEvent
long m_nEvent
Number of events the binomial destribution corresponds to.
Definition: RndmGenerators.h:232
Rndm::Exponential::m_mean
double m_mean
Mean value of the exponential distribution.
Definition: RndmGenerators.h:50
Rndm::BreitWigner::BreitWigner
BreitWigner(double m, double g)
Standard Constructor.
Definition: RndmGenerators.h:94
Rndm::Binomial::nEvent
long nEvent() const
Access number of events.
Definition: RndmGenerators.h:242
Rndm::DefinedPdf::interpolation
long interpolation() const
Access interpolation type.
Definition: RndmGenerators.h:323
Rndm::Landau::Landau
Landau(double m, double s)
Standard Constructor.
Definition: RndmGenerators.h:117
Rndm::Flat::clone
Flat * clone() const override
Clone parameters.
Definition: RndmGenerators.h:273
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
Rndm::Poisson::m_mean
double m_mean
Mean value of the Poisson distribution.
Definition: RndmGenerators.h:212
Rndm::Numbers
Random number accessor This small class encapsulates the use of the random number generator...
Definition: RndmGenerators.h:370
InterfaceID
Interface ID class.
Definition: IInterface.h:30
Rndm::Bit::Bit
Bit()
Standard Constructor.
Definition: RndmGenerators.h:281
Rndm::Binomial::probability
double probability() const
Access number of events.
Definition: RndmGenerators.h:244
Rndm::Landau::m_sigma
double m_sigma
Definition: RndmGenerators.h:114
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:386
Rndm::Poisson::clone
Poisson * clone() const override
Clone parameters.
Definition: RndmGenerators.h:223
Rndm::DefinedPdf::DefinedPdf
DefinedPdf(const std::vector< double > &pdf, long intpol)
Standard Constructor.
Definition: RndmGenerators.h:314
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:335
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IRndmGen::Param
Definition: IRndmGen.h:40
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
Rndm::Gauss::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:40
Rndm::Flat
Parameters for the flat random number generation within boundaries [minimum, maximum].
Definition: RndmGenerators.h:254
Rndm::Flat::m_maximum
double m_maximum
Upper boundary for random numbers.
Definition: RndmGenerators.h:259
SmartIF.h
Rndm::DefinedPdf::m_pdf
std::vector< double > m_pdf
Vector containing probability distribution function.
Definition: RndmGenerators.h:309
Rndm::Gamma::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:200
Rndm::StudentT::StudentT
StudentT(double a)
Standard Constructor.
Definition: RndmGenerators.h:169
Rndm::BreitWignerCutOff::cutOff
double cutOff() const
Access width of the distribution.
Definition: RndmGenerators.h:153
IOTest.start
start
Definition: IOTest.py:88
Rndm::BreitWigner::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:103
Rndm::Gauss::m_mean
double m_mean
Mean of the Gauss distribution.
Definition: RndmGenerators.h:26
Rndm::DefinedPdf::m_interpolation
long m_interpolation
Interpolation type.
Definition: RndmGenerators.h:311
Rndm::Binomial::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:246
Rndm::Flat::maximum
double maximum() const
Access upper edge.
Definition: RndmGenerators.h:269
Rndm::StudentT
Parameters for the StudentT distributed random number generation.
Definition: RndmGenerators.h:162
Rndm::Gamma::m_lambda
double m_lambda
Lambda parameter.
Definition: RndmGenerators.h:188
Rndm::DefinedPdf::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:325
gaudirun.l
dictionary l
Definition: gaudirun.py:421
Rndm::Binomial
Parameters for the Binomial distributed random number generation.
Definition: RndmGenerators.h:229
Rndm::Numbers::shootArray
StatusCode shootArray(std::vector< double > &array, long num, long start=0)
Pop a new number from the buffer.
Definition: RndmGenerators.h:411
Rndm::Gamma::kValue
double kValue() const
Access K parameter.
Definition: RndmGenerators.h:196
Rndm::Landau::sigma
double sigma() const
Access width of the distribution.
Definition: RndmGenerators.h:124
Rndm::Landau
Parameters for the Landau distributed random number generation.
Definition: RndmGenerators.h:110
Rndm::BreitWigner::clone
BreitWigner * clone() const override
Clone parameters.
Definition: RndmGenerators.h:105
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:67
std::vector< double >
Rndm::Numbers::pop
double pop()
Pop a new number from the buffer.
Definition: RndmGenerators.h:402
Rndm::Gauss::m_sigma
double m_sigma
Sigma of the Gauss distribution.
Definition: RndmGenerators.h:28
Rndm::Landau::clone
Landau * clone() const override
Clone parameters.
Definition: RndmGenerators.h:128
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Rndm::GaussianTail::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:349
Rndm::BreitWignerCutOff
Parameters for the BreitWigner distributed random number generation with cut off;.
Definition: RndmGenerators.h:134
Rndm::Gauss::sigma
double sigma() const
Access width of the distribution.
Definition: RndmGenerators.h:38
Rndm::Landau::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:122
Rndm::Gamma
Parameters for the Gamma distributed random number generation.
Definition: RndmGenerators.h:182
Rndm::Generator
Definition: RndmGenerators.h:17
gaudirun.g
dictionary g
Definition: gaudirun.py:420
gaudirun.s
string s
Definition: gaudirun.py:245
Rndm::BreitWignerCutOff::BreitWignerCutOff
BreitWignerCutOff(double m, double g, double c)
Standard Constructor.
Definition: RndmGenerators.h:141
Rndm::Exponential::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:60
Rndm::Gamma::Gamma
Gamma(double k, double l)
Standard Constructor.
Definition: RndmGenerators.h:191
Rndm::BreitWignerCutOff::clone
BreitWignerCutOff * clone() const override
Clone parameters.
Definition: RndmGenerators.h:157
Rndm::BreitWignerCutOff::gamma
double gamma() const
Access width of the distribution.
Definition: RndmGenerators.h:151
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::Binomial::Binomial
Binomial(long n, double p)
Standard Constructor.
Definition: RndmGenerators.h:237
Rndm::StudentT::m_aValue
double m_aValue
StudentT distribution parameter.
Definition: RndmGenerators.h:166
Rndm::Gauss::clone
Gauss * clone() const override
Clone parameters.
Definition: RndmGenerators.h:42
Rndm::Chi2::Chi2
Chi2(long n_dof)
Standard Constructor.
Definition: RndmGenerators.h:74
Rndm::StudentT::aValue
double aValue() const
Access A parameter.
Definition: RndmGenerators.h:173
Rndm::GaussianTail::cut
double cut() const
Access cut value of the distribution.
Definition: RndmGenerators.h:345
Rndm::BreitWignerCutOff::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:149
Rndm::GaussianTail
Parameters for the Gaussian tail number generation.
Definition: RndmGenerators.h:332
Rndm::DefinedPdf
Generate a random number Generator following generally distributed random values, given a user-define...
Definition: RndmGenerators.h:306
Rndm::Exponential
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:47
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
Rndm::Chi2::clone
Chi2 * clone() const override
Clone parameters.
Definition: RndmGenerators.h:82
Rndm::Flat::minimum
double minimum() const
Access lower edge.
Definition: RndmGenerators.h:267
Rndm::DefinedPdf::clone
DefinedPdf * clone() const override
Clone parameters.
Definition: RndmGenerators.h:327
Rndm::Chi2::m_nDOF
long m_nDOF
Number of degrees of freedom.
Definition: RndmGenerators.h:71
Rndm::BreitWigner::mean
double mean() const
Access mean value of the distribution.
Definition: RndmGenerators.h:99
Rndm::BreitWigner
Parameters for the BreitWigner distributed random number generation.
Definition: RndmGenerators.h:87
Rndm::Poisson::Poisson
Poisson(double m)
Standard Constructor.
Definition: RndmGenerators.h:215
Rndm::Bit::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:285
Rndm::BreitWigner::gamma
double gamma() const
Access width of the distribution.
Definition: RndmGenerators.h:101
Rndm::BreitWigner::m_mean
double m_mean
Mean and Gamma parameter of the Breit-Wigner distribution.
Definition: RndmGenerators.h:91
Rndm::GaussianTail::clone
GaussianTail * clone() const override
Clone parameters.
Definition: RndmGenerators.h:351
Rndm::GaussianTail::sigma
double sigma() const
Access sigma of the distribution.
Definition: RndmGenerators.h:347
Rndm::Exponential::Exponential
Exponential(double m)
Standard Constructor.
Definition: RndmGenerators.h:53
Rndm::DefinedPdf::pdf
std::vector< double > & pdf()
Access pdf.
Definition: RndmGenerators.h:321
Rndm::Poisson::typeID
static const InterfaceID & typeID()
Identifier for factory.
Definition: RndmGenerators.h:221