[816] | 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 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 27 | // |
---|
| 28 | // MODULE: G4SPSRandomGenerator.hh |
---|
| 29 | // |
---|
| 30 | // Version: 1.0 |
---|
| 31 | // Date: 5/02/04 |
---|
| 32 | // Author: Fan Lei |
---|
| 33 | // Organisation: QinetiQ ltd. |
---|
| 34 | // Customer: ESA/ESTEC |
---|
| 35 | // |
---|
| 36 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 37 | // |
---|
| 38 | // CHANGE HISTORY |
---|
| 39 | // -------------- |
---|
| 40 | // |
---|
| 41 | // 26/10/2004 F Lei |
---|
| 42 | // Created separated the theta, phi generators for position distributions. |
---|
| 43 | // |
---|
| 44 | // Version 1.0, 05/02/2004, Fan Lei, Created. |
---|
| 45 | // Based on the G4GeneralParticleSource class in Geant4 v6.0 |
---|
| 46 | // |
---|
| 47 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 48 | // |
---|
| 49 | // Class Description: |
---|
| 50 | // |
---|
| 51 | // Special random number generator used by G4GeneralParticleSource to allow |
---|
| 52 | // biasing applied at the lowest level for all distributions. |
---|
| 53 | // |
---|
| 54 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 55 | // |
---|
| 56 | // MEMBER FUNCTIONS |
---|
| 57 | // ---------------- |
---|
| 58 | // |
---|
| 59 | // G4SPSRandomGenerator () |
---|
| 60 | // Constructor: Initializes variables |
---|
| 61 | // |
---|
| 62 | // ~G4SPSRandomGenerator () |
---|
| 63 | // Destructor: |
---|
| 64 | // |
---|
| 65 | // void SetXBias(G4ThreeVector) |
---|
| 66 | // Allows the user to re-distribute the random |
---|
| 67 | // numbers used to generate x co-ordinates. |
---|
| 68 | // |
---|
| 69 | // void SetYBias(G4ThreeVector) |
---|
| 70 | // Allows the user to re-distribute the random |
---|
| 71 | // numbers used to generate y co-ordinates. |
---|
| 72 | // |
---|
| 73 | // void SetZBias(G4ThreeVector) |
---|
| 74 | // Allows the user to re-distribute the random |
---|
| 75 | // numbers used to generate z co-ordinates. |
---|
| 76 | // |
---|
| 77 | // void SetThetaBias(G4ThreeVector) |
---|
| 78 | // Allows the user to re-distribute the random |
---|
| 79 | // numbers used to generate values of theta. |
---|
| 80 | // |
---|
| 81 | // void SetPhiBias(G4ThreeVector) |
---|
| 82 | // Allows the user to re-distribute the random |
---|
| 83 | // numbers used to generate values of phi. |
---|
| 84 | // |
---|
| 85 | // void SetPosThetaBias(G4ThreeVector) |
---|
| 86 | // Allows the user to re-distribute the random |
---|
| 87 | // numbers used to generate values of theta for position distribution. |
---|
| 88 | // |
---|
| 89 | // void SetPosPhiBias(G4ThreeVector) |
---|
| 90 | // Allows the user to re-distribute the random |
---|
| 91 | // numbers used to generate values of phi for position distribution. |
---|
| 92 | // |
---|
| 93 | // void SetEnergyBias(G4ThreeVector) |
---|
| 94 | // Allows the user to re-distribute the random |
---|
| 95 | // numbers used to generate the energies. |
---|
| 96 | // |
---|
| 97 | // G4double GenRandX() |
---|
| 98 | // Generates the random number for x, with or without biasing. |
---|
| 99 | // |
---|
| 100 | // G4double GenRandY() |
---|
| 101 | // Generates the random number for y, with or without biasing. |
---|
| 102 | // |
---|
| 103 | // G4double GenRandZ() |
---|
| 104 | // Generates the random number for z, with or without biasing. |
---|
| 105 | // |
---|
| 106 | // G4double GenRandTheta() |
---|
| 107 | // Generates the random number for theta, with or without biasing. |
---|
| 108 | // |
---|
| 109 | // G4double GenRandPhi() |
---|
| 110 | // Generates the random number for phi, with or without biasing. |
---|
| 111 | // |
---|
| 112 | // G4double GenRandEnergy() |
---|
| 113 | // Generates the random number for energy, with or without biasing. |
---|
| 114 | // |
---|
| 115 | // G4double GenRandPosTheta() |
---|
| 116 | // Generates the random number for theta, with or without biasing for position distribution. |
---|
| 117 | // |
---|
| 118 | // G4double GenRandPosPhi() |
---|
| 119 | // Generates the random number for phi, with or without biasing for position distribution. |
---|
| 120 | // |
---|
| 121 | // inline G4double GetBiasWeight() |
---|
| 122 | // Returns the weight change after biasing |
---|
| 123 | // |
---|
| 124 | // void ReSetHist(G4String); |
---|
| 125 | // Re-sets the histogram for user defined distribution |
---|
| 126 | // |
---|
| 127 | // void SetVerbosity(G4int) |
---|
| 128 | // Sets the verbosity level. |
---|
| 129 | // |
---|
| 130 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 131 | // |
---|
| 132 | #ifndef G4SPSRandomGenerator_h |
---|
| 133 | #define G4SPSRandomGenerator_h 1 |
---|
| 134 | |
---|
| 135 | #include "G4PhysicsOrderedFreeVector.hh" |
---|
| 136 | #include "G4DataInterpolation.hh" |
---|
| 137 | |
---|
| 138 | class G4SPSRandomGenerator |
---|
| 139 | { |
---|
| 140 | public: |
---|
| 141 | G4SPSRandomGenerator (); |
---|
| 142 | ~G4SPSRandomGenerator (); |
---|
| 143 | |
---|
| 144 | // static G4SPSRandomGenerator* getInstance (); |
---|
| 145 | |
---|
| 146 | // Biasing Methods |
---|
| 147 | void SetXBias(G4ThreeVector); |
---|
| 148 | void SetYBias(G4ThreeVector); |
---|
| 149 | void SetZBias(G4ThreeVector); |
---|
| 150 | void SetThetaBias(G4ThreeVector); |
---|
| 151 | void SetPhiBias(G4ThreeVector); |
---|
| 152 | void SetEnergyBias(G4ThreeVector); |
---|
| 153 | void SetPosThetaBias(G4ThreeVector); |
---|
| 154 | void SetPosPhiBias(G4ThreeVector); |
---|
| 155 | G4double GenRandX(); |
---|
| 156 | G4double GenRandY(); |
---|
| 157 | G4double GenRandZ(); |
---|
| 158 | G4double GenRandTheta(); |
---|
| 159 | G4double GenRandPhi(); |
---|
| 160 | G4double GenRandEnergy(); |
---|
| 161 | G4double GenRandPosTheta(); |
---|
| 162 | G4double GenRandPosPhi(); |
---|
| 163 | |
---|
| 164 | inline void SetIntensityWeight(G4double weight) {bweights[8]=weight;}; |
---|
| 165 | |
---|
| 166 | inline G4double GetBiasWeight() |
---|
| 167 | { return bweights[0]*bweights[1]*bweights[2]*bweights[3]*bweights[4]*bweights[5]*bweights[6]*bweights[7]*bweights[8];}; |
---|
| 168 | |
---|
| 169 | // method to re-set the histograms |
---|
| 170 | void ReSetHist(G4String); |
---|
| 171 | |
---|
| 172 | // Set the verbosity level. |
---|
| 173 | void SetVerbosity(G4int a) {verbosityLevel = a; } ; |
---|
| 174 | |
---|
| 175 | private: |
---|
| 176 | |
---|
| 177 | // static G4SPSRandomGenerator *instance; |
---|
| 178 | |
---|
| 179 | G4bool XBias, IPDFXBias; |
---|
| 180 | G4PhysicsOrderedFreeVector XBiasH; |
---|
| 181 | G4PhysicsOrderedFreeVector IPDFXBiasH; |
---|
| 182 | G4bool YBias, IPDFYBias; |
---|
| 183 | G4PhysicsOrderedFreeVector YBiasH; |
---|
| 184 | G4PhysicsOrderedFreeVector IPDFYBiasH; |
---|
| 185 | G4bool ZBias, IPDFZBias; |
---|
| 186 | G4PhysicsOrderedFreeVector ZBiasH; |
---|
| 187 | G4PhysicsOrderedFreeVector IPDFZBiasH; |
---|
| 188 | G4bool ThetaBias, IPDFThetaBias; |
---|
| 189 | G4PhysicsOrderedFreeVector ThetaBiasH; |
---|
| 190 | G4PhysicsOrderedFreeVector IPDFThetaBiasH; |
---|
| 191 | G4bool PhiBias, IPDFPhiBias; |
---|
| 192 | G4PhysicsOrderedFreeVector PhiBiasH; |
---|
| 193 | G4PhysicsOrderedFreeVector IPDFPhiBiasH; |
---|
| 194 | G4bool EnergyBias, IPDFEnergyBias; |
---|
| 195 | G4PhysicsOrderedFreeVector EnergyBiasH; |
---|
| 196 | G4PhysicsOrderedFreeVector IPDFEnergyBiasH; |
---|
| 197 | G4bool PosThetaBias, IPDFPosThetaBias; |
---|
| 198 | G4PhysicsOrderedFreeVector PosThetaBiasH; |
---|
| 199 | G4PhysicsOrderedFreeVector IPDFPosThetaBiasH; |
---|
| 200 | G4bool PosPhiBias, IPDFPosPhiBias; |
---|
| 201 | G4PhysicsOrderedFreeVector PosPhiBiasH; |
---|
| 202 | G4PhysicsOrderedFreeVector IPDFPosPhiBiasH; |
---|
| 203 | |
---|
| 204 | G4double bweights[9]; //record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights |
---|
| 205 | |
---|
| 206 | // Verbosity |
---|
| 207 | G4int verbosityLevel; |
---|
| 208 | |
---|
| 209 | G4PhysicsOrderedFreeVector ZeroPhysVector ; // for re-set only |
---|
| 210 | |
---|
| 211 | }; |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | #endif |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | |
---|