- Timestamp:
- May 28, 2009, 4:26:57 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/lowenergy/src/G4LivermoreComptonModel.cc
r1007 r1055 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4LivermoreComptonModel.cc,v 1.1 2008/10/30 14:17:46 sincerti Exp $ 27 // GEANT4 tag $Name: geant4-09-02 $ 28 // 26 // $Id: G4LivermoreComptonModel.cc,v 1.6 2009/04/18 18:29:34 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $ 28 // 29 // 30 // Author: Sebastien Inserti 31 // 30 October 2008 32 // 33 // History: 34 // -------- 35 // 18 Apr 2009 V Ivanchenko Cleanup initialisation and generation of secondaries: 36 // - apply internal high-energy limit only in constructor 37 // - do not apply low-energy limit (default is 0) 38 // - remove GetMeanFreePath method and table 39 // - added protection against numerical problem in energy sampling 40 // - use G4ElementSelector 29 41 30 42 #include "G4LivermoreComptonModel.hh" … … 37 49 38 50 G4LivermoreComptonModel::G4LivermoreComptonModel(const G4ParticleDefinition*, 39 const G4String& nam) 40 :G4VEmModel(nam),isInitialised(false) 51 const G4String& nam) 52 :G4VEmModel(nam),isInitialised(false),meanFreePathTable(0), 53 scatterFunctionData(0),crossSectionHandler(0) 41 54 { 42 lowEnergyLimit = 250 * eV; // SI - Could be 10 eV ?55 lowEnergyLimit = 250 * eV; 43 56 highEnergyLimit = 100 * GeV; 44 SetLowEnergyLimit(lowEnergyLimit);57 // SetLowEnergyLimit(lowEnergyLimit); 45 58 SetHighEnergyLimit(highEnergyLimit); 46 59 47 verboseLevel= 0;60 verboseLevel=0 ; 48 61 // Verbosity scale: 49 62 // 0 = nothing … … 52 65 // 3 = calculation of cross sections, file openings, sampling of atoms 53 66 // 4 = entering in methods 54 55 G4cout << "Livermore Compton model is constructed " << G4endl 56 << "Energy range: " 57 << lowEnergyLimit / keV << " keV - " 58 << highEnergyLimit / GeV << " GeV" 59 << G4endl; 60 67 68 if( verboseLevel>0 ) { 69 G4cout << "Livermore Compton model is constructed " << G4endl 70 << "Energy range: " 71 << lowEnergyLimit / eV << " eV - " 72 << highEnergyLimit / GeV << " GeV" 73 << G4endl; 74 } 61 75 } 62 76 … … 65 79 G4LivermoreComptonModel::~G4LivermoreComptonModel() 66 80 { 67 delete meanFreePathTable; 68 delete crossSectionHandler; 69 delete scatterFunctionData; 81 if (crossSectionHandler) delete crossSectionHandler; 82 if (scatterFunctionData) delete scatterFunctionData; 70 83 } 71 84 … … 73 86 74 87 void G4LivermoreComptonModel::Initialise(const G4ParticleDefinition* particle, 75 88 const G4DataVector& cuts) 76 89 { 77 90 if (verboseLevel > 3) 78 91 G4cout << "Calling G4LivermoreComptonModel::Initialise()" << G4endl; 79 92 80 InitialiseElementSelectors(particle,cuts); 81 82 // Energy limits 83 84 if (LowEnergyLimit() < lowEnergyLimit) 85 { 86 G4cout << "G4LivermoreComptonModel: 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 << "G4LivermoreComptonModel: high energy limit decreased from " << 94 HighEnergyLimit()/GeV << " GeV to " << highEnergyLimit << " GeV" << G4endl; 95 SetHighEnergyLimit(highEnergyLimit); 96 } 97 93 if (crossSectionHandler) 94 { 95 crossSectionHandler->Clear(); 96 delete crossSectionHandler; 97 } 98 98 99 // Reading of data files - all materials are read 99 100 … … 113 114 shellData.LoadData(file); 114 115 115 meanFreePathTable = 0;116 meanFreePathTable = crossSectionHandler->BuildMeanFreePathForMaterials();117 118 116 if (verboseLevel > 2) 119 117 G4cout << "Loaded cross section files for Livermore Compton model" << G4endl; 120 118 121 G4cout << "Livermore Compton model is initialized " << G4endl 122 << "Energy range: " 123 << LowEnergyLimit() / keV << " keV - " 124 << HighEnergyLimit() / GeV << " GeV" 125 << G4endl; 126 127 // 128 119 InitialiseElementSelectors(particle,cuts); 120 121 if( verboseLevel>0 ) { 122 G4cout << "Livermore Compton model is initialized " << G4endl 123 << "Energy range: " 124 << LowEnergyLimit() / eV << " eV - " 125 << HighEnergyLimit() / GeV << " GeV" 126 << G4endl; 127 } 128 // 129 129 if(isInitialised) return; 130 131 if(pParticleChange) 132 fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange); 133 else 134 fParticleChange = new G4ParticleChangeForGamma(); 135 130 fParticleChange = GetParticleChangeForGamma(); 136 131 isInitialised = true; 137 132 } … … 148 143 G4cout << "Calling ComputeCrossSectionPerAtom() of G4LivermoreComptonModel" << G4endl; 149 144 150 G4double cs = crossSectionHandler->FindValue(G4int(Z), GammaEnergy); 145 if (GammaEnergy < lowEnergyLimit || GammaEnergy > highEnergyLimit) return 0.0; 146 147 G4double cs = crossSectionHandler->FindValue(G4int(Z), GammaEnergy); 151 148 return cs; 152 149 } … … 155 152 156 153 void G4LivermoreComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect, 157 const G4MaterialCutsCouple* couple, 158 const G4DynamicParticle* aDynamicGamma, 159 G4double, 160 G4double) 154 const G4MaterialCutsCouple* couple, 155 const G4DynamicParticle* aDynamicGamma, 156 G4double, G4double) 161 157 { 158 162 159 // The scattered gamma energy is sampled according to Klein - Nishina formula. 163 160 // then accepted or rejected depending on the Scattering Function multiplied … … 174 171 // (Nucl Phys 20(1960),15). 175 172 176 if (verboseLevel > 3)177 G4cout << "Calling SampleSecondaries() of G4LivermoreComptonModel" << G4endl;178 179 173 G4double photonEnergy0 = aDynamicGamma->GetKineticEnergy(); 180 181 if (photonEnergy0 <= lowEnergyLimit) 182 { 174 175 if (verboseLevel > 3) { 176 G4cout << "G4LivermoreComptonModel::SampleSecondaries() E(MeV)= " 177 << photonEnergy0/MeV << " in " << couple->GetMaterial()->GetName() 178 << G4endl; 179 } 180 181 // low-energy gamma is absorpted by this process 182 if (photonEnergy0 <= lowEnergyLimit) 183 { 183 184 fParticleChange->ProposeTrackStatus(fStopAndKill); 184 185 fParticleChange->SetProposedKineticEnergy(0.); 185 186 fParticleChange->ProposeLocalEnergyDeposit(photonEnergy0); 186 // SI - IS THE FOLLOWING RETURN NECESSARY ?187 187 return ; 188 }188 } 189 189 190 190 G4double e0m = photonEnergy0 / electron_mass_c2 ; … … 192 192 193 193 // Select randomly one element in the current material 194 G4int Z = crossSectionHandler->SelectRandomAtom(couple,photonEnergy0); 194 // G4int Z = crossSectionHandler->SelectRandomAtom(couple,photonEnergy0); 195 const G4ParticleDefinition* particle = aDynamicGamma->GetDefinition(); 196 const G4Element* elm = SelectRandomAtom(couple,particle,photonEnergy0); 197 G4int Z = (G4int)elm->GetZ(); 195 198 196 199 G4double epsilon0 = 1. / (1. + 2. * e0m); … … 212 215 if ( alpha1/(alpha1+alpha2) > G4UniformRand()) 213 216 { 214 epsilon = std::exp(-alpha1 * G4UniformRand()); // std::pow(epsilon0,G4UniformRand()) 217 // std::pow(epsilon0,G4UniformRand()) 218 epsilon = std::exp(-alpha1 * G4UniformRand()); 215 219 epsilonSq = epsilon * epsilon; 216 220 } … … 238 242 // Doppler broadening - Method based on: 239 243 // Y. Namito, S. Ban and H. Hirayama, 240 // "Implementation of the Doppler Broadening of a Compton-Scattered Photon Into the EGS4 Code"241 // NIM A 349, pp. 489-494, 1994244 // "Implementation of the Doppler Broadening of a Compton-Scattered Photon 245 // into the EGS4 Code", NIM A 349, pp. 489-494, 1994 242 246 243 247 // Maximum number of sampling iterations … … 257 261 eMax = photonEnergy0 - bindingE; 258 262 259 // Randomly sample bound electron momentum (memento: the data set is in Atomic Units) 263 // Randomly sample bound electron momentum 264 // (memento: the data set is in Atomic Units) 260 265 G4double pSample = profileData.RandomSelectMomentum(Z,shell); 261 266 // Rescale from atomic units … … 299 304 300 305 if (photonEnergy1 > 0.) 301 {302 fParticleChange->SetProposedKineticEnergy(photonEnergy1) ;303 }306 { 307 fParticleChange->SetProposedKineticEnergy(photonEnergy1) ; 308 } 304 309 else 305 { 306 fParticleChange->SetProposedKineticEnergy(0.) ; 307 fParticleChange->ProposeTrackStatus(fStopAndKill); 308 } 310 { 311 photonEnergy1 = 0.; 312 fParticleChange->SetProposedKineticEnergy(0.) ; 313 fParticleChange->ProposeTrackStatus(fStopAndKill); 314 } 309 315 310 316 // Kinematics of the scattered electron 311 317 G4double eKineticEnergy = photonEnergy0 - photonEnergy1 - bindingE; 318 319 // protection against negative final energy: no e- is created 320 if(eKineticEnergy < 0.0) { 321 fParticleChange->ProposeLocalEnergyDeposit(photonEnergy0 - photonEnergy1); 322 return; 323 } 312 324 G4double eTotalEnergy = eKineticEnergy + electron_mass_c2; 313 325 … … 329 341 eDirection.rotateUz(photonDirection0); 330 342 331 // SI - The range test has been removed wrt original G4LowEnergyCompton class343 // SI - The range test has been removed wrt original G4LowEnergyCompton class 332 344 333 345 fParticleChange->ProposeLocalEnergyDeposit(bindingE); 334 346 335 G4DynamicParticle* dp = new G4DynamicParticle (G4Electron::Electron(),eDirection,eKineticEnergy) ; 347 G4DynamicParticle* dp = new G4DynamicParticle (G4Electron::Electron(), 348 eDirection,eKineticEnergy) ; 336 349 fvect->push_back(dp); 337 350 } 338 351 339 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....340 341 G4double G4LivermoreComptonModel::GetMeanFreePath(const G4Track& track,342 G4double, // previousStepSize343 G4ForceCondition*)344 {345 const G4DynamicParticle* photon = track.GetDynamicParticle();346 G4double energy = photon->GetKineticEnergy();347 const G4MaterialCutsCouple* couple = track.GetMaterialCutsCouple();348 size_t materialIndex = couple->GetIndex();349 350 G4double meanFreePath;351 if (energy > highEnergyLimit) meanFreePath = meanFreePathTable->FindValue(highEnergyLimit,materialIndex);352 else if (energy < lowEnergyLimit) meanFreePath = DBL_MAX;353 else meanFreePath = meanFreePathTable->FindValue(energy,materialIndex);354 return meanFreePath;355 }356
Note: See TracChangeset
for help on using the changeset viewer.