Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4SPSPosDistribution.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // G4SPSPosDistribution
0027 //
0028 // Class Description:
0029 //
0030 // To generate the position of a primary vertex according to
0031 // the 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 application take care
0035 // 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 // - 06/06/2014, Andrea Dotti
0045 //     Added mutex to control access to shared resources (data members).
0046 //     In Getters and Setters, mutex is NOT used in GenerateOne because
0047 //     it is assumed that properties are not changed during event loop.
0048 // - 13/02/2017, Maxime Chauvin
0049 //     Added surface and volume shape "EllipticCylinder"
0050 // --------------------------------------------------------------------
0051 #ifndef G4SPSPosDistribution_hh
0052 #define G4SPSPosDistribution_hh 1
0053 
0054 #include "G4Navigator.hh"
0055 #include "G4SPSRandomGenerator.hh"
0056 #include "G4Threading.hh"
0057 #include "G4Cache.hh"
0058 
0059 class G4SPSPosDistribution
0060 {
0061   public:
0062 
0063     G4SPSPosDistribution();
0064       // Constructor: initializes data and instantiates the Navigator class
0065 
0066    ~G4SPSPosDistribution();
0067       // Destructor
0068 
0069     // Methods to create source position dist
0070 
0071     void SetPosDisType(const G4String&);
0072       // Allows user to choose Point, Plane, Surface or Volume source
0073       // position distributions
0074 
0075     void SetPosDisShape(const G4String&);
0076       // Allows the user to choose the particular shape they wish for the
0077       // position distribution. Choices are: Square, Circle, Ellipse,
0078       // Rectangle, Sphere, Ellipsoid, Cylinder, Parallelepiped
0079 
0080     void SetCentreCoords(const G4ThreeVector&);
0081       // Sets the coordinates of the centre of the position distribution
0082 
0083     void SetPosRot1(const G4ThreeVector&); 
0084       // Used to specify the coordinate system for the position distribution
0085       // along with SetPosRot2. Sets the vector x' and need not be a unit vector
0086 
0087     void SetPosRot2(const G4ThreeVector&); 
0088       // Used in connection with SetPosRot1. This sets a vector in the plane
0089       // x'y'. By a series of cross products x', y', z' are generated. Again
0090       // need not be a unit vector
0091 
0092     void SetHalfX(G4double);
0093       // Sets the half length in x
0094 
0095     void SetHalfY(G4double);
0096       // Sets the half length in y
0097 
0098     void SetHalfZ(G4double);
0099       // Sets the half length in z
0100 
0101     void SetRadius(G4double);
0102       // Sets the radius where appropriate for source distribution shapes
0103 
0104     void SetRadius0(G4double);
0105       // Sets the inner radius where appropriate for source distribution shapes
0106 
0107     void SetBeamSigmaInR(G4double);
0108       // Sets the sigma for 1D beam
0109 
0110     void SetBeamSigmaInX(G4double);
0111       // Sets the first sigma for 2D beam
0112 
0113     void SetBeamSigmaInY(G4double);
0114       // Sets the second sigma for 2D beam
0115 
0116     void SetParAlpha(G4double);
0117       // Sets the angle Alpha in the Parallelepiped shapes
0118 
0119     void SetParTheta(G4double);
0120       // Sets the angle Theta in the Parallelepiped shapes
0121 
0122     void SetParPhi(G4double);
0123       // Sets the angle Phi in the Parallelepiped shapes
0124 
0125     void ConfineSourceToVolume(const G4String&);
0126       // Used to confine the start positions to a particular volume
0127 
0128     void SetBiasRndm (G4SPSRandomGenerator* a);
0129       // Sets the biased random number generator
0130 
0131     void SetVerbosity(G4int a);
0132       // Sets the verbosity level
0133 
0134     G4ThreeVector GenerateOne();
0135       // Generate one random position
0136 
0137     const G4String& GetPosDisType() const;
0138     const G4String& GetPosDisShape() const;
0139     const G4ThreeVector& GetCentreCoords() const;
0140     G4double GetHalfX() const;
0141     G4double GetHalfY() const;
0142     G4double GetHalfZ() const;
0143     G4double GetRadius() const;
0144     inline G4double GetRadius0() const { return Radius0; }
0145     inline G4double GetParAlpha() const { return ParAlpha; }
0146     inline G4double GetParTheta() const { return ParTheta; }
0147     inline G4double GetParPhi()   const { return ParPhi; }
0148     inline const G4ThreeVector& GetRotx() const { return Rotx; }
0149     inline const G4ThreeVector& GetRoty() const { return Roty; }
0150     inline const G4ThreeVector& GetRotz() const { return Rotz; }
0151     inline G4bool GetConfined() const { return Confine; }
0152     inline const G4String& GetConfineVolume() const { return VolName; }
0153 
0154     const G4ThreeVector& GetSideRefVec1() const;
0155     const G4ThreeVector& GetSideRefVec2() const;
0156     const G4ThreeVector& GetSideRefVec3() const;
0157     const G4String& GetSourcePosType() const;
0158     const G4ThreeVector& GetParticlePos() const;
0159 
0160   private:
0161 
0162     void GenerateRotationMatrices();
0163 
0164     // The following functions generate the source position
0165     //
0166     void GeneratePointSource(G4ThreeVector& outoutPos);
0167     void GeneratePointsInBeam(G4ThreeVector& outoutPos);
0168     void GeneratePointsInPlane(G4ThreeVector& outoutPos);
0169     void GeneratePointsOnSurface(G4ThreeVector& outputPos);
0170     void GeneratePointsInVolume(G4ThreeVector& outputPos);
0171 
0172     G4bool IsSourceConfined(G4ThreeVector& outputPos);
0173 
0174   private:
0175 
0176     // NOTE:
0177     // This is a shared resource, however setters that
0178     // changes the parameters via UI commands are by design
0179     // thread-safe because only one thread will call these methods
0180     // See G4GeneralParticleSourceMessenger constructor for an explanation
0181     //
0182     struct thread_data_t  // Caching of some data
0183     {
0184       G4ThreeVector CSideRefVec1;
0185       G4ThreeVector CSideRefVec2;
0186       G4ThreeVector CSideRefVec3;
0187       G4ThreeVector CParticlePos;
0188       thread_data_t();
0189     };
0190 
0191     G4String SourcePosType;
0192       // Point, Plane, Surface, Volume
0193     G4String Shape;
0194       // Circle, Square, Rectangle, etc...
0195     G4ThreeVector CentreCoords;
0196       // Coordinates of centre of input shape
0197     G4ThreeVector Rotx, Roty, Rotz;
0198       // Unit vectors defining rotation matrix
0199     G4double halfx, halfy, halfz;
0200       // Half lengths
0201     G4double Radius;
0202       // Radius for circles or spheres
0203     G4double Radius0;
0204       // The inner radius of an annulus
0205     G4double SR, SX, SY;
0206       // Standard deviation in radial, x, y for beam type source
0207     G4double ParAlpha,  ParTheta, ParPhi;
0208       // Angle for Right Parallellepipeds
0209     G4bool Confine = false;
0210       // If true confines source distribution to VolName
0211     G4String VolName;
0212       // Volume name
0213     G4int verbosityLevel;
0214       // Verbosity
0215     G4SPSRandomGenerator* PosRndm = nullptr;
0216      // Biased random generator
0217 
0218     G4Cache<thread_data_t> ThreadData;
0219     G4Mutex a_mutex;
0220 };
0221 
0222 #endif