ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4SPSRandomGenerator.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4SPSRandomGenerator.hh
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 "G4ThreeVector.hh"
144 #include "G4Threading.hh"
145 #include "G4Cache.hh"
146 
158 public:
161 
162  // static G4SPSRandomGenerator* getInstance ();
163 
164  // Biasing Methods
165  void SetXBias(G4ThreeVector);
166  void SetYBias(G4ThreeVector);
167  void SetZBias(G4ThreeVector);
173  G4double GenRandX();
174  G4double GenRandY();
175  G4double GenRandZ();
181 
183 
185 
186  // method to re-set the histograms
187  void ReSetHist(G4String);
188 
189  // Set the verbosity level.
190  void SetVerbosity(G4int a);
191 
192 private:
193  //Encapsulate in a struct
194  //to gurantee that correct
195  //initial state is set via constructor
196  struct a_check {
198  a_check() { val = false; }
199  };
200  //See .cc for an explanation of this
201  //in method GenRandX()
234 
235  //G4double alpha; // for biasing energy
236  struct bweights_t {
238  bweights_t();
239  G4double& operator[] (const int i);
240  };
242  //G4double bweights[9]; //record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
243 
244  // Verbosity
246 
247  G4Mutex mutex; //protect shared resources
248 };
249 
250 #endif
251