Geant4  10.00.p01
RandExponential.icc
Go to the documentation of this file.
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandExponential ---
7 // inlined functions implementation file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 
11 // =======================================================================
12 // Gabriele Cosmo - Created: 19th August 1998
13 // =======================================================================
14 
15 #include <cmath> // for log()
16 
17 namespace CLHEP {
18 
19 inline RandExponential::RandExponential(HepRandomEngine & anEngine,
20  double mean )
21 : HepRandom(), localEngine(&anEngine, do_nothing_deleter()), defaultMean(mean) {}
22 
23 inline RandExponential::RandExponential(HepRandomEngine * anEngine,
24  double mean )
25 : HepRandom(), localEngine(anEngine), defaultMean(mean) {}
26 
27 //-------------
28 
29 inline double RandExponential::shoot(HepRandomEngine* anEngine) {
30  return -std::log(anEngine->flat());
31 }
32 
33 inline double RandExponential::shoot(HepRandomEngine* anEngine,
34  double mean) {
35  return -std::log(anEngine->flat())*mean;
36 }
37 
38 //-------------
39 
40 inline double RandExponential::fire() {
41  return -std::log(localEngine->flat())*defaultMean;
42 }
43 
44 inline double RandExponential::fire(double mean) {
45  return -std::log(localEngine->flat())*mean;
46 }
47 
48 } // namespace CLHEP