405 if (verboseLevel > 1)
406 G4cout <<
" >>> G4CollisionOutput::setOnShell" <<
G4endl;
415 if(verboseLevel > 2){
416 G4cout <<
" bullet momentum = " << ini_mom.
e() <<
", "<< ini_mom.
x() <<
", "<< ini_mom.
y()<<
", "<< ini_mom.
z()<<
G4endl;
417 G4cout <<
" target momentum = " << momt.
e()<<
", "<< momt.
x()<<
", "<< momt.
y()<<
", "<< momt.
z()<<
G4endl;
418 G4cout <<
" Fstate momentum = " << out_mom.
e()<<
", "<< out_mom.
x()<<
", "<< out_mom.
y()<<
", "<< out_mom.
z()<<
G4endl;
423 mom_non_cons = ini_mom - out_mom;
429 if(verboseLevel > 2) {
431 G4cout <<
" momentum non conservation: " << G4endl
432 <<
" e " << enc <<
" p " << pnc << G4endl
433 <<
" remaining exitation " << eex_rest <<
G4endl;
436 if (std::fabs(enc) <= accuracy && pnc <= accuracy) {
444 if (verboseLevel > 2)
G4cout <<
" re-balancing four-momenta" <<
G4endl;
453 for (
G4int ip=npart-1; ip>=0; ip--) {
454 if (outgoingParticles[ip].getKineticEnergy()+enc > 0.) {
455 last_mom = outgoingParticles[ip].getMomentum();
456 last_mom += mom_non_cons;
457 outgoingParticles[ip].setMomentum(last_mom);
461 }
else if (nnuc > 0) {
462 for (
G4int in=nnuc-1; in>=0; in--) {
463 if (outgoingNuclei[in].getKineticEnergy()+enc > 0.) {
464 last_mom = outgoingNuclei[in].getMomentum();
465 last_mom += mom_non_cons;
466 outgoingNuclei[in].setMomentum(last_mom);
470 }
else if (nfrag > 0) {
471 for (
G4int ifr=nfrag-1; ifr>=0; ifr--) {
473 last_mom = recoilFragments[ifr].GetMomentum()/
GeV;
474 if ((last_mom.
e()-last_mom.
m())+enc > 0.) {
475 last_mom += mom_non_cons;
476 recoilFragments[ifr].SetMomentum(last_mom*
GeV);
484 mom_non_cons = ini_mom - out_mom;
485 pnc = mom_non_cons.
rho();
486 enc = mom_non_cons.
e();
488 if(verboseLevel > 2){
490 G4cout <<
" momentum non conservation after (1): " << G4endl
491 <<
" e " << enc <<
" p " << pnc <<
G4endl;
495 G4bool need_hard_tuning =
true;
499 for (
G4int i=0; i < nfrag; i++) {
500 G4double eex = recoilFragments[0].GetExcitationEnergy();
501 if (eex > 0.0 && eex + encMeV >= 0.0) {
508 need_hard_tuning =
false;
512 }
else if (nnuc > 0) {
513 for (
G4int i=0; i < nnuc; i++) {
514 G4double eex = outgoingNuclei[i].getExitationEnergy();
515 if (eex > 0.0 && eex + encMeV >= 0.0) {
516 outgoingNuclei[i].setExitationEnergy(eex+encMeV);
517 need_hard_tuning =
false;
521 if (need_hard_tuning && encMeV > 0.) {
522 outgoingNuclei[0].setExitationEnergy(encMeV);
523 need_hard_tuning =
false;
527 if (!need_hard_tuning) {
533 if (verboseLevel > 2)
534 G4cout <<
" trying hard (particle-pair) tuning" <<
G4endl;
564 std::pair<std::pair<G4int, G4int>,
G4int> tune_par = selectPairToTune(enc);
565 std::pair<G4int, G4int> tune_particles = tune_par.first;
566 G4int mom_ind = tune_par.second;
569 (tune_particles.first >= 0 && tune_particles.second >= 0 &&
572 if (!tuning_possible) {
573 if (verboseLevel > 2)
G4cout <<
" tuning impossible " <<
G4endl;
577 if(verboseLevel > 2) {
578 G4cout <<
" p1 " << tune_particles.first <<
" p2 " << tune_particles.second
579 <<
" ind " << mom_ind <<
G4endl;
582 G4LorentzVector mom1 = outgoingParticles[tune_particles.first].getMomentum();
583 G4LorentzVector mom2 = outgoingParticles[tune_particles.second].getMomentum();
585 if (tuneSelectedPair(mom1, mom2, mom_ind)) {
586 outgoingParticles[tune_particles.first ].setMomentum(mom1);
587 outgoingParticles[tune_particles.second].setMomentum(mom2);
594 mom_non_cons = ini_mom - out_mom;
595 pnc = mom_non_cons.
rho();
596 enc = mom_non_cons.e();
598 on_shell = (std::fabs(enc) < accuracy || pnc < accuracy);
600 if(verboseLevel > 2) {
601 G4cout <<
" momentum non conservation tuning: " << G4endl
602 <<
" e " << enc <<
" p " << pnc
603 << (on_shell?
" success":
" FAILURE") << G4endl;
G4LorentzVector getMomentum() const
void printCollisionOutput(std::ostream &os=G4cout) const
G4LorentzVector getTotalOutputMomentum() const
void setVectM(const Hep3Vector &spatial, double mass)
G4GLOB_DLL std::ostream G4cout
G4int numberOfOutgoingParticles() const
G4int numberOfOutgoingNuclei() const
static constexpr double GeV
void setRemainingExitationEnergy()
G4int numberOfFragments() const