File indexing completed on 2024-11-15 09:38:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_RNDMGENGENERATORS_H
0012 #define GAUDIKERNEL_RNDMGENGENERATORS_H
0013
0014
0015 #include <vector>
0016
0017
0018 #include "GaudiKernel/IRndmGen.h"
0019 #include "GaudiKernel/SmartIF.h"
0020
0021
0022 class IRndmGen;
0023 class IRndmGenSvc;
0024
0025 namespace Rndm {
0026
0027 template <class TYPE>
0028 class Generator;
0029
0030
0031
0032 class GAUDI_API Gauss : public IRndmGen::Param {
0033 protected:
0034
0035 friend class Generator<Gauss>;
0036
0037 double m_mean;
0038
0039 double m_sigma;
0040
0041 public:
0042
0043 Gauss( double m, double s ) : IRndmGen::Param( IID_IRndmGauss ), m_mean( m ), m_sigma( s ) {}
0044
0045 double mean() const { return m_mean; }
0046
0047 double sigma() const { return m_sigma; }
0048
0049 static const InterfaceID& typeID() { return IID_IRndmGauss; }
0050
0051 Gauss* clone() const override { return new Gauss( m_mean, m_sigma ); }
0052 };
0053
0054
0055
0056 class GAUDI_API Exponential : public IRndmGen::Param {
0057 protected:
0058
0059 double m_mean;
0060
0061 public:
0062
0063 Exponential( double m ) : IRndmGen::Param( IID_IRndmExponential ), m_mean( m ) {}
0064
0065 double mean() const { return m_mean; }
0066
0067 static const InterfaceID& typeID() { return IID_IRndmExponential; }
0068
0069 Exponential* clone() const override { return new Exponential( m_mean ); }
0070 };
0071
0072
0073
0074 class GAUDI_API Chi2 : public IRndmGen::Param {
0075 friend class Generator<Chi2>;
0076
0077 protected:
0078
0079 long m_nDOF;
0080
0081 public:
0082
0083 Chi2( long n_dof ) : IRndmGen::Param( IID_IRndmChi2 ), m_nDOF( n_dof ) {}
0084
0085 long nDOF() const { return m_nDOF; }
0086
0087 static const InterfaceID& typeID() { return IID_IRndmChi2; }
0088
0089 Chi2* clone() const override { return new Chi2( m_nDOF ); }
0090 };
0091
0092
0093
0094 class GAUDI_API BreitWigner : public IRndmGen::Param {
0095 friend class Generator<BreitWigner>;
0096
0097 protected:
0098
0099 double m_mean, m_gamma;
0100
0101 public:
0102
0103 BreitWigner( double m, double g ) : IRndmGen::Param( IID_IRndmBreitWigner ), m_mean( m ), m_gamma( g ) {}
0104
0105 double mean() const { return m_mean; }
0106
0107 double gamma() const { return m_gamma; }
0108
0109 static const InterfaceID& typeID() { return IID_IRndmBreitWigner; }
0110
0111 BreitWigner* clone() const override { return new BreitWigner( m_mean, m_gamma ); }
0112 };
0113
0114
0115
0116 class GAUDI_API Landau : public IRndmGen::Param {
0117 friend class Generator<Landau>;
0118
0119 protected:
0120
0121 double m_mean, m_sigma;
0122
0123 public:
0124
0125 Landau( double m, double s ) : IRndmGen::Param( IID_IRndmLandau ), m_mean( m ), m_sigma( s ) {}
0126
0127 double mean() const { return m_mean; }
0128
0129 double sigma() const { return m_sigma; }
0130
0131 static const InterfaceID& typeID() { return IID_IRndmLandau; }
0132
0133 Landau* clone() const override { return new Landau( m_mean, m_sigma ); }
0134 };
0135
0136
0137
0138
0139 class GAUDI_API BreitWignerCutOff : public IRndmGen::Param {
0140 friend class Generator<BreitWignerCutOff>;
0141
0142 protected:
0143
0144 double m_mean, m_gamma, m_cut;
0145
0146 public:
0147
0148 BreitWignerCutOff( double m, double g, double c )
0149 : IRndmGen::Param( IID_IRndmBreitWignerCutOff ), m_mean( m ), m_gamma( g ), m_cut( c ) {}
0150
0151 double mean() const { return m_mean; }
0152
0153 double gamma() const { return m_gamma; }
0154
0155 double cutOff() const { return m_cut; }
0156
0157 static const InterfaceID& typeID() { return IID_IRndmBreitWignerCutOff; }
0158
0159 BreitWignerCutOff* clone() const override { return new BreitWignerCutOff( m_mean, m_gamma, m_cut ); }
0160 };
0161
0162
0163
0164 class GAUDI_API StudentT : public IRndmGen::Param {
0165 friend class Generator<StudentT>;
0166
0167 protected:
0168
0169 double m_aValue;
0170
0171 public:
0172
0173 StudentT( double a ) : IRndmGen::Param( IID_IRndmStudentT ), m_aValue( a ) {}
0174
0175 double aValue() const { return m_aValue; }
0176
0177 static const InterfaceID& typeID() { return IID_IRndmStudentT; }
0178
0179 StudentT* clone() const override { return new StudentT( m_aValue ); }
0180 };
0181
0182
0183
0184 class GAUDI_API Gamma : public IRndmGen::Param {
0185 friend class Generator<Gamma>;
0186
0187 protected:
0188
0189 double m_kValue;
0190
0191 double m_lambda;
0192
0193 public:
0194
0195 Gamma( double k, double l ) : IRndmGen::Param( IID_IRndmGamma ), m_kValue( k ), m_lambda( l ) {}
0196
0197 double kValue() const { return m_kValue; }
0198
0199 double lambda() const { return m_lambda; }
0200
0201 static const InterfaceID& typeID() { return IID_IRndmGamma; }
0202
0203 Gamma* clone() const override { return new Gamma( m_kValue, m_lambda ); }
0204 };
0205
0206
0207
0208
0209 class GAUDI_API Poisson : public IRndmGen::Param {
0210 friend class Generator<Poisson>;
0211
0212 protected:
0213
0214 double m_mean;
0215
0216 public:
0217
0218 Poisson( double m ) : IRndmGen::Param( IID_IRndmPoisson ), m_mean( m ) {}
0219
0220 double mean() const { return m_mean; }
0221
0222 static const InterfaceID& typeID() { return IID_IRndmPoisson; }
0223
0224 Poisson* clone() const override { return new Poisson( m_mean ); }
0225 };
0226
0227
0228
0229
0230 class GAUDI_API Binomial : public IRndmGen::Param {
0231 protected:
0232
0233 long m_nEvent;
0234
0235 double m_probability;
0236
0237 public:
0238
0239 Binomial( long n, double p ) : IRndmGen::Param( IID_IRndmBinomial ), m_nEvent( n ), m_probability( p ) {}
0240
0241 long nEvent() const { return m_nEvent; }
0242
0243 double probability() const { return m_probability; }
0244
0245 static const InterfaceID& typeID() { return IID_IRndmBinomial; }
0246
0247 Binomial* clone() const override { return new Binomial( m_nEvent, m_probability ); }
0248 };
0249
0250
0251
0252
0253 class GAUDI_API Flat : public IRndmGen::Param {
0254 protected:
0255
0256 double m_minimum;
0257
0258 double m_maximum;
0259
0260 public:
0261
0262 Flat( double mi, double ma ) : IRndmGen::Param( IID_IRndmFlat ), m_minimum( mi ), m_maximum( ma ) {}
0263
0264 double minimum() const { return m_minimum; }
0265
0266 double maximum() const { return m_maximum; }
0267
0268 static const InterfaceID& typeID() { return IID_IRndmFlat; }
0269
0270 Flat* clone() const override { return new Flat( m_minimum, m_maximum ); }
0271 };
0272
0273
0274
0275 class GAUDI_API Bit : public IRndmGen::Param {
0276 public:
0277
0278 Bit() : IRndmGen::Param( IID_IRndmBit ) {}
0279
0280 static const InterfaceID& typeID() { return IID_IRndmBit; }
0281
0282 Bit* clone() const override { return new Bit(); }
0283 };
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301 class GAUDI_API DefinedPdf : public IRndmGen::Param {
0302 protected:
0303
0304 std::vector<double> m_pdf;
0305
0306 long m_interpolation;
0307
0308 public:
0309
0310 DefinedPdf( const std::vector<double>& pdf, long intpol )
0311 : IRndmGen::Param( IID_IRndmDefinedPdf ), m_pdf( pdf ), m_interpolation( intpol ) {}
0312
0313 std::vector<double>& pdf() { return m_pdf; }
0314
0315 long interpolation() const { return m_interpolation; }
0316
0317 static const InterfaceID& typeID() { return IID_IRndmDefinedPdf; }
0318
0319 DefinedPdf* clone() const override { return new DefinedPdf( m_pdf, m_interpolation ); }
0320 };
0321
0322
0323
0324 class GAUDI_API GaussianTail : public IRndmGen::Param {
0325 protected:
0326
0327 double m_cut;
0328
0329 double m_sigma;
0330
0331 public:
0332
0333 GaussianTail( double a, double s ) : IRndmGen::Param( IID_IRndmGaussianTail ), m_cut( a ), m_sigma( s ) {}
0334
0335 double cut() const { return m_cut; }
0336
0337 double sigma() const { return m_sigma; }
0338
0339 static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
0340
0341 GaussianTail* clone() const override { return new GaussianTail( m_cut, m_sigma ); }
0342 };
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359 class GAUDI_API Numbers {
0360 protected:
0361
0362 SmartIF<IRndmGen> m_generator;
0363
0364 public:
0365
0366 Numbers() = default;
0367
0368 Numbers( const Numbers& ) = default;
0369
0370 Numbers( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par );
0371
0372 virtual ~Numbers();
0373
0374 virtual StatusCode initialize( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par );
0375 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
0376
0377 Numbers( IRndmGenSvc* svc, const IRndmGen::Param& par );
0378
0379 virtual StatusCode initialize( IRndmGenSvc* svc, const IRndmGen::Param& par );
0380 #endif
0381
0382 virtual StatusCode finalize();
0383
0384 operator bool() const { return m_generator; }
0385
0386 double operator()() const { return this->shoot(); }
0387
0388 double pop() const { return this->shoot(); }
0389
0390 double shoot() const { return m_generator ? m_generator->shoot() : -1; }
0391
0392 StatusCode shootArray( std::vector<double>& array, long num, long start = 0 ) const {
0393 return m_generator ? m_generator->shootArray( array, num, start ) : StatusCode::FAILURE;
0394 }
0395 };
0396 }
0397 #endif