Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:03:30

0001 // $Id: RandGaussT.h,v 1.5 2010/06/16 17:24:53 garren Exp $
0002 // -*- C++ -*-
0003 //
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                          --- RandGaussT ---
0007 //                          class header file
0008 // -----------------------------------------------------------------------
0009 
0010 // Class defining methods RandGaussT, which is derived from RandGauss.
0011 // The user interface is identical.  
0012 // RandGaussT ---
0013 //   Always uses exactly one flat random from the engine
0014 //   Is stateless so that saveEngineStatus works even if invoked knowing
0015 //   only that the distribution is a HepRandom.  (RandGauss is not stateless.)
0016 //   Is accurate to more than 12 decimal places in all cases, and more so 
0017 //   near the end points.
0018 //   Runs about as fast as RandGauss.
0019 // RandGaussT utilizes HepStat::flatToGaussian(r), so its effective footprint
0020 // (for the tables used) is almost 30K bytes.
0021 
0022 // =======================================================================
0023 // M. Fischler      Created 2/2/00
0024 // M Fischler      - put and get to/from streams 12/10/04
0025 //
0026 // =======================================================================
0027 
0028 #ifndef RandGaussT_h
0029 #define RandGaussT_h 1
0030 
0031 #include "CLHEP/Random/defs.h"
0032 #include "CLHEP/Random/RandGauss.h"
0033 #include "CLHEP/Random/Stat.h"
0034 
0035 namespace CLHEP {
0036 
0037 /**
0038  * @author
0039  * @ingroup random
0040  */
0041 class RandGaussT : public RandGauss {
0042 
0043 public:
0044 
0045   inline RandGaussT ( HepRandomEngine& anEngine, double mean=0.0,
0046                                                 double stdDev=1.0 );
0047   inline RandGaussT ( HepRandomEngine* anEngine, double mean=0.0,
0048                                                 double stdDev=1.0 );
0049   // These constructors should be used to instantiate a RandGaussT
0050   // distribution object defining a local engine for it.
0051   // The static generator will be skipped using the non-static methods
0052   // defined below.
0053   // If the engine is passed by pointer the corresponding engine object
0054   // will be deleted by the RandGaussT destructor.
0055   // If the engine is passed by reference the corresponding engine object
0056   // will not be deleted by the RandGaussT destructor.
0057 
0058   // Destructor
0059   virtual ~RandGaussT();
0060 
0061   //
0062   // Methods to generate Gaussian-distributed random deviates:
0063   //
0064   //   If a fast good engine takes 1 usec, RandGauss::fire() adds 1 usec;
0065   //   RandGaussT::fire() similarly adds 1 usec.
0066   //
0067 
0068   // Static methods to shoot random values using the static generator
0069 
0070   static  inline double shoot();
0071 
0072   static  inline double shoot( double mean, double stdDev );
0073 
0074   static  void shootArray ( const int size, double* vect,
0075                             double mean=0.0, double stdDev=1.0 );
0076 
0077   //  Static methods to shoot random values using a given engine
0078   //  by-passing the static generator.
0079 
0080   static  inline double shoot( HepRandomEngine* anotherEngine );
0081 
0082   static  inline double shoot( HepRandomEngine* anotherEngine, 
0083                                   double mean, double stdDev );
0084 
0085 
0086   static  void shootArray ( HepRandomEngine* anotherEngine, 
0087                 const int size,
0088                             double* vect, double mean=0.0,
0089                             double stdDev=1.0 );
0090 
0091   //  Instance methods using the localEngine to instead of the static 
0092   //  generator, and the default mean and stdDev established at construction
0093 
0094   inline double fire();
0095 
0096   inline double fire ( double mean, double stdDev );
0097   
0098   void fireArray  ( const int size, double* vect);
0099   void fireArray  ( const int size, double* vect,
0100                     double mean, double stdDev );
0101 
0102   virtual double operator()();
0103   virtual double operator()( double mean, double stdDev );
0104 
0105   // Save and restore to/from streams
0106   
0107   std::ostream & put ( std::ostream & os ) const;
0108   std::istream & get ( std::istream & is );
0109 
0110   std::string name() const;
0111   HepRandomEngine & engine();
0112 
0113   static std::string distributionName() {return "RandGaussT";}  
0114   // Provides the name of this distribution class
0115   
0116 private:
0117 
0118   // All the engine info, and the default mean and sigma, are in the RandGauss
0119   // base class.
0120 
0121 };
0122 
0123 }  // namespace CLHEP
0124 
0125 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0126 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0127 using namespace CLHEP;
0128 #endif
0129 
0130 #include "CLHEP/Random/RandGaussT.icc"
0131 
0132 #endif