Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/qmd/src/G4QMDCollision.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/qmd/src/G4QMDCollision.cc (Version 11.3.0) and /processes/hadronic/models/qmd/src/G4QMDCollision.cc (Version 10.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // 080602 Fix memory leaks by T. Koi               26 // 080602 Fix memory leaks by T. Koi 
 27 // 081120 Add deltaT in signature of CalKinema     27 // 081120 Add deltaT in signature of CalKinematicsOfBinaryCollisions
 28 //        Add several required updating of Mea     28 //        Add several required updating of Mean Filed 
 29 //        Modified handling of absorption case     29 //        Modified handling of absorption case by T. Koi
 30 // 090126 Fix in absorption case by T. Koi         30 // 090126 Fix in absorption case by T. Koi  
 31 // 090331 Fix for gamma participant by T. Koi      31 // 090331 Fix for gamma participant by T. Koi 
 32 //                                                 32 //
 33 #include "G4QMDCollision.hh"                       33 #include "G4QMDCollision.hh"
 34 #include "G4Scatterer.hh"                          34 #include "G4Scatterer.hh"
 35 #include "G4Pow.hh"                                35 #include "G4Pow.hh"
 36 #include "G4Exp.hh"                                36 #include "G4Exp.hh"
 37 #include "G4Log.hh"                                37 #include "G4Log.hh"
 38 #include "G4PhysicalConstants.hh"                  38 #include "G4PhysicalConstants.hh"
 39 #include "G4SystemOfUnits.hh"                      39 #include "G4SystemOfUnits.hh"
 40 #include "Randomize.hh"                            40 #include "Randomize.hh"
 41                                                    41 
 42 G4QMDCollision::G4QMDCollision()                   42 G4QMDCollision::G4QMDCollision()
 43 : fdeltar ( 4.0 )                                  43 : fdeltar ( 4.0 )
 44 , fbcmax0 ( 1.323142 ) // NN maximum impact pa     44 , fbcmax0 ( 1.323142 ) // NN maximum impact parameter
 45 , fbcmax1 ( 2.523 )    // others maximum impac     45 , fbcmax1 ( 2.523 )    // others maximum impact parameter
 46 // , sig0 ( 55 )   // NN cross section             46 // , sig0 ( 55 )   // NN cross section
 47 //110617 fix for gcc 4.6 compilation warnings      47 //110617 fix for gcc 4.6 compilation warnings 
 48 //, sig1 ( 200 )  // others cross section          48 //, sig1 ( 200 )  // others cross section
 49 , fepse ( 0.0001 )                                 49 , fepse ( 0.0001 )
 50 {                                                  50 {
 51    //These two pointers will be set through Se     51    //These two pointers will be set through SetMeanField method
 52    theSystem=NULL;                                 52    theSystem=NULL;
 53    theMeanField=NULL;                              53    theMeanField=NULL;
 54    theScatterer = new G4Scatterer();               54    theScatterer = new G4Scatterer();
 55 }                                                  55 }
 56                                                    56 
 57 /*                                                 57 /*
 58 G4QMDCollision::G4QMDCollision( const G4QMDCol     58 G4QMDCollision::G4QMDCollision( const G4QMDCollision& obj )
 59 : fdeltar ( obj.fdeltar )                          59 : fdeltar ( obj.fdeltar )
 60 , fbcmax0 ( obj.fbcmax0 ) // NN maximum impact     60 , fbcmax0 ( obj.fbcmax0 ) // NN maximum impact parameter
 61 , fbcmax1 ( obj.fbcmax1 )    // others maximum     61 , fbcmax1 ( obj.fbcmax1 )    // others maximum impact parameter
 62 , fepse ( obj.fepse )                              62 , fepse ( obj.fepse )
 63 {                                                  63 {
 64                                                    64    
 65    if ( obj.theSystem != NULL ) {                  65    if ( obj.theSystem != NULL ) {
 66       theSystem = new G4QMDSystem;                 66       theSystem = new G4QMDSystem;
 67       *theSystem = *obj.theSystem;                 67       *theSystem = *obj.theSystem;
 68    } else {                                        68    } else {
 69       theSystem = NULL;                            69       theSystem = NULL;
 70    }                                               70    }
 71    if ( obj.theMeanField != NULL ) {               71    if ( obj.theMeanField != NULL ) {
 72       theMeanField = new G4QMDMeanField;           72       theMeanField = new G4QMDMeanField;
 73       *theMeanField = *obj.theMeanField;           73       *theMeanField = *obj.theMeanField;
 74    } else {                                        74    } else {
 75       theMeanField = NULL;                         75       theMeanField = NULL;
 76    }                                               76    }
 77    theScatterer = new G4Scatterer();               77    theScatterer = new G4Scatterer();
 78    *theScatterer = *obj.theScatterer;              78    *theScatterer = *obj.theScatterer;
 79 }                                                  79 }
 80                                                    80 
 81 G4QMDCollision & G4QMDCollision::operator= ( c     81 G4QMDCollision & G4QMDCollision::operator= ( const G4QMDCollision& obj)
 82 {                                                  82 {
 83    fdeltar = obj.fdeltar;                          83    fdeltar = obj.fdeltar;
 84    fbcmax0 = obj.fbcmax1;                          84    fbcmax0 = obj.fbcmax1;
 85    fepse = obj.fepse;                              85    fepse = obj.fepse;
 86                                                    86 
 87    if ( obj.theSystem != NULL ) {                  87    if ( obj.theSystem != NULL ) {
 88       delete theSystem;                            88       delete theSystem;
 89       theSystem = new G4QMDSystem;                 89       theSystem = new G4QMDSystem;
 90       *theSystem = *obj.theSystem;                 90       *theSystem = *obj.theSystem;
 91    } else {                                        91    } else {
 92       theSystem = NULL;                            92       theSystem = NULL;
 93    }                                               93    }
 94    if ( obj.theMeanField != NULL ) {               94    if ( obj.theMeanField != NULL ) {
 95       delete theMeanField;                         95       delete theMeanField;
 96       theMeanField = new G4QMDMeanField;           96       theMeanField = new G4QMDMeanField;
 97       *theMeanField = *obj.theMeanField;           97       *theMeanField = *obj.theMeanField;
 98    } else {                                        98    } else {
 99       theMeanField = NULL;                         99       theMeanField = NULL;
100    }                                              100    }
101    delete theScatterer;                           101    delete theScatterer;
102    theScatterer = new G4Scatterer();              102    theScatterer = new G4Scatterer();
103    *theScatterer = *obj.theScatterer;             103    *theScatterer = *obj.theScatterer;
104                                                   104 
105    return *this;                                  105    return *this;
106 }                                                 106 }
107 */                                                107 */
108                                                   108 
109                                                   109 
110 G4QMDCollision::~G4QMDCollision()                 110 G4QMDCollision::~G4QMDCollision()
111 {                                                 111 {
112    //if ( theSystem != NULL ) delete theSystem    112    //if ( theSystem != NULL ) delete theSystem;
113    //if ( theMeanField != NULL ) delete theMea    113    //if ( theMeanField != NULL ) delete theMeanField;
114    delete theScatterer;                           114    delete theScatterer;
115 }                                                 115 }
116                                                   116 
117                                                   117 
118 void G4QMDCollision::CalKinematicsOfBinaryColl    118 void G4QMDCollision::CalKinematicsOfBinaryCollisions( G4double dt )
119 {                                                 119 {
120    G4double deltaT = dt;                          120    G4double deltaT = dt; 
121                                                   121 
122    G4int n = theSystem->GetTotalNumberOfPartic    122    G4int n = theSystem->GetTotalNumberOfParticipant(); 
123 //081118                                          123 //081118
124    //G4int nb = 0;                                124    //G4int nb = 0;
125    for ( G4int i = 0 ; i < n ; i++ )              125    for ( G4int i = 0 ; i < n ; i++ )
126    {                                              126    {
127       theSystem->GetParticipant( i )->UnsetHit    127       theSystem->GetParticipant( i )->UnsetHitMark();
128       theSystem->GetParticipant( i )->UnsetHit    128       theSystem->GetParticipant( i )->UnsetHitMark();
129       //nb += theSystem->GetParticipant( i )->    129       //nb += theSystem->GetParticipant( i )->GetBaryonNumber();
130    }                                              130    }
131    //G4cout << "nb = " << nb << " n = " << n <    131    //G4cout << "nb = " << nb << " n = " << n << G4endl;
132                                                   132 
133                                                   133 
134 //071101                                          134 //071101
135    for ( G4int i = 0 ; i < n ; i++ )              135    for ( G4int i = 0 ; i < n ; i++ )
136    {                                              136    {
137                                                   137 
138       //std::cout << i << " " << theSystem->Ge    138       //std::cout << i << " " << theSystem->GetParticipant( i )->GetDefinition()->GetParticleName() << " " << theSystem->GetParticipant( i )->GetPosition() << std::endl;
139                                                   139 
140       if ( theSystem->GetParticipant( i )->Get    140       if ( theSystem->GetParticipant( i )->GetDefinition()->IsShortLived() )
141       {                                           141       {
142                                                   142 
143          G4bool decayed = false;                  143          G4bool decayed = false; 
144                                                   144 
145          const G4ParticleDefinition* pd0 = the    145          const G4ParticleDefinition* pd0 = theSystem->GetParticipant( i )->GetDefinition();
146          G4ThreeVector p0 = theSystem->GetPart    146          G4ThreeVector p0 = theSystem->GetParticipant( i )->GetMomentum();
147          G4ThreeVector r0 = theSystem->GetPart    147          G4ThreeVector r0 = theSystem->GetParticipant( i )->GetPosition();
148                                                   148 
149          G4LorentzVector p40 = theSystem->GetP    149          G4LorentzVector p40 = theSystem->GetParticipant( i )->Get4Momentum();
150                                                   150 
151          G4double eini = theMeanField->GetTota    151          G4double eini = theMeanField->GetTotalPotential() + p40.e();
152                                                   152 
153          G4int n0 = theSystem->GetTotalNumberO    153          G4int n0 = theSystem->GetTotalNumberOfParticipant(); 
154          G4int i0 = 0;                            154          G4int i0 = 0; 
155                                                   155 
156          G4bool isThisEnergyOK = false;           156          G4bool isThisEnergyOK = false;
157                                                   157 
158          G4int maximumNumberOfTrial=4;            158          G4int maximumNumberOfTrial=4;
159          for ( G4int ii = 0 ; ii < maximumNumb    159          for ( G4int ii = 0 ; ii < maximumNumberOfTrial ; ii++ )
160          {                                        160          { 
161                                                   161 
162             //G4LorentzVector p4 = theSystem->    162             //G4LorentzVector p4 = theSystem->GetParticipant( i )->Get4Momentum();
163             G4LorentzVector p400 = p40;           163             G4LorentzVector p400 = p40;
164                                                   164 
165             p400 *= GeV;                          165             p400 *= GeV;
166             //G4KineticTrack kt( theSystem->Ge    166             //G4KineticTrack kt( theSystem->GetParticipant( i )->GetDefinition() , 0.0 , (theSystem->GetParticipant( i )->GetPosition())*fermi , p4 );
167             G4KineticTrack kt( pd0 , 0.0 , r0*    167             G4KineticTrack kt( pd0 , 0.0 , r0*fermi , p400 );
168             //std::cout << "G4KineticTrack " <    168             //std::cout << "G4KineticTrack " << i << " " <<  kt.GetDefinition()->GetParticleName() <<  kt.GetPosition() << std::endl;
169             G4KineticTrackVector* secs = NULL;    169             G4KineticTrackVector* secs = NULL;
170             secs = kt.Decay();                    170             secs = kt.Decay();
171             G4int id = 0;                         171             G4int id = 0;
172             G4double et = 0;                      172             G4double et = 0;
173             if ( secs )                           173             if ( secs )
174             {                                     174             {
175                for ( G4KineticTrackVector::ite    175                for ( G4KineticTrackVector::iterator it 
176                      = secs->begin() ; it != s    176                      = secs->begin() ; it != secs->end() ; it++ )
177                {                                  177                {
178 /*                                                178 /*
179                   G4cout << "G4KineticTrack"      179                   G4cout << "G4KineticTrack" 
180                   << " " << (*it)->GetDefiniti    180                   << " " << (*it)->GetDefinition()->GetParticleName()
181                   << " " << (*it)->Get4Momentu    181                   << " " << (*it)->Get4Momentum()
182                   << " " << (*it)->GetPosition    182                   << " " << (*it)->GetPosition()/fermi
183                   << G4endl;                      183                   << G4endl;
184 */                                                184 */
185                    if ( id == 0 )                 185                    if ( id == 0 ) 
186                    {                              186                    {
187                       theSystem->GetParticipan    187                       theSystem->GetParticipant( i )->SetDefinition( (*it)->GetDefinition() );
188                       theSystem->GetParticipan    188                       theSystem->GetParticipant( i )->SetMomentum( (*it)->Get4Momentum().v()/GeV );
189                       theSystem->GetParticipan    189                       theSystem->GetParticipant( i )->SetPosition( (*it)->GetPosition()/fermi );
190                       //theMeanField->Cal2Body    190                       //theMeanField->Cal2BodyQuantities( i ); 
191                       et += (*it)->Get4Momentu    191                       et += (*it)->Get4Momentum().e()/GeV;
192                    }                              192                    }
193                    if ( id > 0 )                  193                    if ( id > 0 )
194                    {                              194                    {
195                       // Append end;              195                       // Append end;
196                       theSystem->SetParticipan    196                       theSystem->SetParticipant ( new G4QMDParticipant ( (*it)->GetDefinition() , (*it)->Get4Momentum().v()/GeV , (*it)->GetPosition()/fermi ) );
197                       et += (*it)->Get4Momentu    197                       et += (*it)->Get4Momentum().e()/GeV;
198                       if ( id > 1 )               198                       if ( id > 1 )
199                       {                           199                       {
200                          //081118                 200                          //081118
201                          //G4cout << "G4QMDCol    201                          //G4cout << "G4QMDCollision id >2; id= " << id  << G4endl; 
202                       }                           202                       }
203                    }                              203                    }
204                    id++; // number of daughter    204                    id++; // number of daughter particles
205                                                   205 
206                    delete *it;                    206                    delete *it;
207                }                                  207                }
208                                                   208 
209                theMeanField->Update();            209                theMeanField->Update();
210                i0 = id-1; // 0 enter to i         210                i0 = id-1; // 0 enter to i
211                                                   211 
212                delete secs;                       212                delete secs;
213             }                                     213             }
214                                                   214 
215 //          EnergyCheck                           215 //          EnergyCheck  
216                                                   216 
217             G4double efin = theMeanField->GetT    217             G4double efin = theMeanField->GetTotalPotential() + et; 
218             //std::cout <<  std::abs ( eini -     218             //std::cout <<  std::abs ( eini - efin ) - fepse << std::endl; 
219 //            std::cout <<  std::abs ( eini -     219 //            std::cout <<  std::abs ( eini - efin ) - fepse*10 << std::endl; 
220 //                                           *    220 //                                           *10 TK  
221             if ( std::abs ( eini - efin ) < fe    221             if ( std::abs ( eini - efin ) < fepse*10 ) 
222             {                                     222             {
223                // Energy OK                       223                // Energy OK 
224                isThisEnergyOK = true;             224                isThisEnergyOK = true;
225                break;                             225                break; 
226             }                                     226             }
227             else                                  227             else
228             {                                     228             {
229                                                   229 
230                theSystem->GetParticipant( i )-    230                theSystem->GetParticipant( i )->SetDefinition( pd0 );
231                theSystem->GetParticipant( i )-    231                theSystem->GetParticipant( i )->SetPosition( r0 );
232                theSystem->GetParticipant( i )-    232                theSystem->GetParticipant( i )->SetMomentum( p0 );
233                                                   233 
234                //for ( G4int i0i = 0 ; i0i < i << 234                for ( G4int i0i = 0 ; i0i < id-1 ; i0i++ )
235                //160210 deletion must be done  << 235                {
236                for ( G4int i0i = id-2 ; 0 <= i << 
237                   //081118                        236                   //081118
238                   //std::cout << "Decay Energi    237                   //std::cout << "Decay Energitically Blocked deleteing " << i0i+n0  << std::endl;
239                   theSystem->DeleteParticipant    238                   theSystem->DeleteParticipant( i0i+n0 );
240                }                                  239                }
241                //081103                           240                //081103
242                theMeanField->Update();            241                theMeanField->Update();
243             }                                     242             }
244                                                   243 
245          }                                        244          }
246                                                   245 
247                                                   246 
248 //       Pauli Check                              247 //       Pauli Check 
249          if ( isThisEnergyOK == true )            248          if ( isThisEnergyOK == true )
250          {                                        249          {
251             if ( theMeanField->IsPauliBlocked     250             if ( theMeanField->IsPauliBlocked ( i ) != true ) 
252             {                                     251             {
253                                                   252 
254                G4bool allOK = true;               253                G4bool allOK = true; 
255                for ( G4int i0i = 0 ; i0i < i0     254                for ( G4int i0i = 0 ; i0i < i0 ; i0i++ )
256                {                                  255                {
257                   if ( theMeanField->IsPauliBl    256                   if ( theMeanField->IsPauliBlocked ( i0i+n0 ) == true )
258                   {                               257                   {
259                      allOK = false;               258                      allOK = false;
260                      break;                       259                      break;
261                   }                               260                   } 
262                }                                  261                }
263                                                   262 
264                if ( allOK )                       263                if ( allOK ) 
265                {                                  264                {
266                   decayed = true; //Decay Succ    265                   decayed = true; //Decay Succeeded
267                }                                  266                }
268             }                                     267             }
269                                                   268 
270          }                                        269          }
271 //                                                270 //       
272                                                   271 
273          if ( decayed )                           272          if ( decayed )
274          {                                        273          {
275             //081119                              274             //081119
276             //G4cout << "Decay Suceeded! " <<     275             //G4cout << "Decay Suceeded! " << std::endl;
277             theSystem->GetParticipant( i )->Se    276             theSystem->GetParticipant( i )->SetHitMark();
278             for ( G4int i0i = 0 ; i0i < i0 ; i    277             for ( G4int i0i = 0 ; i0i < i0 ; i0i++ )
279             {                                     278             {
280                 theSystem->GetParticipant( i0i    279                 theSystem->GetParticipant( i0i+n0 )->SetHitMark();
281             }                                     280             }
282                                                   281 
283          }                                        282          }
284          else                                     283          else
285          {                                        284          {
286                                                   285 
287 //          Decay Blocked and re-enter orginal    286 //          Decay Blocked and re-enter orginal participant;
288                                                   287 
289             if ( isThisEnergyOK == true )  //     288             if ( isThisEnergyOK == true )  // for false case already done
290             {                                     289             {
291                                                   290 
292                theSystem->GetParticipant( i )-    291                theSystem->GetParticipant( i )->SetDefinition( pd0 );
293                theSystem->GetParticipant( i )-    292                theSystem->GetParticipant( i )->SetPosition( r0 );
294                theSystem->GetParticipant( i )-    293                theSystem->GetParticipant( i )->SetMomentum( p0 );
295                                                   294 
296                for ( G4int i0i = 0 ; i0i < i0     295                for ( G4int i0i = 0 ; i0i < i0 ; i0i++ )
297                {                                  296                {
298                   //081118                        297                   //081118
299                   //std::cout << "Decay Blocke    298                   //std::cout << "Decay Blocked deleteing " << i0i+n0  << std::endl;
300                   //160210 adding commnet: del << 
301                   theSystem->DeleteParticipant    299                   theSystem->DeleteParticipant( i0+n0-i0i-1 );
302                }                                  300                }
303                //081103                           301                //081103
304                theMeanField->Update();            302                theMeanField->Update();
305             }                                     303             }
306                                                   304 
307          }                                        305          }
308                                                   306 
309       }  //shortlive                              307       }  //shortlive
310    }  // go next participant                      308    }  // go next participant 
311 //071101                                          309 //071101
312                                                   310 
313                                                   311 
314    n = theSystem->GetTotalNumberOfParticipant(    312    n = theSystem->GetTotalNumberOfParticipant(); 
315                                                   313 
316 //081118                                          314 //081118
317    //for ( G4int i = 1 ; i < n ; i++ )            315    //for ( G4int i = 1 ; i < n ; i++ )
318    for ( G4int i = 1 ; i < theSystem->GetTotal    316    for ( G4int i = 1 ; i < theSystem->GetTotalNumberOfParticipant() ; i++ )
319    {                                              317    {
320                                                   318 
321       //std::cout << "Collision i " << i << st    319       //std::cout << "Collision i " << i << std::endl;
322       if ( theSystem->GetParticipant( i )->IsT    320       if ( theSystem->GetParticipant( i )->IsThisHit() ) continue; 
323                                                   321 
324       G4ThreeVector ri =  theSystem->GetPartic    322       G4ThreeVector ri =  theSystem->GetParticipant( i )->GetPosition();
325       G4LorentzVector p4i =  theSystem->GetPar    323       G4LorentzVector p4i =  theSystem->GetParticipant( i )->Get4Momentum();
326       G4double rmi =  theSystem->GetParticipan    324       G4double rmi =  theSystem->GetParticipant( i )->GetMass();
327       const G4ParticleDefinition* pdi =  theSy    325       const G4ParticleDefinition* pdi =  theSystem->GetParticipant( i )->GetDefinition();
328 //090331 gamma                                    326 //090331 gamma 
329       if ( pdi->GetPDGMass() == 0.0 ) continue    327       if ( pdi->GetPDGMass() == 0.0 ) continue;
330                                                   328 
331       //std::cout << " p4i00 " << p4i << std::    329       //std::cout << " p4i00 " << p4i << std::endl;
332       for ( G4int j = 0 ; j < i ; j++ )           330       for ( G4int j = 0 ; j < i ; j++ )
333       {                                           331       {
334                                                   332 
335                                                   333 
336 /*                                                334 /*
337          G4cout << "Collision " << i << " " <<    335          G4cout << "Collision " << i << " " << theSystem->GetParticipant( i )->IsThisProjectile() << G4endl;
338          G4cout << "Collision " << j << " " <<    336          G4cout << "Collision " << j << " " << theSystem->GetParticipant( j )->IsThisProjectile() << G4endl;
339          G4cout << "Collision " << i << " " <<    337          G4cout << "Collision " << i << " " << theSystem->GetParticipant( i )->IsThisTarget() << G4endl;
340          G4cout << "Collision " << j << " " <<    338          G4cout << "Collision " << j << " " << theSystem->GetParticipant( j )->IsThisTarget() << G4endl;
341 */                                                339 */
342                                                   340 
343          // Only 1 Collision allowed for each     341          // Only 1 Collision allowed for each particle in a time step. 
344          //081119                                 342          //081119
345          if ( theSystem->GetParticipant( i )->    343          if ( theSystem->GetParticipant( i )->IsThisHit() ) continue; 
346          if ( theSystem->GetParticipant( j )->    344          if ( theSystem->GetParticipant( j )->IsThisHit() ) continue; 
347                                                   345 
348          //std::cout << "Collision " << i << "    346          //std::cout << "Collision " << i << " " << j << std::endl;
349                                                   347 
350          // Do not allow collision between nuc    348          // Do not allow collision between nucleons in target/projectile til its first collision.
351          if ( theSystem->GetParticipant( i )->    349          if ( theSystem->GetParticipant( i )->IsThisProjectile() )
352          {                                        350          {
353             if ( theSystem->GetParticipant( j     351             if ( theSystem->GetParticipant( j )->IsThisProjectile() ) continue;
354          }                                        352          }
355          else if ( theSystem->GetParticipant(     353          else if ( theSystem->GetParticipant( i )->IsThisTarget() )
356          {                                        354          {
357             if ( theSystem->GetParticipant( j     355             if ( theSystem->GetParticipant( j )->IsThisTarget() ) continue;
358          }                                        356          }
359                                                   357 
360                                                   358 
361          G4ThreeVector rj =  theSystem->GetPar    359          G4ThreeVector rj =  theSystem->GetParticipant( j )->GetPosition();
362          G4LorentzVector p4j =  theSystem->Get    360          G4LorentzVector p4j =  theSystem->GetParticipant( j )->Get4Momentum();
363          G4double rmj =  theSystem->GetPartici    361          G4double rmj =  theSystem->GetParticipant( j )->GetMass();
364          const G4ParticleDefinition* pdj =  th    362          const G4ParticleDefinition* pdj =  theSystem->GetParticipant( j )->GetDefinition();
365 //090331 gamma                                    363 //090331 gamma 
366          if ( pdj->GetPDGMass() == 0.0 ) conti    364          if ( pdj->GetPDGMass() == 0.0 ) continue;
367                                                   365 
368          G4double rr2 = theMeanField->GetRR2(     366          G4double rr2 = theMeanField->GetRR2( i , j );
369                                                   367 
370 //       Here we assume elab (beam momentum le    368 //       Here we assume elab (beam momentum less than 5 GeV/n )
371          if ( rr2 > fdeltar*fdeltar ) continue    369          if ( rr2 > fdeltar*fdeltar ) continue;
372                                                   370 
373          //G4double s = (p4i+p4j)*(p4i+p4j);      371          //G4double s = (p4i+p4j)*(p4i+p4j);
374          //G4double srt = std::sqrt ( s );        372          //G4double srt = std::sqrt ( s );
375                                                   373 
376          G4double srt = std::sqrt( (p4i+p4j)*(    374          G4double srt = std::sqrt( (p4i+p4j)*(p4i+p4j) );
377                                                   375 
378          G4double cutoff = 0.0;                   376          G4double cutoff = 0.0;
379          G4double fbcmax = 0.0;                   377          G4double fbcmax = 0.0;
380          //110617 fix for gcc 4.6 compilation     378          //110617 fix for gcc 4.6 compilation warnings 
381          //G4double sig = 0.0;                    379          //G4double sig = 0.0;
382                                                   380 
383          if ( rmi < 0.94 && rmj < 0.94 )          381          if ( rmi < 0.94 && rmj < 0.94 ) 
384          {                                        382          {
385 //          nucleon or pion case                  383 //          nucleon or pion case
386             cutoff = rmi + rmj + 0.02;            384             cutoff = rmi + rmj + 0.02; 
387             fbcmax = fbcmax0;                     385             fbcmax = fbcmax0;
388             //110617 fix for gcc 4.6 compilati    386             //110617 fix for gcc 4.6 compilation warnings 
389             //sig = sig0;                         387             //sig = sig0;
390          }                                        388          }
391          else                                     389          else
392          {                                        390          {
393             cutoff = rmi + rmj;                   391             cutoff = rmi + rmj; 
394             fbcmax = fbcmax1;                     392             fbcmax = fbcmax1;
395             //110617 fix for gcc compilation w    393             //110617 fix for gcc compilation warnings 
396             //sig = sig1;                         394             //sig = sig1;
397          }                                        395          }
398                                                   396 
399          //std::cout << "Collision cutoff " <<    397          //std::cout << "Collision cutoff " << i << " " << j << " " << cutoff << std::endl;
400          if ( srt < cutoff ) continue;            398          if ( srt < cutoff ) continue; 
401                                                   399         
402          G4ThreeVector dr = ri - rj;              400          G4ThreeVector dr = ri - rj;
403          G4double rsq = dr*dr;                    401          G4double rsq = dr*dr;
404                                                   402 
405          G4double pij = p4i*p4j;                  403          G4double pij = p4i*p4j; 
406          G4double pidr = p4i.vect()*dr;           404          G4double pidr = p4i.vect()*dr;
407          G4double pjdr = p4j.vect()*dr;           405          G4double pjdr = p4j.vect()*dr;
408                                                   406 
409          G4double aij = 1.0 - ( rmi*rmj /pij )    407          G4double aij = 1.0 - ( rmi*rmj /pij ) * ( rmi*rmj /pij ); 
410          G4double bij = pidr / rmi - pjdr*rmi/    408          G4double bij = pidr / rmi - pjdr*rmi/pij;
411          G4double cij = rsq + ( pidr / rmi ) *    409          G4double cij = rsq + ( pidr / rmi ) * ( pidr / rmi );
412          G4double brel = std::sqrt ( std::abs     410          G4double brel = std::sqrt ( std::abs ( cij - bij*bij/aij ) );
413                                                   411  
414          if ( brel > fbcmax ) continue;           412          if ( brel > fbcmax ) continue;
415          //std::cout << "collisions3 " << std:    413          //std::cout << "collisions3 " << std::endl;
416                                                   414      
417          G4double bji = -pjdr/rmj + pidr * rmj    415          G4double bji = -pjdr/rmj + pidr * rmj /pij;
418                                                   416  
419          G4double ti = ( pidr/rmi - bij / aij     417          G4double ti = ( pidr/rmi - bij / aij ) * p4i.e() / rmi;
420          G4double tj = (-pjdr/rmj - bji / aij     418          G4double tj = (-pjdr/rmj - bji / aij ) * p4j.e() / rmj;
421                                                   419 
422                                                   420 
423 /*                                                421 /*
424          G4cout << "collisions4  p4i " << p4i     422          G4cout << "collisions4  p4i " << p4i << G4endl;
425          G4cout << "collisions4  ri " << ri <<    423          G4cout << "collisions4  ri " << ri << G4endl;
426          G4cout << "collisions4  p4j " << p4j     424          G4cout << "collisions4  p4j " << p4j << G4endl;
427          G4cout << "collisions4  rj " << rj <<    425          G4cout << "collisions4  rj " << rj << G4endl;
428          G4cout << "collisions4  dr " << dr <<    426          G4cout << "collisions4  dr " << dr << G4endl;
429          G4cout << "collisions4  pij " << pij     427          G4cout << "collisions4  pij " << pij << G4endl;
430          G4cout << "collisions4  aij " << aij     428          G4cout << "collisions4  aij " << aij << G4endl;
431          G4cout << "collisions4  bij bji " <<     429          G4cout << "collisions4  bij bji " << bij << " " << bji << G4endl;
432          G4cout << "collisions4  pidr pjdr " <    430          G4cout << "collisions4  pidr pjdr " << pidr << " " << pjdr << G4endl;
433          G4cout << "collisions4  p4i.e() p4j.e    431          G4cout << "collisions4  p4i.e() p4j.e() " << p4i.e() << " " << p4j.e() << G4endl;
434          G4cout << "collisions4  rmi rmj " <<     432          G4cout << "collisions4  rmi rmj " << rmi << " " << rmj << G4endl;
435          G4cout << "collisions4 " << ti << " "    433          G4cout << "collisions4 " << ti << " " << tj << G4endl;
436 */                                                434 */
437          if ( std::abs ( ti + tj ) > deltaT )     435          if ( std::abs ( ti + tj ) > deltaT ) continue;
438          //std::cout << "collisions4 " << std:    436          //std::cout << "collisions4 " << std::endl;
439                                                   437 
440          G4ThreeVector beta = ( p4i + p4j ).bo    438          G4ThreeVector beta = ( p4i + p4j ).boostVector();
441                                                   439 
442          G4LorentzVector p = p4i;                 440          G4LorentzVector p = p4i;
443          G4LorentzVector p4icm = p.boost( p.fi    441          G4LorentzVector p4icm = p.boost( p.findBoostToCM ( p4j ) );
444          G4ThreeVector pcm = p4icm.vect();        442          G4ThreeVector pcm = p4icm.vect();
445                                                   443          
446          G4double prcm = pcm.mag();               444          G4double prcm = pcm.mag();
447                                                   445 
448          if ( prcm <= 0.00001 ) continue;         446          if ( prcm <= 0.00001 ) continue; 
449          //std::cout << "collisions5 " << std:    447          //std::cout << "collisions5 " << std::endl;
450                                                   448 
451          G4bool energetically_forbidden = !( C    449          G4bool energetically_forbidden = !( CalFinalStateOfTheBinaryCollision ( i , j ) ); // Use Geant4 Collision Library
452          //G4bool energetically_forbidden = !(    450          //G4bool energetically_forbidden = !( CalFinalStateOfTheBinaryCollisionJQMD ( sig , cutoff , pcm , prcm , srt, beta , gamma , i , j ) ); // JQMD Elastic 
453                                                   451 
454 /*                                                452 /*
455          G4bool pauli_blocked = false;            453          G4bool pauli_blocked = false;
456          if ( energetically_forbidden == false    454          if ( energetically_forbidden == false ) // result true 
457          {                                        455          { 
458             if ( theMeanField->IsPauliBlocked     456             if ( theMeanField->IsPauliBlocked ( i ) == true || theMeanField->IsPauliBlocked ( j ) == true ) 
459             {                                     457             {
460                pauli_blocked = true;              458                pauli_blocked = true;
461                //std::cout << "G4QMDRESULT Col    459                //std::cout << "G4QMDRESULT Collsion Pauli Blocked " << std::endl;
462             }                                     460             }
463          }                                        461          }
464          else                                     462          else
465          {                                        463          {
466             if ( theMeanField->IsPauliBlocked     464             if ( theMeanField->IsPauliBlocked ( i ) == true || theMeanField->IsPauliBlocked ( j ) == true ) 
467                pauli_blocked = false;             465                pauli_blocked = false;
468             //std::cout << "G4QMDRESULT Collsi    466             //std::cout << "G4QMDRESULT Collsion Blocked " << std::endl;
469          }                                        467          } 
470 */                                                468 */
471                                                   469 
472 /*                                                470 /*
473             G4cout << "G4QMDRESULT Collsion in    471             G4cout << "G4QMDRESULT Collsion initial p4 i and j " 
474                       << p4i << " " << p4j        472                       << p4i << " " << p4j
475                       << G4endl;                  473                       << G4endl;
476 */                                                474 */
477 //       081118                                   475 //       081118
478          //if ( energetically_forbidden == tru    476          //if ( energetically_forbidden == true || pauli_blocked == true )
479          if ( energetically_forbidden == true     477          if ( energetically_forbidden == true )
480          {                                        478          {
481                                                   479 
482             //G4cout << " energetically_forbid    480             //G4cout << " energetically_forbidden  " << G4endl;
483 //          Collsion not allowed then re enter    481 //          Collsion not allowed then re enter orginal participants 
484 //          Now only momentum, becasuse we onl    482 //          Now only momentum, becasuse we only consider elastic scattering of nucleons
485                                                   483 
486             theSystem->GetParticipant( i )->Se    484             theSystem->GetParticipant( i )->SetMomentum( p4i.vect() );
487             theSystem->GetParticipant( i )->Se    485             theSystem->GetParticipant( i )->SetDefinition( pdi );
488             theSystem->GetParticipant( i )->Se    486             theSystem->GetParticipant( i )->SetPosition( ri );
489                                                   487 
490             theSystem->GetParticipant( j )->Se    488             theSystem->GetParticipant( j )->SetMomentum( p4j.vect() );
491             theSystem->GetParticipant( j )->Se    489             theSystem->GetParticipant( j )->SetDefinition( pdj );
492             theSystem->GetParticipant( j )->Se    490             theSystem->GetParticipant( j )->SetPosition( rj );
493                                                   491 
494             theMeanField->Cal2BodyQuantities(     492             theMeanField->Cal2BodyQuantities( i ); 
495             theMeanField->Cal2BodyQuantities(     493             theMeanField->Cal2BodyQuantities( j ); 
496                                                   494 
497          }                                        495          }
498          else                                     496          else 
499          {                                        497          {
500                                                   498 
501                                                   499             
502            G4bool absorption = false;             500            G4bool absorption = false; 
503            if ( n == theSystem->GetTotalNumber    501            if ( n == theSystem->GetTotalNumberOfParticipant()+1 ) absorption = true;
504            if ( absorption )                      502            if ( absorption ) 
505            {                                      503            {
506               //G4cout << "Absorption happend     504               //G4cout << "Absorption happend " << G4endl; 
507               i = i-1;                            505               i = i-1; 
508               n = n-1;                            506               n = n-1;
509            }                                      507            } 
510                                                   508               
511 //          Collsion allowed (really happened)    509 //          Collsion allowed (really happened) 
512                                                   510 
513             // Unset Projectile/Target flag       511             // Unset Projectile/Target flag
514             theSystem->GetParticipant( i )->Un    512             theSystem->GetParticipant( i )->UnsetInitialMark();
515             if ( !absorption ) theSystem->GetP    513             if ( !absorption ) theSystem->GetParticipant( j )->UnsetInitialMark();
516                                                   514 
517             theSystem->GetParticipant( i )->Se    515             theSystem->GetParticipant( i )->SetHitMark();
518             if ( !absorption ) theSystem->GetP    516             if ( !absorption ) theSystem->GetParticipant( j )->SetHitMark();
519                                                   517 
520             theSystem->IncrementCollisionCount    518             theSystem->IncrementCollisionCounter();
521                                                   519 
522 /*                                                520 /*
523             G4cout << "G4QMDRESULT Collsion Re    521             G4cout << "G4QMDRESULT Collsion Really Happened between " 
524                       << i << " and " << j        522                       << i << " and " << j 
525                       << G4endl;                  523                       << G4endl;
526             G4cout << "G4QMDRESULT Collsion in    524             G4cout << "G4QMDRESULT Collsion initial p4 i and j " 
527                       << p4i << " " << p4j        525                       << p4i << " " << p4j
528                       << G4endl;                  526                       << G4endl;
529             G4cout << "G4QMDRESULT Collsion af    527             G4cout << "G4QMDRESULT Collsion after p4 i and j " 
530                       << theSystem->GetPartici    528                       << theSystem->GetParticipant( i )->Get4Momentum()
531                       << " "                      529                       << " " 
532                       << theSystem->GetPartici    530                       << theSystem->GetParticipant( j )->Get4Momentum()
533                       << G4endl;                  531                       << G4endl;
534             G4cout << "G4QMDRESULT Collsion Di    532             G4cout << "G4QMDRESULT Collsion Diff " 
535                       << p4i + p4j - theSystem    533                       << p4i + p4j - theSystem->GetParticipant( i )->Get4Momentum() - theSystem->GetParticipant( j )->Get4Momentum()
536                       << G4endl;                  534                       << G4endl;
537             G4cout << "G4QMDRESULT Collsion in    535             G4cout << "G4QMDRESULT Collsion initial r i and j " 
538                       << ri << " " << rj          536                       << ri << " " << rj
539                       << G4endl;                  537                       << G4endl;
540             G4cout << "G4QMDRESULT Collsion af    538             G4cout << "G4QMDRESULT Collsion after r i and j " 
541                       << theSystem->GetPartici    539                       << theSystem->GetParticipant( i )->GetPosition()
542                       << " "                      540                       << " " 
543                       << theSystem->GetPartici    541                       << theSystem->GetParticipant( j )->GetPosition()
544                       << G4endl;                  542                       << G4endl;
545 */                                                543 */
546                                                   544              
547                                                   545 
548          }                                        546          }
549                                                   547 
550       }                                           548       }
551                                                   549 
552    }                                              550    }
553                                                   551 
554                                                   552 
555 }                                                 553 }
556                                                   554 
557                                                   555 
558                                                   556 
559 G4bool G4QMDCollision::CalFinalStateOfTheBinar    557 G4bool G4QMDCollision::CalFinalStateOfTheBinaryCollision( G4int i , G4int j )
560 {                                                 558 {
561                                                   559 
562 //081103                                          560 //081103
563    //G4cout << "CalFinalStateOfTheBinaryCollis    561    //G4cout << "CalFinalStateOfTheBinaryCollision " << i << " " << j << " " << theSystem->GetTotalNumberOfParticipant() << G4endl;
564                                                   562 
565    G4bool result = false;                         563    G4bool result = false;
566    G4bool energyOK = false;                       564    G4bool energyOK = false; 
567    G4bool pauliOK = false;                        565    G4bool pauliOK = false; 
568    G4bool abs = false;                            566    G4bool abs = false;
569    G4QMDParticipant* absorbed = NULL;             567    G4QMDParticipant* absorbed = NULL;  
570                                                   568 
571    G4LorentzVector p4i = theSystem->GetPartici    569    G4LorentzVector p4i = theSystem->GetParticipant( i )->Get4Momentum();
572    G4LorentzVector p4j = theSystem->GetPartici    570    G4LorentzVector p4j = theSystem->GetParticipant( j )->Get4Momentum();
573                                                   571 
574 //071031                                          572 //071031
575                                                   573 
576    G4double epot = theMeanField->GetTotalPoten    574    G4double epot = theMeanField->GetTotalPotential();
577                                                   575 
578    G4double eini = epot + p4i.e() + p4j.e();      576    G4double eini = epot + p4i.e() + p4j.e();
579                                                   577 
580 //071031                                          578 //071031
581    // will use KineticTrack                       579    // will use KineticTrack
582    const G4ParticleDefinition* pdi0 =theSystem    580    const G4ParticleDefinition* pdi0 =theSystem->GetParticipant( i )->GetDefinition();
583    const G4ParticleDefinition* pdj0 =theSystem    581    const G4ParticleDefinition* pdj0 =theSystem->GetParticipant( j )->GetDefinition();
584    G4LorentzVector p4i0 = p4i*GeV;                582    G4LorentzVector p4i0 = p4i*GeV;
585    G4LorentzVector p4j0 = p4j*GeV;                583    G4LorentzVector p4j0 = p4j*GeV;
586    G4ThreeVector ri0 = ( theSystem->GetPartici    584    G4ThreeVector ri0 = ( theSystem->GetParticipant( i )->GetPosition() )*fermi;
587    G4ThreeVector rj0 = ( theSystem->GetPartici    585    G4ThreeVector rj0 = ( theSystem->GetParticipant( j )->GetPosition() )*fermi;
588                                                   586 
589    for ( G4int iitry = 0 ; iitry < 4 ; iitry++    587    for ( G4int iitry = 0 ; iitry < 4 ; iitry++ )
590    {                                              588    {
591                                                   589 
592       abs = false;                                590       abs = false;
593                                                   591 
594       G4KineticTrack kt1( pdi0 , 0.0 , ri0 , p    592       G4KineticTrack kt1( pdi0 , 0.0 , ri0 , p4i0 );
595       G4KineticTrack kt2( pdj0 , 0.0 , rj0 , p    593       G4KineticTrack kt2( pdj0 , 0.0 , rj0 , p4j0 );
596                                                   594 
597       G4LorentzVector p4ix_new;                   595       G4LorentzVector p4ix_new; 
598       G4LorentzVector p4jx_new;                   596       G4LorentzVector p4jx_new; 
599       G4KineticTrackVector* secs = NULL;          597       G4KineticTrackVector* secs = NULL;
600       secs = theScatterer->Scatter( kt1 , kt2     598       secs = theScatterer->Scatter( kt1 , kt2 );
601                                                   599 
602       //std::cout << "G4QMDSCATTERER BEFORE "     600       //std::cout << "G4QMDSCATTERER BEFORE " << kt1.GetDefinition()->GetParticleName() << " " << kt1.Get4Momentum()/GeV << " " << kt1.GetPosition()/fermi << std::endl;
603       //std::cout << "G4QMDSCATTERER BEFORE "     601       //std::cout << "G4QMDSCATTERER BEFORE " << kt2.GetDefinition()->GetParticleName() << " " << kt2.Get4Momentum()/GeV << " " << kt2.GetPosition()/fermi << std::endl;
604       //std::cout << "THESCATTERER " << theSca    602       //std::cout << "THESCATTERER " << theScatterer->GetCrossSection ( kt1 , kt2 )/millibarn << " " << elastic << " " << sig << std::endl;
605                                                   603 
606                                                   604 
607       if ( secs )                                 605       if ( secs )
608       {                                           606       {
609          G4int iti = 0;                           607          G4int iti = 0;
610          if (  secs->size() == 2 )                608          if (  secs->size() == 2 )
611          {                                        609          {
612             for ( G4KineticTrackVector::iterat    610             for ( G4KineticTrackVector::iterator it 
613                 = secs->begin() ; it != secs->    611                 = secs->begin() ; it != secs->end() ; it++ )
614             {                                     612             {
615                if ( iti == 0 )                    613                if ( iti == 0 ) 
616                {                                  614                {
617                   theSystem->GetParticipant( i    615                   theSystem->GetParticipant( i )->SetDefinition( (*it)->GetDefinition() );
618                   p4ix_new = (*it)->Get4Moment    616                   p4ix_new = (*it)->Get4Momentum()/GeV;
619                   //std::cout << "THESCATTERER    617                   //std::cout << "THESCATTERER " << (*it)->GetDefinition()->GetParticleName() << std::endl;
620                   theSystem->GetParticipant( i    618                   theSystem->GetParticipant( i )->SetMomentum( p4ix_new.v() );
621                }                                  619                } 
622                if ( iti == 1 )                    620                if ( iti == 1 )
623                {                                  621                {
624                   theSystem->GetParticipant( j    622                   theSystem->GetParticipant( j )->SetDefinition( (*it)->GetDefinition() );
625                   p4jx_new = (*it)->Get4Moment    623                   p4jx_new = (*it)->Get4Momentum()/GeV;
626                   //std::cout << "THESCATTERER    624                   //std::cout << "THESCATTERER " << p4jx_new.e()-p4jx_new.m() << std::endl;
627                   theSystem->GetParticipant( j    625                   theSystem->GetParticipant( j )->SetMomentum( p4jx_new.v() );
628                }                                  626                }
629                //std::cout << "G4QMDSCATTERER     627                //std::cout << "G4QMDSCATTERER AFTER " << (*it)->GetDefinition()->GetParticleName() << " " << (*it)->Get4Momentum()/GeV << std::endl;
630                iti++;                             628                iti++;
631             }                                     629             }
632          }                                        630          }
633          else if ( secs->size() == 1 )            631          else if ( secs->size() == 1 )
634          {                                        632          {
635 //081118                                          633 //081118
636             abs = true;                           634             abs = true;
637             //G4cout << "G4QMDCollision pion a    635             //G4cout << "G4QMDCollision pion absrorption " << secs->front()->GetDefinition()->GetParticleName() << G4endl;
638             //secs->front()->Decay();             636             //secs->front()->Decay();
639             theSystem->GetParticipant( i )->Se    637             theSystem->GetParticipant( i )->SetDefinition( secs->front()->GetDefinition() );
640             p4ix_new = secs->front()->Get4Mome    638             p4ix_new = secs->front()->Get4Momentum()/GeV;
641             theSystem->GetParticipant( i )->Se    639             theSystem->GetParticipant( i )->SetMomentum( p4ix_new.v() );
642                                                   640 
643          }                                        641          } 
644                                                   642 
645 //081118                                          643 //081118
646          if ( secs->size() > 2 )                  644          if ( secs->size() > 2 ) 
647          {                                        645          {
648                                                   646 
649             G4cout << "G4QMDCollision secs siz    647             G4cout << "G4QMDCollision secs size > 2;  " << secs->size() << G4endl;
650                                                   648 
651             for ( G4KineticTrackVector::iterat    649             for ( G4KineticTrackVector::iterator it 
652                 = secs->begin() ; it != secs->    650                 = secs->begin() ; it != secs->end() ; it++ )
653             {                                     651             {
654                G4cout << "G4QMDSCATTERER AFTER    652                G4cout << "G4QMDSCATTERER AFTER " << (*it)->GetDefinition()->GetParticleName() << " " << (*it)->Get4Momentum()/GeV << G4endl;
655             }                                     653             }
656                                                   654 
657          }                                        655          }
658                                                   656 
659          // deleteing KineticTrack                657          // deleteing KineticTrack
660          for ( G4KineticTrackVector::iterator     658          for ( G4KineticTrackVector::iterator it 
661                = secs->begin() ; it != secs->e    659                = secs->begin() ; it != secs->end() ; it++ )
662          {                                        660          {  
663             delete *it;                           661             delete *it;
664          }                                        662          }
665                                                   663 
666          delete secs;                             664          delete secs;
667       }                                           665       }
668 //071031                                          666 //071031
669                                                   667 
670       if ( !abs )                                 668       if ( !abs )
671       {                                           669       { 
672          theMeanField->Cal2BodyQuantities( i )    670          theMeanField->Cal2BodyQuantities( i ); 
673          theMeanField->Cal2BodyQuantities( j )    671          theMeanField->Cal2BodyQuantities( j ); 
674       }                                           672       } 
675       else                                        673       else
676       {                                           674       {
677          absorbed = theSystem->EraseParticipan    675          absorbed = theSystem->EraseParticipant( j ); 
678          theMeanField->Update();                  676          theMeanField->Update();
679       }                                           677       }
680                                                   678 
681       epot = theMeanField->GetTotalPotential()    679       epot = theMeanField->GetTotalPotential();
682                                                   680 
683       G4double efin = epot + p4ix_new.e() + p4    681       G4double efin = epot + p4ix_new.e() + p4jx_new.e(); 
684                                                   682 
685       //std::cout << "Collision NEW epot " <<     683       //std::cout << "Collision NEW epot " << i << " " << j << " " << epot << " " << std::abs ( eini - efin ) - fepse << std::endl;
686                                                   684 
687 /*                                                685 /*
688       G4cout << "Collision efin " << i << " "     686       G4cout << "Collision efin " << i << " " << j << " " << efin << G4endl;
689       G4cout << "Collision " << i << " " << j     687       G4cout << "Collision " << i << " " << j << " " << std::abs ( eini - efin ) << " " << fepse << G4endl;
690       G4cout << "Collision " << std::abs ( ein    688       G4cout << "Collision " << std::abs ( eini - efin ) << " " << fepse << G4endl;
691 */                                                689 */
692                                                   690 
693 //071031                                          691 //071031
694       if ( std::abs ( eini - efin ) < fepse )     692       if ( std::abs ( eini - efin ) < fepse ) 
695       {                                           693       {
696          // Collison OK                           694          // Collison OK 
697          //std::cout << "collisions6" << std::    695          //std::cout << "collisions6" << std::endl;
698          //std::cout << "collisions before " <    696          //std::cout << "collisions before " << p4i << " " << p4j << std::endl;
699          //std::cout << "collisions after " <<    697          //std::cout << "collisions after " << theSystem->GetParticipant( i )->Get4Momentum() << " " << theSystem->GetParticipant( j )->Get4Momentum() << std::endl;
700          //std::cout << "collisions dif " << (    698          //std::cout << "collisions dif " << ( p4i + p4j ) - ( theSystem->GetParticipant( i )->Get4Momentum() + theSystem->GetParticipant( j )->Get4Momentum() ) << std::endl;
701          //std::cout << "collisions before " <    699          //std::cout << "collisions before " << ri0/fermi << " " << rj0/fermi << std::endl;
702          //std::cout << "collisions after " <<    700          //std::cout << "collisions after " << theSystem->GetParticipant( i )->GetPosition() << " " << theSystem->GetParticipant( j )->GetPosition() << std::endl;
703          energyOK = true;                         701          energyOK = true;
704          break;                                   702          break;
705       }                                           703       }
706       else                                        704       else
707       {                                           705       {
708          //G4cout << "Energy Not OK " << G4end    706          //G4cout << "Energy Not OK " << G4endl;
709          if ( abs )                               707          if ( abs )
710          {                                        708          {
711             //G4cout << "TKDB reinsert j " <<     709             //G4cout << "TKDB reinsert j " << G4endl;
712             theSystem->InsertParticipant( abso    710             theSystem->InsertParticipant( absorbed , j );   
713             theMeanField->Update();               711             theMeanField->Update();
714          }                                        712          }
715          // do not need reinsert in no absropt    713          // do not need reinsert in no absroption case 
716       }                                           714       }
717 //071031                                          715 //071031
718    }                                              716    }
719                                                   717 
720 // Energetically forbidden collision              718 // Energetically forbidden collision
721                                                   719 
722    if ( energyOK )                                720    if ( energyOK )
723    {                                              721    {
724       // Pauli Check                              722       // Pauli Check 
725       //G4cout << "Pauli Checking " << theSyst    723       //G4cout << "Pauli Checking " << theSystem->GetTotalNumberOfParticipant() << G4endl;
726       if ( !abs )                                 724       if ( !abs ) 
727       {                                           725       {
728          if ( !( theMeanField->IsPauliBlocked     726          if ( !( theMeanField->IsPauliBlocked ( i ) == true || theMeanField->IsPauliBlocked ( j ) == true ) ) 
729          {                                        727          {
730             //G4cout << "Binary Collision Happ    728             //G4cout << "Binary Collision Happen " << theSystem->GetTotalNumberOfParticipant() << G4endl;
731             pauliOK = true;                       729             pauliOK = true;
732          }                                        730          }
733       }                                           731       }
734       else                                        732       else 
735       {                                           733       {
736          //if ( theMeanField->IsPauliBlocked (    734          //if ( theMeanField->IsPauliBlocked ( i ) == false ) 
737          //090126                            i    735          //090126                            i-1 cause jth is erased
738          if ( theMeanField->IsPauliBlocked ( i    736          if ( theMeanField->IsPauliBlocked ( i-1 ) == false ) 
739          {                                        737          { 
740             //G4cout << "Absorption Happen " <    738             //G4cout << "Absorption Happen " << theSystem->GetTotalNumberOfParticipant() << G4endl;
741             delete absorbed;                      739             delete absorbed;
742             pauliOK = true;                       740             pauliOK = true;
743          }                                        741          }
744       }                                           742       }
745                                                   743       
746                                                   744 
747       if ( pauliOK )                              745       if ( pauliOK ) 
748       {                                           746       {
749          result = true;                           747          result = true;
750       }                                           748       }
751       else                                        749       else
752       {                                           750       {
753          //G4cout << "Pauli Blocked" << G4endl    751          //G4cout << "Pauli Blocked" << G4endl;
754          if ( abs )                               752          if ( abs )
755          {                                        753          {
756             //G4cout << "TKDB reinsert j pauli    754             //G4cout << "TKDB reinsert j pauli block" << G4endl;
757             theSystem->InsertParticipant( abso    755             theSystem->InsertParticipant( absorbed , j );   
758             theMeanField->Update();               756             theMeanField->Update(); 
759          }                                        757          }
760       }                                           758       }
761    }                                              759    }
762                                                   760 
763    return result;                                 761    return result;
764                                                   762 
765 }                                                 763 } 
766                                                   764 
767                                                   765 
768                                                   766 
769 G4bool G4QMDCollision::CalFinalStateOfTheBinar    767 G4bool G4QMDCollision::CalFinalStateOfTheBinaryCollisionJQMD( G4double sig , G4double cutoff , G4ThreeVector pcm , G4double prcm , G4double srt , G4ThreeVector beta , G4double gamma , G4int i , G4int j )
770 {                                                 768 {
771                                                   769 
772    //G4cout << "CalFinalStateOfTheBinaryCollis    770    //G4cout << "CalFinalStateOfTheBinaryCollisionJQMD" << G4endl;
773                                                   771 
774    G4bool result = true;                          772    G4bool result = true;
775                                                   773 
776    G4LorentzVector p4i =  theSystem->GetPartic    774    G4LorentzVector p4i =  theSystem->GetParticipant( i )->Get4Momentum();
777    G4double rmi =  theSystem->GetParticipant(     775    G4double rmi =  theSystem->GetParticipant( i )->GetMass();
778    G4int zi =  theSystem->GetParticipant( i )-    776    G4int zi =  theSystem->GetParticipant( i )->GetChargeInUnitOfEplus();
779                                                   777 
780    G4LorentzVector p4j =  theSystem->GetPartic    778    G4LorentzVector p4j =  theSystem->GetParticipant( j )->Get4Momentum();
781    G4double rmj =  theSystem->GetParticipant(     779    G4double rmj =  theSystem->GetParticipant( j )->GetMass();
782    G4int zj =  theSystem->GetParticipant( j )-    780    G4int zj =  theSystem->GetParticipant( j )->GetChargeInUnitOfEplus();
783                                                   781 
784    G4double pr = prcm;                            782    G4double pr = prcm;
785                                                   783 
786    G4double c2  = pcm.z()/pr;                     784    G4double c2  = pcm.z()/pr;
787                                                   785     
788    G4double csrt = srt - cutoff;                  786    G4double csrt = srt - cutoff;
789                                                   787 
790    //G4double pri = prcm;                         788    //G4double pri = prcm;
791    //G4double prf = sqrt ( 0.25 * srt*srt -rm2    789    //G4double prf = sqrt ( 0.25 * srt*srt -rm2 );
792                                                   790     
793    G4double asrt = srt - rmi - rmj;               791    G4double asrt = srt - rmi - rmj;
794    G4double pra = prcm;                           792    G4double pra = prcm;
795                                                   793    
796                                                   794 
797                                                   795 
798    G4double elastic = 0.0;                        796    G4double elastic = 0.0; 
799                                                   797 
800    if ( zi == zj )                                798    if ( zi == zj )
801    {                                              799    {
802       if ( csrt < 0.4286 )                        800       if ( csrt < 0.4286 )
803       {                                           801       {
804          elastic = 35.0 / ( 1. + csrt * 100.0     802          elastic = 35.0 / ( 1. + csrt * 100.0 )  +  20.0;
805       }                                           803       }
806       else                                        804       else
807       {                                           805       {
808          elastic = ( - std::atan( ( csrt - 0.4    806          elastic = ( - std::atan( ( csrt - 0.4286 ) * 1.5 - 0.8 )
809                  *   2. / pi + 1.0 ) * 9.65 +     807                  *   2. / pi + 1.0 ) * 9.65 + 7.0;
810       }                                           808       }         
811    }                                              809    }
812    else                                           810    else
813    {                                              811    {
814       if ( csrt < 0.4286 )                        812       if ( csrt < 0.4286 )
815       {                                           813       {
816          elastic = 28.0 / ( 1. + csrt * 100.0     814          elastic = 28.0 / ( 1. + csrt * 100.0 )  +  27.0;
817       }                                           815       }
818       else                                        816       else
819       {                                           817       {
820          elastic = ( - std::atan( ( csrt - 0.4    818          elastic = ( - std::atan( ( csrt - 0.4286 ) * 1.5 - 0.8 )
821                  *   2. / pi + 1.0 ) * 12.34 +    819                  *   2. / pi + 1.0 ) * 12.34 + 10.0;
822       }                                           820       }         
823    }                                              821    }
824                                                   822 
825 //   std::cout << "Collision csrt " << i << "     823 //   std::cout << "Collision csrt " << i << " " << j << " " << csrt << std::endl;
826 //   std::cout << "Collision elstic " << i <<     824 //   std::cout << "Collision elstic " << i << " " << j << " " << elastic << std::endl;
827                                                   825 
828                                                   826 
829 //   std::cout << "Collision sig " << i << " "    827 //   std::cout << "Collision sig " << i << " " << j  << " " << sig << std::endl;
830    if ( G4UniformRand() > elastic / sig )         828    if ( G4UniformRand() > elastic / sig ) 
831    {                                              829    { 
832       //std::cout << "Inelastic " << std::endl    830       //std::cout << "Inelastic " << std::endl; 
833       //std::cout << "elastic/sig " << elastic    831       //std::cout << "elastic/sig " << elastic/sig << std::endl; 
834       return result;                              832       return result; 
835    }                                              833    }
836    else                                           834    else
837    {                                              835    {
838       //std::cout << "Elastic " << std::endl;     836       //std::cout << "Elastic " << std::endl; 
839    }                                              837    } 
840 //   std::cout << "Collision ELSTIC " << i <<     838 //   std::cout << "Collision ELSTIC " << i << " " << j << std::endl;
841                                                   839 
842                                                   840    
843    G4double as = G4Pow::GetInstance()->powN (     841    G4double as = G4Pow::GetInstance()->powN ( 3.65 * asrt , 6 );
844    G4double a = 6.0 * as / (1.0 + as);            842    G4double a = 6.0 * as / (1.0 + as);
845    G4double ta = -2.0 * pra*pra;                  843    G4double ta = -2.0 * pra*pra;
846    G4double x = G4UniformRand();                  844    G4double x = G4UniformRand(); 
847    G4double t1 = G4Log( (1-x) * G4Exp(2.*a*ta)    845    G4double t1 = G4Log( (1-x) * G4Exp(2.*a*ta) + x )  /  a;
848    G4double c1 = 1.0 - t1/ta;                     846    G4double c1 = 1.0 - t1/ta;
849                                                   847  
850    if( std::abs(c1) > 1.0 ) c1 = 2.0 * x - 1.0    848    if( std::abs(c1) > 1.0 ) c1 = 2.0 * x - 1.0;
851                                                   849 
852 /*                                                850 /*
853    G4cout << "Collision as " << i << " " << j     851    G4cout << "Collision as " << i << " " << j << " " << as << G4endl;
854    G4cout << "Collision a " << i << " " << j <    852    G4cout << "Collision a " << i << " " << j << " " << a << G4endl;
855    G4cout << "Collision ta " << i << " " << j     853    G4cout << "Collision ta " << i << " " << j << " " << ta << G4endl;
856    G4cout << "Collision x " << i << " " << j <    854    G4cout << "Collision x " << i << " " << j << " " << x << G4endl;
857    G4cout << "Collision t1 " << i << " " << j     855    G4cout << "Collision t1 " << i << " " << j << " " << t1 << G4endl;
858    G4cout << "Collision c1 " << i << " " << j     856    G4cout << "Collision c1 " << i << " " << j << " " << c1 << G4endl;
859 */                                                857 */
860    t1 = 2.0*pi*G4UniformRand();                   858    t1 = 2.0*pi*G4UniformRand(); 
861 //   std::cout << "Collision t1 " << i << " "     859 //   std::cout << "Collision t1 " << i << " " << j << " " << t1 << std::endl;
862    G4double t2 = 0.0;                             860    G4double t2 = 0.0;
863    if ( pcm.x() == 0.0 && pcm.y() == 0 )          861    if ( pcm.x() == 0.0 && pcm.y() == 0 )
864    {                                              862    {
865       t2 = 0.0;                                   863       t2 = 0.0;
866    }                                              864    }
867    else                                           865    else 
868    {                                              866    {
869       t2 = std::atan2( pcm.y() , pcm.x() );       867       t2 = std::atan2( pcm.y() , pcm.x() );
870    }                                              868    }
871 //      std::cout << "Collision t2 " << i << "    869 //      std::cout << "Collision t2 " << i << " " << j << " " << t2 << std::endl;
872                                                   870 
873    G4double s1 = std::sqrt ( 1.0 - c1*c1 );       871    G4double s1 = std::sqrt ( 1.0 - c1*c1 );
874    G4double s2 = std::sqrt ( 1.0 - c2*c2 );       872    G4double s2 = std::sqrt ( 1.0 - c2*c2 );
875                                                   873  
876    G4double ct1 = std::cos(t1);                   874    G4double ct1 = std::cos(t1);      
877    G4double st1 = std::sin(t1);                   875    G4double st1 = std::sin(t1);      
878                                                   876 
879    G4double ct2 = std::cos(t2);                   877    G4double ct2 = std::cos(t2);      
880    G4double st2 = std::sin(t2);                   878    G4double st2 = std::sin(t2);      
881                                                   879 
882    G4double ss = c2*s1*ct1 + s2*c1;               880    G4double ss = c2*s1*ct1 + s2*c1;
883                                                   881 
884    pcm.setX( pr * ( ss*ct2 - s1*st1*st2) );       882    pcm.setX( pr * ( ss*ct2 - s1*st1*st2) );
885    pcm.setY( pr * ( ss*st2 + s1*st1*ct2) );       883    pcm.setY( pr * ( ss*st2 + s1*st1*ct2) );
886    pcm.setZ( pr * ( c1*c2 - s1*s2*ct1) );         884    pcm.setZ( pr * ( c1*c2 - s1*s2*ct1) );
887                                                   885 
888 // std::cout << "Collision pcm " << i << " " <    886 // std::cout << "Collision pcm " << i << " " << j << " " << pcm << std::endl;
889                                                   887 
890    G4double epot = theMeanField->GetTotalPoten    888    G4double epot = theMeanField->GetTotalPotential();
891                                                   889 
892    G4double eini = epot + p4i.e() + p4j.e();      890    G4double eini = epot + p4i.e() + p4j.e();
893    G4double etwo = p4i.e() + p4j.e();             891    G4double etwo = p4i.e() + p4j.e();
894                                                   892 
895 /*                                                893 /*
896    G4cout << "Collision epot " << i << " " <<     894    G4cout << "Collision epot " << i << " " << j << " " << epot << G4endl;
897    G4cout << "Collision eini " << i << " " <<     895    G4cout << "Collision eini " << i << " " << j << " " << eini << G4endl;
898    G4cout << "Collision etwo " << i << " " <<     896    G4cout << "Collision etwo " << i << " " << j << " " << etwo << G4endl;
899 */                                                897 */
900                                                   898 
901                                                   899 
902    for ( G4int itry = 0 ; itry < 4 ; itry++ )     900    for ( G4int itry = 0 ; itry < 4 ; itry++ )
903    {                                              901    {
904                                                   902 
905       G4double eicm = std::sqrt ( rmi*rmi + pc    903       G4double eicm = std::sqrt ( rmi*rmi + pcm*pcm );
906       G4double pibeta = pcm*beta;                 904       G4double pibeta = pcm*beta;
907                                                   905 
908       G4double trans = gamma * ( gamma * pibet    906       G4double trans = gamma * ( gamma * pibeta / ( gamma + 1 ) + eicm );
909                                                   907    
910       G4ThreeVector pi_new = beta*trans + pcm;    908       G4ThreeVector pi_new = beta*trans + pcm;
911                                                   909    
912       G4double ejcm = std::sqrt ( rmj*rmj + pc    910       G4double ejcm = std::sqrt ( rmj*rmj + pcm*pcm );
913       trans = gamma * ( gamma * pibeta / ( gam    911       trans = gamma * ( gamma * pibeta / ( gamma + 1 ) + ejcm );
914                                                   912 
915       G4ThreeVector pj_new = beta*trans - pcm;    913       G4ThreeVector pj_new = beta*trans - pcm;
916                                                   914 
917 //                                                915 //
918 // Delete old                                     916 // Delete old 
919 // Add new Particitipants                         917 // Add new Particitipants
920 //                                                918 //
921 // Now only change momentum ( Beacuse we only     919 // Now only change momentum ( Beacuse we only have elastic sctter of nucleon
922 // In future Definition also will be change       920 // In future Definition also will be change 
923 //                                                921 //
924                                                   922 
925       theSystem->GetParticipant( i )->SetMomen    923       theSystem->GetParticipant( i )->SetMomentum( pi_new );
926       theSystem->GetParticipant( j )->SetMomen    924       theSystem->GetParticipant( j )->SetMomentum( pj_new );
927                                                   925 
928       G4double pi_new_e = (theSystem->GetParti    926       G4double pi_new_e = (theSystem->GetParticipant( i )->Get4Momentum()).e();
929       G4double pj_new_e = (theSystem->GetParti    927       G4double pj_new_e = (theSystem->GetParticipant( j )->Get4Momentum()).e();
930                                                   928 
931       theMeanField->Cal2BodyQuantities( i );      929       theMeanField->Cal2BodyQuantities( i ); 
932       theMeanField->Cal2BodyQuantities( j );      930       theMeanField->Cal2BodyQuantities( j ); 
933                                                   931 
934       epot = theMeanField->GetTotalPotential()    932       epot = theMeanField->GetTotalPotential();
935                                                   933 
936       G4double efin = epot + pi_new_e + pj_new    934       G4double efin = epot + pi_new_e + pj_new_e ; 
937                                                   935 
938       //std::cout << "Collision NEW epot " <<     936       //std::cout << "Collision NEW epot " << i << " " << j << " " << epot << " " << std::abs ( eini - efin ) - fepse << std::endl;
939 /*                                                937 /*
940       G4cout << "Collision efin " << i << " "     938       G4cout << "Collision efin " << i << " " << j << " " << efin << G4endl;
941       G4cout << "Collision " << i << " " << j     939       G4cout << "Collision " << i << " " << j << " " << std::abs ( eini - efin ) << " " << fepse << G4endl;
942       G4cout << "Collision " << std::abs ( ein    940       G4cout << "Collision " << std::abs ( eini - efin ) << " " << fepse << G4endl;
943 */                                                941 */
944                                                   942 
945 //071031                                          943 //071031
946       if ( std::abs ( eini - efin ) < fepse )     944       if ( std::abs ( eini - efin ) < fepse ) 
947       {                                           945       {
948    // Collison OK                                 946    // Collison OK 
949          //std::cout << "collisions6" << std::    947          //std::cout << "collisions6" << std::endl;
950          //std::cout << "collisions before " <    948          //std::cout << "collisions before " << p4i << " " << p4j << std::endl;
951          //std::cout << "collisions after " <<    949          //std::cout << "collisions after " << theSystem->GetParticipant( i )->Get4Momentum() << " " << theSystem->GetParticipant( j )->Get4Momentum() << std::endl;
952          //std::cout << "collisions dif " << (    950          //std::cout << "collisions dif " << ( p4i + p4j ) - ( theSystem->GetParticipant( i )->Get4Momentum() + theSystem->GetParticipant( j )->Get4Momentum() ) << std::endl;
953          //std::cout << "collisions before " <    951          //std::cout << "collisions before " << rix/fermi << " " << rjx/fermi << std::endl;
954          //std::cout << "collisions after " <<    952          //std::cout << "collisions after " << theSystem->GetParticipant( i )->GetPosition() << " " << theSystem->GetParticipant( j )->GetPosition() << std::endl;
955       }                                           953       }
956 //071031                                          954 //071031
957                                                   955 
958          if ( std::abs ( eini - efin ) < fepse    956          if ( std::abs ( eini - efin ) < fepse ) return result;  // Collison OK 
959                                                   957       
960          G4double cona = ( eini - efin + etwo     958          G4double cona = ( eini - efin + etwo ) / gamma;
961          G4double fac2 = 1.0 / ( 4.0 * cona*co    959          G4double fac2 = 1.0 / ( 4.0 * cona*cona * pr*pr ) *
962                        ( ( cona*cona - ( rmi*r    960                        ( ( cona*cona - ( rmi*rmi + rmj*rmj ) )*( cona*cona - ( rmi*rmi + rmj*rmj ) )
963                        - 4.0 * rmi*rmi * rmj*r    961                        - 4.0 * rmi*rmi * rmj*rmj );
964                                                   962 
965          if ( fac2 > 0 )                          963          if ( fac2 > 0 ) 
966          {                                        964          {
967             G4double fact = std::sqrt ( fac2 )    965             G4double fact = std::sqrt ( fac2 ); 
968             pcm = fact*pcm;                       966             pcm = fact*pcm;
969          }                                        967          }
970                                                   968 
971                                                   969 
972    }                                              970    }
973                                                   971 
974 // Energetically forbidden collision              972 // Energetically forbidden collision
975    result = false;                                973    result = false;
976                                                   974 
977    return result;                                 975    return result;
978                                                   976 
979 }                                                 977 } 
980                                                   978