[968] | 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 | // |
---|
[1007] | 26 | // $Id: G4LivermoreRayleighModel.cc,v 1.1 2008/10/30 14:16:35 sincerti Exp $ |
---|
| 27 | // GEANT4 tag $Name: geant4-09-02 $ |
---|
[968] | 28 | // |
---|
| 29 | |
---|
| 30 | #include "G4LivermoreRayleighModel.hh" |
---|
| 31 | |
---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 33 | |
---|
| 34 | using namespace std; |
---|
| 35 | |
---|
| 36 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 37 | |
---|
| 38 | G4LivermoreRayleighModel::G4LivermoreRayleighModel(const G4ParticleDefinition*, |
---|
| 39 | const G4String& nam) |
---|
[1007] | 40 | :G4VEmModel(nam),isInitialised(false) |
---|
[968] | 41 | { |
---|
| 42 | lowEnergyLimit = 250 * eV; // SI - Could be 10 eV ? |
---|
| 43 | highEnergyLimit = 100 * GeV; |
---|
| 44 | |
---|
| 45 | SetLowEnergyLimit(lowEnergyLimit); |
---|
| 46 | SetHighEnergyLimit(highEnergyLimit); |
---|
| 47 | // |
---|
| 48 | verboseLevel= 0; |
---|
| 49 | // Verbosity scale: |
---|
| 50 | // 0 = nothing |
---|
| 51 | // 1 = warning for energy non-conservation |
---|
| 52 | // 2 = details of energy budget |
---|
| 53 | // 3 = calculation of cross sections, file openings, sampling of atoms |
---|
| 54 | // 4 = entering in methods |
---|
| 55 | |
---|
| 56 | G4cout << "Livermore Rayleigh is constructed " << G4endl |
---|
| 57 | << "Energy range: " |
---|
| 58 | << lowEnergyLimit / keV << " keV - " |
---|
| 59 | << highEnergyLimit / GeV << " GeV" |
---|
| 60 | << G4endl; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 64 | |
---|
| 65 | G4LivermoreRayleighModel::~G4LivermoreRayleighModel() |
---|
| 66 | { |
---|
[1007] | 67 | delete meanFreePathTable; |
---|
| 68 | delete crossSectionHandler; |
---|
| 69 | delete formFactorData; |
---|
[968] | 70 | } |
---|
| 71 | |
---|
| 72 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 73 | |
---|
| 74 | void G4LivermoreRayleighModel::Initialise(const G4ParticleDefinition* particle, |
---|
| 75 | const G4DataVector& cuts) |
---|
| 76 | { |
---|
| 77 | if (verboseLevel > 3) |
---|
| 78 | G4cout << "Calling G4LivermoreRayleighModel::Initialise()" << G4endl; |
---|
| 79 | |
---|
[1007] | 80 | InitialiseElementSelectors(particle,cuts); |
---|
| 81 | |
---|
[968] | 82 | // Energy limits |
---|
| 83 | |
---|
| 84 | if (LowEnergyLimit() < lowEnergyLimit) |
---|
| 85 | { |
---|
| 86 | G4cout << "G4LivermoreRayleighModel: low energy limit increased from " << |
---|
| 87 | LowEnergyLimit()/eV << " eV to " << lowEnergyLimit << " eV" << G4endl; |
---|
| 88 | SetLowEnergyLimit(lowEnergyLimit); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | if (HighEnergyLimit() > highEnergyLimit) |
---|
| 92 | { |
---|
| 93 | G4cout << "G4LivermoreRayleighModel: high energy limit decreased from " << |
---|
| 94 | HighEnergyLimit()/GeV << " GeV to " << highEnergyLimit << " GeV" << G4endl; |
---|
| 95 | SetHighEnergyLimit(highEnergyLimit); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | // Data are read for all materials |
---|
| 99 | |
---|
| 100 | crossSectionHandler = new G4CrossSectionHandler; |
---|
| 101 | crossSectionHandler->Clear(); |
---|
| 102 | G4String crossSectionFile = "rayl/re-cs-"; |
---|
| 103 | crossSectionHandler->LoadData(crossSectionFile); |
---|
| 104 | |
---|
| 105 | meanFreePathTable = 0; |
---|
| 106 | meanFreePathTable = crossSectionHandler->BuildMeanFreePathForMaterials(); |
---|
| 107 | |
---|
| 108 | G4VDataSetAlgorithm* ffInterpolation = new G4LogLogInterpolation; |
---|
| 109 | G4String formFactorFile = "rayl/re-ff-"; |
---|
| 110 | formFactorData = new G4CompositeEMDataSet(ffInterpolation,1.,1.); |
---|
| 111 | formFactorData->LoadData(formFactorFile); |
---|
| 112 | |
---|
| 113 | // |
---|
| 114 | |
---|
| 115 | if (verboseLevel > 2) |
---|
| 116 | G4cout << "Loaded cross section files for Livermore Rayleigh model" << G4endl; |
---|
| 117 | |
---|
| 118 | G4cout << "Livermore Rayleigh model is initialized " << G4endl |
---|
| 119 | << "Energy range: " |
---|
| 120 | << LowEnergyLimit() / keV << " keV - " |
---|
| 121 | << HighEnergyLimit() / GeV << " GeV" |
---|
| 122 | << G4endl; |
---|
| 123 | |
---|
| 124 | if(isInitialised) return; |
---|
| 125 | |
---|
| 126 | if(pParticleChange) |
---|
| 127 | fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange); |
---|
| 128 | else |
---|
| 129 | fParticleChange = new G4ParticleChangeForGamma(); |
---|
| 130 | |
---|
| 131 | isInitialised = true; |
---|
| 132 | |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 136 | |
---|
| 137 | G4double G4LivermoreRayleighModel::ComputeCrossSectionPerAtom( |
---|
| 138 | const G4ParticleDefinition*, |
---|
| 139 | G4double GammaEnergy, |
---|
| 140 | G4double Z, G4double, |
---|
| 141 | G4double, G4double) |
---|
| 142 | { |
---|
| 143 | if (verboseLevel > 3) |
---|
| 144 | G4cout << "Calling CrossSectionPerAtom() of G4LivermoreRayleighModel" << G4endl; |
---|
| 145 | |
---|
| 146 | G4double cs = crossSectionHandler->FindValue(G4int(Z), GammaEnergy); |
---|
| 147 | return cs; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 151 | |
---|
| 152 | void G4LivermoreRayleighModel::SampleSecondaries(std::vector<G4DynamicParticle*>* /*fvect*/, |
---|
| 153 | const G4MaterialCutsCouple* couple, |
---|
| 154 | const G4DynamicParticle* aDynamicGamma, |
---|
| 155 | G4double, |
---|
| 156 | G4double) |
---|
| 157 | { |
---|
| 158 | if (verboseLevel > 3) |
---|
| 159 | G4cout << "Calling SampleSecondaries() of G4LivermoreRayleighModel" << G4endl; |
---|
| 160 | |
---|
| 161 | G4double photonEnergy0 = aDynamicGamma->GetKineticEnergy(); |
---|
| 162 | |
---|
| 163 | if (photonEnergy0 <= lowEnergyLimit) |
---|
| 164 | { |
---|
| 165 | fParticleChange->ProposeTrackStatus(fStopAndKill); |
---|
| 166 | fParticleChange->SetProposedKineticEnergy(0.); |
---|
| 167 | fParticleChange->ProposeLocalEnergyDeposit(photonEnergy0); |
---|
[1007] | 168 | // SI - IS THE FOLLOWING RETURN NECESSARY ? |
---|
[968] | 169 | return ; |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | G4ParticleMomentum photonDirection0 = aDynamicGamma->GetMomentumDirection(); |
---|
| 173 | |
---|
| 174 | // Select randomly one element in the current material |
---|
| 175 | G4int Z = crossSectionHandler->SelectRandomAtom(couple,photonEnergy0); |
---|
| 176 | |
---|
| 177 | // Sample the angle of the scattered photon |
---|
| 178 | |
---|
| 179 | G4double wlPhoton = h_Planck*c_light/photonEnergy0; |
---|
| 180 | |
---|
| 181 | G4double gReject,x,dataFormFactor; |
---|
| 182 | G4double randomFormFactor; |
---|
| 183 | G4double cosTheta; |
---|
| 184 | G4double sinTheta; |
---|
| 185 | G4double fcostheta; |
---|
| 186 | |
---|
| 187 | do |
---|
| 188 | { |
---|
| 189 | do |
---|
| 190 | { |
---|
| 191 | cosTheta = 2. * G4UniformRand() - 1.; |
---|
| 192 | fcostheta = ( 1. + cosTheta*cosTheta)/2.; |
---|
| 193 | } while (fcostheta < G4UniformRand()); |
---|
| 194 | |
---|
| 195 | G4double sinThetaHalf = std::sqrt((1. - cosTheta) / 2.); |
---|
| 196 | x = sinThetaHalf / (wlPhoton/cm); |
---|
| 197 | if (x > 1.e+005) |
---|
| 198 | dataFormFactor = formFactorData->FindValue(x,Z-1); |
---|
| 199 | else |
---|
| 200 | dataFormFactor = formFactorData->FindValue(0.,Z-1); |
---|
| 201 | randomFormFactor = G4UniformRand() * Z * Z; |
---|
| 202 | sinTheta = std::sqrt(1. - cosTheta*cosTheta); |
---|
| 203 | gReject = dataFormFactor * dataFormFactor; |
---|
| 204 | |
---|
| 205 | } while( gReject < randomFormFactor); |
---|
| 206 | |
---|
| 207 | // Scattered photon angles. ( Z - axis along the parent photon) |
---|
| 208 | G4double phi = twopi * G4UniformRand() ; |
---|
| 209 | G4double dirX = sinTheta*std::cos(phi); |
---|
| 210 | G4double dirY = sinTheta*std::sin(phi); |
---|
| 211 | G4double dirZ = cosTheta; |
---|
| 212 | |
---|
| 213 | // Update G4VParticleChange for the scattered photon |
---|
| 214 | G4ThreeVector photonDirection1(dirX, dirY, dirZ); |
---|
| 215 | photonDirection1.rotateUz(photonDirection0); |
---|
| 216 | fParticleChange->ProposeMomentumDirection(photonDirection1); |
---|
| 217 | |
---|
| 218 | fParticleChange->SetProposedKineticEnergy(photonEnergy0); |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 222 | |
---|
| 223 | G4double G4LivermoreRayleighModel::GetMeanFreePath(const G4Track& track, |
---|
| 224 | G4double, // previousStepSize |
---|
| 225 | G4ForceCondition*) |
---|
| 226 | { |
---|
| 227 | const G4DynamicParticle* photon = track.GetDynamicParticle(); |
---|
| 228 | G4double energy = photon->GetKineticEnergy(); |
---|
| 229 | const G4MaterialCutsCouple* couple = track.GetMaterialCutsCouple(); |
---|
| 230 | size_t materialIndex = couple->GetIndex(); |
---|
| 231 | |
---|
| 232 | G4double meanFreePath; |
---|
| 233 | if (energy > highEnergyLimit) meanFreePath = meanFreePathTable->FindValue(highEnergyLimit,materialIndex); |
---|
| 234 | else if (energy < lowEnergyLimit) meanFreePath = DBL_MAX; |
---|
| 235 | else meanFreePath = meanFreePathTable->FindValue(energy,materialIndex); |
---|
| 236 | return meanFreePath; |
---|
| 237 | } |
---|
| 238 | |
---|