Changeset 1315 for trunk/source/processes/hadronic/models/cascade/cascade/src/G4PreCompoundCascadeInterface.cc
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/cascade/cascade/src/G4PreCompoundCascadeInterface.cc
r962 r1315 23 23 // * acceptance of all terms of the Geant4 Software license. * 24 24 // ******************************************************************** 25 // $Id: G4PreCompoundCascadeInterface.cc,v 1.13 2010/05/21 18:07:30 mkelsey Exp $ 26 // Geant4 tag: $Name: geant4-09-04-beta-cand-01 $ 25 27 // 28 // 20100114 M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly 29 // 20100413 M. Kelsey -- Pass G4CollisionOutput by ref to ::collide() 30 // 20100414 M. Kelsey -- Check for K0L/K0S before using G4InuclElemPart::type 31 // 20100419 M. Kelsey -- Access G4CollisionOutput lists by const-ref, and 32 // const_iterator 33 // 20100428 M. Kelsey -- Use G4InuclParticleNames enum 34 // 20100429 M. Kelsey -- Change "case gamma:" to "case photon:" 35 // 20100517 M. Kelsey -- Follow new ctors for G4*Collider family. 36 // 20100520 M. Kelsey -- Add missing name string to ctor, follow code changes 37 // from G4CascadeInterface. 26 38 27 39 #include "G4PreCompoundCascadeInterface.hh" 28 40 #include "globals.hh" 29 #include "G4DynamicParticleVector.hh" 30 #include "G4IonTable.hh" 31 #include "G4PreCompoundInuclCollider.hh" 32 #include "G4IntraNucleiCascader.hh" 33 #include "G4ElementaryParticleCollider.hh" 34 #include "G4NonEquilibriumEvaporator.hh" 35 #include "G4BigBanger.hh" 41 #include "G4CollisionOutput.hh" 42 #include "G4DynamicParticle.hh" 36 43 #include "G4InuclElementaryParticle.hh" 37 44 #include "G4InuclNuclei.hh" 38 45 #include "G4InuclParticle.hh" 39 #include "G4CollisionOutput.hh" 46 #include "G4InuclParticleNames.hh" 47 #include "G4KaonZeroShort.hh" 48 #include "G4KaonZeroLong.hh" 49 #include "G4LorentzRotation.hh" 50 #include "G4Nucleus.hh" 51 #include "G4ParticleDefinition.hh" 52 #include "G4PreCompoundInuclCollider.hh" 53 #include "G4Track.hh" 40 54 #include "G4V3DNucleus.hh" 41 #include "G4Track.hh" 42 #include "G4Nucleus.hh" 43 #include "G4NucleiModel.hh" 44 #include "G4LorentzRotation.hh" 45 46 47 typedef std::vector<G4InuclElementaryParticle>::iterator particleIterator; 48 typedef std::vector<G4InuclNuclei>::iterator nucleiIterator; 49 50 G4PreCompoundCascadeInterface::G4PreCompoundCascadeInterface() 51 :verboseLevel(0) { 55 56 using namespace G4InuclParticleNames; 57 58 59 typedef std::vector<G4InuclElementaryParticle>::const_iterator particleIterator; 60 typedef std::vector<G4InuclNuclei>::const_iterator nucleiIterator; 61 62 G4PreCompoundCascadeInterface::G4PreCompoundCascadeInterface(const G4String& nam) 63 :G4VIntraNuclearTransportModel(nam), verboseLevel(0) { 52 64 53 65 if (verboseLevel > 3) { … … 85 97 // NOTE: Geant4 units are MeV = 1 and GeV = 1000. Cascade code by default use GeV = 1. 86 98 87 enum particleType { nuclei = 0, proton = 1, neutron = 2, pionPlus = 3, 88 pionMinus = 5, pionZero = 7, photon = 10, 89 kaonPlus = 11, kaonMinus = 13, kaonZero = 15, 90 kaonZeroBar = 17, lambda = 21, sigmaPlus = 23, 91 sigmaZero = 25, sigmaMinus = 27, xiZero = 29, xiMinus = 31 }; 92 93 G4int bulletType = 0; 94 95 // Coding particles 96 if (aTrack.GetDefinition() == G4Proton::Proton() ) bulletType = proton; 97 if (aTrack.GetDefinition() == G4Neutron::Neutron() ) bulletType = neutron; 98 if (aTrack.GetDefinition() == G4PionPlus::PionPlus() ) bulletType = pionPlus; 99 if (aTrack.GetDefinition() == G4PionMinus::PionMinus() ) bulletType = pionMinus; 100 if (aTrack.GetDefinition() == G4PionZero::PionZero() ) bulletType = pionZero; 101 if (aTrack.GetDefinition() == G4Gamma::Gamma() ) bulletType = photon; 102 if (aTrack.GetDefinition() == G4KaonPlus::KaonPlus() ) bulletType = kaonPlus; 103 if (aTrack.GetDefinition() == G4KaonMinus::KaonMinus() ) bulletType = kaonMinus; 104 if (aTrack.GetDefinition() == G4Lambda::Lambda() ) bulletType = lambda; 105 if (aTrack.GetDefinition() == G4SigmaPlus::SigmaPlus() ) bulletType = sigmaPlus; 106 if (aTrack.GetDefinition() == G4SigmaZero::SigmaZero() ) bulletType = sigmaZero; 107 if (aTrack.GetDefinition() == G4SigmaMinus::SigmaMinus() ) bulletType = sigmaMinus; 108 if (aTrack.GetDefinition() == G4XiZero::XiZero() ) bulletType = xiZero; 109 if (aTrack.GetDefinition() == G4XiMinus::XiMinus() ) bulletType = xiMinus; 110 99 G4int bulletType; 111 100 if (aTrack.GetDefinition() == G4KaonZeroLong::KaonZeroLong() || 112 aTrack.GetDefinition() == G4KaonZeroShort::KaonZeroShort() ) { 113 if (G4UniformRand() > 0.5) { 114 bulletType = kaonZero; 115 } else { 116 bulletType = kaonZeroBar; 117 } 118 } 101 aTrack.GetDefinition() == G4KaonZeroShort::KaonZeroShort() ) 102 bulletType = (G4UniformRand() > 0.5) ? kaonZero : kaonZeroBar; 103 else 104 bulletType = G4InuclElementaryParticle::type(aTrack.GetDefinition()); 119 105 120 106 // Code momentum and energy. 121 G4double px,py,pz;122 px=aTrack.Get4Momentum().px() / GeV;123 py=aTrack.Get4Momentum().py() / GeV;124 pz=aTrack.Get4Momentum().pz() / GeV;125 126 107 G4LorentzVector projectileMomentum = aTrack.Get4Momentum(); 127 108 G4LorentzRotation toZ; … … 130 111 G4LorentzRotation toLabFrame = toZ.inverse(); 131 112 132 G4CascadeMomentum momentumBullet; 133 momentumBullet[0] =0.; 134 momentumBullet[1] =0; 135 momentumBullet[2] =0; 136 momentumBullet[3] =std::sqrt(px*px+py*py+pz*pz); 137 138 G4InuclElementaryParticle * bullet = new G4InuclElementaryParticle(momentumBullet, bulletType); 113 G4LorentzVector momentumBullet(0., 0., aTrack.GetTotalMomentum()/GeV, 114 aTrack.GetTotalEnergy()/GeV); 115 116 G4InuclElementaryParticle * bullet = 117 new G4InuclElementaryParticle(momentumBullet, bulletType); 139 118 140 119 sumEnergy = bullet->getKineticEnergy(); // In GeV 141 142 if (bulletType == proton || bulletType == neutron || bulletType == lambda || 143 bulletType == sigmaPlus || bulletType == sigmaZero || bulletType == sigmaMinus || 144 bulletType == xiZero || bulletType == xiMinus) { 145 146 sumBaryon += 1; 147 } 120 sumBaryon += bullet->baryon(); 148 121 149 122 // Set target 150 123 G4InuclNuclei* target = 0; 151 124 G4InuclParticle* targetH = 0; 152 // and outcoming particles153 G4DynamicParticle* cascadeParticle = 0;154 155 G4CascadeMomentum targetMomentum;156 125 157 126 G4double theNucleusA = theNucleus.GetN(); 158 127 159 128 if ( !(G4int(theNucleusA) == 1) ) { 160 target = new G4InuclNuclei(targetMomentum, 161 theNucleusA, 162 theNucleus.GetZ()); 163 target->setEnergy(); 164 165 const G4CascadeMomentum& bmom = bullet->getMomentum(); 166 eInit = std::sqrt(bmom[0] * bmom[0]); 167 const G4CascadeMomentum& tmom = target->getMomentum(); 168 eInit += std::sqrt(tmom[0] * tmom[0]); 129 target = new G4InuclNuclei(theNucleusA, theNucleus.GetZ()); 130 eInit = bullet->getEnergy() + target->getEnergy(); 169 131 170 132 sumBaryon += theNucleusA; … … 183 145 184 146 // Colliders initialisation 185 G4ElementaryParticleCollider* colep = new G4ElementaryParticleCollider; 186 187 G4IntraNucleiCascader* inc = new G4IntraNucleiCascader; // the actual cascade 188 inc->setInteractionCase(1); // Interaction type is particle with nuclei. 189 190 G4NonEquilibriumEvaporator* noneq = new G4NonEquilibriumEvaporator; 191 G4BigBanger* bigb = new G4BigBanger; 192 G4PreCompoundInuclCollider* collider = new G4PreCompoundInuclCollider(colep, inc, noneq, bigb); 147 G4PreCompoundInuclCollider* collider = new G4PreCompoundInuclCollider; 193 148 194 149 G4int maxTries = 10; // maximum tries for inelastic collision to avoid infinite loop … … 197 152 if (G4int(theNucleusA) == 1) { // special treatment for target H(1,1) (proton) 198 153 199 targetH = new G4InuclElementaryParticle( targetMomentum,1);154 targetH = new G4InuclElementaryParticle(1); 200 155 201 156 G4float cutElastic[32]; … … 214 169 cutElastic[kaonPlus ] = 0.5; // 0.5 GeV 215 170 cutElastic[kaonMinus] = 0.5; 216 cutElastic[kaonMinus] = 0.5;217 171 cutElastic[kaonZero] = 0.5; 218 172 cutElastic[kaonZeroBar] = 0.5; … … 222 176 223 177 224 if (momentumBullet [3]> cutElastic[bulletType]) { // inelastic collision possible178 if (momentumBullet.z() > cutElastic[bulletType]) { // inelastic collision possible 225 179 226 180 do { // we try to create inelastic interaction 227 output = collider->collide(bullet, targetH); 181 output.reset(); 182 collider->collide(bullet, targetH, output); 228 183 nTries++; 229 184 } while( … … 235 190 236 191 } else { // only elastic collision is energetically possible 237 output = collider->collide(bullet, targetH);192 collider->collide(bullet, targetH, output); 238 193 } 239 194 240 195 sumBaryon += 1; 241 196 242 const G4CascadeMomentum& bmom = bullet->getMomentum(); 243 eInit = std::sqrt(bmom[0] * bmom[0]); 244 const G4CascadeMomentum& tmom = targetH->getMomentum(); 245 eInit += std::sqrt(tmom[0] * tmom[0]); 197 eInit = bullet->getEnergy() + target->getEnergy(); 246 198 247 199 if (verboseLevel > 2) { … … 254 206 do // we try to create inelastic interaction 255 207 { 256 output = collider->collide(bullet, target ); 208 output.reset(); 209 collider->collide(bullet, target, output); 257 210 nTries++; 258 211 } while ( 259 // (nTries < maxTries) &&260 //(output.getOutgoingParticles().size() + output.getNucleiFragments().size() < 2.5) &&261 //(output.getOutgoingParticles().size()!=0) &&262 //(output.getOutgoingParticles().begin()->type()==bullet->type())263 //);264 265 212 (nTries < maxTries) && 266 213 output.getOutgoingParticles().size() == 1 && // we retry when elastic collision happened … … 272 219 } 273 220 274 if (verboseLevel > 1) 275 { 221 if (verboseLevel > 1) { 276 222 G4cout << " Cascade output: " << G4endl; 277 223 output.printCollisionOutput(); 278 224 } 279 225 226 // Rotate event to put Z axis along original projectile direction 227 output.rotateEvent(toLabFrame); 228 280 229 // Convert cascade data to use hadronics interface 281 std::vector<G4InuclNuclei>nucleiFragments = output.getNucleiFragments();282 std::vector<G4InuclElementaryParticle> particles =output.getOutgoingParticles();230 const std::vector<G4InuclNuclei>& nucleiFragments = output.getNucleiFragments(); 231 const std::vector<G4InuclElementaryParticle>& particles = output.getOutgoingParticles(); 283 232 284 233 theResult.SetStatusChange(stopAndKill); 285 234 235 // Get outcoming particles 236 G4DynamicParticle* cascadeParticle = 0; 286 237 if (!particles.empty()) { 287 particleIterator ipart; 288 G4int outgoingParticle; 289 290 for (ipart = particles.begin(); ipart != particles.end(); ipart++) { 291 outgoingParticle = ipart->type(); 292 const G4CascadeMomentum& mom = ipart->getMomentum(); 293 eTot += std::sqrt(mom[0] * mom[0]); 294 295 G4double ekin = ipart->getKineticEnergy() * GeV; 296 G4ThreeVector aMom(mom[1], mom[2], mom[3]); 297 aMom = aMom.unit(); 298 299 if (ipart->baryon() ) { 300 sumBaryon -= 1; 238 particleIterator ipart = particles.begin(); 239 for (; ipart != particles.end(); ipart++) { 240 G4int outgoingType = ipart->type(); 241 242 eTot += ipart->getEnergy(); 243 sumBaryon -= ipart->baryon(); 244 sumEnergy -= ipart->getKineticEnergy(); 245 246 if (!ipart->valid() || ipart->quasi_deutron()) { 247 G4cerr << " ERROR: G4PreCompoundCascadeInterface::Propagate incompatible" 248 << " particle type " << ipart->type() << G4endl; 249 continue; 301 250 } 302 251 303 sumEnergy -= ekin / GeV; 304 305 switch(outgoingParticle) { 306 307 case proton: 308 #ifdef debug_G4PreCompoundCascadeInterface 309 G4cerr << "proton " << counter << " " << aMom << " " << ekin << G4endl; 310 #endif 311 cascadeParticle = new G4DynamicParticle(G4Proton::ProtonDefinition(), aMom, ekin); 312 break; 313 314 case neutron: 315 316 #ifdef debug_G4PreCompoundCascadeInterface 317 G4cerr << "neutron "<< counter<<" "<<aMom<<" "<< ekin<<G4endl; 318 #endif 319 cascadeParticle = new G4DynamicParticle(G4Neutron::NeutronDefinition(), aMom, ekin); 320 break; 321 322 case pionPlus: 323 cascadeParticle = new G4DynamicParticle(G4PionPlus::PionPlusDefinition(), aMom, ekin); 324 325 #ifdef debug_G4PreCompoundCascadeInterface 326 G4cerr << "pionPlus "<< counter<<" "<<aMom<<" "<< ekin<<G4endl; 327 #endif 328 break; 329 330 case pionMinus: 331 cascadeParticle = new G4DynamicParticle(G4PionMinus::PionMinusDefinition(), aMom, ekin); 332 333 #ifdef debug_G4PreCompoundCascadeInterface 334 G4cerr << "pionMinus "<< counter<<" "<<aMom<<" "<< ekin<<G4endl; 335 #endif 336 break; 337 338 case pionZero: 339 cascadeParticle = new G4DynamicParticle(G4PionZero::PionZeroDefinition(), aMom, ekin); 340 341 #ifdef debug_G4PreCompoundCascadeInterface 342 G4cerr << "pionZero "<< counter<<" "<<aMom<<" "<< ekin<<G4endl; 343 #endif 344 break; 345 346 case photon: 347 cascadeParticle = new G4DynamicParticle(G4Gamma::Gamma(), aMom, ekin); 348 349 #ifdef debug_G4PreCompoundCascadeInterface 350 G4cerr << "photon "<< counter<<" "<<aMom<<" "<< ekin<<G4endl; 351 #endif 352 break; 353 354 355 case kaonPlus: 356 cascadeParticle = new G4DynamicParticle(G4KaonPlus::KaonPlusDefinition(), aMom, ekin); 357 break; 358 359 case kaonMinus: 360 cascadeParticle = new G4DynamicParticle(G4KaonMinus::KaonMinusDefinition(), aMom, ekin); 361 break; 362 363 case kaonZero: 364 if (G4UniformRand() > 0.5) { 365 cascadeParticle = new G4DynamicParticle(G4KaonZeroLong::KaonZeroLongDefinition(), aMom, ekin); 366 } else { 367 cascadeParticle = new G4DynamicParticle(G4KaonZeroShort::KaonZeroShortDefinition(), aMom, ekin); 368 } 369 break; 370 371 case kaonZeroBar: 372 if (G4UniformRand() > 0.5) { 373 cascadeParticle = new G4DynamicParticle(G4KaonZeroLong::KaonZeroLongDefinition(), aMom, ekin); 374 } else { 375 cascadeParticle = new G4DynamicParticle(G4KaonZeroShort::KaonZeroShortDefinition(), aMom, ekin); 376 } 377 break; 378 379 case lambda: 380 cascadeParticle = new G4DynamicParticle(G4Lambda::LambdaDefinition(), aMom, ekin); 381 break; 382 383 case sigmaPlus: 384 cascadeParticle = new G4DynamicParticle(G4SigmaPlus::SigmaPlusDefinition(), aMom, ekin); 385 break; 386 387 case sigmaZero: 388 cascadeParticle = new G4DynamicParticle(G4SigmaZero::SigmaZeroDefinition(), aMom, ekin); 389 break; 390 391 case sigmaMinus: 392 cascadeParticle = new G4DynamicParticle(G4SigmaMinus::SigmaMinusDefinition(), aMom, ekin); 393 break; 394 395 case xiZero: 396 cascadeParticle = new G4DynamicParticle(G4XiZero::XiZeroDefinition(), aMom, ekin); 397 break; 398 399 case xiMinus: 400 cascadeParticle = new G4DynamicParticle(G4XiMinus::XiMinusDefinition(), aMom, ekin); 401 break; 402 403 default: 404 G4cout << " ERROR: G4PreCompoundCascadeInterface::Propagate undefined particle type" << G4endl; 252 // Copy local G4DynPart to public output (handle kaon mixing specially) 253 if (outgoingType == kaonZero || outgoingType == kaonZeroBar) { 254 G4ThreeVector momDir = ipart->getMomentum().vect().unit(); 255 G4double ekin = ipart->getKineticEnergy(); 256 257 G4ParticleDefinition* pd = G4KaonZeroShort::Definition(); 258 if (G4UniformRand() > 0.5) pd = G4KaonZeroLong::Definition(); 259 260 cascadeParticle = new G4DynamicParticle(pd, momDir, ekin); 261 } else { 262 cascadeParticle = new G4DynamicParticle(ipart->getDynamicParticle()); 405 263 } 406 407 cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame); 264 408 265 theResult.AddSecondary(cascadeParticle); 409 266 } … … 412 269 // get nuclei fragments 413 270 G4DynamicParticle * aFragment = 0; 414 G4ParticleDefinition * aIonDef = 0;415 G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();416 417 271 if (!nucleiFragments.empty()) { 418 nucleiIterator ifrag; 419 420 for (ifrag = nucleiFragments.begin(); ifrag != nucleiFragments.end(); ifrag++) 421 { 422 G4double eKin = ifrag->getKineticEnergy() * GeV; 423 const G4CascadeMomentum& mom = ifrag->getMomentum(); 424 eTot += std::sqrt(mom[0] * mom[0]); 425 426 G4ThreeVector aMom(mom[1], mom[2], mom[3]); 427 aMom = aMom.unit(); 428 429 // hpw @@@ ==> Should be zero: G4double fragmentExitation = ifrag->getExitationEnergyInGeV(); 430 431 if (verboseLevel > 2) { 432 G4cout << " Nuclei fragment: " << G4endl; 433 ifrag->printParticle(); 434 } 435 436 G4int A = G4int(ifrag->getA()); 437 G4int Z = G4int(ifrag->getZ()); 438 aIonDef = theTableOfParticles->FindIon(Z, A, 0, Z); 439 440 aFragment = new G4DynamicParticle(aIonDef, aMom, eKin); 441 442 sumBaryon -= A; 443 sumEnergy -= eKin / GeV; 444 445 aFragment->Set4Momentum(aFragment->Get4Momentum()*=toLabFrame); 446 theResult.AddSecondary(aFragment); 272 nucleiIterator ifrag = nucleiFragments.begin(); 273 for (; ifrag != nucleiFragments.end(); ifrag++) { 274 eTot += ifrag->getEnergy(); 275 sumBaryon -= ifrag->getA(); 276 sumEnergy -= ifrag->getKineticEnergy(); 277 278 if (verboseLevel > 2) { 279 G4cout << " Nuclei fragment: " << G4endl; 280 ifrag->printParticle(); 447 281 } 448 } 449 282 283 // Copy local G4DynPart to public output 284 aFragment = new G4DynamicParticle(ifrag->getDynamicParticle()); 285 theResult.AddSecondary(aFragment); 286 } 287 } 288 289 // Report violations of energy, baryon conservation 450 290 if (verboseLevel > 2) { 451 291 if (sumBaryon != 0) { 452 G4cout << "ERROR: no baryon number conservation, sum of baryons = " << sumBaryon << G4endl; 292 G4cout << "ERROR: no baryon number conservation, sum of baryons = " 293 << sumBaryon << G4endl; 453 294 } 454 295 455 296 if (sumEnergy > 0.01 ) { 456 G4cout << "Kinetic energy conservation violated by " << sumEnergy << " GeV" << G4endl; 297 G4cout << "Kinetic energy conservation violated by " 298 << sumEnergy << " GeV" << G4endl; 457 299 } 458 300 459 G4cout << "Total energy conservation at level ~" << (eInit - eTot) * GeV << " MeV" << G4endl; 301 G4cout << "Total energy conservation at level ~" 302 << (eInit - eTot) * GeV << " MeV" << G4endl; 460 303 461 304 if (sumEnergy < -5.0e-5 ) { // 0.05 MeV 462 G4cout << "FATAL ERROR: energy created " << sumEnergy * GeV << " MeV" << G4endl; 305 G4cout << "FATAL ERROR: energy created " 306 << sumEnergy * GeV << " MeV" << G4endl; 463 307 } 464 308 } 465 309 466 310 delete bullet; 467 delete colep;468 delete inc;469 delete noneq;470 delete bigb;471 311 delete collider; 472 312 473 313 if(target != 0) delete target; 474 314 if(targetH != 0) delete targetH; 475 // if(cascadeParticle != 0) delete cascadeParticle;476 // if(aFragment != 0) delete aFragment;477 315 478 316 return &theResult;
Note: See TracChangeset
for help on using the changeset viewer.