269{
272
273
274 static G4bool CWinit =
true;
275 if(CWinit)
276 {
277 CWinit=false;
279 }
280
283#ifdef debug
284 G4cout<<
"G4QCohChargeExchange::PostStepDoIt: Before the GetMeanFreePath is called In4M="
287#endif
290#ifdef debug
291 G4cout<<
"G4QCohChargeExchange::PostStepDoIt: After GetMeanFreePath is called"<<
G4endl;
292#endif
296 if(std::fabs(Momentum-momentum)>.000001)
297 G4cerr<<
"*Warning*G4QCohChEx::PostStepDoIt:P(IU)="<<Momentum<<
"#"<<momentum<<
G4endl;
298#ifdef pdebug
299 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt: pP(IU)="<<Momentum<<
"="<<momentum
300 <<
",pM="<<pM<<
",proj4M="<<proj4M<<proj4M.
m()<<
G4endl;
301#endif
303 {
304 G4cerr<<
"G4QCoherentChargeExchange::PostStepDoIt: Only NA is implemented."<<
G4endl;
305 return 0;
306 }
311#ifdef debug
312 G4cout<<
"G4QCohChargeExchange::PostStepDoIt: "<<nE<<
" elements in the material."<<
G4endl;
313#endif
315
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346#ifdef debug
348 G4cout<<
"G4QCohChrgExchange::PostStepDoIt: projPDG="<<projPDG<<
", stPDG="<<prPDG<<
G4endl;
349#endif
350 if(!projPDG)
351 {
352 G4cerr<<
"*Warning*G4QCoherentChargeExchange::PostStepDoIt:UndefinedProjHadron"<<
G4endl;
353 return 0;
354 }
355
356
358 if(projPDG==2112) pM=mProt;
360
361 G4int EPIM=ElProbInMat.size();
362#ifdef debug
363 G4cout<<
"G4QCohChEx::PostStDoIt:m="<<EPIM<<
",n="<<nE<<
",T="<<ElProbInMat[EPIM-1]<<
G4endl;
364#endif
366 if(EPIM>1)
367 {
369 for(i=0; i<nE; ++i)
370 {
371#ifdef debug
372 G4cout<<
"G4QCohChEx::PostStepDoIt:EPM["<<i<<
"]="<<ElProbInMat[i]<<
",r="<<rnd<<
G4endl;
373#endif
374 if (rnd<ElProbInMat[i]) break;
375 }
376 if(i>=nE) i=nE-1;
377 }
378 G4Element* pElement=(*theElementVector)[i];
380#ifdef debug
381 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt: i="<<i<<
", Z(element)="<<Z<<
G4endl;
382#endif
383 if(Z<=0)
384 {
385 G4cerr<<
"-Warning-G4QCoherentChargeExchange::PostStepDoIt: Element with Z="<<Z<<
G4endl;
386 if(Z<0) return 0;
387 }
388 std::vector<G4double>* SPI = IsoProbInEl[i];
389 std::vector<G4int>* IsN = ElIsoN[i];
390 G4int nofIsot=SPI->size();
391#ifdef debug
392 G4cout<<
"G4QCohChargeExchange::PosStDoIt:nI="<<nofIsot<<
",T="<<(*SPI)[nofIsot-1]<<
G4endl;
393#endif
395 if(nofIsot>1)
396 {
398 for(j=0; j<nofIsot; ++j)
399 {
400#ifdef debug
401 G4cout<<
"G4QCohChargEx::PostStepDoIt: SP["<<j<<
"]="<<(*SPI)[j]<<
", r="<<rndI<<
G4endl;
402#endif
403 if(rndI < (*SPI)[j]) break;
404 }
405 if(j>=nofIsot) j=nofIsot-1;
406 }
407 G4int N =(*IsN)[j]; ;
408#ifdef debug
409 G4cout<<
"G4QCohChargeEx::PostStepDoIt: j="<<i<<
", N(isotope)="<<N<<
", MeV="<<MeV<<
G4endl;
410#endif
411 if(N<0)
412 {
413 G4cerr<<
"*Warning*G4QCohChEx::PostStepDoIt: Isotope with Z="<<Z<<
", 0>N="<<N<<
G4endl;
414 return 0;
415 }
416 nOfNeutrons=N;
417#ifdef debug
418 G4cout<<
"G4QCohChargeExchange::PostStepDoIt: N="<<N<<
" for element with Z="<<Z<<
G4endl;
419#endif
420 if(N<0)
421 {
422 G4cerr<<
"*Warning*G4QCoherentChargeExchange::PostStepDoIt:Element with N="<<N<<
G4endl;
423 return 0;
424 }
426#ifdef debug
427 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt: track is initialized"<<
G4endl;
428#endif
429 G4double weight = track.GetWeight();
430 G4double localtime = track.GetGlobalTime();
432#ifdef debug
433 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt: before Touchable extraction"<<
G4endl;
434#endif
436#ifdef debug
437 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt: Touchable is extracted"<<
G4endl;
438#endif
439
440 G4int targPDG=90000000+Z*1000+N;
441 if(projPDG==2212) targPDG+=999;
442 else if(projPDG==2112) targPDG-=999;
448#ifdef debug
449 G4cout<<
"G4QCohChrgEx::PostStepDoIt: tM="<<tM<<
", p4M="<<proj4M<<
", t4M="<<tot4M<<
G4endl;
450#endif
451 EnMomConservation=tot4M;
452
453#ifdef debug
454 G4cout<<
"G4QCCX::PSDI:false, P="<<Momentum<<
",Z="<<Z<<
",N="<<N<<
",PDG="<<projPDG<<
G4endl;
455#endif
456 G4double xSec=CalculateXSt(
false,
true, Momentum, Z, N, projPDG);
457#ifdef debug
458 G4cout<<
"G4QCoChEx::PSDI:PDG="<<projPDG<<
",P="<<Momentum<<
",CS="<<xSec/millibarn<<
G4endl;
459#endif
460#ifdef nandebug
461 if(xSec>0. || xSec<0. || xSec==0);
462 else G4cout<<
"*Warning*G4QCohChargeExchange::PSDI: xSec="<<xSec/millibarn<<
G4endl;
463#endif
464
465 if(xSec <= 0.)
466 {
467#ifdef pdebug
468 G4cerr<<
"*Warning*G4QCoherentChargeExchange::PSDoIt:*Zero cross-section* PDG="<<projPDG
469 <<
",tPDG="<<targPDG<<
",P="<<Momentum<<
G4endl;
470#endif
471
476 }
477 G4double mint=CalculateXSt(
false,
false, Momentum, Z, N, projPDG);
478#ifdef pdebug
479 G4cout<<
"G4QCohChEx::PoStDoIt:pPDG="<<projPDG<<
",tPDG="<<targPDG<<
",P="<<Momentum<<
",CS="
480 <<xSec<<
",-t="<<mint<<
G4endl;
481#endif
482#ifdef nandebug
483 if(mint>-.0000001);
484 else G4cout<<
"*Warning*G4QCoherentChargeExchange::PostStDoIt:-t="<<mint<<
G4endl;
485#endif
486 G4double maxt=CalculateXSt(
true,
false, Momentum, Z, N, projPDG);
487 if(maxt<=0.) maxt=1.e-27;
489
490#ifdef ppdebug
491 G4cout<<
"G4QCoherentChargeExchange::PoStDoIt:t="<<mint<<
",dpcm2="<<maxt
492 <<
",Ek="<<kinEnergy<<
",tM="<<tM<<
",pM="<<pM<<
",cost="<<cost<<
G4endl;
493#endif
494 if(cost>1. || cost<-1. || !(cost>-1. || cost<1.))
495 {
496 if(cost>1.000001 || cost<-1.000001 || !(cost>-1. || cost<1.))
497 {
501 G4double twop2cm=(tM2+tM2)*(pEn*pEn-pM2)/sM;
502 G4cout<<
"*Warning*G4QCohChEx::PostStepDoIt:cos="<<cost<<
",t="<<mint<<
",T="<<kinEnergy
503 <<
",tM="<<tM<<
",tmax="<<2*kinEnergy*tM<<
",p="<<projPDG<<
",t="<<targPDG<<
G4endl;
504 G4cout<<
"..G4QCohChEx::PoStDoI: dpcm2="<<twop2cm<<
"="<<maxt<<
G4endl;
505 }
506 if (cost>1.) cost=1.;
507 else if(cost<-1.) cost=-1.;
508 }
512 if(!
G4QHadron(tot4M).RelDecayIn2(scat4M, reco4M, dir4M, cost, cost))
513 {
514 G4cerr<<
"G4QCohChEx::PSDI:t4M="<<tot4M<<
",pM="<<pM<<
",tM="<<tM<<
",cost="<<cost<<
G4endl;
515
516 }
517#ifdef debug
518 G4cout<<
"G4QCohChEx::PoStDoIt:s4M="<<scat4M<<
"+r4M="<<reco4M<<
"="<<scat4M+reco4M<<
G4endl;
519 G4cout<<
"G4QCohChEx::PoStDoIt: scatE="<<scat4M.
e()-pM<<
", recoE="<<reco4M.
e()-tM<<
",d4M="
520 <<tot4M-scat4M-reco4M<<
G4endl;
521#endif
522
524
529 EnMomConservation-=scat4M;
535
538#ifdef pdebug
539 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt: Ion Z="<<Z<<
", A="<<aA<<
G4endl;
540#endif
542 if(!theDefinition)
G4cout<<
"*Warning*G4QCohChEx::PostStepDoIt:drop PDG="<<targPDG<<
G4endl;
543#ifdef pdebug
545#endif
547 EnMomConservation-=reco4M;
548#ifdef tdebug
549 G4cout<<
"G4QCohChEx::PostSDoIt:"<<targPDG<<reco4M<<reco4M.
m()<<EnMomConservation<<
G4endl;
550#endif
552#ifdef debug
556 G4cout<<
"G4QCohChEx::PostStpDoIt:p="<<curD<<curD.
mag()<<
",e="<<curE<<
",m="<<curM<<
G4endl;
557#endif
558
563#ifdef debug
564 G4cout<<
"G4QCoherentChargeExchange::PostStepDoIt:*** PostStepDoIt is done ***"<<
G4endl;
565#endif
567}
CLHEP::HepLorentzVector G4LorentzVector
const G4ThreeVector & GetMomentumDirection() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
G4LorentzVector Get4Momentum() const
void Set4Momentum(const G4LorentzVector &momentum)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
void AddSecondary(G4Track *aSecondary)
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
virtual void Initialize(const G4Track &)
const G4String & GetParticleType() const
const G4String & GetParticleName() const
const G4String & GetParticleSubType() const
G4ParticleDefinition * FindIon(G4int atomicNumber, G4int atomicMass, G4double excitationEnergy)
static G4ParticleTable * GetParticleTable()
static G4QCHIPSWorld * Get()
G4QParticleVector * GetParticles(G4int nOfParts=0)
G4double GetMeanFreePath(const G4Track &aTrack, G4double previousStepSize, G4ForceCondition *condition)
void SetWeight(G4double aValue)
void SetTouchableHandle(const G4TouchableHandle &apValue)
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
G4ParticleChange aParticleChange