Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SPSAngDistribution.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// G4SPSAngDistribution
27//
28// Class description:
29//
30// To generate the direction of a primary vertex according to the
31// defined distribution. This is a shared class between threads.
32// Only one thread should use the set-methods here.
33// Note that this is exactly what is achieved using UI commands.
34// If you use the set methods to set defaults in your
35// application take care that only one thread is executing them.
36// In addition take care of calling these methods before the run is started
37// Do not use these setters during the event loop.
38
39// Author: Fan Lei, QinetiQ ltd.
40// Customer: ESA/ESTEC
41// History:
42// - 05/02/2004, Fan Lei - Created.
43// Based on the G4GeneralParticleSource class.
44// - 26/10/2004, Fan Lei
45// Added a "focused" option to allow all primary particles pointing to
46// a user specified focusing point.
47// - 06/06/2014, Andrea Dotti, SLAC
48// For thread safety: this is a shared object,
49// Added mutex to control access to shared resources (data members).
50// in Getters and Setters, mutex is NOT used in GenerateOne() because it is
51// assumed that properties are not changed during event loop.
52// --------------------------------------------------------------------
53#ifndef G4SPSAngDistribution_hh
54#define G4SPSAngDistribution_hh 1
55
58#include "G4ParticleMomentum.hh"
59
62
63#include "G4Threading.hh"
64#include "G4AutoLock.hh"
65
67{
68
69 public:
70
72 // Constructor: Initializes variables
74 // Destructor
75
76 // Angular Distribution Methods
77
78 void SetAngDistType(const G4String&);
79 // Used to set the type of angular distribution wanted. Arguments
80 // are iso, cos, beam and user for isotropic, cosine-law, beam and
81 // user-defined respectively.
82
83 void DefineAngRefAxes(const G4String&, const G4ThreeVector&);
84 // Used in a similar way as SetPosRot() to define vectors, one x'
85 // and one in the plane x'y', to create a rotated set of axes for
86 // the angular distribution.
87
89 // Sets the minimum value for the angle theta.
90
91 void SetMinPhi(G4double);
92 // Sets the minimum value for phi.
93
95 // Sets the maximum value for theta.
96
97 void SetMaxPhi(G4double);
98 // Sets the maximum value for phi.
99
101 // Sets the sigma for 1D beam.
102
104 // Sets the first sigma for 2D beam.
105
107 // Sets the second sigma for 2D beam.
108
109 void UserDefAngTheta(const G4ThreeVector&);
110 // This method allows the user to define a histogram in Theta.
111
112 void UserDefAngPhi(const G4ThreeVector&);
113 // This method allows the user to define a histogram in phi.
114
115 void SetFocusPoint(const G4ThreeVector&);
116 void SetParticleMomentumDirection(const G4ParticleMomentum& aMomDirection);
119 // Allows user to have user-defined spectra either with respect to the
120 // coordinate system (default) or with respect to the surface normal.
121
123 // Sets the required position generator, required for determining
124 // the cosine-law distribution.
125
127 // Sets the biased random number generator.
128
130 // Generates one random direction.
131
132 void ReSetHist(const G4String&);
133 // Re-sets the histogram for user defined distribution..
134
135 void SetVerbosity(G4int a);
136 // Sets the verbosity level.
137
138 // Some accessors
139
146
147 private:
148
149 // These methods generate the momentum vectors for the particles.
150
151 void GenerateFocusedFlux(G4ParticleMomentum& outputMom);
152 // This method generates momentum vectors for particles pointing to
153 // an user specified focusing point.
154
155 void GenerateIsotropicFlux(G4ParticleMomentum& outputMom);
156 // This method generates momentum vectors for particles according
157 // to an isotropic distribution.
158
159 void GenerateCosineLawFlux(G4ParticleMomentum& outputMom);
160 // This method generates momentum vectors for particles according
161 // to a cosine-law distribution.
162
163 void GenerateBeamFlux(G4ParticleMomentum& outputMom);
164 void GeneratePlanarFlux(G4ParticleMomentum& outputMom);
165
166 void GenerateUserDefFlux(G4ParticleMomentum& outputMom);
167 // Controls generation of momentum vectors according to user-defined
168 // distributions.
169
170 G4double GenerateUserDefTheta();
171 // Generates the theta angle according to a user-defined distribution.
172
173 G4double GenerateUserDefPhi();
174 // Generates phi according to a user-defined distribution.
175
176 private:
177
178 // Angular distribution variables.
179
180 G4String AngDistType; // String to hold Ang dist type iso, cos, user
181 G4ThreeVector AngRef1, AngRef2, AngRef3; // Reference axes for ang dist
182 G4double MinTheta, MaxTheta, MinPhi, MaxPhi; // min/max theta/phi
183 G4double DR,DX,DY ; // Standard deviations for beam divergence
184 G4double Theta{0.}, Phi{0.}; // Store these for use with DEBUG
185 G4ThreeVector FocusPoint ; // the focusing point in mother coordinates
186 G4bool IPDFThetaExist, IPDFPhiExist; // tell whether IPDF histos exist
187 G4PhysicsFreeVector UDefThetaH; // Theta histo data
188 G4PhysicsFreeVector IPDFThetaH; //Cumulative Theta histogram.
189 G4PhysicsFreeVector UDefPhiH; // Phi histo bins
190 G4PhysicsFreeVector IPDFPhiH; // Cumulative phi histogram.
191 G4String UserDistType; //String to hold user distributions
192 G4bool UserWRTSurface; // G4bool to tell whether user wants distribution wrt
193 // surface normals or co-ordinate system
194 G4bool UserAngRef; // Set to true when user defines a new coordinates
195
196 G4ParticleMomentum particle_momentum_direction;
197
198 G4SPSPosDistribution* posDist = nullptr; // need for the cosine-law distrib.
199 G4SPSRandomGenerator* angRndm = nullptr; // biased random generator
200
201 G4int verbosityLevel; // Verbosity
202
203 G4PhysicsFreeVector ZeroPhysVector; // for re-set only
204
205 G4Mutex mutex; // Protect access to shared resources
206};
207
208#endif
std::mutex G4Mutex
Definition: G4Threading.hh:81
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
void SetBeamSigmaInAngX(G4double)
void SetBeamSigmaInAngR(G4double)
void SetPosDistribution(G4SPSPosDistribution *a)
void UserDefAngTheta(const G4ThreeVector &)
void SetFocusPoint(const G4ThreeVector &)
void SetAngDistType(const G4String &)
void UserDefAngPhi(const G4ThreeVector &)
G4ParticleMomentum GenerateOne()
void SetParticleMomentumDirection(const G4ParticleMomentum &aMomDirection)
void SetBeamSigmaInAngY(G4double)
void ReSetHist(const G4String &)
void SetBiasRndm(G4SPSRandomGenerator *a)
void DefineAngRefAxes(const G4String &, const G4ThreeVector &)