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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 
 56 #include "G4PhysicsFreeVector.hh"
 57 #include "G4DataInterpolation.hh"
 58 #include "G4ParticleMomentum.hh"
 59 
 60 #include "G4SPSPosDistribution.hh"
 61 #include "G4SPSRandomGenerator.hh"
 62 
 63 #include "G4Threading.hh"
 64 #include "G4AutoLock.hh"
 65 
 66 class G4SPSAngDistribution 
 67 {
 68 
 69   public:
 70 
 71     G4SPSAngDistribution (); 
 72       // Constructor: Initializes variables
 73    ~G4SPSAngDistribution ();
 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 
 88     void SetMinTheta(G4double);
 89       // Sets the minimum value for the angle theta.
 90 
 91     void SetMinPhi(G4double);
 92       // Sets the minimum value for phi.  
 93 
 94     void SetMaxTheta(G4double);
 95       // Sets the maximum value for theta.
 96 
 97     void SetMaxPhi(G4double);
 98       // Sets the maximum value for phi.
 99 
100     void SetBeamSigmaInAngR(G4double);
101       // Sets the sigma for 1D beam.
102 
103     void SetBeamSigmaInAngX(G4double);
104       // Sets the first sigma for 2D beam.
105 
106     void SetBeamSigmaInAngY(G4double);
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);
117     void SetUseUserAngAxis(G4bool);
118     void SetUserWRTSurface(G4bool);
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 
122     void SetPosDistribution(G4SPSPosDistribution* a);
123       // Sets the required position generator, required for determining
124       // the cosine-law distribution.
125 
126     void SetBiasRndm(G4SPSRandomGenerator* a);
127       // Sets the biased random number generator.
128 
129     G4ParticleMomentum GenerateOne();
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 
140     G4String GetDistType(); 
141     G4double GetMinTheta();
142     G4double GetMaxTheta();
143     G4double GetMinPhi();
144     G4double GetMaxPhi();
145     G4ThreeVector GetDirection();
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
209