Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4SPSPosDistribution.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: G4SPSPosDistribution.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 //
41 // 06/06/2014 A Dotti
42 // For thread safety: this is a shared object,
43 // mutex has been added to control access to shared resources (data members).
44 // in Getters and Setters, mutex is NOT used in GenerateOne because it is
45 // assumed that properties are not changed during event loop.
46 //
47 // Version 1.0, 05/02/2004, Fan Lei, Created.
48 // Based on the G4GeneralParticleSource class in Geant4 v6.0
49 //
51 //
52 //
53 // Class Description:
54 //
55 // To generate the position of a primary vertex according to the defined distribution
56 //
58 //
59 // MEMBER FUNCTIONS
60 // ----------------
61 //
62 // G4SPSPosDistribution ()
63 // Constructor: Initializes variables and instantiates the Navigator class
64 //
65 // ~G4SPSPosDistribution ()
66 // Destructor:
67 //
68 // void SetPosDisType(G4String)
69 // Allows user to choose Point, Plane, Surface or Volume source
70 // position distributions.
71 //
72 // void SetPosDisShape(G4String)
73 // Allows the user to choose the particular shape they wish for the
74 // position distribution. Choices are Square, Circle, Ellipse, Rectangle,
75 // Sphere, Ellipsoid, Cylinder, Parallelepiped.
76 //
77 // void SetCentreCoords(G4ThreeVector)
78 // Sets the co-ordinates of the centre of the position distribution.
79 //
80 // void SetPosRot1(G4ThreeVector)
81 // Used to specify the co-ordinate system for the position distribution
82 // along with SetPosRot2. SetPosRot1 sets the vector x' and need not be
83 // a unit vector.
84 //
85 // void SetPosRot2(G4ThreeVector)
86 // Used in connection with SetPosRot1. This sets a vector in the plane
87 // x'y'. By a series of cross products x', y', z' are generated. Again
88 // need not be a unit vector.
89 //
90 // void SetHalfX(G4double)
91 // Sets the half length in x.
92 //
93 // void SetHalfY(G4double)
94 // Sets the half length in y.
95 //
96 // void SetHalfZ(G4double)
97 // Sets the half length in z.
98 //
99 // void SetRadius(G4double)
100 // Sets the radius where appropriate for source distribution shapes.
101 //
102 // void SetRadius0(G4double)
103 // Sets the inner radius where appropriate for source distribution shapes.
104 //
105 // void SetBeamSigmaInR(G4double);
106 // Sets the sigma for 1D beam
107 //
108 // void SetBeamSigmaInX(G4double);
109 // Sets the first sigma for 2D beam
110 //
111 // void SetBeamSigmaInY(G4double);
112 // Sets the second sigma for 2D beam
113 //
114 // void SetParAlpha(G4double)
115 // Sets the angle Alpha in the Parallelepiped shapes.
116 //
117 // void SetParTheta(G4double)
118 // Sets the angle Theta in the Parallelepiped shapes.
119 //
120 // void SetParPhi(G4double)
121 // Sets the angle Phi in the Parallelepiped shapes.
122 //
123 // void ConfineSourceToVolume(G4String)
124 // Used to confine the start positions to a particular volume.
125 //
126 // void SetBiasRndm (G4SPSRandomGenerator* a) { posRndm = a ; };
127 // Sets the biased random number generator
128 //
129 // G4ThreeVector GenerateOne();
130 // Generate one random position
131 //
132 // void SetVerbosity(G4int)
133 // Sets the verbosity level.
134 //
136 //
137 #ifndef G4SPSPosDistribution_h
138 #define G4SPSPosDistribution_h 1
139 
140 #include "G4Navigator.hh"
141 #include "G4SPSRandomGenerator.hh"
142 #include "G4Threading.hh"
143 #include "G4Cache.hh"
144 
157 {
158 public:
161 
171  // methods to create source position dist.
172  void SetPosDisType(G4String); // Point, Plane, Surface, Volume
173  void SetPosDisShape(G4String);
174  // SetPosDisShape - Square, Circle, Annulus, Ellipse, Rectangle, Sphere,
175  // Ellipsoid, Cylinder, Right (parallelepiped).
177  void SetPosRot1(G4ThreeVector);
178  void SetPosRot2(G4ThreeVector);
179  void SetHalfX(G4double);
180  void SetHalfY(G4double);
181  void SetHalfZ(G4double);
182  void SetRadius(G4double);
183  void SetRadius0(G4double);
187  void SetParAlpha(G4double);
188  void SetParTheta(G4double);
189  void SetParPhi(G4double);
191  //
193  // Set the verbosity level.
194  void SetVerbosity(G4int a);
195  //
197 
198  G4String GetPosDisType() const;
199  G4String GetPosDisShape() const;
201  G4double GetHalfX() const;
202  G4double GetHalfY() const;
203  G4double GetHalfZ() const;
204  G4double GetRadius() const;
205 
209  G4String GetSourcePosType() const;
211 
212 private:
213 
214  void GenerateRotationMatrices();
215  // the following routines generate the source position
216  void GeneratePointSource(G4ThreeVector& outoutPos);
217  void GeneratePointsInBeam(G4ThreeVector& outoutPos);
218  void GeneratePointsInPlane(G4ThreeVector& outoutPos);
219  void GeneratePointsOnSurface(G4ThreeVector& outputPos);
220  void GeneratePointsInVolume(G4ThreeVector& outputPos);
221 
222  G4bool IsSourceConfined(G4ThreeVector& outputPos);
223 
224 private:
225  //VERY IMPORTANT:
226  //This is a shared resource, however setters that
227  //changes the parameters via UI commands are by design
228  //thread-safe because only one thread will call these methods
229  //See G4GeneralParticleSourceMessenger constructor for an explanation
230  struct thread_data_t {
231  //Caching of some data
232  G4ThreeVector CSideRefVec1;
233  G4ThreeVector CSideRefVec2;
234  G4ThreeVector CSideRefVec3;
235  G4ThreeVector CParticlePos;
236  thread_data_t();
237  };
238  //Point,Plane,Surface,Volume
239  G4String SourcePosType;
240  //Circle,Square,Rectangle etc..
241  G4String Shape;
242  // Coords of centre of input shape
243  G4ThreeVector CentreCoords;
244  // Unit vectors defining rotation matrix
245  G4ThreeVector Rotx;
246  G4ThreeVector Roty;
247  G4ThreeVector Rotz;
248  //half lengths
249  G4double halfx;
250  G4double halfy;
251  G4double halfz;
252  //Radius for circles or spheres
253  G4double Radius;
254  // The inner radius of an annulus
255  G4double Radius0;
256  // Standard deviation in raduial, x, y for beam type source
257  G4double SR;
258  G4double SX;
259  G4double SY;
260  //Angle for Right Parallellepipeds
261  G4double ParAlpha;
262  G4double ParTheta;
263  G4double ParPhi;
264  //If true confines source distribution to VolName
265  G4bool Confine;
266  G4String VolName;
267  // Verbosity
268  G4int verbosityLevel;
269  G4Cache<thread_data_t> ThreadData;
270  // biased random generator
271  G4Mutex a_mutex;
272  G4SPSRandomGenerator* PosRndm;
273 };
274 
275 
276 #endif
277 
278 
279 
280 
G4ThreeVector GetSideRefVec2() const
void SetBiasRndm(G4SPSRandomGenerator *a)
G4String GetPosDisShape() const
G4double GetRadius() const
int G4int
Definition: G4Types.hh:78
G4double GetHalfY() const
void SetCentreCoords(G4ThreeVector)
G4ThreeVector GetCentreCoords() const
bool G4bool
Definition: G4Types.hh:79
void SetPosRot1(G4ThreeVector)
G4ThreeVector GetSideRefVec3() const
G4int G4Mutex
Definition: G4Threading.hh:173
void SetPosRot2(G4ThreeVector)
G4ThreeVector GetSideRefVec1() const
G4String GetPosDisType() const
G4ThreeVector GetParticlePos() const
G4double GetHalfX() const
double G4double
Definition: G4Types.hh:76
void ConfineSourceToVolume(G4String)
G4String GetSourcePosType() const
G4double GetHalfZ() const