Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCLRandom.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // INCL++ intra-nuclear cascade model
27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28 // Davide Mancusi, CEA
29 // Alain Boudard, CEA
30 // Sylvie Leray, CEA
31 // Joseph Cugnon, University of Liege
32 //
33 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 /*
38  * G4INCLRandom.hh
39  *
40  * \date 7 June 2009
41  * \author Pekka Kaitaniemi
42  */
43 
44 #ifndef G4INCLRANDOM_HH_
45 #define G4INCLRANDOM_HH_
46 
47 #include <iostream>
48 #include <cmath>
49 #include <utility>
51 #include "G4INCLThreeVector.hh"
52 #include "G4INCLGlobals.hh"
53 #include "G4INCLLogger.hh"
54 
55 namespace G4INCL {
56 
57  namespace Random {
58  /**
59  * Set the random number generator implementation to be used globally by INCL.
60  *
61  * @see G4INCL::IRandomGenerator
62  */
63  void setGenerator(G4INCL::IRandomGenerator *aGenerator);
64 
65  /**
66  * Set the seeds of the current generator.
67  *
68  */
69  void setSeeds(const SeedVector &sv);
70 
71  /**
72  * Get the seeds of the current generator.
73  *
74  */
76 
77  /**
78  * Generate flat distribution of random numbers.
79  */
80  G4double shoot();
81 
82  /**
83  * Return a random number in the ]0,1] interval
84  */
85  G4double shoot0();
86 
87  /**
88  * Return a random number in the [0,1[ interval
89  */
90  G4double shoot1();
91 
92  /**
93  * Return a random integer in the [0,n[ interval
94  */
95  template<typename T> T shootInteger(T n);
96 
97  /**
98  * Generate random numbers using gaussian distribution.
99  */
100  G4double gauss(G4double sigma=1.);
101 
102  /**
103  * Generate isotropically-distributed ThreeVectors of given norm.
104  */
106 
107  /**
108  * Generate ThreeVectors that are uniformly distributed in a sphere of
109  * radius rmax.
110  */
112 
113  /** \brief Generate Gaussianly-distributed ThreeVectors
114  *
115  * Generate ThreeVectors that are distributed as a three-dimensional
116  * Gaussian of the given sigma.
117  */
118  ThreeVector gaussVector(G4double sigma=1.);
119 
120  /// \brief Generate pairs of correlated Gaussian random numbers
121  std::pair<G4double,G4double> correlatedGaussian(const G4double corrCoeff, const G4double x0=0., const G4double sigma=1.);
122 
123  /// \brief Generate pairs of correlated uniform random numbers
124  std::pair<G4double,G4double> correlatedUniform(const G4double corrCoeff);
125 
126  /**
127  * Delete the generator
128  */
129  void deleteGenerator();
130 
131  /**
132  * Check if the generator is initialized.
133  */
135 
136  }
137 
138 }
139 
140 #endif /* G4INCLRANDOM_HH_ */
ThreeVector gaussVector(G4double sigma=1.)
Generate Gaussianly-distributed ThreeVectors.
ThreeVector sphereVector(G4double rmax=1.)
void deleteGenerator()
T shootInteger(T n)
Definition: G4INCLRandom.cc:93
G4double shoot0()
Definition: G4INCLRandom.cc:78
ThreeVector normVector(G4double norm=1.)
SeedVector getSeeds()
Definition: G4INCLRandom.cc:70
G4double shoot1()
Definition: G4INCLRandom.cc:85
std::pair< G4double, G4double > correlatedUniform(const G4double corrCoeff)
Generate pairs of correlated uniform random numbers.
bool G4bool
Definition: G4Types.hh:79
const G4int n
void setGenerator(G4INCL::IRandomGenerator *aGenerator)
Definition: G4INCLRandom.cc:58
G4double gauss(G4double sigma=1.)
Definition: G4INCLRandom.cc:97
G4double shoot()
Definition: G4INCLRandom.cc:74
double G4double
Definition: G4Types.hh:76
std::pair< G4double, G4double > correlatedGaussian(const G4double corrCoeff, const G4double x0=0., const G4double sigma=1.)
Generate pairs of correlated Gaussian random numbers.
double Random(double min=0.0, double max=1.0)
Definition: UUtils.cc:69
G4bool isInitialized()
void setSeeds(const SeedVector &sv)
Definition: G4INCLRandom.cc:66