00001 // $Id: RandGaussT.h,v 1.5 2002/04/12 15:02:44 evc Exp $ 00002 // -*- C++ -*- 00003 // 00004 // ----------------------------------------------------------------------- 00005 // HEP Random 00006 // --- RandGaussT --- 00007 // class header file 00008 // ----------------------------------------------------------------------- 00009 00010 // Class defining methods RandGaussT, which is derived from RandGauss. 00011 // The user interface is identical. 00012 // RandGaussT --- 00013 // Always uses exactly one flat random from the engine 00014 // Is stateless so that saveEngineStatus works even if invoked knowing 00015 // only that the distribution is a HepRandom. (RandGauss is not stateless.) 00016 // Is accurate to more than 12 decimal places in all cases, and more so 00017 // near the end points. 00018 // Runs about as fast as RandGauss. 00019 // RandGaussT utilizes HepStat::flatToGaussian(r), so its effective footprint 00020 // (for the tables used) is almost 30K bytes. 00021 00022 // ======================================================================= 00023 // M. Fischler Created 2/2/00 00024 // 00025 // ======================================================================= 00026 00027 #ifndef RandGaussT_h 00028 #define RandGaussT_h 1 00029 00030 #include "CLHEP/Random/RandGauss.h" 00031 #include "CLHEP/Random/Stat.h" 00032 00037 class RandGaussT : public RandGauss { 00038 00039 public: 00040 00041 inline RandGaussT ( HepRandomEngine& anEngine, double mean=0.0, 00042 double stdDev=1.0 ); 00043 inline RandGaussT ( HepRandomEngine* anEngine, double mean=0.0, 00044 double stdDev=1.0 ); 00045 // These constructors should be used to instantiate a RandGaussT 00046 // distribution object defining a local engine for it. 00047 // The static generator will be skipped using the non-static methods 00048 // defined below. 00049 // If the engine is passed by pointer the corresponding engine object 00050 // will be deleted by the RandGaussT destructor. 00051 // If the engine is passed by reference the corresponding engine object 00052 // will not be deleted by the RandGaussT destructor. 00053 00054 // Destructor 00055 virtual ~RandGaussT(); 00056 00057 // 00058 // Methods to generate Gaussian-distributed random deviates: 00059 // 00060 // If a fast good engine takes 1 usec, RandGauss::fire() adds 1 usec; 00061 // RandGaussT::fire() similarly adds 1 usec. 00062 // 00063 00064 // Static methods to shoot random values using the static generator 00065 00066 static inline double shoot(); 00067 00068 static inline double shoot( double mean, double stdDev ); 00069 00070 static void shootArray ( const int size, double* vect, 00071 double mean=0.0, double stdDev=1.0 ); 00072 00073 // Static methods to shoot random values using a given engine 00074 // by-passing the static generator. 00075 00076 static inline double shoot( HepRandomEngine* anotherEngine ); 00077 00078 static inline double shoot( HepRandomEngine* anotherEngine, 00079 double mean, double stdDev ); 00080 00081 00082 static void shootArray ( HepRandomEngine* anotherEngine, 00083 const int size, 00084 double* vect, double mean=0.0, 00085 double stdDev=1.0 ); 00086 00087 // Instance methods using the localEngine to instead of the static 00088 // generator, and the default mean and stdDev established at construction 00089 00090 inline double fire(); 00091 00092 inline double fire ( double mean, double stdDev ); 00093 00094 void fireArray ( const int size, double* vect); 00095 void fireArray ( const int size, double* vect, 00096 double mean, double stdDev ); 00097 00098 virtual double operator()(); 00099 virtual double operator()( double mean, double stdDev ); 00100 00101 protected: 00102 00103 private: 00104 00105 // Private copy constructor. Defining it here disallows use. 00106 RandGaussT(const RandGaussT& d); 00107 00108 // All the engine info, and the default mean and sigma, are in the RandGauss 00109 // base class. 00110 00111 }; 00112 00113 #include "CLHEP/Random/RandGaussT.icc" 00114 00115 #endif