265{
266
276
278 if (collision != 0)
279 {
281 if (aCrossSection > 0.0)
282 {
283
284
285 #ifdef debug_G4Scatterer
286 G4cout <<
"be4 FinalState 1(p,e,m): "
289 << ", 2: "
293 #endif
294
295
297 if(!products || products->size() == 0) return products;
298
299 #ifdef debug_G4Scatterer
301 #endif
302
304
305
306 #ifdef debug_G4Scatterer
307 G4cout <<
" FinalState 1: "
308 << final->Get4Momentum()<< " "
309 << final->Get4Momentum().mag() ;
310 #endif
311
312 if(products->size() == 1) return products;
313 final=products->operator[](1);
314 #ifdef debug_G4Scatterer
316 << final->Get4Momentum() << " "
317 <<
final->Get4Momentum().mag() <<
" " <<
G4endl;
318 #endif
319
320 final= products->operator[](0);
322 if(products->size()==2)
323 {
324 final=products->operator[](1);
325 pFinal +=final->Get4Momentum();
326 }
327
328 #ifdef debug_G4Scatterer
329 if ( (pInitial-pFinal).mag() > 0.1*MeV )
330 {
331 G4cout <<
"G4Scatterer: momentum imbalance, pInitial= " <<pInitial <<
" pFinal= " <<pFinal<<
G4endl;
332 }
334 #endif
335
336 for(size_t hpw=0; hpw<products->size(); hpw++)
337 {
338 energyBalance-=products->operator[](hpw)->Get4Momentum().t();
339 pxBalance-=products->operator[](hpw)->Get4Momentum().vect().x();
340 pyBalance-=products->operator[](hpw)->Get4Momentum().vect().y();
341 pzBalance-=products->operator[](hpw)->Get4Momentum().vect().z();
342 chargeBalance-=
G4lrint(products->operator[](hpw)->GetDefinition()->GetPDGCharge());
343 baryonBalance-=products->operator[](hpw)->GetDefinition()->GetBaryonNumber();
344 }
345 if(getenv("ScattererEnergyBalanceCheck"))
346 std::cout << "DEBUGGING energy balance A: "
347 <<energyBalance<<" "
348 <<pxBalance<<" "
349 <<pyBalance<<" "
350 <<pzBalance<<" "
351 <<chargeBalance<<" "
352 <<baryonBalance<<" "
354 if(chargeBalance !=0 )
355 {
358 for(size_t hpw=0; hpw<products->size(); hpw++)
359 {
360 G4cout << products->operator[](hpw)->GetDefinition()->GetParticleName()<<
G4endl;
361 }
363 "Problem in ChargeBalance");
364 }
365 return products;
366 }
367 }
368
369 return NULL;
370}
G4DLLIMPORT std::ostream G4cout
G4int GetBaryonNumber() const
const G4String & GetParticleName() const
virtual G4KineticTrackVector * FinalState(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)