Changeset 962 for trunk/source/processes/hadronic/models/coherent_elastic/src/G4ChargeExchangeProcess.cc
- Timestamp:
- Apr 6, 2009, 12:30:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/coherent_elastic/src/G4ChargeExchangeProcess.cc
r819 r962 25 25 // 26 26 // 27 // $Id: G4ChargeExchangeProcess.cc,v 1. 9 2007/01/30 10:23:26vnivanch Exp $28 // GEANT4 tag $Name: $27 // $Id: G4ChargeExchangeProcess.cc,v 1.15 2008/11/27 16:43:00 vnivanch Exp $ 28 // GEANT4 tag $Name: geant4-09-02-ref-02 $ 29 29 // 30 30 // 31 // Geant4 Hadron Elastic Scattering Process -- headerfile31 // Geant4 Hadron Charge Exchange Process -- source file 32 32 // 33 33 // Created 21 April 2006 V.Ivanchenko … … 45 45 #include "G4CrossSectionDataStore.hh" 46 46 #include "G4HadronElasticDataSet.hh" 47 #include "G4VQCrossSection.hh"48 #include "G4QElasticCrossSection.hh"49 #include "G4QCHIPSWorld.hh"50 47 #include "G4Element.hh" 51 48 #include "G4ElementVector.hh" … … 53 50 #include "G4Neutron.hh" 54 51 #include "G4Proton.hh" 55 #include "G4HadronElastic.hh"56 52 #include "G4PhysicsLinearVector.hh" 57 53 … … 59 55 : G4HadronicProcess(procName), first(true) 60 56 { 61 thEnergy = 19.*MeV; 57 SetProcessSubType(fChargeExchange); 58 thEnergy = 20.*MeV; 62 59 verboseLevel= 1; 63 qCManager = 0;64 60 AddDataSet(new G4HadronElasticDataSet); 65 61 theProton = G4Proton::Proton(); … … 99 95 } 100 96 101 void G4ChargeExchangeProcess::SetQElasticCrossSection(G4VQCrossSection* p)102 {103 qCManager = p;104 }105 106 97 void G4ChargeExchangeProcess:: 107 98 BuildPhysicsTable(const G4ParticleDefinition& aParticleType) … … 120 111 121 112 G4double F[n] = {0.33,0.27,0.29,0.31,0.27,0.18,0.13,0.1,0.09,0.07}; 122 factors = new G4PhysicsLinearVector(0.0, 1.8*GeV,n);113 factors = new G4PhysicsLinearVector(0.0,2.0*GeV,n); 123 114 for(size_t i=0; i<n; i++) {factors->PutValue(i,F[i]);} 124 115 … … 126 117 127 118 G4double F[n] = {0.50,0.45,0.40,0.35,0.30,0.25,0.06,0.04,0.005,0.0}; 128 factors = new G4PhysicsLinearVector(0.0, 3.6*GeV,n);119 factors = new G4PhysicsLinearVector(0.0,4.0*GeV,n); 129 120 for(size_t i=0; i<n; i++) {factors->PutValue(i,F[i]);} 130 121 } 122 //factors->SetSpline(true); 131 123 132 124 if(verboseLevel>1) … … 135 127 << G4endl; 136 128 } 137 store->BuildPhysicsTable(aParticleType); 138 } 139 140 G4double G4ChargeExchangeProcess::GetMeanFreePath(const G4Track& track, 141 G4double, 142 G4ForceCondition* cond) 143 { 144 *cond = NotForced; 145 const G4DynamicParticle* dp = track.GetDynamicParticle(); 146 const G4Material* material = track.GetMaterial(); 147 cross = 0.0; 148 G4double x = DBL_MAX; 149 150 // The process is effective only above the threshold 151 if(dp->GetKineticEnergy() < thEnergy) return x; 152 153 // Compute cross sesctions 154 const G4ElementVector* theElementVector = material->GetElementVector(); 155 const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume(); 156 G4double temp = material->GetTemperature(); 157 G4int nelm = material->GetNumberOfElements(); 158 if(verboseLevel>1) 159 G4cout << "G4ChargeExchangeProcess get mfp for " 160 << theParticle->GetParticleName() 161 << " p(GeV)= " << dp->GetTotalMomentum()/GeV 162 << " in " << material->GetName() 163 << G4endl; 164 for (G4int i=0; i<nelm; i++) { 165 const G4Element* elm = (*theElementVector)[i]; 166 G4double x = GetMicroscopicCrossSection(dp, elm, temp); 167 cross += theAtomNumDensityVector[i]*x; 168 xsec[i] = cross; 169 } 170 if(verboseLevel>1) 171 G4cout << "G4ChargeExchangeProcess cross(1/mm)= " << cross 172 << " E(MeV)= " << dp->GetKineticEnergy() 173 << " " << theParticle->GetParticleName() 174 << " in " << material->GetName() 175 << G4endl; 176 if(cross > DBL_MIN) x = 1./cross; 177 178 return x; 129 G4HadronicProcess::BuildPhysicsTable(aParticleType); 179 130 } 180 131 … … 188 139 G4int iz = G4int(Z); 189 140 G4double x = 0.0; 190 if(iz == 1) return x; 141 142 // The process is effective only above the threshold 143 if(iz == 1 || dp->GetKineticEnergy() < thEnergy) return x; 191 144 192 145 if(verboseLevel>1) … … 195 148 << G4endl; 196 149 x = store->GetCrossSection(dp, elm, temp); 197 198 // NaN finder199 if(!(x < 0.0 || x >= 0.0)) {200 if (verboseLevel > -1) {201 G4cout << "G4ChargeExchangeProcess WARNING: Z= " << iz202 << " pdg= " << pPDG203 << " mom(GeV)= " << dp->GetTotalMomentum()/GeV204 << " cross= " << x205 << " set to zero"206 << G4endl;207 }208 x = 0.0;209 }210 150 211 151 if(verboseLevel>1) … … 217 157 G4bool b; 218 158 G4double A = elm->GetN(); 219 x *= factors->GetValue(dp->GetTotalMomentum(), b)/std::pow(A, 0.42); 159 G4double ptot = dp->GetTotalMomentum(); 160 x *= factors->GetValue(ptot, b)/std::pow(A, 0.42); 220 161 if(theParticle == thePiPlus || theParticle == theProton || 221 162 theParticle == theKPlus || theParticle == theANeutron) 222 x *= (1.0 - Z/A);163 { x *= (1.0 - Z/A); } 223 164 224 165 else if(theParticle == thePiMinus || theParticle == theNeutron || 225 166 theParticle == theKMinus || theParticle == theAProton) 226 x *= Z/A; 167 { x *= Z/A; } 168 169 if(theParticle->GetPDGMass() < GeV) { 170 if(ptot > 2.*GeV) x *= 4.0*GeV*GeV/(ptot*ptot); 171 } 172 173 if(verboseLevel>1) 174 G4cout << "Corrected cross(mb)= " << x/millibarn << G4endl; 227 175 228 176 return x; 229 }230 231 G4VParticleChange* G4ChargeExchangeProcess::PostStepDoIt(232 const G4Track& track,233 const G4Step& step)234 {235 G4ForceCondition* cn = 0;236 aParticleChange.Initialize(track);237 G4double mfp = GetMeanFreePath(track, 0.0, cn);238 if(mfp == DBL_MAX) return G4VDiscreteProcess::PostStepDoIt(track,step);239 240 G4double kineticEnergy = track.GetKineticEnergy();241 G4Material* material = track.GetMaterial();242 243 // Select element244 const G4ElementVector* theElementVector = material->GetElementVector();245 G4Element* elm = (*theElementVector)[0];246 G4int nelm = material->GetNumberOfElements() - 1;247 if (nelm > 0) {248 G4double x = G4UniformRand()*cross;249 G4int i = -1;250 do {i++;} while (x > xsec[i] && i < nelm);251 elm = (*theElementVector)[i];252 }253 G4double Z = elm->GetZ();254 G4double A = G4double(G4int(elm->GetN()+0.5));255 256 // Select isotope257 G4IsotopeVector* isv = elm->GetIsotopeVector();258 G4int ni = 0;259 if(isv) ni = isv->size();260 261 if(ni == 1) {262 A = G4double((*isv)[0]->GetN());263 } else if(ni > 1) {264 265 G4double* ab = elm->GetRelativeAbundanceVector();266 G4int j = -1;267 ni--;268 G4double y = G4UniformRand();269 do {270 j++;271 y -= ab[j];272 } while (y > 0.0 && j < ni);273 A = G4double((*isv)[j]->GetN());274 }275 G4HadronicInteraction* hadi =276 ChooseHadronicInteraction( kineticEnergy, material, elm);277 278 // Initialize the hadronic projectile from the track279 G4HadProjectile thePro(track);280 if(verboseLevel>1)281 G4cout << "G4ChargeExchangeProcess::PostStepDoIt for "282 << theParticle->GetParticleName()283 << " Target Z= " << Z284 << " A= " << A << G4endl;285 targetNucleus.SetParameters(A, Z);286 287 aParticleChange.Initialize(track);288 G4HadFinalState* result = hadi->ApplyYourself(thePro, targetNucleus);289 G4ThreeVector indir = track.GetMomentumDirection();290 G4int nsec = result->GetNumberOfSecondaries();291 292 if(verboseLevel>1)293 G4cout << "Efin= " << result->GetEnergyChange()294 << " de= " << result->GetLocalEnergyDeposit()295 << " nsec= " << nsec296 << G4endl;297 298 299 if(nsec > 0) {300 aParticleChange.ProposeEnergy(0.0);301 aParticleChange.ProposeTrackStatus(fStopAndKill);302 aParticleChange.ProposeLocalEnergyDeposit(result->GetLocalEnergyDeposit());303 aParticleChange.SetNumberOfSecondaries(nsec);304 for(G4int j=0; j<nsec; j++) {305 G4DynamicParticle* p = result->GetSecondary(j)->GetParticle();306 G4ThreeVector pdir = p->GetMomentumDirection();307 // G4cout << "recoil " << pdir << G4endl;308 pdir = pdir.rotateUz(indir);309 // G4cout << "recoil rotated " << pdir << G4endl;310 p->SetMomentumDirection(pdir);311 aParticleChange.AddSecondary(p);312 }313 }314 result->Clear();315 316 return G4VDiscreteProcess::PostStepDoIt(track,step);317 177 } 318 178
Note: See TracChangeset
for help on using the changeset viewer.