Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:37

0001 // $Id: RandExponential.h,v 1.5 2010/06/16 17:24:53 garren Exp $
0002 // -*- C++ -*-
0003 //
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                        --- RandExponential ---
0007 //                          class header file
0008 // -----------------------------------------------------------------------
0009 // This file is part of Geant4 (simulation toolkit for HEP).
0010 //
0011 // Class defining methods for shooting exponential distributed random
0012 // values, given a mean (default mean = 1).
0013 // Default mean is used for operator()().
0014 
0015 // =======================================================================
0016 // Gabriele Cosmo - Created: 5th September 1995
0017 //                - Added methods to shoot arrays: 28th July 1997
0018 // J.Marraffino   - Added default mean as attribute and
0019 //                  operator() with mean: 16th Feb 1998
0020 // M Fischler      - put and get to/from streams 12/10/04
0021 // =======================================================================
0022 
0023 #ifndef RandExponential_h
0024 #define RandExponential_h 1
0025 
0026 #include "CLHEP/Random/defs.h"
0027 #include "CLHEP/Random/Random.h"
0028 #include "CLHEP/Utility/memory.h"
0029 
0030 namespace CLHEP {
0031 
0032 /**
0033  * @author <Gabriele.Cosmo@cern.ch>
0034  * @ingroup random
0035  */
0036 class RandExponential : public HepRandom {
0037 
0038 public:
0039 
0040   inline RandExponential ( HepRandomEngine& anEngine, double mean=1.0 );
0041   inline RandExponential ( HepRandomEngine* anEngine, double mean=1.0 );
0042   // These constructors should be used to instantiate a RandExponential
0043   // distribution object defining a local engine for it.
0044   // The static generator will be skipped using the non-static methods
0045   // defined below.
0046   // If the engine is passed by pointer the corresponding engine object
0047   // will be deleted by the RandExponential destructor.
0048   // If the engine is passed by reference the corresponding engine object
0049   // will not be deleted by the RandExponential destructor.
0050 
0051   virtual ~RandExponential();
0052   // Destructor
0053 
0054   // Static methods to shoot random values using the static generator
0055 
0056   static  double shoot();
0057 
0058   static  double shoot( double mean );
0059 
0060   static  void shootArray ( const int size, double* vect,
0061                             double mean=1.0 );
0062 
0063   //  Static methods to shoot random values using a given engine
0064   //  by-passing the static generator.
0065 
0066   static  inline double shoot( HepRandomEngine* anEngine );
0067 
0068   static  inline double shoot( HepRandomEngine* anEngine, double mean );
0069 
0070   static  void shootArray ( HepRandomEngine* anEngine, const int size,
0071                             double* vect, double mean=1.0 );
0072 
0073   //  Methods using the localEngine to shoot random values, by-passing
0074   //  the static generator.
0075 
0076   inline double fire();
0077 
0078   inline double fire( double mean );
0079 
0080   void fireArray ( const int size, double* vect );
0081   void fireArray ( const int size, double* vect, double mean );
0082   
0083   double operator()();
0084   double operator()( double mean );
0085 
0086   // Save and restore to/from streams
0087   
0088   std::ostream & put ( std::ostream & os ) const;
0089   std::istream & get ( std::istream & is );
0090 
0091   std::string name() const;
0092   HepRandomEngine & engine();
0093 
0094   static std::string distributionName() {return "RandExponential";}  
0095   // Provides the name of this distribution class
0096   
0097 private:
0098 
0099   std::shared_ptr<HepRandomEngine> localEngine;
0100   double defaultMean;
0101 
0102 };
0103 
0104 }  // namespace CLHEP
0105 
0106 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0107 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0108 using namespace CLHEP;
0109 #endif
0110 
0111 #include "CLHEP/Random/RandExponential.icc"
0112 
0113 #endif