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 // G4SPSRandomGenerator
0027 //
0028 // Class Description:
0029 //
0030 // Special random number generator used by G4GeneralParticleSource to allow 
0031 // biasing applied at the lowest level for all distributions.
0032 // This is a shared class between threads.
0033 // Only one thread should use the set-methods here.
0034 // Note that this is exactly what is achieved using UI commands.
0035 // If you use the set methods to set defaults in your
0036 // application take care that only one thread is executing them.
0037 // In addition take care of calling these methods before the run is started
0038 // Do not use the setters during the event loop
0039 
0040 // Author: Fan Lei, QinetiQ ltd.
0041 // Customer: ESA/ESTEC
0042 // History:
0043 // - 05/02/2004, Fan Lei - Created.
0044 //     Based on the G4GeneralParticleSource class
0045 // - 06/06/2014, Andrea Dotti
0046 //     Added a mutex to protect access to shared resources (data members).
0047 //     Getters and Setters are mutex'd but not the GetRand* methods,
0048 //     because it is assumed these are called only during the event loop
0049 //     during which the status of this class is invariant
0050 // --------------------------------------------------------------------
0051 #ifndef G4SPSRandomGenerator_hh
0052 #define G4SPSRandomGenerator_hh 1
0053 
0054 #include "G4PhysicsFreeVector.hh"
0055 #include "G4DataInterpolation.hh"
0056 #include "G4ThreeVector.hh"
0057 #include "G4Threading.hh"
0058 #include "G4Cache.hh"
0059 
0060 class G4SPSRandomGenerator
0061 {
0062   public:
0063 
0064     G4SPSRandomGenerator();
0065       // Constructor: initializes variables
0066 
0067    ~G4SPSRandomGenerator();
0068       // Destructor
0069 
0070     // Biasing Methods
0071 
0072     void SetXBias(const G4ThreeVector&);
0073       // Allows the user to re-distribute the random
0074       // numbers used to generate x co-ordinates
0075 
0076     void SetYBias(const G4ThreeVector&);
0077       // Allows the user to re-distribute the random
0078       // numbers used to generate y co-ordinates
0079 
0080     void SetZBias(const G4ThreeVector&);
0081       // Allows the user to re-distribute the random
0082       // numbers used to generate z co-ordinates
0083 
0084     void SetThetaBias(const G4ThreeVector&);
0085       // Allows the user to re-distribute the random
0086       // numbers used to generate values of theta
0087 
0088     void SetPhiBias(const G4ThreeVector&);
0089       // Allows the user to re-distribute the random
0090       // numbers used to generate values of phi
0091 
0092     void SetEnergyBias(const G4ThreeVector&);
0093     // Allows the user to re-distribute the random
0094     // numbers used to generate the energies
0095 
0096     void SetPosThetaBias(const G4ThreeVector&);
0097       // Allows the user to re-distribute the random
0098       // numbers used to generate values of theta for position distribution
0099 
0100     void SetPosPhiBias(const G4ThreeVector&);
0101       // Allows the user to re-distribute the random
0102       // numbers used to generate values of phi for position distribution
0103 
0104     G4double GenRandX();
0105       // Generates the random number for x, with or without biasing
0106 
0107     G4double GenRandY();
0108       // Generates the random number for y, with or without biasing
0109 
0110     G4double GenRandZ();
0111       // Generates the random number for z, with or without biasing
0112 
0113     G4double GenRandTheta();
0114       // Generates the random number for theta, with or without biasing
0115 
0116     G4double GenRandPhi();
0117       // Generates the random number for phi, with or without biasing
0118 
0119     G4double GenRandEnergy();
0120       // Generates the random number for energy, with or without biasing
0121 
0122     G4double GenRandPosTheta();
0123       // Generates the random number for theta, with or without biasing
0124       // for position distribution
0125 
0126     G4double GenRandPosPhi();
0127       // Generates the random number for phi, with or without biasing
0128       // for position distribution
0129 
0130     void SetIntensityWeight(G4double weight);
0131 
0132     G4double GetBiasWeight() const ;
0133       // Returns the weight change after biasing
0134 
0135         // method to re-set the histograms
0136     void ReSetHist(const G4String&);
0137       // Resets the histogram for user defined distribution
0138 
0139     void SetVerbosity(G4int a);
0140       // Sets the verbosity level
0141 
0142   private:
0143 
0144     // Encapsulate in a struct to guarantee that correct
0145     // initial state is set via constructor
0146     //
0147     struct a_check
0148     {
0149       G4bool val;
0150       a_check() { val = false; }
0151     };
0152     
0153     // See .cc for an explanation of this in method GenRandX()
0154     //
0155     G4Cache<a_check> local_IPDFXBias;
0156     G4bool XBias, IPDFXBias;
0157     G4PhysicsFreeVector XBiasH;
0158     G4PhysicsFreeVector IPDFXBiasH;
0159     G4Cache<a_check> local_IPDFYBias;
0160     G4bool YBias, IPDFYBias;
0161     G4PhysicsFreeVector YBiasH;
0162     G4PhysicsFreeVector IPDFYBiasH;
0163     G4Cache<a_check> local_IPDFZBias;
0164     G4bool ZBias, IPDFZBias;
0165     G4PhysicsFreeVector ZBiasH;
0166     G4PhysicsFreeVector IPDFZBiasH;
0167     G4Cache<a_check> local_IPDFThetaBias;
0168     G4bool ThetaBias, IPDFThetaBias;
0169     G4PhysicsFreeVector ThetaBiasH;
0170     G4PhysicsFreeVector IPDFThetaBiasH;
0171     G4Cache<a_check> local_IPDFPhiBias;
0172     G4bool PhiBias, IPDFPhiBias;
0173     G4PhysicsFreeVector PhiBiasH;
0174     G4PhysicsFreeVector IPDFPhiBiasH;
0175     G4Cache<a_check> local_IPDFEnergyBias;
0176     G4bool EnergyBias, IPDFEnergyBias;
0177     G4PhysicsFreeVector EnergyBiasH;
0178     G4PhysicsFreeVector IPDFEnergyBiasH;
0179     G4Cache<a_check> local_IPDFPosThetaBias;
0180     G4bool PosThetaBias, IPDFPosThetaBias;
0181     G4PhysicsFreeVector PosThetaBiasH;
0182     G4PhysicsFreeVector IPDFPosThetaBiasH;
0183     G4Cache<a_check> local_IPDFPosPhiBias;
0184     G4bool PosPhiBias, IPDFPosPhiBias;
0185     G4PhysicsFreeVector PosPhiBiasH;
0186     G4PhysicsFreeVector IPDFPosPhiBiasH;
0187 
0188     struct bweights_t
0189     {
0190       G4double w[9];
0191       bweights_t();
0192       G4double& operator[] (const int i);
0193     };
0194     G4Cache<bweights_t> bweights;
0195       // record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
0196 
0197     G4int verbosityLevel;
0198       // Verbosity
0199  
0200     G4Mutex mutex;
0201       // Protect shared resources
0202 };
0203 
0204 #endif