CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandExponential.h

Go to the documentation of this file.
00001 // $Id: RandExponential.h,v 1.5 2010/06/16 17:24:53 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                        --- RandExponential ---
00007 //                          class header file
00008 // -----------------------------------------------------------------------
00009 // This file is part of Geant4 (simulation toolkit for HEP).
00010 //
00011 // Class defining methods for shooting exponential distributed random
00012 // values, given a mean (default mean = 1).
00013 // Default mean is used for operator()().
00014 
00015 // =======================================================================
00016 // Gabriele Cosmo - Created: 5th September 1995
00017 //                - Added methods to shoot arrays: 28th July 1997
00018 // J.Marraffino   - Added default mean as attribute and
00019 //                  operator() with mean: 16th Feb 1998
00020 // M Fischler      - put and get to/from streams 12/10/04
00021 // =======================================================================
00022 
00023 #ifndef RandExponential_h
00024 #define RandExponential_h 1
00025 
00026 #include "CLHEP/Random/defs.h"
00027 #include "CLHEP/Random/Random.h"
00028 #include "CLHEP/Utility/memory.h"
00029 
00030 namespace CLHEP {
00031 
00036 class RandExponential : public HepRandom {
00037 
00038 public:
00039 
00040   inline RandExponential ( HepRandomEngine& anEngine, double mean=1.0 );
00041   inline RandExponential ( HepRandomEngine* anEngine, double mean=1.0 );
00042   // These constructors should be used to instantiate a RandExponential
00043   // distribution object defining a local engine for it.
00044   // The static generator will be skipped using the non-static methods
00045   // defined below.
00046   // If the engine is passed by pointer the corresponding engine object
00047   // will be deleted by the RandExponential destructor.
00048   // If the engine is passed by reference the corresponding engine object
00049   // will not be deleted by the RandExponential destructor.
00050 
00051   virtual ~RandExponential();
00052   // Destructor
00053 
00054   // Static methods to shoot random values using the static generator
00055 
00056   static  double shoot();
00057 
00058   static  double shoot( double mean );
00059 
00060   static  void shootArray ( const int size, double* vect,
00061                             double mean=1.0 );
00062 
00063   //  Static methods to shoot random values using a given engine
00064   //  by-passing the static generator.
00065 
00066   static  inline double shoot( HepRandomEngine* anEngine );
00067 
00068   static  inline double shoot( HepRandomEngine* anEngine, double mean );
00069 
00070   static  void shootArray ( HepRandomEngine* anEngine, const int size,
00071                             double* vect, double mean=1.0 );
00072 
00073   //  Methods using the localEngine to shoot random values, by-passing
00074   //  the static generator.
00075 
00076   inline double fire();
00077 
00078   inline double fire( double mean );
00079 
00080   void fireArray ( const int size, double* vect );
00081   void fireArray ( const int size, double* vect, double mean );
00082   
00083   double operator()();
00084   double operator()( double mean );
00085 
00086   // Save and restore to/from streams
00087   
00088   std::ostream & put ( std::ostream & os ) const;
00089   std::istream & get ( std::istream & is );
00090 
00091   std::string name() const;
00092   HepRandomEngine & engine();
00093 
00094   static std::string distributionName() {return "RandExponential";}  
00095   // Provides the name of this distribution class
00096   
00097 private:
00098 
00099   shared_ptr<HepRandomEngine> localEngine;
00100   double defaultMean;
00101 
00102 };
00103 
00104 }  // namespace CLHEP
00105 
00106 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00107 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00108 using namespace CLHEP;
00109 #endif
00110 
00111 #include "CLHEP/Random/RandExponential.icc"
00112 
00113 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7