Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4SPSRandomGenerator.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 //
27 //
28 // MODULE: G4SPSRandomGenerator.hh
29 //
30 // Version: 1.0
31 // Date: 5/02/04
32 // Author: Fan Lei
33 // Organisation: QinetiQ ltd.
34 // Customer: ESA/ESTEC
35 //
37 //
38 // CHANGE HISTORY
39 // --------------
40 // 06/06/2014 A Dotti
41 // Note on thread safety: added a mutex to protect access to shared
42 // resources (data members).
43 // Getters and Setters are mutex'd but not the GetRand* methods,
44 // because it is assumed these are called only during the event loop
45 // during which the status of this class is invariant.
46 //
47 // 26/10/2004 F Lei
48 // Created separated the theta, phi generators for position distributions.
49 //
50 // Version 1.0, 05/02/2004, Fan Lei, Created.
51 // Based on the G4GeneralParticleSource class in Geant4 v6.0
52 //
54 //
55 // Class Description:
56 //
57 // Special random number generator used by G4GeneralParticleSource to allow
58 // biasing applied at the lowest level for all distributions.
59 //
61 //
62 // MEMBER FUNCTIONS
63 // ----------------
64 //
65 // G4SPSRandomGenerator ()
66 // Constructor: Initializes variables
67 //
68 // ~G4SPSRandomGenerator ()
69 // Destructor:
70 //
71 // void SetXBias(G4ThreeVector)
72 // Allows the user to re-distribute the random
73 // numbers used to generate x co-ordinates.
74 //
75 // void SetYBias(G4ThreeVector)
76 // Allows the user to re-distribute the random
77 // numbers used to generate y co-ordinates.
78 //
79 // void SetZBias(G4ThreeVector)
80 // Allows the user to re-distribute the random
81 // numbers used to generate z co-ordinates.
82 //
83 // void SetThetaBias(G4ThreeVector)
84 // Allows the user to re-distribute the random
85 // numbers used to generate values of theta.
86 //
87 // void SetPhiBias(G4ThreeVector)
88 // Allows the user to re-distribute the random
89 // numbers used to generate values of phi.
90 //
91 // void SetPosThetaBias(G4ThreeVector)
92 // Allows the user to re-distribute the random
93 // numbers used to generate values of theta for position distribution.
94 //
95 // void SetPosPhiBias(G4ThreeVector)
96 // Allows the user to re-distribute the random
97 // numbers used to generate values of phi for position distribution.
98 //
99 // void SetEnergyBias(G4ThreeVector)
100 // Allows the user to re-distribute the random
101 // numbers used to generate the energies.
102 //
103 // G4double GenRandX()
104 // Generates the random number for x, with or without biasing.
105 //
106 // G4double GenRandY()
107 // Generates the random number for y, with or without biasing.
108 //
109 // G4double GenRandZ()
110 // Generates the random number for z, with or without biasing.
111 //
112 // G4double GenRandTheta()
113 // Generates the random number for theta, with or without biasing.
114 //
115 // G4double GenRandPhi()
116 // Generates the random number for phi, with or without biasing.
117 //
118 // G4double GenRandEnergy()
119 // Generates the random number for energy, with or without biasing.
120 //
121 // G4double GenRandPosTheta()
122 // Generates the random number for theta, with or without biasing for position distribution.
123 //
124 // G4double GenRandPosPhi()
125 // Generates the random number for phi, with or without biasing for position distribution.
126 //
127 // inline G4double GetBiasWeight()
128 // Returns the weight change after biasing
129 //
130 // void ReSetHist(G4String);
131 // Re-sets the histogram for user defined distribution
132 //
133 // void SetVerbosity(G4int)
134 // Sets the verbosity level.
135 //
137 //
138 #ifndef G4SPSRandomGenerator_h
139 #define G4SPSRandomGenerator_h 1
140 
142 #include "G4DataInterpolation.hh"
143 #include "G4Threading.hh"
144 #include "G4Cache.hh"
145 
157 public:
160 
161  // static G4SPSRandomGenerator* getInstance ();
162 
163  // Biasing Methods
164  void SetXBias(G4ThreeVector);
165  void SetYBias(G4ThreeVector);
166  void SetZBias(G4ThreeVector);
172  G4double GenRandX();
173  G4double GenRandY();
174  G4double GenRandZ();
180 
181  void SetIntensityWeight(G4double weight);
182 
184 
185  // method to re-set the histograms
186  void ReSetHist(G4String);
187 
188  // Set the verbosity level.
189  void SetVerbosity(G4int a);
190 
191 private:
192  //Encapsulate in a struct
193  //to gurantee that correct
194  //initial state is set via constructor
195  struct a_check {
196  G4bool val;
197  a_check() { val = false; }
198  };
199  //See .cc for an explanation of this
200  //in method GenRandX()
201  G4Cache<a_check> local_IPDFXBias;
202  G4bool XBias, IPDFXBias;
204  G4PhysicsOrderedFreeVector IPDFXBiasH;
205  G4Cache<a_check> local_IPDFYBias;
206  G4bool YBias, IPDFYBias;
208  G4PhysicsOrderedFreeVector IPDFYBiasH;
209  G4Cache<a_check> local_IPDFZBias;
210  G4bool ZBias, IPDFZBias;
212  G4PhysicsOrderedFreeVector IPDFZBiasH;
213  G4Cache<a_check> local_IPDFThetaBias;
214  G4bool ThetaBias, IPDFThetaBias;
215  G4PhysicsOrderedFreeVector ThetaBiasH;
216  G4PhysicsOrderedFreeVector IPDFThetaBiasH;
217  G4Cache<a_check> local_IPDFPhiBias;
218  G4bool PhiBias, IPDFPhiBias;
220  G4PhysicsOrderedFreeVector IPDFPhiBiasH;
221  G4Cache<a_check> local_IPDFEnergyBias;
222  G4bool EnergyBias, IPDFEnergyBias;
223  G4PhysicsOrderedFreeVector EnergyBiasH;
224  G4PhysicsOrderedFreeVector IPDFEnergyBiasH;
225  G4Cache<a_check> local_IPDFPosThetaBias;
226  G4bool PosThetaBias, IPDFPosThetaBias;
227  G4PhysicsOrderedFreeVector PosThetaBiasH;
228  G4PhysicsOrderedFreeVector IPDFPosThetaBiasH;
229  G4Cache<a_check> local_IPDFPosPhiBias;
230  G4bool PosPhiBias, IPDFPosPhiBias;
231  G4PhysicsOrderedFreeVector PosPhiBiasH;
232  G4PhysicsOrderedFreeVector IPDFPosPhiBiasH;
233 
234  //G4double alpha; // for biasing energy
235  struct bweights_t {
236  G4double w[9];
237  bweights_t();
238  G4double& operator[] (const int i);
239  };
240  G4Cache<bweights_t> bweights;
241  //G4double bweights[9]; //record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
242 
243  // Verbosity
244  G4int verbosityLevel;
245 
246  G4Mutex mutex; //protect shared resources
247 };
248 
249 #endif
250 
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
void SetEnergyBias(G4ThreeVector)
void SetYBias(G4ThreeVector)
int G4int
Definition: G4Types.hh:78
void SetPosThetaBias(G4ThreeVector)
void SetThetaBias(G4ThreeVector)
void SetZBias(G4ThreeVector)
void SetXBias(G4ThreeVector)
bool G4bool
Definition: G4Types.hh:79
void SetPhiBias(G4ThreeVector)
G4int G4Mutex
Definition: G4Threading.hh:173
void SetIntensityWeight(G4double weight)
double G4double
Definition: G4Types.hh:76
void SetPosPhiBias(G4ThreeVector)