| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# 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
    00011 // Forward declarations
    00012 class IRndmGen;
    00013 class IRndmGenSvc;
    00014
    00015 namespace Rndm   {
    00016
    00017   template <class TYPE> class Generator;
    00018
    00021   class Gauss : public IRndmGen::Param        {
    00022   protected:
    00024     friend class Generator<Gauss>;
    00026     double m_mean;
    00028     double m_sigma;
    00029   public:
    00031     Gauss(double m, double s)
    00032     : IRndmGen::Param(IID_IRndmGauss), m_mean(m), m_sigma(s)  { }
    00034     virtual ~Gauss()                          {  }
    00036     double mean()  const                      {   return m_mean; }
    00038     double sigma()  const                     {   return m_sigma; }
    00040     static const InterfaceID& typeID()        {   return IID_IRndmGauss; }
    00042     virtual IRndmGen::Param* clone() const {
    00043       return new Gauss(m_mean, m_sigma);
    00044     }
    00045   };
    00046
    00049   class Exponential : public IRndmGen::Param  {
    00050   protected:
    00052     double m_mean;
    00053   public:
    00055     Exponential(double m)
    00056     : IRndmGen::Param(IID_IRndmExponential), m_mean(m)  { }
    00058     virtual ~Exponential()                 {  }
    00060     double mean()  const                   { return m_mean; }
    00062     static const InterfaceID& typeID()     { return IID_IRndmExponential; }
    00064     virtual IRndmGen::Param* clone() const { return new Exponential(m_mean); }
    00065   };
    00066
    00069   class Chi2 : public IRndmGen::Param         {
    00070     friend class Generator<Chi2>;
    00071   protected:
    00073     long m_nDOF;
    00074   public:
    00076     Chi2(long   n_dof) : IRndmGen::Param(IID_IRndmChi2), m_nDOF(n_dof) { }
    00078     virtual ~Chi2()                           { }
    00080     long nDOF()  const                        { return m_nDOF; }
    00082     static const InterfaceID& typeID()        { return IID_IRndmChi2; }
    00084     virtual IRndmGen::Param* clone()  const   { return new Chi2(m_nDOF); }
    00085   };
    00086
    00089   class BreitWigner : public IRndmGen::Param  {
    00090     friend class Generator<BreitWigner>;
    00091   protected:
    00093     double m_mean, m_gamma;
    00094   public:
    00096     BreitWigner(double m, double g)
    00097     : IRndmGen::Param(IID_IRndmBreitWigner), m_mean(m), m_gamma(g) { }
    00099     virtual ~BreitWigner()                    { }
    00101     double mean()  const                      { return m_mean;                }
    00103     double gamma()  const                     { return m_gamma;               }
    00105     static const InterfaceID& typeID()        { return IID_IRndmBreitWigner;  }
    00107     virtual IRndmGen::Param* clone()  const   {
    00108       return new BreitWigner(m_mean, m_gamma);
    00109     }
    00110   };
    00111
    00114   class Landau : public IRndmGen::Param       {
    00115     friend class Generator<Landau>;
    00116   protected:
    00118     double m_mean, m_sigma;
    00119   public:
    00121     Landau(double m, double s)
    00122     : IRndmGen::Param(IID_IRndmLandau), m_mean(m), m_sigma(s) { }
    00124     virtual ~Landau()                         { }
    00126     double mean()  const                      { return m_mean;                }
    00128     double sigma()  const                     { return m_sigma;               }
    00130     static const InterfaceID& typeID()        { return IID_IRndmLandau;       }
    00132     virtual IRndmGen::Param* clone() const    {
    00133       return new Landau(m_mean, m_sigma);
    00134     }
    00135   };
    00136
    00140   class BreitWignerCutOff : public IRndmGen::Param    {
    00141     friend class Generator<BreitWignerCutOff>;
    00142   protected:
    00144     double m_mean, m_gamma, m_cut;
    00145   public:
    00147     BreitWignerCutOff(double m, double g, double c)
    00148     : IRndmGen::Param(IID_IRndmBreitWignerCutOff),
    00149       m_mean(m),
    00150       m_gamma(g),
    00151       m_cut(c) {  }
    00153     virtual ~BreitWignerCutOff()              { }
    00155     double mean()  const                      { return m_mean; }
    00157     double gamma()  const                     { return m_gamma; }
    00159     double cutOff()  const                    { return m_cut; }
    00161     static const InterfaceID& typeID()        { return IID_IRndmBreitWignerCutOff;}
    00163     virtual IRndmGen::Param* clone() const {
    00164       return new BreitWignerCutOff(m_mean, m_gamma, m_cut);
    00165     }
    00166   };
    00167
    00170   class StudentT : public IRndmGen::Param     {
    00171     friend class Generator<StudentT>;
    00172   protected:
    00174     double m_aValue;
    00175   public:
    00177     StudentT(double a) : IRndmGen::Param(IID_IRndmStudentT), m_aValue(a) { }
    00179     virtual ~StudentT()                       { }
    00181     double aValue()  const                    { return m_aValue;              }
    00183     static const InterfaceID& typeID()        { return IID_IRndmStudentT;     }
    00185     virtual IRndmGen::Param* clone()  const   { return new StudentT(m_aValue);}
    00186   };
    00187
    00190   class Gamma : public IRndmGen::Param        {
    00191     friend class Generator<Gamma>;
    00192   protected:
    00194     double m_kValue;
    00196     double m_lambda;
    00197   public:
    00199     Gamma(double k, double l)
    00200     : IRndmGen::Param(IID_IRndmGamma), m_kValue(k), m_lambda(l) { }
    00202     virtual ~Gamma()                          {  }
    00204     double kValue()  const                    { return m_kValue;              }
    00206     double lambda()  const                    { return m_lambda;              }
    00208     static const InterfaceID& typeID()        { return IID_IRndmGamma;        }
    00210     virtual IRndmGen::Param* clone()  const   {
    00211       return new Gamma(m_kValue, m_lambda);
    00212     }
    00213   };
    00214
    00218   class Poisson : public IRndmGen::Param      {
    00219     friend class Generator<Poisson>;
    00220   protected:
    00222     double m_mean;
    00223   public:
    00225     Poisson(double m) : IRndmGen::Param(IID_IRndmPoisson), m_mean(m) { }
    00227     virtual ~Poisson()                        {  }
    00229     double mean()  const                      { return m_mean;                }
    00231     static const InterfaceID& typeID()        { return IID_IRndmPoisson;      }
    00233     virtual IRndmGen::Param* clone()  const   { return new Poisson(m_mean);   }
    00234   };
    00235
    00239   class Binomial : public IRndmGen::Param    {
    00240   protected:
    00242     long m_nEvent;
    00244     double m_probability;
    00245   public:
    00247     Binomial(long n, double p)
    00248     : IRndmGen::Param(IID_IRndmBinomial), m_nEvent(n), m_probability(p) { }
    00250     virtual ~Binomial()                       {  }
    00252     long nEvent()  const                      { return m_nEvent;              }
    00254     double probability()  const               { return m_probability;         }
    00256     static const InterfaceID& typeID()        { return IID_IRndmBinomial;     }
    00258     virtual IRndmGen::Param* clone()  const   {
    00259       return new Binomial(m_nEvent, m_probability);
    00260     }
    00261   };
    00262
    00266   class Flat : public IRndmGen::Param         {
    00267   protected:
    00269     double m_minimum;
    00271     double m_maximum;
    00272   public:
    00274     Flat(double mi, double ma)
    00275     : IRndmGen::Param(IID_IRndmFlat), m_minimum(mi), m_maximum(ma) { }
    00277     virtual ~Flat()                           {  }
    00279     double minimum()  const                   { return m_minimum;             }
    00281     double maximum()  const                   { return m_maximum;             }
    00283     static const InterfaceID& typeID()        { return IID_IRndmFlat;         }
    00285     virtual IRndmGen::Param* clone()  const   {
    00286       return new Flat(m_minimum, m_maximum);
    00287     }
    00288   };
    00289
    00292   class Bit : public IRndmGen::Param          {
    00293   public:
    00295     Bit() : IRndmGen::Param(IID_IRndmBit)     {  }
    00297     virtual ~Bit()                            {  }
    00299     static const InterfaceID& typeID()        { return IID_IRndmBit; }
    00301     virtual IRndmGen::Param* clone()  const   { return new Bit(); }
    00302   };
    00303
    00320   class DefinedPdf : public IRndmGen::Param   {
    00321   protected:
    00323     std::vector<double> m_pdf;
    00325     long m_interpolation;
    00326   public:
    00328     DefinedPdf(const std::vector<double>& pdf, long intpol)
    00329     : IRndmGen::Param(IID_IRndmDefinedPdf),
    00330       m_pdf(pdf),
    00331       m_interpolation(intpol)  {     }
    00333     virtual ~DefinedPdf()                     {  }
    00335     std::vector<double>& pdf()                { return m_pdf;                 }
    00337     long interpolation()  const               { return m_interpolation;       }
    00339     static const InterfaceID& typeID()        { return IID_IRndmDefinedPdf;   }
    00341     virtual IRndmGen::Param* clone()  const   {
    00342       return new DefinedPdf(m_pdf,m_interpolation);
    00343     }
    00344   };
    00345
    00348   class GaussianTail : public IRndmGen::Param        {
    00349   protected:
    00351     double m_cut;
    00353     double m_sigma;
    00354   public:
    00356     GaussianTail(double a, double s)
    00357       : IRndmGen::Param(IID_IRndmGaussianTail), m_cut(a), m_sigma(s)  { }
    00359     virtual ~GaussianTail() { }
    00361     double cut()  const { return m_cut; }
    00363     double sigma()  const { return m_sigma; }
    00365     static const InterfaceID& typeID() { return IID_IRndmGaussianTail; }
    00367     virtual IRndmGen::Param* clone() const {
    00368       return new GaussianTail(m_cut, m_sigma);
    00369     }
    00370   };
    00371
    00372
    00388   class Numbers   {
    00389   protected:
    00391     IRndmGen*           m_generator;
    00392   public:
    00394     Numbers();
    00396     Numbers(const Numbers& copy );
    00398     Numbers(IRndmGenSvc* svc, const IRndmGen::Param& par);
    00400     virtual ~Numbers();
    00402     virtual StatusCode initialize(IRndmGenSvc* svc, const IRndmGen::Param& par);
    00404     virtual StatusCode finalize();
    00406     operator bool  ()  const  {
    00407       return m_generator != 0;
    00408     }
    00410     double operator() ()   {
    00411       return this->shoot();
    00412     }
    00414     double pop()    {
    00415       return this->shoot();
    00416     }
    00418     double shoot()    {
    00419       if ( 0 != m_generator )   {
    00420         return m_generator->shoot();
    00421       }
    00422       return -1;
    00423     }
    00425     StatusCode shootArray(std::vector<double>& array, long num, long start=0)  {
    00426       if ( 0 != m_generator )   {
    00427         return m_generator->shootArray(array, num, start);
    00428       }
    00429       return StatusCode::FAILURE;
    00430     }
    00431   };
    00432 }
    00433 #endif    // GAUDIKERNEL_RNDMGENGENERATORS_H