Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:06

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4SPSAngDistribution
0027 //
0028 // Class description:
0029 //
0030 // To generate the direction of a primary vertex according to the
0031 // defined distribution. This is a shared class between threads.
0032 // Only one thread should use the set-methods here.
0033 // Note that this is exactly what is achieved using UI commands.
0034 // If you use the set methods to set defaults in your
0035 // application take care that only one thread is executing them.
0036 // In addition take care of calling these methods before the run is started
0037 // Do not use these setters during the event loop.
0038 
0039 // Author: Fan Lei, QinetiQ ltd.
0040 // Customer: ESA/ESTEC
0041 // History:
0042 // - 05/02/2004, Fan Lei - Created.
0043 //    Based on the G4GeneralParticleSource class.
0044 // - 26/10/2004, Fan Lei
0045 //    Added a "focused" option to allow all primary particles pointing to 
0046 //    a user specified focusing point. 
0047 // - 06/06/2014, Andrea Dotti, SLAC
0048 //    For thread safety: this is a shared object,
0049 //    Added mutex to control access to shared resources (data members).
0050 //    in Getters and Setters, mutex is NOT used in GenerateOne() because it is
0051 //    assumed that properties are not changed during event loop.
0052 // --------------------------------------------------------------------
0053 #ifndef G4SPSAngDistribution_hh
0054 #define G4SPSAngDistribution_hh 1
0055 
0056 #include "G4PhysicsFreeVector.hh"
0057 #include "G4DataInterpolation.hh"
0058 #include "G4ParticleMomentum.hh"
0059 
0060 #include "G4SPSPosDistribution.hh"
0061 #include "G4SPSRandomGenerator.hh"
0062 
0063 #include "G4Threading.hh"
0064 #include "G4AutoLock.hh"
0065 
0066 class G4SPSAngDistribution 
0067 {
0068 
0069   public:
0070 
0071     G4SPSAngDistribution (); 
0072       // Constructor: Initializes variables
0073    ~G4SPSAngDistribution ();
0074       // Destructor
0075 
0076     // Angular Distribution Methods
0077 
0078     void SetAngDistType(const G4String&);
0079       // Used to set the type of angular distribution wanted. Arguments
0080       // are iso, cos, beam and user for isotropic, cosine-law, beam and
0081       // user-defined respectively.
0082 
0083     void DefineAngRefAxes(const G4String&, const G4ThreeVector&);
0084       // Used in a similar way as SetPosRot() to define vectors, one x'
0085       // and one in the plane x'y', to create a rotated set of axes for
0086       // the angular distribution.
0087 
0088     void SetMinTheta(G4double);
0089       // Sets the minimum value for the angle theta.
0090 
0091     void SetMinPhi(G4double);
0092       // Sets the minimum value for phi.  
0093 
0094     void SetMaxTheta(G4double);
0095       // Sets the maximum value for theta.
0096 
0097     void SetMaxPhi(G4double);
0098       // Sets the maximum value for phi.
0099 
0100     void SetBeamSigmaInAngR(G4double);
0101       // Sets the sigma for 1D beam.
0102 
0103     void SetBeamSigmaInAngX(G4double);
0104       // Sets the first sigma for 2D beam.
0105 
0106     void SetBeamSigmaInAngY(G4double);
0107       // Sets the second sigma for 2D beam.
0108 
0109     void UserDefAngTheta(const G4ThreeVector&);
0110       // This method allows the user to define a histogram in Theta.
0111 
0112     void UserDefAngPhi(const G4ThreeVector&);
0113       // This method allows the user to define a histogram in phi.
0114 
0115     void SetFocusPoint(const G4ThreeVector&);
0116     void SetParticleMomentumDirection(const G4ParticleMomentum& aMomDirection);
0117     void SetUseUserAngAxis(G4bool);
0118     void SetUserWRTSurface(G4bool);
0119       // Allows user to have user-defined spectra either with respect to the
0120       // coordinate system (default) or with respect to the surface normal.
0121 
0122     void SetPosDistribution(G4SPSPosDistribution* a);
0123       // Sets the required position generator, required for determining
0124       // the cosine-law distribution.
0125 
0126     void SetBiasRndm(G4SPSRandomGenerator* a);
0127       // Sets the biased random number generator.
0128 
0129     G4ParticleMomentum GenerateOne();
0130       // Generates one random direction.
0131 
0132     void ReSetHist(const G4String&);
0133       // Re-sets the histogram for user defined distribution..
0134 
0135     void SetVerbosity(G4int a);
0136       // Sets the verbosity level.
0137 
0138     // Some accessors
0139 
0140     G4String GetDistType(); 
0141     G4double GetMinTheta();
0142     G4double GetMaxTheta();
0143     G4double GetMinPhi();
0144     G4double GetMaxPhi();
0145     G4ThreeVector GetDirection();
0146 
0147   private:
0148 
0149   // These methods generate the momentum vectors for the particles.
0150 
0151     void GenerateFocusedFlux(G4ParticleMomentum& outputMom);
0152       // This method generates momentum vectors for particles pointing to
0153       // an user specified focusing point.
0154 
0155     void GenerateIsotropicFlux(G4ParticleMomentum& outputMom);
0156       // This method generates momentum vectors for particles according
0157       // to an isotropic distribution.
0158 
0159     void GenerateCosineLawFlux(G4ParticleMomentum& outputMom);
0160       // This method generates momentum vectors for particles according
0161       // to a cosine-law distribution.
0162 
0163     void GenerateBeamFlux(G4ParticleMomentum& outputMom);
0164     void GeneratePlanarFlux(G4ParticleMomentum& outputMom);
0165 
0166     void GenerateUserDefFlux(G4ParticleMomentum& outputMom);
0167       // Controls generation of momentum vectors according to user-defined
0168       // distributions.
0169 
0170     G4double GenerateUserDefTheta();
0171       // Generates the theta angle according to a user-defined distribution.
0172 
0173     G4double GenerateUserDefPhi();
0174       // Generates phi according to a user-defined distribution.
0175 
0176   private:
0177 
0178     // Angular distribution variables.
0179 
0180     G4String AngDistType; // String to hold Ang dist type iso, cos, user
0181     G4ThreeVector AngRef1, AngRef2, AngRef3; // Reference axes for ang dist
0182     G4double MinTheta, MaxTheta, MinPhi, MaxPhi; // min/max theta/phi
0183     G4double DR,DX,DY ; // Standard deviations for beam divergence 
0184     G4double Theta{0.}, Phi{0.}; // Store these for use with DEBUG
0185     G4ThreeVector FocusPoint ; // the focusing point in mother coordinates
0186     G4bool IPDFThetaExist, IPDFPhiExist; // tell whether IPDF histos exist
0187     G4PhysicsFreeVector UDefThetaH; // Theta histo data
0188     G4PhysicsFreeVector IPDFThetaH; //Cumulative Theta histogram.
0189     G4PhysicsFreeVector UDefPhiH; // Phi histo bins
0190     G4PhysicsFreeVector IPDFPhiH; // Cumulative phi histogram.
0191     G4String UserDistType; //String to hold user distributions
0192     G4bool UserWRTSurface; // G4bool to tell whether user wants distribution wrt
0193                            // surface normals or co-ordinate system
0194     G4bool UserAngRef; // Set to true when user defines a new coordinates
0195 
0196     G4ParticleMomentum particle_momentum_direction;
0197 
0198     G4SPSPosDistribution* posDist = nullptr; // need for the cosine-law distrib.
0199     G4SPSRandomGenerator* angRndm = nullptr; // biased random generator
0200 
0201     G4int verbosityLevel; // Verbosity
0202 
0203     G4PhysicsFreeVector ZeroPhysVector; // for re-set only
0204 
0205     G4Mutex mutex; // Protect access to shared resources
0206 };
0207 
0208 #endif