Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MTRandGauss.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 //
27 // $Id:$
28 //
29 // Class G4MTRandGauss
30 //
31 // Modified version with MT extensions
32 // of corresponding CLHEP class RandGauss
33 
34 // --------------------------------------------------------------------
35 #ifndef G4MTRandGauss_h
36 #define G4MTRandGauss_h 1
37 
38 #include "G4MTHepRandom.hh"
39 
41 {
42 
43 public:
44 
45  inline G4MTRandGauss ( CLHEP::HepRandomEngine& anEngine, G4double mean=0.0,
46  G4double stdDev=1.0 );
47  inline G4MTRandGauss ( CLHEP::HepRandomEngine* anEngine, G4double mean=0.0,
48  G4double stdDev=1.0 );
49  // These constructors should be used to instantiate a G4MTRandGauss
50  // distribution object defining a local engine for it.
51  // The static generator will be skipped using the non-static methods
52  // defined below.
53  // If the engine is passed by pointer the corresponding engine object
54  // will be deleted by the G4MTRandGauss destructor.
55  // If the engine is passed by reference the corresponding engine object
56  // will not be deleted by the G4MTRandGauss destructor.
57 
58  virtual ~G4MTRandGauss();
59  // Destructor
60 
61  // Static methods to shoot random values using the static generator
62 
63  static G4double shoot();
64 
65  static inline G4double shoot( G4double mean, G4double stdDev );
66 
67  static void shootArray ( const G4int size, G4double* vect,
68  G4double mean=0.0, G4double stdDev=1.0 );
69 
70  // Static methods to shoot random values using a given engine
71  // by-passing the static generator.
72 
73  static G4double shoot( CLHEP::HepRandomEngine* anEngine );
74 
75  static inline G4double shoot( CLHEP::HepRandomEngine* anEngine,
76  G4double mean, G4double stdDev );
77 
78  static void shootArray ( CLHEP::HepRandomEngine* anEngine, const G4int size,
79  G4double* vect, G4double mean=0.0,
80  G4double stdDev=1.0 );
81 
82  // Methods using the localEngine to shoot random values, by-passing
83  // the static generator.
84 
85  G4double fire();
86 
87  inline G4double fire( G4double mean, G4double stdDev );
88 
89  void fireArray ( const G4int size, G4double* vect);
90  void fireArray ( const G4int size, G4double* vect,
91  G4double mean, G4double stdDev );
92 
93  virtual G4double operator()();
94  virtual G4double operator()( G4double mean, G4double stdDev );
95 
96  // values.
97 
98  static G4bool getFlag() {return set_st;}
99 
100  static void setFlag( G4bool val ) {set_st = val;}
101 
102  G4bool getF() const {return set;}
103 
104  void setF( G4bool val ) {set = val;}
105 
106  // Methods overriding the base class static saveEngineStatus ones,
107  // by adding extra data so that save in one program, then further gaussians,
108  // will produce the identical sequence to restore in another program, then
109  // generating gaussian randoms there
110 
111  static G4double getVal() {return nextGauss_st;}
112 
113  static void setVal( G4double nextVal ) {nextGauss_st = nextVal;}
114 
115  G4double normal();
116 
119 
121 
122 private:
123 
124  G4bool deleteEngine, set;
125  G4double nextGauss;
126 
127  // static data
128  static G4ThreadLocal G4bool set_st;
129  static G4ThreadLocal G4double nextGauss_st;
130 
131 };
132 
133 #include "G4MTRandGauss.icc"
134 
135 #endif
G4double defaultStdDev
virtual G4double operator()()
static void shootArray(const G4int size, G4double *vect, G4double mean=0.0, G4double stdDev=1.0)
G4double defaultMean
G4double fire()
#define G4ThreadLocal
Definition: tls.hh:52
G4MTRandGauss(CLHEP::HepRandomEngine &anEngine, G4double mean=0.0, G4double stdDev=1.0)
int G4int
Definition: G4Types.hh:78
void setF(G4bool val)
G4double normal()
bool G4bool
Definition: G4Types.hh:79
static G4bool getFlag()
virtual ~G4MTRandGauss()
void fireArray(const G4int size, G4double *vect)
static G4double shoot()
double G4double
Definition: G4Types.hh:76
static G4double getVal()
static void setFlag(G4bool val)
CLHEP::HepRandomEngine * localEngine
G4bool getF() const
static void setVal(G4double nextVal)