Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // $Id: RandExponential.icc,v 1.3 2010/06/16 17:24:53 garren Exp $
0002 // -*- C++ -*-
0003 // 
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                       --- RandExponential ---
0007 //                 inlined functions implementation file
0008 // -----------------------------------------------------------------------
0009 // This file is part of Geant4 (simulation toolkit for HEP).
0010  
0011 // =======================================================================
0012 // Gabriele Cosmo - Created: 19th August 1998
0013 // =======================================================================
0014 
0015 #include <cmath>    // for log()
0016 
0017 namespace CLHEP {
0018 
0019 inline RandExponential::RandExponential(HepRandomEngine & anEngine,
0020                                         double mean )
0021 : HepRandom(), localEngine(&anEngine, do_nothing_deleter()), defaultMean(mean) {}
0022 
0023 inline RandExponential::RandExponential(HepRandomEngine * anEngine,
0024                                         double mean )
0025 : HepRandom(), localEngine(anEngine), defaultMean(mean) {}
0026 
0027 //-------------
0028 
0029 inline double RandExponential::shoot(HepRandomEngine* anEngine) {
0030   return -std::log(anEngine->flat());
0031 }
0032 
0033 inline double RandExponential::shoot(HepRandomEngine* anEngine,
0034                                         double mean) {
0035   return -std::log(anEngine->flat())*mean;
0036 }
0037 
0038 //-------------
0039 
0040 inline double RandExponential::fire() {
0041   return -std::log(localEngine->flat())*defaultMean;
0042 }
0043 
0044 inline double RandExponential::fire(double mean) {
0045   return -std::log(localEngine->flat())*mean;
0046 }
0047 
0048 }  // namespace CLHEP