| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# RndmGenerators.h

Go to the documentation of this file.

    00001 // $Id: RndmGenerators.h,v 1.8 2005/07/21 14:35:31 hmd Exp $
    00002 #ifndef GAUDIKERNEL_RNDMGENGENERATORS_H
    00003 #define GAUDIKERNEL_RNDMGENGENERATORS_H
    00004
    00005 // STL include files
    00006 #include <vector>
    00007
    00008 // Framework include files
    00009 #include "GaudiKernel/IRndmGen.h"
    00010 #include "GaudiKernel/SmartIF.h"
    00011
    00012 // Forward declarations
    00013 class IRndmGen;
    00014 class IRndmGenSvc;
    00015
    00016 namespace Rndm   {
    00017
    00018   template <class TYPE> class Generator;
    00019
    00022   class GAUDI_API Gauss: public IRndmGen::Param {
    00023   protected:
    00025     friend class Generator<Gauss>;
    00027     double m_mean;
    00029     double m_sigma;
    00030   public:
    00032     Gauss(double m, double s)
    00033     : IRndmGen::Param(IID_IRndmGauss), m_mean(m), m_sigma(s)  { }
    00035     virtual ~Gauss()                          {  }
    00037     double mean()  const                      {   return m_mean; }
    00039     double sigma()  const                     {   return m_sigma; }
    00041     static const InterfaceID& typeID()        {   return IID_IRndmGauss; }
    00043     virtual IRndmGen::Param* clone() const {
    00044       return new Gauss(m_mean, m_sigma);
    00045     }
    00046   };
    00047
    00050   class GAUDI_API Exponential: public IRndmGen::Param  {
    00051   protected:
    00053     double m_mean;
    00054   public:
    00056     Exponential(double m)
    00057     : IRndmGen::Param(IID_IRndmExponential), m_mean(m)  { }
    00059     virtual ~Exponential()                 {  }
    00061     double mean()  const                   { return m_mean; }
    00063     static const InterfaceID& typeID()     { return IID_IRndmExponential; }
    00065     virtual IRndmGen::Param* clone() const { return new Exponential(m_mean); }
    00066   };
    00067
    00070   class GAUDI_API Chi2: public IRndmGen::Param {
    00071     friend class Generator<Chi2>;
    00072   protected:
    00074     long m_nDOF;
    00075   public:
    00077     Chi2(long   n_dof) : IRndmGen::Param(IID_IRndmChi2), m_nDOF(n_dof) { }
    00079     virtual ~Chi2()                           { }
    00081     long nDOF()  const                        { return m_nDOF; }
    00083     static const InterfaceID& typeID()        { return IID_IRndmChi2; }
    00085     virtual IRndmGen::Param* clone()  const   { return new Chi2(m_nDOF); }
    00086   };
    00087
    00090   class GAUDI_API BreitWigner : public IRndmGen::Param {
    00091     friend class Generator<BreitWigner>;
    00092   protected:
    00094     double m_mean, m_gamma;
    00095   public:
    00097     BreitWigner(double m, double g)
    00098     : IRndmGen::Param(IID_IRndmBreitWigner), m_mean(m), m_gamma(g) { }
    00100     virtual ~BreitWigner()                    { }
    00102     double mean()  const                      { return m_mean;                }
    00104     double gamma()  const                     { return m_gamma;               }
    00106     static const InterfaceID& typeID()        { return IID_IRndmBreitWigner;  }
    00108     virtual IRndmGen::Param* clone()  const   {
    00109       return new BreitWigner(m_mean, m_gamma);
    00110     }
    00111   };
    00112
    00115   class GAUDI_API Landau : public IRndmGen::Param {
    00116     friend class Generator<Landau>;
    00117   protected:
    00119     double m_mean, m_sigma;
    00120   public:
    00122     Landau(double m, double s)
    00123     : IRndmGen::Param(IID_IRndmLandau), m_mean(m), m_sigma(s) { }
    00125     virtual ~Landau()                         { }
    00127     double mean()  const                      { return m_mean;                }
    00129     double sigma()  const                     { return m_sigma;               }
    00131     static const InterfaceID& typeID()        { return IID_IRndmLandau;       }
    00133     virtual IRndmGen::Param* clone() const    {
    00134       return new Landau(m_mean, m_sigma);
    00135     }
    00136   };
    00137
    00141   class GAUDI_API BreitWignerCutOff : public IRndmGen::Param {
    00142     friend class Generator<BreitWignerCutOff>;
    00143   protected:
    00145     double m_mean, m_gamma, m_cut;
    00146   public:
    00148     BreitWignerCutOff(double m, double g, double c)
    00149     : IRndmGen::Param(IID_IRndmBreitWignerCutOff),
    00150       m_mean(m),
    00151       m_gamma(g),
    00152       m_cut(c) {  }
    00154     virtual ~BreitWignerCutOff()              { }
    00156     double mean()  const                      { return m_mean; }
    00158     double gamma()  const                     { return m_gamma; }
    00160     double cutOff()  const                    { return m_cut; }
    00162     static const InterfaceID& typeID()        { return IID_IRndmBreitWignerCutOff;}
    00164     virtual IRndmGen::Param* clone() const {
    00165       return new BreitWignerCutOff(m_mean, m_gamma, m_cut);
    00166     }
    00167   };
    00168
    00171   class GAUDI_API StudentT: public IRndmGen::Param {
    00172     friend class Generator<StudentT>;
    00173   protected:
    00175     double m_aValue;
    00176   public:
    00178     StudentT(double a) : IRndmGen::Param(IID_IRndmStudentT), m_aValue(a) { }
    00180     virtual ~StudentT()                       { }
    00182     double aValue()  const                    { return m_aValue;              }
    00184     static const InterfaceID& typeID()        { return IID_IRndmStudentT;     }
    00186     virtual IRndmGen::Param* clone()  const   { return new StudentT(m_aValue);}
    00187   };
    00188
    00191   class GAUDI_API Gamma: public IRndmGen::Param {
    00192     friend class Generator<Gamma>;
    00193   protected:
    00195     double m_kValue;
    00197     double m_lambda;
    00198   public:
    00200     Gamma(double k, double l)
    00201     : IRndmGen::Param(IID_IRndmGamma), m_kValue(k), m_lambda(l) { }
    00203     virtual ~Gamma()                          {  }
    00205     double kValue()  const                    { return m_kValue;              }
    00207     double lambda()  const                    { return m_lambda;              }
    00209     static const InterfaceID& typeID()        { return IID_IRndmGamma;        }
    00211     virtual IRndmGen::Param* clone()  const   {
    00212       return new Gamma(m_kValue, m_lambda);
    00213     }
    00214   };
    00215
    00219   class GAUDI_API Poisson: public IRndmGen::Param {
    00220     friend class Generator<Poisson>;
    00221   protected:
    00223     double m_mean;
    00224   public:
    00226     Poisson(double m) : IRndmGen::Param(IID_IRndmPoisson), m_mean(m) { }
    00228     virtual ~Poisson()                        {  }
    00230     double mean()  const                      { return m_mean;                }
    00232     static const InterfaceID& typeID()        { return IID_IRndmPoisson;      }
    00234     virtual IRndmGen::Param* clone()  const   { return new Poisson(m_mean);   }
    00235   };
    00236
    00240   class GAUDI_API Binomial: public IRndmGen::Param {
    00241   protected:
    00243     long m_nEvent;
    00245     double m_probability;
    00246   public:
    00248     Binomial(long n, double p)
    00249     : IRndmGen::Param(IID_IRndmBinomial), m_nEvent(n), m_probability(p) { }
    00251     virtual ~Binomial()                       {  }
    00253     long nEvent()  const                      { return m_nEvent;              }
    00255     double probability()  const               { return m_probability;         }
    00257     static const InterfaceID& typeID()        { return IID_IRndmBinomial;     }
    00259     virtual IRndmGen::Param* clone()  const   {
    00260       return new Binomial(m_nEvent, m_probability);
    00261     }
    00262   };
    00263
    00267   class GAUDI_API Flat: public IRndmGen::Param {
    00268   protected:
    00270     double m_minimum;
    00272     double m_maximum;
    00273   public:
    00275     Flat(double mi, double ma)
    00276     : IRndmGen::Param(IID_IRndmFlat), m_minimum(mi), m_maximum(ma) { }
    00278     virtual ~Flat()                           {  }
    00280     double minimum()  const                   { return m_minimum;             }
    00282     double maximum()  const                   { return m_maximum;             }
    00284     static const InterfaceID& typeID()        { return IID_IRndmFlat;         }
    00286     virtual IRndmGen::Param* clone()  const   {
    00287       return new Flat(m_minimum, m_maximum);
    00288     }
    00289   };
    00290
    00293   class GAUDI_API Bit: public IRndmGen::Param {
    00294   public:
    00296     Bit() : IRndmGen::Param(IID_IRndmBit)     {  }
    00298     virtual ~Bit()                            {  }
    00300     static const InterfaceID& typeID()        { return IID_IRndmBit; }
    00302     virtual IRndmGen::Param* clone()  const   { return new Bit(); }
    00303   };
    00304
    00321   class GAUDI_API DefinedPdf: public IRndmGen::Param {
    00322   protected:
    00324     std::vector<double> m_pdf;
    00326     long m_interpolation;
    00327   public:
    00329     DefinedPdf(const std::vector<double>& pdf, long intpol)
    00330     : IRndmGen::Param(IID_IRndmDefinedPdf),
    00331       m_pdf(pdf),
    00332       m_interpolation(intpol)  {     }
    00334     virtual ~DefinedPdf()                     {  }
    00336     std::vector<double>& pdf()                { return m_pdf;                 }
    00338     long interpolation()  const               { return m_interpolation;       }
    00340     static const InterfaceID& typeID()        { return IID_IRndmDefinedPdf;   }
    00342     virtual IRndmGen::Param* clone()  const   {
    00343       return new DefinedPdf(m_pdf,m_interpolation);
    00344     }
    00345   };
    00346
    00349   class GAUDI_API GaussianTail: public IRndmGen::Param {
    00350   protected:
    00352     double m_cut;
    00354     double m_sigma;
    00355   public:
    00357     GaussianTail(double a, double s)
    00358       : IRndmGen::Param(IID_IRndmGaussianTail), m_cut(a), m_sigma(s)  { }
    00360     virtual ~GaussianTail() { }
    00362     double cut()  const { return m_cut; }
    00364     double sigma()  const { return m_sigma; }
    00366     static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
    00368     virtual IRndmGen::Param* clone() const {
    00369       return new GaussianTail(m_cut, m_sigma);
    00370     }
    00371   };
    00372
    00373
    00389   class GAUDI_API Numbers   {
    00390   protected:
    00392     IRndmGen*           m_generator;
    00393   public:
    00395     Numbers();
    00397     Numbers(const Numbers& copy );
    00399     Numbers(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par);
    00401     virtual ~Numbers();
    00403     virtual StatusCode initialize(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par);
    00404 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
    00406     Numbers(IRndmGenSvc* svc, const IRndmGen::Param& par);
    00408     virtual StatusCode initialize(IRndmGenSvc* svc, const IRndmGen::Param& par);
    00409 #endif
    00411     virtual StatusCode finalize();
    00413     operator bool  ()  const  {
    00414       return m_generator != 0;
    00415     }
    00417     double operator() ()   {
    00418       return this->shoot();
    00419     }
    00421     double pop()    {
    00422       return this->shoot();
    00423     }
    00425     double shoot()    {
    00426       if ( 0 != m_generator )   {
    00427         return m_generator->shoot();
    00428       }
    00429       return -1;
    00430     }
    00432     StatusCode shootArray(std::vector<double>& array, long num, long start=0)  {
    00433       if ( 0 != m_generator )   {
    00434         return m_generator->shootArray(array, num, start);
    00435       }
    00436       return StatusCode::FAILURE;
    00437     }
    00438   };
    00439 }
    00440 #endif    // GAUDIKERNEL_RNDMGENGENERATORS_H