99   #ifdef debugFTFexictation 
  105   if ( Pprojectile.
z() < 0.0 ) 
return false;
 
  108   G4int absProjectilePDGcode = std::abs( ProjectilePDGcode );
 
  115   G4int absTargetPDGcode = std::abs( TargetPDGcode );
 
  128   G4bool PutOnMassShell( 
false );
 
  135   if ( M0projectile < MminProjectile ) {
 
  136     PutOnMassShell = 
true;
 
  141   G4double M0projectile2 = M0projectile * M0projectile;
 
  144   if ( M0projectile > ProjectileDiffStateMinMass ) {
 
  145     ProjectileDiffStateMinMass    = M0projectile + 220.0*
MeV;
 
  146     ProjectileNonDiffStateMinMass = M0projectile + 220.0*
MeV;
 
  147     if ( absProjectilePDGcode > 3000 ) {  
 
  148       ProjectileDiffStateMinMass    += 140.0*
MeV;
 
  149       ProjectileNonDiffStateMinMass += 140.0*
MeV;
 
  155   if ( M0target < MminTarget ) {
 
  156     PutOnMassShell = 
true;
 
  161   G4double M0target2 = M0target * M0target; 
 
  164   if ( M0target > TargetDiffStateMinMass ) {
 
  165     TargetDiffStateMinMass    = M0target + 220.0*
MeV;
 
  166     TargetNonDiffStateMinMass = M0target + 220.0*
MeV;
 
  167     if ( absTargetPDGcode > 3000 ) {  
 
  168       TargetDiffStateMinMass    += 140.0*
MeV;
 
  169       TargetNonDiffStateMinMass += 140.0*
MeV;
 
  173   #ifdef debugFTFexictation 
  174   G4cout << 
"Proj Targ PDGcodes " << ProjectilePDGcode << 
" " << TargetPDGcode << G4endl
 
  175          << 
"M0projectile Y " << M0projectile << 
" " << ProjectileRapidity << 
G4endl;
 
  177   G4cout << 
"Pproj " << Pprojectile << G4endl << 
"Ptarget " << Ptarget << 
G4endl;
 
  183   G4double SumMasses = M0projectile + M0target;  
 
  189   if ( Ptmp.pz() <= 0.0 ) 
return false;  
 
  191   toCms.
rotateZ( -1*Ptmp.phi() );
 
  192   toCms.
rotateY( -1*Ptmp.theta() );
 
  199   #ifdef debugFTFexictation 
  200   G4cout << 
"SqrtS     " << SqrtS << G4endl << 
"M0pr M0tr SumM+220 " << M0projectile << 
" " 
  201          << M0target << 
" " << SumMasses << 
G4endl;
 
  204   if ( SqrtS < M0projectile + M0target ) 
return false;
 
  205   if ( SqrtS < SumMasses ) 
return false;
 
  208   PZcms2 = ( S*S + M0projectile2*M0projectile2 + M0target2*M0target2
 
  209              - 2*S*M0projectile2 - 2*S*M0target2 - 2*M0projectile2*M0target2 ) / 4.0 / S;
 
  211   #ifdef debugFTFexictation 
  212   G4cout << 
"PZcms2 after PutOnMassShell " << PZcms2 << 
G4endl;
 
  215   if ( PZcms2 < 0 ) 
return false;
 
  218   PZcms = std::sqrt( PZcms2 );
 
  219   if ( PutOnMassShell ) {
 
  220     if ( Pprojectile.z() > 0.0 ) {
 
  221       Pprojectile.setPz(  PZcms );
 
  222       Ptarget.setPz(     -PZcms );
 
  224       Pprojectile.setPz( -PZcms );
 
  225       Ptarget.setPz(      PZcms );
 
  227     Pprojectile.setE( std::sqrt( M0projectile2 +
 
  228                                  Pprojectile.x()*Pprojectile.x() +
 
  229                                  Pprojectile.y()*Pprojectile.y() +
 
  231     Ptarget.setE( std::sqrt( M0target2 +
 
  232                              Ptarget.x()*Ptarget.x() +
 
  233                              Ptarget.y()*Ptarget.y() +
 
  246   #ifdef debugFTFexictation 
  247   G4cout << 
"Start --------------------" << G4endl << 
"Proj M0 Mdif Mndif " << M0projectile 
 
  248          << 
" " << ProjectileDiffStateMinMass << 
"  " << ProjectileNonDiffStateMinMass << G4endl
 
  249          << 
"Targ M0 Mdif Mndif " << M0target << 
" " << TargetDiffStateMinMass << 
" "  
  250          << TargetNonDiffStateMinMass << G4endl << 
"SqrtS " << SqrtS << G4endl
 
  251          << 
"Proj CMS " << Pprojectile << G4endl << 
"Targ CMS " << Ptarget << 
G4endl;
 
  268   if ( QeNoExc + QeExc + ProbProjectileDiffraction + ProbTargetDiffraction > 1.0 ) {
 
  269     QeNoExc = 1.0 - QeExc - ProbProjectileDiffraction - ProbTargetDiffraction;
 
  273   if ( QeExc + QeNoExc != 0.0 ) ProbExc = QeExc/(QeExc + QeNoExc);
 
  279   G4double ProbOfDiffraction = ProbProjectileDiffraction + ProbTargetDiffraction;
 
  281   #ifdef debugFTFexictation 
  282   G4cout << 
"Proc Probs " << QeNoExc << 
" " << QeExc << 
" " << ProbProjectileDiffraction
 
  283          << 
" " << ProbTargetDiffraction << G4endl 
 
  284          << 
"ProjectileRapidity " << ProjectileRapidity << 
G4endl;
 
  289   G4double MtestPr( 0.0 ), MtestTr( 0.0 );
 
  291   if ( 1.0 - QeExc - QeNoExc > 0.0 ) { 
 
  292     ProbProjectileDiffraction /= ( 1.0 - QeExc - QeNoExc );
 
  293     ProbTargetDiffraction     /= ( 1.0 - QeExc - QeNoExc );
 
  298     #ifdef debugFTFexictation 
  299     G4cout << 
"Q exchange --------------------------" << 
G4endl;
 
  302     G4int NewProjCode( 0 ), NewTargCode( 0 );
 
  303     G4int ProjQ1( 0 ), ProjQ2( 0 ), ProjQ3( 0 );
 
  306     if ( absProjectilePDGcode < 1000 ) {  
 
  307       UnpackMeson( ProjectilePDGcode, ProjQ1, ProjQ2 );  
 
  309       UnpackBaryon( ProjectilePDGcode, ProjQ1, ProjQ2, ProjQ3 );
 
  313     G4int TargQ1( 0 ), TargQ2( 0 ), TargQ3( 0 );
 
  314     UnpackBaryon( TargetPDGcode, TargQ1, TargQ2, TargQ3 ); 
 
  316     #ifdef debugFTFexictation 
  317     G4cout << 
"Proj Quarks " << ProjQ1 << 
" " << ProjQ2 << 
" " << ProjQ3 << G4endl
 
  318            << 
"Targ Quarks " << TargQ1 << 
" " << TargQ2 << 
" " << TargQ3 << 
G4endl;
 
  322     G4int ProjExchangeQ( 0 );
 
  323     G4int TargExchangeQ( 0 );
 
  325     if ( absProjectilePDGcode < 1000 ) {  
 
  328         ProjExchangeQ = ProjQ1;
 
  330         G4int NpossibleStates = 3;
 
  332         if ( ProjQ1 != TargQ1 ) NpossibleStates++;
 
  333         if ( ProjQ1 != TargQ2 ) NpossibleStates++;
 
  334         if ( ProjQ1 != TargQ3 ) NpossibleStates++;  
 
  336         G4int Nsampled = G4RandFlat::shootInt( 
G4long( NpossibleStates ) ) + 1;
 
  340         if ( ProjQ1 != TargQ1 ) {
 
  342           if ( NpossibleStates == Nsampled ) {
 
  343             TargExchangeQ = TargQ1; TargQ1 = ProjExchangeQ; ProjQ1 = TargExchangeQ;
 
  346         if ( ProjQ1 != TargQ2 ) {
 
  348           if ( NpossibleStates == Nsampled ) {
 
  349             TargExchangeQ = TargQ2; TargQ2 = ProjExchangeQ; ProjQ1 = TargExchangeQ;
 
  352         if ( ProjQ1 != TargQ3 ) {
 
  354           if ( NpossibleStates == Nsampled ) {
 
  355             TargExchangeQ = TargQ3; TargQ3 = ProjExchangeQ; ProjQ1 = TargExchangeQ;
 
  364         ProjExchangeQ = ProjQ2;
 
  366         G4int NpossibleStates = 3;
 
  368         if ( ProjQ2 != TargQ1 ) NpossibleStates++;
 
  369         if ( ProjQ2 != TargQ2 ) NpossibleStates++;
 
  370         if ( ProjQ2 != TargQ3 ) NpossibleStates++;
 
  372         G4int Nsampled = G4RandFlat::shootInt( 
G4long( NpossibleStates ) ) + 1;
 
  375         if ( ProjQ2 != TargQ1 ) {
 
  377           if ( NpossibleStates == Nsampled ) {
 
  378             TargExchangeQ = TargQ1; TargQ1 = ProjExchangeQ; ProjQ2 = TargExchangeQ;
 
  381         if ( ProjQ2 != TargQ2 ) {
 
  383           if ( NpossibleStates == Nsampled ) {
 
  384             TargExchangeQ = TargQ2; TargQ2 = ProjExchangeQ; ProjQ2 = TargExchangeQ;
 
  387         if ( ProjQ2 != TargQ3 ) {
 
  389           if ( NpossibleStates == Nsampled ) {
 
  390             TargExchangeQ = TargQ3; TargQ3 = ProjExchangeQ; ProjQ2 = TargExchangeQ;
 
  400       #ifdef debugFTFexictation 
  401       G4cout << 
"Exchanged Qs in Pr Tr " << ProjExchangeQ << 
" " << TargExchangeQ << 
G4endl;
 
  404       G4int aProjQ1 = std::abs( ProjQ1 );
 
  405       G4int aProjQ2 = std::abs( ProjQ2 );
 
  407       G4bool ProjExcited = 
false;
 
  410       while ( attempts < 50 ) {  
 
  414         if ( aProjQ1 == aProjQ2 ) {
 
  415           if ( aProjQ1 != 3 ) {
 
  430           if ( aProjQ1 > aProjQ2 ) {
 
  431             NewProjCode = aProjQ1*100 + aProjQ2*10 + 1;
 
  433             NewProjCode = aProjQ2*100 + aProjQ1*10 + 1;
 
  437         #ifdef debugFTFexictation 
  448         if      ( aProjQ1 == 1 ) { Qquarks -= ProjQ1; }
 
  449         else if ( aProjQ1 == 2 ) { Qquarks += ProjQ1; }
 
  450         else                     { Qquarks -= ProjQ1/aProjQ1; }
 
  452         if      ( aProjQ2 == 1 ) { Qquarks -= ProjQ2; }
 
  453         else if ( aProjQ2 == 2 ) { Qquarks += ProjQ2; }
 
  454         else                     { Qquarks -= ProjQ2/aProjQ2; }
 
  456         if ( Qquarks < 0 ) NewProjCode *= -1;
 
  458         #ifdef debugFTFexictation 
  459         G4cout << 
"NewProjCode +2 or 0 " << NewProjCode << 
G4endl;
 
  460         G4cout<<
"+++++++++++++++++++++++++++++++++++++++"<<
G4endl;
 
  462         G4cout<<
"+++++++++++++++++++++++++++++++++++++++"<<
G4endl;
 
  467         if ( ! TestParticle ) 
continue;
 
  472         if ( SqrtS - M0target < MminProjectile ) 
continue;
 
  478         #ifdef debugFTFexictation 
  481         G4cout << 
"M0projectile projectile PDGMass " << M0projectile << 
" "  
  486         NewTargCode = NewNucleonId( TargQ1, TargQ2, TargQ3 );
 
  488         #ifdef debugFTFexictation 
  489         G4cout << 
"New TrQ " << TargQ1 << 
" " << TargQ2 << 
" " << TargQ3 << G4endl
 
  490                << 
"NewTargCode " << NewTargCode << 
G4endl;
 
  493         if ( TargQ1 != TargQ2  &&  TargQ1 != TargQ3  &&  TargQ2 != TargQ3 ) {  
 
  499         } 
else if ( TargQ1 == TargQ2  &&  TargQ1 == TargQ3 ) {
 
  500           NewTargCode += 2; ProjExcited = 
true;                         
 
  503             NewTargCode += 2; ProjExcited = 
true;                       
 
  506         } 
else if ( ! ProjExcited  &&
 
  508                     SqrtS > M0projectile + DeltaMass ) {                
 
  515         if ( ! TestParticle ) 
continue;
 
  517         #ifdef debugFTFexictation 
  523         if ( SqrtS - MtestPr < MminTarget ) 
continue;
 
  528         if ( SqrtS > MtestPr + MtestTr ) 
break;
 
  532       if ( attempts >= 50 ) 
return false;
 
  545       if ( MtestPr >= Pprojectile.mag() ) { 
 
  546         M0projectile = MtestPr;
 
  547       } 
else if ( projectile->
GetStatus() != 0 ) {
 
  548         M0projectile = MtestPr;
 
  551       #ifdef debugFTFexictation 
  552       G4cout << 
"M0projectile After check " << M0projectile << 
G4endl;
 
  555       M0projectile2 = M0projectile * M0projectile;
 
  556       ProjectileDiffStateMinMass    = M0projectile + 220.0*
MeV;  
 
  557       ProjectileNonDiffStateMinMass = M0projectile + 220.0*
MeV;  
 
  559       if ( MtestTr >= Ptarget.mag() ) {
 
  577       M0target2 = M0target * M0target;
 
  579       #ifdef debugFTFexictation 
  580       G4cout << 
"New targ M0 M0^2 " << M0target << 
" " << M0target2 << 
G4endl;
 
  583       TargetDiffStateMinMass    = M0target + 220.0*
MeV;          
 
  584       TargetNonDiffStateMinMass = M0target + 220.0*
MeV;          
 
  597         if ( Ksi < 0.333333 ) {
 
  598           ProjExchangeQ = ProjQ1;
 
  599         } 
else if ( 0.333333 <= Ksi  &&  Ksi < 0.666667 ) {
 
  600           ProjExchangeQ = ProjQ2;
 
  602           ProjExchangeQ = ProjQ3;
 
  606           TargExchangeQ = TargQ1; TargQ1 = ProjExchangeQ; ProjExchangeQ = TargExchangeQ;
 
  609             TargExchangeQ = TargQ2; TargQ2 = ProjExchangeQ; ProjExchangeQ = TargExchangeQ;
 
  611             TargExchangeQ = TargQ3; TargQ3 = ProjExchangeQ; ProjExchangeQ = TargExchangeQ;
 
  615         #ifdef debugFTFexictation 
  616         G4cout << 
"Exchange Qs Pr  Tr " << ProjExchangeQ << 
" " << TargExchangeQ << 
G4endl;
 
  619         if ( Ksi < 0.333333 ) {
 
  620           ProjQ1 = ProjExchangeQ;
 
  621         } 
else if ( 0.333333 <= Ksi  &&  Ksi < 0.666667 ) {
 
  622           ProjQ2 = ProjExchangeQ;
 
  624           ProjQ3 = ProjExchangeQ;
 
  629         if ( Ksi < 0.333333 ) {
 
  630           TargExchangeQ = TargQ1;
 
  631         } 
else if ( 0.333333 <= Ksi  &&  Ksi < 0.666667 ) {
 
  632           TargExchangeQ = TargQ2;
 
  634           TargExchangeQ = TargQ3;
 
  637           ProjExchangeQ = ProjQ1; ProjQ1 = TargExchangeQ; TargExchangeQ = ProjExchangeQ;
 
  640             ProjExchangeQ = ProjQ2; ProjQ2 = TargExchangeQ; TargExchangeQ = ProjExchangeQ;
 
  642             ProjExchangeQ = ProjQ3; ProjQ3 = TargExchangeQ; TargExchangeQ = ProjExchangeQ;
 
  646         if ( Ksi < 0.333333 ) {
 
  647           TargQ1 = TargExchangeQ;
 
  648         } 
else if ( 0.333333 <= Ksi  &&  Ksi < 0.666667 )  {
 
  649           TargQ2 = TargExchangeQ;
 
  651           TargQ3 = TargExchangeQ;
 
  656       NewProjCode = NewNucleonId( ProjQ1, ProjQ2, ProjQ3 );
 
  657       NewTargCode = NewNucleonId( TargQ1, TargQ2, TargQ3 );
 
  660       while ( attempts < 50 ) {  
 
  664         if ( ProjQ1 == ProjQ2  &&  ProjQ1 == ProjQ3 ) {
 
  673           if ( 
G4UniformRand() < DeltaProbAtQuarkExchange  &&  SqrtS > DeltaMass + M0target ) {
 
  680         if ( TargQ1 == TargQ2  &&  TargQ1 == TargQ3 ) { 
 
  689           if ( 
G4UniformRand() < DeltaProbAtQuarkExchange  &&  SqrtS > M0projectile + DeltaMass ) {
 
  696         #ifdef debugFTFexictation 
  697         G4cout << 
"NewProjCode NewTargCode " << NewProjCode << 
" " << NewTargCode << 
G4endl;
 
  701         if ( absProjectilePDGcode == NewProjCode  &&  absTargetPDGcode == NewTargCode ) { 
 
  731         if ( ! TestParticle ) 
continue;
 
  735         if ( SqrtS - M0target < MminProjectile ) 
continue;
 
  742         if ( ! TestParticle ) 
continue;
 
  746         if ( SqrtS - MtestPr < MminTarget ) 
continue;
 
  751         if ( SqrtS > MtestPr + MtestTr ) 
break;
 
  754       if ( attempts >= 50 ) 
return false;
 
  756       if ( MtestPr >= Pprojectile.mag() ) { 
 
  757         M0projectile = MtestPr;
 
  758       } 
else if ( projectile->
GetStatus() != 0  ) {
 
  759         M0projectile = MtestPr;
 
  761       M0projectile2 = M0projectile * M0projectile;
 
  762       ProjectileDiffStateMinMass =    M0projectile + 220.0*
MeV;  
 
  763       ProjectileNonDiffStateMinMass = M0projectile + 220.0*
MeV;  
 
  765       if ( MtestTr >= Ptarget.mag() ) {
 
  770       M0target2 = M0target * M0target;
 
  771       TargetDiffStateMinMass    = M0target + 220.0*
MeV;          
 
  772       TargetNonDiffStateMinMass = M0target + 220.0*
MeV;          
 
  778     if ( SqrtS < M0projectile + M0target ) 
return false;
 
  780     PZcms2 = ( S*S + M0projectile2*M0projectile2 + M0target2*M0target2
 
  781                - 2*S*M0projectile2 - 2*S*M0target2 - 2*M0projectile2*M0target2 ) / 4.0 / S;
 
  783     #ifdef debugFTFexictation 
  784     G4cout << 
"At the end// NewProjCode " << NewProjCode << G4endl 
 
  785            << 
"At the end// NewTargCode " << NewTargCode << G4endl
 
  786            << 
"M0pr  M0tr  SqS " << M0projectile << 
" " << M0target << 
" " << SqrtS << G4endl
 
  787            << 
"M0pr2 M0tr2 SqS " << M0projectile2 << 
" " << M0target2 << 
" " << SqrtS << G4endl
 
  788            << 
"PZcms2 after the change " << PZcms2 << G4endl << 
G4endl;
 
  791     if ( PZcms2 < 0 ) 
return false;  
 
  796     PZcms = std::sqrt( PZcms2 );
 
  797     Pprojectile.setPz( PZcms );
 
  798     Pprojectile.setE( std::sqrt( M0projectile2 + PZcms2 ) );
 
  799     Ptarget.setPz(    -PZcms );
 
  800     Ptarget.setE( std::sqrt( M0target2 + PZcms2 ) );
 
  805     #ifdef debugFTFexictation 
  806     G4cout << 
"Proj Targ and Proj+Targ in CMS" << G4endl << Pprojectile << G4endl << Ptarget
 
  807            << G4endl << Pprojectile + Ptarget << 
G4endl;
 
  811     if ( SqrtS < M0projectile + TargetDiffStateMinMass  ||
 
  812          SqrtS < ProjectileDiffStateMinMass + M0target  ||
 
  813          ProbOfDiffraction == 0.0 ) ProbExc = 0.0;
 
  817       #ifdef debugFTFexictation 
  818       G4cout << 
"Make elastic scattering of new hadrons" << 
G4endl;
 
  821       Pprojectile.transform( toLab );
 
  822       Ptarget.transform( toLab );
 
  829       #ifdef debugFTFexictation 
  830       G4cout << 
"Result of el. scatt " << Result << G4endl << 
"Proj Targ and Proj+Targ in Lab" 
  840     #ifdef debugFTFexictation 
  846     ProbOfDiffraction = ProbProjectileDiffraction + ProbTargetDiffraction;
 
  847     if ( ProbOfDiffraction != 0.0 ) {
 
  848       ProbProjectileDiffraction /= ProbOfDiffraction;
 
  849       ProbTargetDiffraction     /= ProbOfDiffraction;
 
  855   ProbOfDiffraction = ProbProjectileDiffraction + ProbTargetDiffraction;
 
  857   #ifdef debugFTFexictation 
  858   G4cout << 
"Excitation --------------------" << G4endl
 
  859          << 
"Proj M0 MdMin MndMin " << M0projectile << 
" " << ProjectileDiffStateMinMass << 
"  " 
  860          << ProjectileNonDiffStateMinMass << G4endl
 
  861          << 
"Targ M0 MdMin MndMin " << M0target << 
" " << TargetDiffStateMinMass << 
" "  
  862          << TargetNonDiffStateMinMass << G4endl << 
"SqrtS " << SqrtS << G4endl
 
  863          << 
"Prob: ProjDiff TargDiff + Sum " << ProbProjectileDiffraction << 
" "  
  864          << ProbTargetDiffraction << 
" " << ProbOfDiffraction << 
G4endl;
 
  867   if ( ProbOfDiffraction != 0.0 ) {
 
  868     ProbProjectileDiffraction /= ProbOfDiffraction;
 
  870     ProbProjectileDiffraction = 0.0;
 
  873   #ifdef debugFTFexictation 
  874   G4cout << 
"Prob: ProjDiff TargDiff + Sum " << ProbProjectileDiffraction << 
" "  
  875          << ProbTargetDiffraction << 
" " << ProbOfDiffraction << 
G4endl;
 
  878   G4double ProjectileDiffStateMinMass2    = 
sqr( ProjectileDiffStateMinMass );
 
  879   G4double ProjectileNonDiffStateMinMass2 = 
sqr( ProjectileNonDiffStateMinMass );
 
  880   G4double TargetDiffStateMinMass2        = 
sqr( TargetDiffStateMinMass );
 
  881   G4double TargetNonDiffStateMinMass2     = 
sqr( TargetNonDiffStateMinMass );
 
  889   G4double PMinusNew, PPlusNew, TPlusNew, TMinusNew;
 
  892   G4int whilecount = 0;  
 
  899       #ifdef debugFTFexictation 
  914         if ( whilecount > 1000 ) {
 
  920         ProjMassT2 = ProjectileDiffStateMinMass2;
 
  921         ProjMassT  = ProjectileDiffStateMinMass;
 
  922         TargMassT2 = M0target2;
 
  923         TargMassT  = M0target;
 
  924         if ( SqrtS < ProjMassT + TargMassT ) 
return false;
 
  926         PZcms2 =( S*S + ProjMassT2*ProjMassT2 + TargMassT2*TargMassT2
 
  927                   - 2.0*S*ProjMassT2 - 2.0*S*TargMassT2 - 2.0*ProjMassT2*TargMassT2 ) / 4.0 / S;
 
  929         if ( PZcms2 < 0 ) 
return false; 
 
  931         maxPtSquare = PZcms2;
 
  933         Qmomentum = 
G4LorentzVector( GaussianPt( AveragePt2, maxPtSquare ), 0 );
 
  936         ProjMassT2 = ProjectileDiffStateMinMass2 + Pt2;
 
  937         ProjMassT = std::sqrt( ProjMassT2 );
 
  938         TargMassT2 = M0target2 + Pt2;
 
  939         TargMassT = std::sqrt( TargMassT2 );
 
  940         if ( SqrtS < ProjMassT + TargMassT ) 
continue;
 
  942         PZcms2 = ( S*S + ProjMassT2*ProjMassT2 + TargMassT2*TargMassT2
 
  943                    - 2.0*S*ProjMassT2 - 2.0*S*TargMassT2 - 2.0*ProjMassT2*TargMassT2 ) / 4.0 / S;
 
  945         if ( PZcms2 < 0 ) 
continue;
 
  947         PZcms = std::sqrt( PZcms2 );
 
  948         PMinusMin = std::sqrt( ProjMassT2 + PZcms2 ) - PZcms;
 
  949         PMinusMax = SqrtS - TargMassT;
 
  952         PMinusNew = ChooseP( PMinusMin, PMinusMax );
 
  954         TMinusNew = SqrtS - PMinusNew;
 
  955         Qminus = Ptarget.minus() - TMinusNew;
 
  956         TPlusNew = TargMassT2 / TMinusNew;
 
  957         Qplus = Ptarget.plus() - TPlusNew;
 
  958         Qmomentum.
setPz( (Qplus - Qminus)/2 );
 
  959         Qmomentum.
setE(  (Qplus + Qminus)/2 );
 
  961       } 
while ( ( Pprojectile + Qmomentum ).mag2() <  ProjectileDiffStateMinMass2 );  
 
  971       #ifdef debugFTFexictation 
  986         if ( whilecount > 1000 ) {
 
  992         ProjMassT2 = M0projectile2;
 
  993         ProjMassT  = M0projectile;
 
  995         TargMassT2 = TargetDiffStateMinMass2;
 
  996         TargMassT  = TargetDiffStateMinMass;
 
  998         if ( SqrtS < ProjMassT + TargMassT ) 
return false;
 
 1000         PZcms2 = ( S*S + ProjMassT2*ProjMassT2 + TargMassT2*TargMassT2
 
 1001                    - 2.0*S*ProjMassT2 - 2.0*S*TargMassT2 - 2.0*ProjMassT2*TargMassT2 ) / 4.0 / S;
 
 1003         if ( PZcms2 < 0 ) 
return false; 
 
 1005         maxPtSquare = PZcms2;
 
 1007         Qmomentum = 
G4LorentzVector( GaussianPt( AveragePt2, maxPtSquare ), 0 );
 
 1010         ProjMassT2 = M0projectile2 + Pt2;
 
 1011         ProjMassT  = std::sqrt( ProjMassT2 );
 
 1012         TargMassT2 = TargetDiffStateMinMass2 + Pt2;
 
 1013         TargMassT  = std::sqrt( TargMassT2 );
 
 1014         if ( SqrtS < ProjMassT + TargMassT ) 
continue;
 
 1016         PZcms2 = ( S*S + ProjMassT2*ProjMassT2 + TargMassT2*TargMassT2
 
 1017                    - 2.0*S*ProjMassT2 - 2.0*S*TargMassT2 - 2.0*ProjMassT2*TargMassT2 ) / 4.0 / S;
 
 1019         if ( PZcms2 < 0 ) 
continue;
 
 1021         PZcms = std::sqrt( PZcms2 );
 
 1022         TPlusMin = std::sqrt( TargMassT2 + PZcms2 ) - PZcms;
 
 1024         TPlusMax = SqrtS - ProjMassT;
 
 1026         TPlusNew = ChooseP( TPlusMin, TPlusMax );
 
 1029         PPlusNew = SqrtS - TPlusNew;
 
 1030         Qplus = PPlusNew - Pprojectile.plus();
 
 1031         PMinusNew = ProjMassT2 / PPlusNew;
 
 1032         Qminus = PMinusNew - Pprojectile.minus();
 
 1033         Qmomentum.
setPz( (Qplus - Qminus)/2 );
 
 1034         Qmomentum.
setE(  (Qplus + Qminus)/2 );
 
 1036       } 
while ( ( Ptarget - Qmomentum ).mag2() <  TargetDiffStateMinMass2 );  
 
 1048     #ifdef debugFTFexictation 
 1063       if ( whilecount > 1000 ) {
 
 1069       ProjMassT2 = ProjectileNonDiffStateMinMass2;
 
 1070       ProjMassT  = ProjectileNonDiffStateMinMass;
 
 1071       TargMassT2 = TargetNonDiffStateMinMass2;
 
 1072       TargMassT  = TargetNonDiffStateMinMass;
 
 1073       if ( SqrtS < ProjMassT + TargMassT ) 
return false;
 
 1075       PZcms2 = ( S*S + ProjMassT2*ProjMassT2 + TargMassT2*TargMassT2
 
 1076                  - 2.0*S*ProjMassT2 - 2.0*S*TargMassT2 - 2.0*ProjMassT2*TargMassT2 ) / 4.0 / S;
 
 1078       if ( PZcms2 < 0 ) 
return false; 
 
 1080       maxPtSquare = PZcms2;
 
 1082       Qmomentum = 
G4LorentzVector( GaussianPt( AveragePt2, maxPtSquare ), 0 );
 
 1085       ProjMassT2 = ProjectileNonDiffStateMinMass2 + Pt2;
 
 1086       ProjMassT  = std::sqrt( ProjMassT2 );
 
 1087       TargMassT2 = TargetNonDiffStateMinMass2 + Pt2;
 
 1088       TargMassT  = std::sqrt( TargMassT2 );
 
 1089       if ( SqrtS < ProjMassT + TargMassT ) 
continue;
 
 1091       PZcms2 =( S*S + ProjMassT2*ProjMassT2 + TargMassT2*TargMassT2
 
 1092                 -2.0*S*ProjMassT2 - 2.0*S*TargMassT2 -2.0*ProjMassT2*TargMassT2 ) / 4.0 / S;
 
 1094       if ( PZcms2 < 0 ) 
continue;
 
 1096       PZcms = std::sqrt( PZcms2 );
 
 1097       PMinusMin = std::sqrt( ProjMassT2 + PZcms2 ) - PZcms;
 
 1099       PMinusMax = SqrtS - TargMassT;
 
 1101       TPlusMin = std::sqrt( TargMassT2 + PZcms2 ) - PZcms;
 
 1103       TPlusMax = SqrtS - ProjMassT;
 
 1117         PMinusNew = ChooseP( PMinusMin, PMinusMax );
 
 1118         TPlusNew = ChooseP( TPlusMin, TPlusMax );
 
 1120         PMinusNew = ( PMinusMax - PMinusMin )*
G4UniformRand() + PMinusMin;
 
 1121         TPlusNew = ( TPlusMax - TPlusMin )*
G4UniformRand() + TPlusMin;
 
 1124       Qminus = PMinusNew - Pprojectile.minus();
 
 1126       Qplus = -( TPlusNew - Ptarget.plus() );
 
 1127       Qmomentum.
setPz( (Qplus - Qminus)/2 );
 
 1128       Qmomentum.
setE(  (Qplus + Qminus)/2 );
 
 1130       #ifdef debugFTFexictation 
 1131       G4cout << ( Pprojectile + Qmomentum ).mag2() << 
" " << ProjectileNonDiffStateMinMass2
 
 1132              << G4endl << ( Ptarget - Qmomentum ).mag2() << 
" " 
 1133              << TargetNonDiffStateMinMass2 << 
G4endl;
 
 1138     } 
while ( ( Pprojectile + Qmomentum ).mag2() <  ProjectileNonDiffStateMinMass2  ||  
 
 1139               ( Ptarget     - Qmomentum ).mag2() <  TargetNonDiffStateMinMass2      ||  
 
 1140               ( Pprojectile + Qmomentum ).pz()   <  0.);  
 
 1147   Pprojectile += Qmomentum;
 
 1148   Ptarget     -= Qmomentum;
 
 1172   #ifdef debugFTFexictation 
 1173   G4cout << 
"Mproj " << Pprojectile.mag() << G4endl << 
"Mtarg " << Ptarget.mag() << 
G4endl;
 
 1206   if ( start == NULL ) { 
 
 1207     G4cout << 
" G4FTFModel::String() Error: No start parton found" << 
G4endl;
 
 1208     FirstString = 0; SecondString = 0;
 
 1213   if ( end == NULL ) { 
 
 1214     G4cout << 
" G4FTFModel::String() Error: No end parton found" <<  
G4endl;
 
 1215     FirstString = 0; SecondString = 0;
 
 1236   if ( isProjectile ) {
 
 1246   G4double Pt( 0.0 ), x1( 0.0 ), x3( 0.0 );  
 
 1269       if ( Pt > 500.0*
MeV ) {
 
 1270         G4double Ymax = 
G4Log( W/2.0/Pt + std::sqrt( W2/4.0/Pt/Pt - 1.0 ) );
 
 1272         x1 = 1.0 - Pt/W * 
G4Exp( Y );
 
 1273         x3 = 1.0 - Pt/W * 
G4Exp(-Y );
 
 1277         if ( PDGcode_startQ <  3 ) Mass_startQ =  325.0*
MeV;
 
 1278         if ( PDGcode_startQ == 3 ) Mass_startQ =  500.0*
MeV;
 
 1279         if ( PDGcode_startQ == 4 ) Mass_startQ = 1600.0*
MeV;
 
 1281         if ( PDGcode_endQ <  3 ) Mass_endQ =  325.0*
MeV;
 
 1282         if ( PDGcode_endQ == 3 ) Mass_endQ =  500.0*
MeV;
 
 1283         if ( PDGcode_endQ == 4 ) Mass_endQ = 1600.0*
MeV;
 
 1285         G4double P2_1 = W2*x1*x1/4.0 - Mass_endQ*Mass_endQ;
 
 1286         G4double P2_3 = W2*x3*x3/4.0 - Mass_startQ*Mass_startQ;
 
 1288         if ( P2_1 <= 0.0  ||  P2_3 <= 0.0 ) { 
 
 1294           G4double CosT12 = ( P2_3 - P2_1 - P2_2 ) / (2.0*P_1*P_2);
 
 1295           G4double CosT13 = ( P2_2 - P2_1 - P2_3 ) / (2.0*P_1*P_3);
 
 1298           if ( std::abs( CosT12 ) > 1.0  ||  std::abs( CosT13 ) > 1.0 ) {
 
 1302             Pt = P_2 * std::sqrt( 1.0 - CosT12*CosT12 );  
 
 1306             Pstart.
setE( x3*W/2.0 );                
 
 1308             Pend.
setE( x1*W/2.0 );
 
 1310             G4double XkQ = GetQuarkFractionOfKink( 0.0, 1.0 );
 
 1311             if ( Pkink.
getZ() > 0.0 ) {
 
 1313                 PkinkQ1 = XkQ*Pkink;
 
 1315                 PkinkQ1 = (1.0 - XkQ)*Pkink;
 
 1319                 PkinkQ1 = (1.0 - XkQ)*Pkink;
 
 1321                 PkinkQ1 = XkQ*Pkink;
 
 1325             PkinkQ2 = Pkink - PkinkQ1;
 
 1328                                std::sqrt( 
sqr( 
sqr(x1) - 
sqr(x3) ) + 
sqr( 2.0*x1*x3*CosT13 ) );
 
 1329             G4double Psi = std::acos( Cos2Psi );
 
 1332             if ( isProjectile ) {
 
 1358     std::vector< G4double > QuarkProbabilitiesAtGluonSplitUp = 
 
 1362     for ( 
unsigned int Iq = 0; Iq < 3; Iq++ ) {
 
 1364       if ( Ksi > QuarkProbabilitiesAtGluonSplitUp[Iq] ) QuarkInGluon++;
 
 1389     G4int absPDGcode = 1500;  
 
 1396     if ( absPDGcode < 1000 ) {  
 
 1397       if ( isProjectile ) { 
 
 1429       if ( isProjectile ) {  
 
 1492     if ( Momentum > 0.0 ) {
 
 1498       tmp.
set( 0.0, 0.0, 1.0 );
 
 1502     if ( isProjectile ) {
 
 1503       Pstart1 *= (-1.0)*Minus/2.0;
 
 1504       Pend1   *= (+1.0)*Plus /2.0;
 
 1506       Pstart1 *= (+1.0)*Plus/ 2.0;
 
 1507       Pend1   *= (-1.0)*Minus/2.0;
 
 1509     Momentum = -Pstart1.
mag();
 
 1510     Pstart1.
setT( Momentum );  
 
 1511     Momentum = -Pend1.
mag();
 
 1512     Pend1.
setT( Momentum );    
 
 1527          << 
" generated string momenta: Diquark " << end->
Get4Momentum() << 
"mass : "  
 1529          << Pstart + Pend << 
G4endl << 
" Original                          "  
 1543   if ( Pmin <= 0.0 || range <= 0.0 ) {
 
 1544     G4cout << 
" Pmin, range : " << Pmin << 
" , " << range << 
G4endl;
 
 1546                                "G4DiffractiveExcitation::ChooseP : Invalid arguments " );
 
 1559   if ( AveragePt2 <= 0.0 ) {
 
 1563                                        ( 
G4Exp( -maxPtSquare/AveragePt2 ) - 1.0 ) );
 
 1567   return G4ThreeVector( Pt * std::cos( phi ), Pt * std::sin( phi ), 0.0 );
 
 1575   const G4int maxNumberOfLoops = 10000;
 
 1576   G4int loopCounter = 0;
 
 1579     yf = z*z + 
sqr(1.0 - z);
 
 1581             ++loopCounter < maxNumberOfLoops );  
 
 1582   if ( loopCounter >= maxNumberOfLoops ) {
 
 1583     z = 0.5*(zmin + zmax);  
 
 1591 void G4DiffractiveExcitation::UnpackMeson( 
const G4int IdPDG, 
G4int& Q1, 
G4int& Q2 )
 const {
 
 1592   G4int absIdPDG = std::abs( IdPDG );
 
 1593   if ( ! ( absIdPDG == 111 || absIdPDG == 221 || absIdPDG == 331 ) ) {
 
 1595     Q1 =  absIdPDG / 100;
 
 1596     Q2 = (absIdPDG % 100) / 10;
 
 1598     if ( IdPDG < 0 ) anti *= -1;
 
 1604     else                         { Q1 = 2; Q2 = -2; }
 
 1612 void G4DiffractiveExcitation::UnpackBaryon( 
G4int IdPDG, 
 
 1615   Q2 = (IdPDG % 1000) / 100;
 
 1616   Q3 = (IdPDG % 100)  / 10;
 
 1629   } 
else if ( Q3 > Q1 ) {
 
 1639   G4int NewCode = Q1*1000 + Q2*100 + Q3*10 + 2; 
 
 1648                              "G4DiffractiveExcitation copy contructor not meant to be called" );
 
 1656                              "G4DiffractiveExcitation = operator not meant to be called" );
 
 1665                              "G4DiffractiveExcitation == operator not meant to be called" );
 
 1673                              "G4DiffractiveExcitation != operator not meant to be called" );
 
void set(double x, double y, double z)
 
G4double SampleMass(const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const 
 
virtual G4bool ElasticScattering(G4VSplitableHadron *aPartner, G4VSplitableHadron *bPartner, G4FTFParameters *theParameters) const 
 
static G4Pow * GetInstance()
 
G4double powA(G4double A, G4double y) const 
 
Hep3Vector boostVector() const 
 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
 
G4double GetProjMinDiffMass()
 
CLHEP::Hep3Vector G4ThreeVector
 
virtual G4bool ExciteParticipants(G4VSplitableHadron *aPartner, G4VSplitableHadron *bPartner, G4FTFParameters *theParameters, G4ElasticHNScattering *theElastic) const 
 
G4int GetSoftCollisionCount()
 
G4double GetProbLogDistr()
 
const G4LorentzVector & Get4Momentum() const 
 
G4double GetTarMinDiffMass()
 
void Set4Momentum(const G4LorentzVector &aMomentum)
 
G4ParticleDefinition * GetDefinition()
 
G4int GetPDGEncoding() const 
 
virtual ~G4DiffractiveExcitation()
 
const G4String & GetParticleSubType() const 
 
void SetDefinition(const G4ParticleDefinition *aDefinition)
 
HepLorentzVector & rotateZ(double)
 
void SetStatus(const G4int aStatus)
 
const G4String & GetParticleName() const 
 
HepLorentzRotation & rotateY(double delta)
 
static constexpr double twopi
 
const G4ParticleDefinition * GetDefinition() const 
 
G4double GetPDGWidth() const 
 
void SetPosition(const G4ThreeVector &aPosition)
 
G4GLOB_DLL std::ostream G4cout
 
void SetTimeOfCreation(G4double aTime)
 
const G4ParticleDefinition const G4Material *G4double range
 
virtual G4Parton * GetNextParton()=0
 
G4double GetTimeOfCreation()
 
HepLorentzRotation & transform(const HepBoost &b)
 
void IncrementCollisionCount(G4int aCount)
 
const G4String & GetParticleType() const 
 
G4double GetProcProb(const G4int ProcN, const G4double y)
 
const G4LorentzVector & Get4Momentum() const 
 
HepLorentzRotation & rotateZ(double delta)
 
G4double GetMinimumMass(const G4ParticleDefinition *p) const 
 
G4double G4Log(G4double x)
 
G4double G4Exp(G4double initial_x)
Exponential Function double precision. 
 
virtual void CreateStrings(G4VSplitableHadron *aHadron, G4bool isProjectile, G4ExcitedString *&FirstString, G4ExcitedString *&SecondString, G4FTFParameters *theParameters) const 
 
G4double GetPDGMass() const 
 
G4double GetTarMinNonDiffMass()
 
static G4ParticleTable * GetParticleTable()
 
T max(const T t1, const T t2)
brief Return the largest of the two arguments 
 
G4int GetPDGiIsospin() const 
 
HepLorentzVector & rotateY(double)
 
const G4ThreeVector & GetPosition() const 
 
G4double GetDeltaProbAtQuarkExchange()
 
G4double GetProbOfSameQuarkExchange()
 
static constexpr double MeV
 
HepLorentzVector & transform(const HepRotation &)
 
G4double GetProjMinNonDiffMass()
 
static constexpr double pi
 
void Set4Momentum(const G4LorentzVector &a4Momentum)
 
G4DiffractiveExcitation()
 
std::vector< G4double > GetQuarkProbabilitiesAtGluonSplitUp()
 
CLHEP::HepLorentzVector G4LorentzVector