Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4SPSRandomGenerator << 23 /////////////////////////////////////////////////////////////////////////////// >> 24 // >> 25 // MODULE: G4SPSRandomGenerator.hh >> 26 // >> 27 // Version: 1.0 >> 28 // Date: 5/02/04 >> 29 // Author: Fan Lei >> 30 // Organisation: QinetiQ ltd. >> 31 // Customer: ESA/ESTEC >> 32 // >> 33 /////////////////////////////////////////////////////////////////////////////// >> 34 // >> 35 // CHANGE HISTORY >> 36 // -------------- >> 37 // >> 38 // >> 39 // Version 1.0, 05/02/2004, Fan Lei, Created. >> 40 // Based on the G4GeneralParticleSource class in Geant4 v6.0 >> 41 // >> 42 /////////////////////////////////////////////////////////////////////////////// 27 // 43 // 28 // Class Description: 44 // Class Description: 29 // 45 // 30 // Special random number generator used by G4G 46 // Special random number generator used by G4GeneralParticleSource to allow 31 // biasing applied at the lowest level for all 47 // biasing applied at the lowest level for all distributions. 32 // This is a shared class between threads. << 48 // 33 // Only one thread should use the set-methods << 49 /////////////////////////////////////////////////////////////////////////////// 34 // Note that this is exactly what is achieved << 50 // 35 // If you use the set methods to set defaults << 51 // MEMBER FUNCTIONS 36 // application take care that only one thread << 52 // ---------------- 37 // In addition take care of calling these meth << 53 // 38 // Do not use the setters during the event loo << 54 // G4SPSRandomGenerator () 39 << 55 // Constructor: Initializes variables 40 // Author: Fan Lei, QinetiQ ltd. << 56 // 41 // Customer: ESA/ESTEC << 57 // ~G4SPSRandomGenerator () 42 // History: << 58 // Destructor: 43 // - 05/02/2004, Fan Lei - Created. << 59 // 44 // Based on the G4GeneralParticleSource cl << 60 // void SetXBias(G4ThreeVector) 45 // - 06/06/2014, Andrea Dotti << 61 // Allows the user to re-distribute the random 46 // Added a mutex to protect access to shar << 62 // numbers used to generate x co-ordinates. 47 // Getters and Setters are mutex'd but not << 63 // 48 // because it is assumed these are called << 64 // void SetYBias(G4ThreeVector) 49 // during which the status of this class i << 65 // Allows the user to re-distribute the random 50 // ------------------------------------------- << 66 // numbers used to generate y co-ordinates. 51 #ifndef G4SPSRandomGenerator_hh << 67 // 52 #define G4SPSRandomGenerator_hh 1 << 68 // void SetZBias(G4ThreeVector) >> 69 // Allows the user to re-distribute the random >> 70 // numbers used to generate z co-ordinates. >> 71 // >> 72 // void SetThetaBias(G4ThreeVector) >> 73 // Allows the user to re-distribute the random >> 74 // numbers used to generate values of theta. >> 75 // >> 76 // void SetPhiBias(G4ThreeVector) >> 77 // Allows the user to re-distribute the random >> 78 // numbers used to generate values of phi. >> 79 // >> 80 // void SetEnergyBias(G4ThreeVector) >> 81 // Allows the user to re-distribute the random >> 82 // numbers used to generate the energies. >> 83 // >> 84 // G4double GenRandX() >> 85 // Generates the random number for x, with or without biasing. >> 86 // >> 87 // G4double GenRandY() >> 88 // Generates the random number for y, with or without biasing. >> 89 // >> 90 // G4double GenRandZ() >> 91 // Generates the random number for z, with or without biasing. >> 92 // >> 93 // G4double GenRandTheta() >> 94 // Generates the random number for theta, with or without biasing. >> 95 // >> 96 // G4double GenRandPhi() >> 97 // Generates the random number for phi, with or without biasing. >> 98 // >> 99 // G4double GenRandEnergy() >> 100 // Generates the random number for energy, with or without biasing. >> 101 // >> 102 // inline G4double GetBiasWeight() >> 103 // Returns the weight change after biasing >> 104 // >> 105 // void ReSetHist(G4String); >> 106 // Re-sets the histogram for user defined distribution >> 107 // >> 108 // void SetVerbosity(G4int) >> 109 // Sets the verbosity level. >> 110 // >> 111 /////////////////////////////////////////////////////////////////////////////// >> 112 // >> 113 #ifndef G4SPSRandomGenerator_h >> 114 #define G4SPSRandomGenerator_h 1 53 115 54 #include "G4PhysicsFreeVector.hh" << 116 #include "G4PhysicsOrderedFreeVector.hh" 55 #include "G4DataInterpolation.hh" 117 #include "G4DataInterpolation.hh" 56 #include "G4ThreeVector.hh" << 57 #include "G4Threading.hh" << 58 #include "G4Cache.hh" << 59 118 60 class G4SPSRandomGenerator 119 class G4SPSRandomGenerator 61 { 120 { 62 public: << 121 public: >> 122 G4SPSRandomGenerator (); >> 123 ~G4SPSRandomGenerator (); >> 124 >> 125 // static G4SPSRandomGenerator* getInstance (); >> 126 >> 127 // Biasing Methods >> 128 void SetXBias(G4ThreeVector); >> 129 void SetYBias(G4ThreeVector); >> 130 void SetZBias(G4ThreeVector); >> 131 void SetThetaBias(G4ThreeVector); >> 132 void SetPhiBias(G4ThreeVector); >> 133 void SetEnergyBias(G4ThreeVector); >> 134 G4double GenRandX(); >> 135 G4double GenRandY(); >> 136 G4double GenRandZ(); >> 137 G4double GenRandTheta(); >> 138 G4double GenRandPhi(); >> 139 G4double GenRandEnergy(); >> 140 >> 141 inline G4double GetBiasWeight() >> 142 { return bweights[0]*bweights[1]*bweights[2]*bweights[3]*bweights[4]*bweights[5];}; >> 143 >> 144 // method to re-set the histograms >> 145 void ReSetHist(G4String); 63 146 64 G4SPSRandomGenerator(); << 147 // Set the verbosity level. 65 // Constructor: initializes variables << 148 void SetVerbosity(G4int a) {verbosityLevel = a; } ; 66 149 67 ~G4SPSRandomGenerator(); << 150 private: 68 // Destructor << 69 151 70 // Biasing Methods << 152 // static G4SPSRandomGenerator *instance; 71 << 153 72 void SetXBias(const G4ThreeVector&); << 154 G4bool XBias, IPDFXBias; 73 // Allows the user to re-distribute the << 155 G4PhysicsOrderedFreeVector XBiasH; 74 // numbers used to generate x co-ordinat << 156 G4PhysicsOrderedFreeVector IPDFXBiasH; 75 << 157 G4bool YBias, IPDFYBias; 76 void SetYBias(const G4ThreeVector&); << 158 G4PhysicsOrderedFreeVector YBiasH; 77 // Allows the user to re-distribute the << 159 G4PhysicsOrderedFreeVector IPDFYBiasH; 78 // numbers used to generate y co-ordinat << 160 G4bool ZBias, IPDFZBias; 79 << 161 G4PhysicsOrderedFreeVector ZBiasH; 80 void SetZBias(const G4ThreeVector&); << 162 G4PhysicsOrderedFreeVector IPDFZBiasH; 81 // Allows the user to re-distribute the << 163 G4bool ThetaBias, IPDFThetaBias; 82 // numbers used to generate z co-ordinat << 164 G4PhysicsOrderedFreeVector ThetaBiasH; 83 << 165 G4PhysicsOrderedFreeVector IPDFThetaBiasH; 84 void SetThetaBias(const G4ThreeVector&); << 166 G4bool PhiBias, IPDFPhiBias; 85 // Allows the user to re-distribute the << 167 G4PhysicsOrderedFreeVector PhiBiasH; 86 // numbers used to generate values of th << 168 G4PhysicsOrderedFreeVector IPDFPhiBiasH; 87 << 169 G4bool EnergyBias, IPDFEnergyBias; 88 void SetPhiBias(const G4ThreeVector&); << 170 G4PhysicsOrderedFreeVector EnergyBiasH; 89 // Allows the user to re-distribute the << 171 G4PhysicsOrderedFreeVector IPDFEnergyBiasH; 90 // numbers used to generate values of ph << 91 << 92 void SetEnergyBias(const G4ThreeVector&); << 93 // Allows the user to re-distribute the ra << 94 // numbers used to generate the energies << 95 << 96 void SetPosThetaBias(const G4ThreeVector&) << 97 // Allows the user to re-distribute the << 98 // numbers used to generate values of th << 99 << 100 void SetPosPhiBias(const G4ThreeVector&); << 101 // Allows the user to re-distribute the << 102 // numbers used to generate values of ph << 103 << 104 G4double GenRandX(); << 105 // Generates the random number for x, wi << 106 << 107 G4double GenRandY(); << 108 // Generates the random number for y, wi << 109 << 110 G4double GenRandZ(); << 111 // Generates the random number for z, wi << 112 << 113 G4double GenRandTheta(); << 114 // Generates the random number for theta << 115 << 116 G4double GenRandPhi(); << 117 // Generates the random number for phi, << 118 << 119 G4double GenRandEnergy(); << 120 // Generates the random number for energ << 121 << 122 G4double GenRandPosTheta(); << 123 // Generates the random number for theta << 124 // for position distribution << 125 << 126 G4double GenRandPosPhi(); << 127 // Generates the random number for phi, << 128 // for position distribution << 129 << 130 void SetIntensityWeight(G4double weight); << 131 << 132 G4double GetBiasWeight() const ; << 133 // Returns the weight change after biasi << 134 << 135 // method to re-set the histograms << 136 void ReSetHist(const G4String&); << 137 // Resets the histogram for user defined << 138 << 139 void SetVerbosity(G4int a); << 140 // Sets the verbosity level << 141 << 142 private: << 143 << 144 // Encapsulate in a struct to guarantee th << 145 // initial state is set via constructor << 146 // << 147 struct a_check << 148 { << 149 G4bool val; << 150 a_check() { val = false; } << 151 }; << 152 << 153 // See .cc for an explanation of this in m << 154 // << 155 G4Cache<a_check> local_IPDFXBias; << 156 G4bool XBias, IPDFXBias; << 157 G4PhysicsFreeVector XBiasH; << 158 G4PhysicsFreeVector IPDFXBiasH; << 159 G4Cache<a_check> local_IPDFYBias; << 160 G4bool YBias, IPDFYBias; << 161 G4PhysicsFreeVector YBiasH; << 162 G4PhysicsFreeVector IPDFYBiasH; << 163 G4Cache<a_check> local_IPDFZBias; << 164 G4bool ZBias, IPDFZBias; << 165 G4PhysicsFreeVector ZBiasH; << 166 G4PhysicsFreeVector IPDFZBiasH; << 167 G4Cache<a_check> local_IPDFThetaBias; << 168 G4bool ThetaBias, IPDFThetaBias; << 169 G4PhysicsFreeVector ThetaBiasH; << 170 G4PhysicsFreeVector IPDFThetaBiasH; << 171 G4Cache<a_check> local_IPDFPhiBias; << 172 G4bool PhiBias, IPDFPhiBias; << 173 G4PhysicsFreeVector PhiBiasH; << 174 G4PhysicsFreeVector IPDFPhiBiasH; << 175 G4Cache<a_check> local_IPDFEnergyBias; << 176 G4bool EnergyBias, IPDFEnergyBias; << 177 G4PhysicsFreeVector EnergyBiasH; << 178 G4PhysicsFreeVector IPDFEnergyBiasH; << 179 G4Cache<a_check> local_IPDFPosThetaBias; << 180 G4bool PosThetaBias, IPDFPosThetaBias; << 181 G4PhysicsFreeVector PosThetaBiasH; << 182 G4PhysicsFreeVector IPDFPosThetaBiasH; << 183 G4Cache<a_check> local_IPDFPosPhiBias; << 184 G4bool PosPhiBias, IPDFPosPhiBias; << 185 G4PhysicsFreeVector PosPhiBiasH; << 186 G4PhysicsFreeVector IPDFPosPhiBiasH; << 187 << 188 struct bweights_t << 189 { << 190 G4double w[9]; << 191 bweights_t(); << 192 G4double& operator[] (const int i); << 193 }; << 194 G4Cache<bweights_t> bweights; << 195 // record x,y,z,theta,phi,energy,posThet << 196 172 197 G4int verbosityLevel; << 173 G4double bweights[6]; //record x,y,z,theta,phi,energy weights 198 // Verbosity << 174 199 << 175 // Verbosity 200 G4Mutex mutex; << 176 G4int verbosityLevel; 201 // Protect shared resources << 177 >> 178 G4PhysicsOrderedFreeVector ZeroPhysVector ; // for re-set only >> 179 202 }; 180 }; 203 181 >> 182 204 #endif 183 #endif >> 184 >> 185 >> 186 >> 187 205 188