| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RndmGenerators.h
Go to the documentation of this file.
1 // $Id: RndmGenerators.h,v 1.8 2005/07/21 14:35:31 hmd Exp $
2 #ifndef GAUDIKERNEL_RNDMGENGENERATORS_H
3 #define GAUDIKERNEL_RNDMGENGENERATORS_H
4
5 // STL include files
6 #include <vector>
7
8 // Framework include files
9 #include "GaudiKernel/IRndmGen.h"
10 #include "GaudiKernel/SmartIF.h"
11
12 // Forward declarations
13 class IRndmGen;
14 class IRndmGenSvc;
15
16 namespace Rndm {
17
18 template <class TYPE> 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 public:
32 Gauss(double m, double s)
33 : IRndmGen::Param(IID_IRndmGauss), m_mean(m), m_sigma(s) { }
35 virtual ~Gauss() { }
37 double mean() const { return m_mean; }
39 double sigma() const { return m_sigma; }
41 static const InterfaceID& typeID() { return IID_IRndmGauss; }
43 virtual IRndmGen::Param* clone() const {
44 return new Gauss(m_mean, m_sigma);
45 }
46 };
47
50 class GAUDI_API Exponential: public IRndmGen::Param {
51 protected:
53 double m_mean;
54 public:
56 Exponential(double m)
57 : IRndmGen::Param(IID_IRndmExponential), m_mean(m) { }
59 virtual ~Exponential() { }
61 double mean() const { return m_mean; }
63 static const InterfaceID& typeID() { return IID_IRndmExponential; }
65 virtual IRndmGen::Param* clone() const { return new Exponential(m_mean); }
66 };
67
70 class GAUDI_API Chi2: public IRndmGen::Param {
71 friend class Generator<Chi2>;
72 protected:
74 long m_nDOF;
75 public:
77 Chi2(long n_dof) : IRndmGen::Param(IID_IRndmChi2), m_nDOF(n_dof) { }
79 virtual ~Chi2() { }
81 long nDOF() const { return m_nDOF; }
83 static const InterfaceID& typeID() { return IID_IRndmChi2; }
85 virtual IRndmGen::Param* clone() const { return new Chi2(m_nDOF); }
86 };
87
90 class GAUDI_API BreitWigner : public IRndmGen::Param {
91 friend class Generator<BreitWigner>;
92 protected:
94 double m_mean, m_gamma;
95 public:
97 BreitWigner(double m, double g)
98 : IRndmGen::Param(IID_IRndmBreitWigner), m_mean(m), m_gamma(g) { }
100 virtual ~BreitWigner() { }
102 double mean() const { return m_mean; }
104 double gamma() const { return m_gamma; }
106 static const InterfaceID& typeID() { return IID_IRndmBreitWigner; }
108 virtual IRndmGen::Param* clone() const {
109 return new BreitWigner(m_mean, m_gamma);
110 }
111 };
112
115 class GAUDI_API Landau : public IRndmGen::Param {
116 friend class Generator<Landau>;
117 protected:
119 double m_mean, m_sigma;
120 public:
122 Landau(double m, double s)
123 : IRndmGen::Param(IID_IRndmLandau), m_mean(m), m_sigma(s) { }
125 virtual ~Landau() { }
127 double mean() const { return m_mean; }
129 double sigma() const { return m_sigma; }
131 static const InterfaceID& typeID() { return IID_IRndmLandau; }
133 virtual IRndmGen::Param* clone() const {
134 return new Landau(m_mean, m_sigma);
135 }
136 };
137
141 class GAUDI_API BreitWignerCutOff : public IRndmGen::Param {
142 friend class Generator<BreitWignerCutOff>;
143 protected:
145 double m_mean, m_gamma, m_cut;
146 public:
148 BreitWignerCutOff(double m, double g, double c)
149 : IRndmGen::Param(IID_IRndmBreitWignerCutOff),
150 m_mean(m),
151 m_gamma(g),
152 m_cut(c) { }
154 virtual ~BreitWignerCutOff() { }
156 double mean() const { return m_mean; }
158 double gamma() const { return m_gamma; }
160 double cutOff() const { return m_cut; }
162 static const InterfaceID& typeID() { return IID_IRndmBreitWignerCutOff;}
164 virtual IRndmGen::Param* clone() const {
165 return new BreitWignerCutOff(m_mean, m_gamma, m_cut);
166 }
167 };
168
171 class GAUDI_API StudentT: public IRndmGen::Param {
172 friend class Generator<StudentT>;
173 protected:
175 double m_aValue;
176 public:
178 StudentT(double a) : IRndmGen::Param(IID_IRndmStudentT), m_aValue(a) { }
180 virtual ~StudentT() { }
182 double aValue() const { return m_aValue; }
184 static const InterfaceID& typeID() { return IID_IRndmStudentT; }
186 virtual IRndmGen::Param* clone() const { return new StudentT(m_aValue);}
187 };
188
191 class GAUDI_API Gamma: public IRndmGen::Param {
192 friend class Generator<Gamma>;
193 protected:
195 double m_kValue;
197 double m_lambda;
198 public:
200 Gamma(double k, double l)
201 : IRndmGen::Param(IID_IRndmGamma), m_kValue(k), m_lambda(l) { }
203 virtual ~Gamma() { }
205 double kValue() const { return m_kValue; }
207 double lambda() const { return m_lambda; }
209 static const InterfaceID& typeID() { return IID_IRndmGamma; }
211 virtual IRndmGen::Param* clone() const {
212 return new Gamma(m_kValue, m_lambda);
213 }
214 };
215
219 class GAUDI_API Poisson: public IRndmGen::Param {
220 friend class Generator<Poisson>;
221 protected:
223 double m_mean;
224 public:
226 Poisson(double m) : IRndmGen::Param(IID_IRndmPoisson), m_mean(m) { }
228 virtual ~Poisson() { }
230 double mean() const { return m_mean; }
232 static const InterfaceID& typeID() { return IID_IRndmPoisson; }
234 virtual IRndmGen::Param* clone() const { return new Poisson(m_mean); }
235 };
236
240 class GAUDI_API Binomial: public IRndmGen::Param {
241 protected:
243 long m_nEvent;
245 double m_probability;
246 public:
248 Binomial(long n, double p)
249 : IRndmGen::Param(IID_IRndmBinomial), m_nEvent(n), m_probability(p) { }
251 virtual ~Binomial() { }
253 long nEvent() const { return m_nEvent; }
255 double probability() const { return m_probability; }
257 static const InterfaceID& typeID() { return IID_IRndmBinomial; }
259 virtual IRndmGen::Param* clone() const {
260 return new Binomial(m_nEvent, m_probability);
261 }
262 };
263
267 class GAUDI_API Flat: public IRndmGen::Param {
268 protected:
270 double m_minimum;
272 double m_maximum;
273 public:
275 Flat(double mi, double ma)
276 : IRndmGen::Param(IID_IRndmFlat), m_minimum(mi), m_maximum(ma) { }
278 virtual ~Flat() { }
280 double minimum() const { return m_minimum; }
282 double maximum() const { return m_maximum; }
284 static const InterfaceID& typeID() { return IID_IRndmFlat; }
286 virtual IRndmGen::Param* clone() const {
287 return new Flat(m_minimum, m_maximum);
288 }
289 };
290
293 class GAUDI_API Bit: public IRndmGen::Param {
294 public:
296 Bit() : IRndmGen::Param(IID_IRndmBit) { }
298 virtual ~Bit() { }
300 static const InterfaceID& typeID() { return IID_IRndmBit; }
302 virtual IRndmGen::Param* clone() const { return new Bit(); }
303 };
304
321 class GAUDI_API DefinedPdf: public IRndmGen::Param {
322 protected:
324 std::vector<double> m_pdf;
326 long m_interpolation;
327 public:
329 DefinedPdf(const std::vector<double>& pdf, long intpol)
330 : IRndmGen::Param(IID_IRndmDefinedPdf),
331 m_pdf(pdf),
332 m_interpolation(intpol) { }
334 virtual ~DefinedPdf() { }
336 std::vector<double>& pdf() { return m_pdf; }
338 long interpolation() const { return m_interpolation; }
340 static const InterfaceID& typeID() { return IID_IRndmDefinedPdf; }
342 virtual IRndmGen::Param* clone() const {
343 return new DefinedPdf(m_pdf,m_interpolation);
344 }
345 };
346
349 class GAUDI_API GaussianTail: public IRndmGen::Param {
350 protected:
352 double m_cut;
354 double m_sigma;
355 public:
357 GaussianTail(double a, double s)
358 : IRndmGen::Param(IID_IRndmGaussianTail), m_cut(a), m_sigma(s) { }
360 virtual ~GaussianTail() { }
362 double cut() const { return m_cut; }
364 double sigma() const { return m_sigma; }
366 static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
368 virtual IRndmGen::Param* clone() const {
369 return new GaussianTail(m_cut, m_sigma);
370 }
371 };
372
373
389 class GAUDI_API Numbers {
390 protected:
392 IRndmGen* m_generator;
393 public:
395 Numbers();
397 Numbers(const Numbers& copy );
399 Numbers(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par);
401 virtual ~Numbers();
403 virtual StatusCode initialize(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par);
404 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
405
406 Numbers(IRndmGenSvc* svc, const IRndmGen::Param& par);
408 virtual StatusCode initialize(IRndmGenSvc* svc, const IRndmGen::Param& par);
409 #endif
410
411 virtual StatusCode finalize();
413 operator bool () const {
414 return m_generator != 0;
415 }
417 double operator() () {
418 return this->shoot();
419 }
421 double pop() {
422 return this->shoot();
423 }
425 double shoot() {
426 if ( 0 != m_generator ) {
427 return m_generator->shoot();
428 }
429 return -1;
430 }
432 StatusCode shootArray(std::vector<double>& array, long num, long start=0) {
433 if ( 0 != m_generator ) {
434 return m_generator->shootArray(array, num, start);
435 }
436 return StatusCode::FAILURE;
437 }
438 };
439 }
440 #endif // GAUDIKERNEL_RNDMGENGENERATORS_H