[819] | 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 | // G4 Low energy model: n-p scattering |
---|
| 28 | // F.W. Jones, L.G. Greeniaus, H.P. Wellisch |
---|
| 29 | |
---|
| 30 | // 11-OCT-2007 F.W. Jones: removed erroneous code for identity |
---|
| 31 | // exchange of particles. |
---|
| 32 | |
---|
| 33 | #include "G4LEnp.hh" |
---|
| 34 | #include "Randomize.hh" |
---|
| 35 | #include "G4ios.hh" |
---|
| 36 | |
---|
| 37 | // Initialization of static data arrays: |
---|
| 38 | #include "G4LEnpData.hh" |
---|
| 39 | #include "Randomize.hh" |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | G4LEnp::G4LEnp():G4HadronicInteraction("G4LEnp") |
---|
| 43 | { |
---|
| 44 | // theParticleChange.SetNumberOfSecondaries(1); |
---|
| 45 | |
---|
| 46 | // SetMinEnergy(10.*MeV); |
---|
| 47 | // SetMaxEnergy(1200.*MeV); |
---|
| 48 | SetMinEnergy(0.); |
---|
| 49 | SetMaxEnergy(1200.*GeV); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | G4LEnp::~G4LEnp() |
---|
| 53 | { |
---|
| 54 | theParticleChange.Clear(); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | G4HadFinalState* |
---|
| 58 | G4LEnp::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) |
---|
| 59 | { |
---|
| 60 | theParticleChange.Clear(); |
---|
| 61 | const G4HadProjectile* aParticle = &aTrack; |
---|
| 62 | |
---|
| 63 | G4double P = aParticle->GetTotalMomentum(); |
---|
| 64 | G4double Px = aParticle->Get4Momentum().x(); |
---|
| 65 | G4double Py = aParticle->Get4Momentum().y(); |
---|
| 66 | G4double Pz = aParticle->Get4Momentum().z(); |
---|
| 67 | G4double ek = aParticle->GetKineticEnergy(); |
---|
| 68 | G4ThreeVector theInitial = aParticle->Get4Momentum().vect(); |
---|
| 69 | |
---|
| 70 | if (verboseLevel > 1) { |
---|
| 71 | G4double E = aParticle->GetTotalEnergy(); |
---|
| 72 | G4double E0 = aParticle->GetDefinition()->GetPDGMass(); |
---|
| 73 | G4double Q = aParticle->GetDefinition()->GetPDGCharge(); |
---|
| 74 | G4double N = targetNucleus.GetN(); |
---|
| 75 | G4double Z = targetNucleus.GetZ(); |
---|
| 76 | G4cout << "G4LEnp:ApplyYourself: incident particle: " |
---|
| 77 | << aParticle->GetDefinition()->GetParticleName() << G4endl; |
---|
| 78 | G4cout << "P = " << P/GeV << " GeV/c" |
---|
| 79 | << ", Px = " << Px/GeV << " GeV/c" |
---|
| 80 | << ", Py = " << Py/GeV << " GeV/c" |
---|
| 81 | << ", Pz = " << Pz/GeV << " GeV/c" << G4endl; |
---|
| 82 | G4cout << "E = " << E/GeV << " GeV" |
---|
| 83 | << ", kinetic energy = " << ek/GeV << " GeV" |
---|
| 84 | << ", mass = " << E0/GeV << " GeV" |
---|
| 85 | << ", charge = " << Q << G4endl; |
---|
| 86 | G4cout << "G4LEnp:ApplyYourself: material:" << G4endl; |
---|
| 87 | G4cout << "A = " << N |
---|
| 88 | << ", Z = " << Z |
---|
| 89 | << ", atomic mass " |
---|
| 90 | << G4Proton::Proton()->GetPDGMass()/GeV << "GeV" |
---|
| 91 | << G4endl; |
---|
| 92 | // |
---|
| 93 | // GHEISHA ADD operation to get total energy, mass, charge |
---|
| 94 | // |
---|
| 95 | E += G4Proton::Proton()->GetPDGMass(); |
---|
| 96 | G4double E02 = E*E - P*P; |
---|
| 97 | E0 = std::sqrt(std::abs(E02)); |
---|
| 98 | if (E02 < 0)E0 *= -1; |
---|
| 99 | Q += Z; |
---|
| 100 | G4cout << "G4LEnp:ApplyYourself: total:" << G4endl; |
---|
| 101 | G4cout << "E = " << E/GeV << " GeV" |
---|
| 102 | << ", mass = " << E0/GeV << " GeV" |
---|
| 103 | << ", charge = " << Q << G4endl; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | // Find energy bin |
---|
| 107 | |
---|
| 108 | G4int je1 = 0; |
---|
| 109 | G4int je2 = NENERGY - 1; |
---|
| 110 | ek = ek/GeV; |
---|
| 111 | do { |
---|
| 112 | G4int midBin = (je1 + je2)/2; |
---|
| 113 | if (ek < elab[midBin]) |
---|
| 114 | je2 = midBin; |
---|
| 115 | else |
---|
| 116 | je1 = midBin; |
---|
| 117 | } while (je2 - je1 > 1); |
---|
| 118 | // G4int j; |
---|
| 119 | //std::abs(ek-elab[je1]) < std::abs(ek-elab[je2]) ? j = je1 : j = je2; |
---|
| 120 | G4double delab = elab[je2] - elab[je1]; |
---|
| 121 | |
---|
| 122 | // Sample the angle |
---|
| 123 | |
---|
| 124 | G4float sample = G4UniformRand(); |
---|
| 125 | G4int ke1 = 0; |
---|
| 126 | G4int ke2 = NANGLE - 1; |
---|
| 127 | G4double dsig = sig[je2][0] - sig[je1][0]; |
---|
| 128 | G4double rc = dsig/delab; |
---|
| 129 | G4double b = sig[je1][0] - rc*elab[je1]; |
---|
| 130 | G4double sigint1 = rc*ek + b; |
---|
| 131 | G4double sigint2 = 0.; |
---|
| 132 | |
---|
| 133 | if (verboseLevel > 1) G4cout << "sample=" << sample << G4endl |
---|
| 134 | << ke1 << " " << ke2 << " " |
---|
| 135 | << sigint1 << " " << sigint2 << G4endl; |
---|
| 136 | |
---|
| 137 | do { |
---|
| 138 | G4int midBin = (ke1 + ke2)/2; |
---|
| 139 | dsig = sig[je2][midBin] - sig[je1][midBin]; |
---|
| 140 | rc = dsig/delab; |
---|
| 141 | b = sig[je1][midBin] - rc*elab[je1]; |
---|
| 142 | G4double sigint = rc*ek + b; |
---|
| 143 | if (sample < sigint) { |
---|
| 144 | ke2 = midBin; |
---|
| 145 | sigint2 = sigint; |
---|
| 146 | } |
---|
| 147 | else { |
---|
| 148 | ke1 = midBin; |
---|
| 149 | sigint1 = sigint; |
---|
| 150 | } |
---|
| 151 | if (verboseLevel > 1)G4cout << ke1 << " " << ke2 << " " |
---|
| 152 | << sigint1 << " " << sigint2 << G4endl; |
---|
| 153 | } while (ke2 - ke1 > 1); |
---|
| 154 | |
---|
| 155 | // sigint1 and sigint2 should be recoverable from above loop |
---|
| 156 | |
---|
| 157 | // G4double dsig = sig[je2][ke1] - sig[je1][ke1]; |
---|
| 158 | // G4double rc = dsig/delab; |
---|
| 159 | // G4double b = sig[je1][ke1] - rc*elab[je1]; |
---|
| 160 | // G4double sigint1 = rc*ek + b; |
---|
| 161 | |
---|
| 162 | // G4double dsig = sig[je2][ke2] - sig[je1][ke2]; |
---|
| 163 | // G4double rc = dsig/delab; |
---|
| 164 | // G4double b = sig[je1][ke2] - rc*elab[je1]; |
---|
| 165 | // G4double sigint2 = rc*ek + b; |
---|
| 166 | |
---|
| 167 | dsig = sigint2 - sigint1; |
---|
| 168 | rc = 1./dsig; |
---|
| 169 | b = ke1 - rc*sigint1; |
---|
| 170 | G4double kint = rc*sample + b; |
---|
| 171 | G4double theta = (0.5 + kint)*pi/180.; |
---|
| 172 | |
---|
| 173 | // G4int k; |
---|
| 174 | //std::abs(sample-sig[j][ke1]) < std::abs(sample-sig[j][ke2]) ? k = ke1 : k = ke2; |
---|
| 175 | // G4double theta = (0.5 + k)*pi/180.; |
---|
| 176 | |
---|
| 177 | if (verboseLevel > 1) { |
---|
| 178 | G4cout << " energy bin " << je1 << " energy=" << elab[je1] << G4endl; |
---|
| 179 | G4cout << " angle bin " << kint << " angle=" << theta/degree << G4endl; |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | // Get the target particle |
---|
| 184 | |
---|
| 185 | G4DynamicParticle* targetParticle = targetNucleus.ReturnTargetParticle(); |
---|
| 186 | |
---|
| 187 | G4double E1 = aParticle->GetTotalEnergy(); |
---|
| 188 | G4double M1 = aParticle->GetDefinition()->GetPDGMass(); |
---|
| 189 | G4double E2 = targetParticle->GetTotalEnergy(); |
---|
| 190 | G4double M2 = targetParticle->GetDefinition()->GetPDGMass(); |
---|
| 191 | G4double totalEnergy = E1 + E2; |
---|
| 192 | G4double pseudoMass = std::sqrt(totalEnergy*totalEnergy - P*P); |
---|
| 193 | // pseudoMass also = std::sqrt(M1*M1 + M2*M2 + 2*M2*E1) |
---|
| 194 | |
---|
| 195 | // Transform into centre of mass system |
---|
| 196 | |
---|
| 197 | G4double px = (M2/pseudoMass)*Px; |
---|
| 198 | G4double py = (M2/pseudoMass)*Py; |
---|
| 199 | G4double pz = (M2/pseudoMass)*Pz; |
---|
| 200 | G4double p = std::sqrt(px*px + py*py + pz*pz); |
---|
| 201 | |
---|
| 202 | if (verboseLevel > 1) { |
---|
| 203 | G4cout << " E1, M1 (GeV) " << E1/GeV << " " << M1/GeV << G4endl; |
---|
| 204 | G4cout << " E2, M2 (GeV) " << E2/GeV << " " << M2/GeV << G4endl; |
---|
| 205 | G4cout << " particle 1 momentum in CM " << px/GeV << " " << py/GeV << " " |
---|
| 206 | << pz/GeV << " " << p/GeV << G4endl; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | // First scatter w.r.t. Z axis |
---|
| 210 | G4double phi = G4UniformRand()*twopi; |
---|
| 211 | G4double pxnew = p*std::sin(theta)*std::cos(phi); |
---|
| 212 | G4double pynew = p*std::sin(theta)*std::sin(phi); |
---|
| 213 | G4double pznew = p*std::cos(theta); |
---|
| 214 | |
---|
| 215 | // Rotate according to the direction of the incident particle |
---|
| 216 | if (px*px + py*py > 0) { |
---|
| 217 | G4double cost, sint, ph, cosp, sinp; |
---|
| 218 | cost = pz/p; |
---|
| 219 | sint = (std::sqrt(std::abs((1-cost)*(1+cost))) + std::sqrt(px*px+py*py)/p)/2; |
---|
| 220 | py < 0 ? ph = 3*halfpi : ph = halfpi; |
---|
| 221 | if (std::abs(px) > 0.000001*GeV) ph = std::atan2(py,px); |
---|
| 222 | cosp = std::cos(ph); |
---|
| 223 | sinp = std::sin(ph); |
---|
| 224 | px = (cost*cosp*pxnew - sinp*pynew + sint*cosp*pznew); |
---|
| 225 | py = (cost*sinp*pxnew + cosp*pynew + sint*sinp*pznew); |
---|
| 226 | pz = (-sint*pxnew + cost*pznew); |
---|
| 227 | // G4ThreeVector it(a,b,c); |
---|
| 228 | // p0->SetMomentum(it); |
---|
| 229 | // G4ThreeVector aTargetMom = theInitial - it; |
---|
| 230 | // targetParticle->SetMomentum(aTargetMom); |
---|
| 231 | } |
---|
| 232 | else { |
---|
| 233 | px = pxnew; |
---|
| 234 | py = pynew; |
---|
| 235 | pz = pznew; |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | if (verboseLevel > 1) { |
---|
| 239 | G4cout << " AFTER SCATTER..." << G4endl; |
---|
| 240 | G4cout << " particle 1 momentum in CM " << px/GeV << " " << py/GeV << " " |
---|
| 241 | << pz/GeV << " " << p/GeV << G4endl; |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | // Transform to lab system |
---|
| 245 | |
---|
| 246 | G4double E1pM2 = E1 + M2; |
---|
| 247 | G4double betaCM = P/E1pM2; |
---|
| 248 | G4double betaCMx = Px/E1pM2; |
---|
| 249 | G4double betaCMy = Py/E1pM2; |
---|
| 250 | G4double betaCMz = Pz/E1pM2; |
---|
| 251 | G4double gammaCM = E1pM2/std::sqrt(E1pM2*E1pM2 - P*P); |
---|
| 252 | |
---|
| 253 | if (verboseLevel > 1) { |
---|
| 254 | G4cout << " betaCM " << betaCMx << " " << betaCMy << " " |
---|
| 255 | << betaCMz << " " << betaCM << G4endl; |
---|
| 256 | G4cout << " gammaCM " << gammaCM << G4endl; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | // Now following GLOREN... |
---|
| 260 | |
---|
| 261 | G4double BETA[5], PA[5], PB[5]; |
---|
| 262 | BETA[1] = -betaCMx; |
---|
| 263 | BETA[2] = -betaCMy; |
---|
| 264 | BETA[3] = -betaCMz; |
---|
| 265 | BETA[4] = gammaCM; |
---|
| 266 | |
---|
| 267 | //The incident particle... |
---|
| 268 | |
---|
| 269 | PA[1] = px; |
---|
| 270 | PA[2] = py; |
---|
| 271 | PA[3] = pz; |
---|
| 272 | PA[4] = std::sqrt(M1*M1 + p*p); |
---|
| 273 | |
---|
| 274 | G4double BETPA = BETA[1]*PA[1] + BETA[2]*PA[2] + BETA[3]*PA[3]; |
---|
| 275 | G4double BPGAM = (BETPA * BETA[4]/(BETA[4] + 1.) - PA[4]) * BETA[4]; |
---|
| 276 | |
---|
| 277 | PB[1] = PA[1] + BPGAM * BETA[1]; |
---|
| 278 | PB[2] = PA[2] + BPGAM * BETA[2]; |
---|
| 279 | PB[3] = PA[3] + BPGAM * BETA[3]; |
---|
| 280 | PB[4] = (PA[4] - BETPA) * BETA[4]; |
---|
| 281 | |
---|
| 282 | G4DynamicParticle* newP = new G4DynamicParticle; |
---|
| 283 | newP->SetDefinition(const_cast<G4ParticleDefinition *>(aParticle->GetDefinition())); |
---|
| 284 | newP->SetMomentum(G4ThreeVector(PB[1], PB[2], PB[3])); |
---|
| 285 | |
---|
| 286 | //The target particle... |
---|
| 287 | |
---|
| 288 | PA[1] = -px; |
---|
| 289 | PA[2] = -py; |
---|
| 290 | PA[3] = -pz; |
---|
| 291 | PA[4] = std::sqrt(M2*M2 + p*p); |
---|
| 292 | |
---|
| 293 | BETPA = BETA[1]*PA[1] + BETA[2]*PA[2] + BETA[3]*PA[3]; |
---|
| 294 | BPGAM = (BETPA * BETA[4]/(BETA[4] + 1.) - PA[4]) * BETA[4]; |
---|
| 295 | |
---|
| 296 | PB[1] = PA[1] + BPGAM * BETA[1]; |
---|
| 297 | PB[2] = PA[2] + BPGAM * BETA[2]; |
---|
| 298 | PB[3] = PA[3] + BPGAM * BETA[3]; |
---|
| 299 | PB[4] = (PA[4] - BETPA) * BETA[4]; |
---|
| 300 | |
---|
| 301 | targetParticle->SetMomentum(G4ThreeVector(PB[1], PB[2], PB[3])); |
---|
| 302 | |
---|
| 303 | if (verboseLevel > 1) { |
---|
| 304 | G4cout << " particle 1 momentum in LAB " |
---|
| 305 | << newP->GetMomentum()*(1./GeV) |
---|
| 306 | << " " << newP->GetTotalMomentum()/GeV << G4endl; |
---|
| 307 | G4cout << " particle 2 momentum in LAB " |
---|
| 308 | << targetParticle->GetMomentum()*(1./GeV) |
---|
| 309 | << " " << targetParticle->GetTotalMomentum()/GeV << G4endl; |
---|
| 310 | G4cout << " TOTAL momentum in LAB " |
---|
| 311 | << (newP->GetMomentum()+targetParticle->GetMomentum())*(1./GeV) |
---|
| 312 | << " " |
---|
| 313 | << (newP->GetMomentum()+targetParticle->GetMomentum()).mag()/GeV |
---|
| 314 | << G4endl; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | theParticleChange.SetMomentumChange(newP->GetMomentumDirection()); |
---|
| 318 | theParticleChange.SetEnergyChange(newP->GetKineticEnergy()); |
---|
| 319 | delete newP; |
---|
| 320 | G4DynamicParticle* p1 = new G4DynamicParticle; |
---|
| 321 | p1->SetDefinition(targetParticle->GetDefinition()); |
---|
| 322 | p1->SetMomentum(targetParticle->GetMomentum()); |
---|
| 323 | theParticleChange.AddSecondary(p1); |
---|
| 324 | |
---|
| 325 | return &theParticleChange; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | // end of file |
---|