Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BinaryCascade.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26
27#include "globals.hh"
29#include "G4SystemOfUnits.hh"
30#include "G4Proton.hh"
31#include "G4Neutron.hh"
32#include "G4LorentzRotation.hh"
33#include "G4BinaryCascade.hh"
37#include "G4Track.hh"
38#include "G4V3DNucleus.hh"
39#include "G4Fancy3DNucleus.hh"
40#include "G4Scatterer.hh"
41#include "G4MesonAbsorption.hh"
42#include "G4ping.hh"
43#include "G4Delete.hh"
44
45#include "G4CollisionManager.hh"
46#include "G4Absorber.hh"
47
49#include "G4ListOfCollisions.hh"
50#include "G4Fragment.hh"
51#include "G4RKPropagation.hh"
52
55#include "G4FermiMomentum.hh"
56
57#include "G4PreCompoundModel.hh"
60
62
63#include "G4PreCompoundModel.hh"
64
65#include <algorithm>
67#include <typeinfo>
68
69// turn on general debugging info, and consistency checks
70
71//#define debug_G4BinaryCascade 1
72
73// more detailed debugging -- deprecated
74//#define debug_H1_BinaryCascade 1
75
76// specific debugging info per method or functionality
77//#define debug_BIC_ApplyCollision 1
78//#define debug_BIC_CheckPauli 1
79//#define debug_BIC_CorrectFinalPandE 1
80//#define debug_BIC_Propagate 1
81//#define debug_BIC_Propagate_Excitation 1
82//#define debug_BIC_Propagate_Collisions 1
83//#define debug_BIC_Propagate_finals 1
84//#define debug_BIC_DoTimeStep 1
85//#define debug_BIC_CorrectBarionsOnBoundary 1
86//#define debug_BIC_GetExcitationEnergy 1
87//#define debug_BIC_DeexcitationProducts 1
88//#define debug_BIC_FinalNucleusMomentum 1
89//#define debug_BIC_Final4Momentum 1
90//#define debug_BIC_FillVoidnucleus 1
91//#define debug_BIC_FindFragments 1
92//#define debug_BIC_BuildTargetList 1
93//#define debug_BIC_FindCollision 1
94//#define debug_BIC_return 1
95
96//-------
97//#if defined(debug_G4BinaryCascade)
98#if 0
99 #define _CheckChargeAndBaryonNumber_(val) CheckChargeAndBaryonNumber(val)
100 //#define debugCheckChargeAndBaryonNumberverbose 1
101#else
102 #define _CheckChargeAndBaryonNumber_(val)
103#endif
104//#if defined(debug_G4BinaryCascade)
105#if 0
106 #define _DebugEpConservation(val) DebugEpConservation(val)
107 //#define debugCheckChargeAndBaryonNumberverbose 1
108#else
109 #define _DebugEpConservation(val)
110#endif
111
112#ifdef G4MULTITHREADED
113 G4Mutex G4BinaryCascade::BICMutex = G4MUTEX_INITIALIZER;
114#endif
115 G4int G4BinaryCascade::theBIC_ID = -1;
116
117//
118// C O N S T R U C T O R S A N D D E S T R U C T O R S
119//
121G4VIntraNuclearTransportModel("Binary Cascade", ptr)
122{
123 // initialise the resonance sector
124 G4ShortLivedConstructor ShortLived;
125 ShortLived.ConstructParticle();
126
127 theCollisionMgr = new G4CollisionManager;
128 theDecay=new G4BCDecay;
129 theImR.push_back(theDecay);
130 theLateParticle= new G4BCLateParticle;
132 theImR.push_back(aAb);
133 G4Scatterer * aSc=new G4Scatterer;
134 theH1Scatterer = new G4Scatterer;
135 theImR.push_back(aSc);
136
137 thePropagator = new G4RKPropagation;
138 theCurrentTime = 0.;
139 theBCminP = 45*MeV;
140 theCutOnP = 90*MeV;
141 theCutOnPAbsorb= 0*MeV; // No Absorption of slow Mesons, other than above G4MesonAbsorption
142
143 // reuse existing pre-compound model
144 if(!ptr) {
147 G4VPreCompoundModel* pre = static_cast<G4VPreCompoundModel*>(p);
148 if(!pre) { pre = new G4PreCompoundModel(); }
149 SetDeExcitation(pre);
150 }
151 theExcitationHandler = GetDeExcitation()->GetExcitationHandler();
152 SetMinEnergy(0.0*GeV);
153 SetMaxEnergy(10.1*GeV);
154 //PrintWelcomeMessage();
155 thePrimaryEscape = true;
156 thePrimaryType = 0;
157
158 SetEnergyMomentumCheckLevels(1.0*perCent, 1.0*MeV);
159
160 // init data members
161 currentA=currentZ=0;
162 lateA=lateZ=0;
163 initialA=initialZ=0;
164 projectileA=projectileZ=0;
165 currentInitialEnergy=initial_nuclear_mass=0.;
166 massInNucleus=0.;
167 theOuterRadius=0.;
168 if ( theBIC_ID == -1 ) {
169#ifdef G4MULTITHREADED
170 G4MUTEXLOCK(&G4BinaryCascade::BICMutex);
171 if ( theBIC_ID == -1 ) {
172#endif
173 theBIC_ID = G4PhysicsModelCatalog::Register("Binary Cascade");
174#ifdef G4MULTITHREADED
175 }
176 G4MUTEXUNLOCK(&G4BinaryCascade::BICMutex);
177#endif
178 }
179
180}
181
183{
184 ClearAndDestroy(&theTargetList);
185 ClearAndDestroy(&theSecondaryList);
186 ClearAndDestroy(&theCapturedList);
187 delete thePropagator;
188 delete theCollisionMgr;
189 for(auto & ptr : theImR) { delete ptr; }
190 theImR.clear();
191 delete theLateParticle;
192 delete theH1Scatterer;
193}
194
195void G4BinaryCascade::ModelDescription(std::ostream& outFile) const
196{
197 outFile << "G4BinaryCascade is an intra-nuclear cascade model in which\n"
198 << "an incident hadron collides with a nucleon, forming two\n"
199 << "final-state particles, one or both of which may be resonances.\n"
200 << "The resonances then decay hadronically and the decay products\n"
201 << "are then propagated through the nuclear potential along curved\n"
202 << "trajectories until they re-interact or leave the nucleus.\n"
203 << "This model is valid for incident pions up to 1.5 GeV and\n"
204 << "nucleons up to 10 GeV.\n"
205 << "The remaining excited nucleus is handed on to ";
206 if (theDeExcitation) // pre-compound
207 {
208 outFile << theDeExcitation->GetModelName() << " : \n ";
210 }
211 else if (theExcitationHandler) // de-excitation
212 {
213 outFile << "G4ExcitationHandler"; //theExcitationHandler->GetModelName();
214 theExcitationHandler->ModelDescription(outFile);
215 }
216 else
217 {
218 outFile << "void.\n";
219 }
220 outFile<< " \n";
221}
222void G4BinaryCascade::PropagateModelDescription(std::ostream& outFile) const
223{
224 outFile << "G4BinaryCascade propagtes secondaries produced by a high\n"
225 << "energy model through the wounded nucleus.\n"
226 << "Secondaries are followed after the formation time and if\n"
227 << "within the nucleus are propagated through the nuclear\n"
228 << "potential along curved trajectories until they interact\n"
229 << "with a nucleon, decay, or leave the nucleus.\n"
230 << "An interaction of a secondary with a nucleon produces two\n"
231 << "final-state particles, one or both of which may be resonances.\n"
232 << "Resonances decay hadronically and the decay products\n"
233 << "are in turn propagated through the nuclear potential along curved\n"
234 << "trajectories until they re-interact or leave the nucleus.\n"
235 << "This model is valid for pions up to 1.5 GeV and\n"
236 << "nucleons up to about 3.5 GeV.\n"
237 << "The remaining excited nucleus is handed on to ";
238 if (theDeExcitation) // pre-compound
239 {
240 outFile << theDeExcitation->GetModelName() << " : \n ";
242 }
243 else if (theExcitationHandler) // de-excitation
244 {
245 outFile << "G4ExcitationHandler"; //theExcitationHandler->GetModelName();
246 theExcitationHandler->ModelDescription(outFile);
247 }
248 else
249 {
250 outFile << "void.\n";
251 }
252outFile<< " \n";
253}
254
255//----------------------------------------------------------------------------
256
257//
258// I M P L E M E N T A T I O N
259//
260
261
262//----------------------------------------------------------------------------
264 G4Nucleus & aNucleus)
265//----------------------------------------------------------------------------
266{
267 if(std::getenv("BCDEBUG") ) G4cerr << " ######### Binary Cascade Reaction starts ######### "<< G4endl;
268
269 G4LorentzVector initial4Momentum = aTrack.Get4Momentum();
270 const G4ParticleDefinition * definition = aTrack.GetDefinition();
271
272 if(initial4Momentum.e()-initial4Momentum.m()<theBCminP &&
273 ( definition==G4Neutron::NeutronDefinition() || definition==G4Proton::ProtonDefinition() ) )
274 {
275 return theDeExcitation->ApplyYourself(aTrack, aNucleus);
276 }
277
279 // initialize the G4V3DNucleus from G4Nucleus
281
282 // Build a KineticTrackVector with the G4Track
283 G4KineticTrackVector * secondaries;// = new G4KineticTrackVector;
284 G4ThreeVector initialPosition(0., 0., 0.); // will be set later
285
286 if(!std::getenv("I_Am_G4BinaryCascade_Developer") )
287 {
288 if(definition!=G4Neutron::NeutronDefinition() &&
289 definition!=G4Proton::ProtonDefinition() &&
290 definition!=G4PionPlus::PionPlusDefinition() &&
292 {
293 G4cerr << "You are trying to use G4BinaryCascade with " <<definition->GetParticleName()<<" as projectile."<<G4endl;
294 G4cerr << "G4BinaryCascade should not be used for projectiles other than nucleons or pions."<<G4endl;
295 G4cerr << "If you want to continue, please switch on the developer environment: "<<G4endl;
296 G4cerr << "setenv I_Am_G4BinaryCascade_Developer 1 "<<G4endl<<G4endl;
297 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade - used for unvalid particle type - Fatal");
298 }
299 }
300
301 // keep primary
302 thePrimaryType = definition;
303 thePrimaryEscape = false;
304
305 G4double timePrimary=aTrack.GetGlobalTime();
306
307 // try until an interaction will happen
308 G4ReactionProductVector * products=0;
309 G4int interactionCounter = 0,collisionLoopMaxCount;
310 do
311 {
312 // reset status that could be changed in previous loop event
313 theCollisionMgr->ClearAndDestroy();
314
315 if(products != 0)
316 { // free memory from previous loop event
317 ClearAndDestroy(products);
318 delete products;
319 products=0;
320 }
321
322 G4int massNumber=aNucleus.GetA_asInt();
323 the3DNucleus->Init(massNumber, aNucleus.GetZ_asInt());
324 thePropagator->Init(the3DNucleus);
325 G4KineticTrack * kt;
326 collisionLoopMaxCount = 200;
327 do // sample impact parameter until collisions are found
328 {
329 theCurrentTime=0;
330 G4double radius = the3DNucleus->GetOuterRadius()+3*fermi;
331 initialPosition=GetSpherePoint(1.1*radius, initial4Momentum); // get random position
332 kt = new G4KineticTrack(definition, 0., initialPosition, initial4Momentum);
334 // secondaries has been cleared by Propagate() in the previous loop event
335 secondaries= new G4KineticTrackVector;
336 secondaries->push_back(kt);
337 if(massNumber > 1) // 1H1 is special case
338 {
339 products = Propagate(secondaries, the3DNucleus);
340 } else {
341 products = Propagate1H1(secondaries,the3DNucleus);
342 }
343 // until we FIND a collision ... or give up
344 } while(! products && --collisionLoopMaxCount>0); /* Loop checking, 31.08.2015, G.Folger */
345
346 if(++interactionCounter>99) break;
347 // ...until we find an ALLOWED collision ... or give up
348 } while(products && products->size() == 0); /* Loop checking, 31.08.2015, G.Folger */
349
350 if(products && products->size()>0)
351 {
352 // G4cout << "BIC Applyyourself: number of products " << products->size() << G4endl;
353
354 // Fill the G4ParticleChange * with products
356 G4ReactionProductVector::iterator iter;
357
358 for(iter = products->begin(); iter != products->end(); ++iter)
359 {
360 G4DynamicParticle * aNewDP =
361 new G4DynamicParticle((*iter)->GetDefinition(),
362 (*iter)->GetTotalEnergy(),
363 (*iter)->GetMomentum());
364 G4HadSecondary aNew = G4HadSecondary(aNewDP);
365 G4double time=(*iter)->GetFormationTime();
366 if(time < 0.0) { time = 0.0; }
367 aNew.SetTime(timePrimary + time);
368 aNew.SetCreatorModelType((*iter)->GetCreatorModel());
370 }
371
372 //DebugFinalEpConservation(aTrack, products);
373
374
375 } else { // no interaction, return primary
376 if(std::getenv("BCDEBUG") ) G4cerr << " ######### Binary Cascade Reaction void, return initial state ######### "<< G4endl;
380 }
381
382 if ( products )
383 {
384 ClearAndDestroy(products);
385 delete products;
386 }
387
388 delete the3DNucleus;
389 the3DNucleus = NULL;
390
391 if(std::getenv("BCDEBUG") ) G4cerr << " ######### Binary Cascade Reaction ends ######### "<< G4endl;
392
393 return &theParticleChange;
394}
395//----------------------------------------------------------------------------
397 G4KineticTrackVector * secondaries, G4V3DNucleus * aNucleus)
398//----------------------------------------------------------------------------
399{
400 G4ping debug("debug_G4BinaryCascade");
401#ifdef debug_BIC_Propagate
402 G4cout << "G4BinaryCascade Propagate starting -------------------------------------------------------" <<G4endl;
403#endif
404
405 the3DNucleus=aNucleus;
407 theOuterRadius = the3DNucleus->GetOuterRadius();
408 theCurrentTime=0;
409 theProjectile4Momentum=G4LorentzVector(0,0,0,0);
410 theMomentumTransfer=G4ThreeVector(0,0,0);
411 // build theSecondaryList, theProjectileList and theCapturedList
412 ClearAndDestroy(&theCapturedList);
413 ClearAndDestroy(&theSecondaryList);
414 theSecondaryList.clear();
415 ClearAndDestroy(&theFinalState);
416 std::vector<G4KineticTrack *>::iterator iter;
417 theCollisionMgr->ClearAndDestroy();
418
419 theCutOnP=90*MeV;
420 if(the3DNucleus->GetMass()>30) theCutOnP = 70*MeV;
421 if(the3DNucleus->GetMass()>60) theCutOnP = 50*MeV;
422 if(the3DNucleus->GetMass()>120) theCutOnP = 45*MeV;
423
424
425 BuildTargetList();
426
427#ifdef debug_BIC_GetExcitationEnergy
428 G4cout << "ExcitationEnergy0 " << GetExcitationEnergy() << G4endl;
429#endif
430
431 thePropagator->Init(the3DNucleus);
432
433 G4bool success = BuildLateParticleCollisions(secondaries);
434 if (! success ) // fails if no excitation energy left....
435 {
436 products=HighEnergyModelFSProducts(products, secondaries);
437 ClearAndDestroy(secondaries);
438 delete secondaries;
439
440#ifdef debug_G4BinaryCascade
441 G4cout << "G4BinaryCascade::Propagate: warning - high energy model failed energy conservation, returning unchanged high energy final state" << G4endl;
442#endif
443
444 return products;
445 }
446 // check baryon and charge ...
447
448 _CheckChargeAndBaryonNumber_("lateparticles");
449 _DebugEpConservation(" be4 findcollisions");
450
451 // if called stand alone find first collisions
452 FindCollisions(&theSecondaryList);
453
454
455 if(theCollisionMgr->Entries() == 0 ) //late particles ALWAYS create Entries
456 {
457 //G4cout << " no collsions -> return 0" << G4endl;
458 delete products;
459#ifdef debug_BIC_return
460 G4cout << "return @ begin2, no collisions "<< G4endl;
461#endif
462 return 0;
463 }
464
465 // end of initialization: do the job now
466 // loop until there are no more collisions
467
468
469 G4bool haveProducts = false;
470 G4int collisionCount=0;
471 G4int collisionLoopMaxCount=1000000;
472 while(theCollisionMgr->Entries() > 0 && currentZ && --collisionLoopMaxCount>0) /* Loop checking, 31.08.2015, G.Folger */
473 {
474 if(Absorb()) { // absorb secondaries, pions only
475 haveProducts = true;
476 }
477 if(Capture()) { // capture secondaries, nucleons only
478 haveProducts = true;
479 }
480
481 // propagate to the next collision if any (collisions could have been deleted
482 // by previous absorption or capture)
483 if(theCollisionMgr->Entries() > 0)
484 {
486 nextCollision = theCollisionMgr->GetNextCollision();
487#ifdef debug_BIC_Propagate_Collisions
488 G4cout << " NextCollision * , Time, curtime = " << nextCollision << " "
489 <<nextCollision->GetCollisionTime()<< " " <<
490 theCurrentTime<< G4endl;
491#endif
492 if (!DoTimeStep(nextCollision->GetCollisionTime()-theCurrentTime) )
493 {
494 // Check if nextCollision is still valid, ie. particle did not leave nucleus
495 if (theCollisionMgr->GetNextCollision() != nextCollision )
496 {
497 nextCollision = 0;
498 }
499 }
500 //_DebugEpConservation("Stepped");
501
502 if( nextCollision )
503 {
504 if (ApplyCollision(nextCollision))
505 {
506 //G4cerr << "ApplyCollision success " << G4endl;
507 haveProducts = true;
508 collisionCount++;
509 //_CheckChargeAndBaryonNumber_("ApplyCollision");
510 //_DebugEpConservation("ApplyCollision");
511
512 } else {
513 //G4cerr << "ApplyCollision failure " << G4endl;
514 theCollisionMgr->RemoveCollision(nextCollision);
515 }
516 }
517 }
518 }
519
520 //--------- end of on Collisions
521 //G4cout << "currentZ @ end loop " << currentZ << G4endl;
522 G4int nProtons(0);
523 for(iter = theTargetList.begin(); iter != theTargetList.end(); ++iter)
524 {
525 if ( (*iter)->GetDefinition() == G4Proton::Proton() ) ++nProtons;
526 }
527 if ( ! theTargetList.size() || ! nProtons ){
528 // nucleus completely destroyed, fill in ReactionProductVector
529 products = FillVoidNucleusProducts(products);
530#ifdef debug_BIC_return
531 G4cout << "return @ Z=0 after collision loop "<< G4endl;
532 PrintKTVector(&theSecondaryList,std::string(" theSecondaryList"));
533 G4cout << "theTargetList size: " << theTargetList.size() << G4endl;
534 PrintKTVector(&theTargetList,std::string(" theTargetList"));
535 PrintKTVector(&theCapturedList,std::string(" theCapturedList"));
536
537 G4cout << " ExcitE be4 Correct : " <<GetExcitationEnergy() << G4endl;
538 G4cout << " Mom Transfered to nucleus : " << theMomentumTransfer << " " << theMomentumTransfer.mag() << G4endl;
539 PrintKTVector(&theFinalState,std::string(" FinalState uncorrected"));
540 G4cout << "returned products: " << products->size() << G4endl;
541 _CheckChargeAndBaryonNumber_("destroyed Nucleus");
542 _DebugEpConservation("destroyed Nucleus");
543#endif
544
545 return products;
546 }
547
548 // No more collisions: absorb, capture and propagate the secondaries out of the nucleus
549 if(Absorb()) {
550 haveProducts = true;
551 // G4cout << "Absorb sucess " << G4endl;
552 }
553
554 if(Capture()) {
555 haveProducts = true;
556 // G4cout << "Capture sucess " << G4endl;
557 }
558
559 if(!haveProducts) // no collisions happened. Return an empty vector.
560 {
561#ifdef debug_BIC_return
562 G4cout << "return 3, no products "<< G4endl;
563#endif
564 return products;
565 }
566
567
568#ifdef debug_BIC_Propagate
569 G4cout << " Momentum transfer to Nucleus " << theMomentumTransfer << " " << theMomentumTransfer.mag() << G4endl;
570 G4cout << " Stepping particles out...... " << G4endl;
571#endif
572
573 StepParticlesOut();
574 _DebugEpConservation("stepped out");
575
576
577 if ( theSecondaryList.size() > 0 )
578 {
579#ifdef debug_G4BinaryCascade
580 G4cerr << "G4BinaryCascade: Warning, have active particles at end" << G4endl;
581 PrintKTVector(&theSecondaryList, "active particles @ end added to theFinalState");
582#endif
583 // add left secondaries to FinalSate
584 for ( iter =theSecondaryList.begin(); iter != theSecondaryList.end(); ++iter)
585 {
586 theFinalState.push_back(*iter);
587 }
588 theSecondaryList.clear();
589
590 }
591 while ( theCollisionMgr->Entries() > 0 ) /* Loop checking, 31.08.2015, G.Folger */
592 {
593#ifdef debug_G4BinaryCascade
594 G4cerr << " Warning: remove left over collision(s) " << G4endl;
595#endif
596 theCollisionMgr->RemoveCollision(theCollisionMgr->GetNextCollision());
597 }
598
599#ifdef debug_BIC_Propagate_Excitation
600
601 PrintKTVector(&theSecondaryList,std::string(" theSecondaryList"));
602 G4cout << "theTargetList size: " << theTargetList.size() << G4endl;
603 // PrintKTVector(&theTargetList,std::string(" theTargetList"));
604 PrintKTVector(&theCapturedList,std::string(" theCapturedList"));
605
606 G4cout << " ExcitE be4 Correct : " <<GetExcitationEnergy() << G4endl;
607 G4cout << " Mom Transfered to nucleus : " << theMomentumTransfer << " " << theMomentumTransfer.mag() << G4endl;
608 PrintKTVector(&theFinalState,std::string(" FinalState uncorrected"));
609#endif
610
611 //
612
613
614 G4double ExcitationEnergy=GetExcitationEnergy();
615
616#ifdef debug_BIC_Propagate_finals
617 PrintKTVector(&theFinalState,std::string(" FinalState be4 corr"));
618 G4cout << " Excitation Energy prefinal, #collisions:, out, captured "
619 << ExcitationEnergy << " "
620 << collisionCount << " "
621 << theFinalState.size() << " "
622 << theCapturedList.size()<<G4endl;
623#endif
624
625 if (ExcitationEnergy < 0 )
626 {
627 G4int maxtry=5, ntry=0;
628 do {
629 CorrectFinalPandE();
630 ExcitationEnergy=GetExcitationEnergy();
631 } while ( ++ntry < maxtry && ExcitationEnergy < 0 ); /* Loop checking, 31.08.2015, G.Folger */
632 }
633 _DebugEpConservation("corrected");
634
635#ifdef debug_BIC_Propagate_finals
636 PrintKTVector(&theFinalState,std::string(" FinalState corrected"));
637 G4cout << " Excitation Energy final, #collisions:, out, captured "
638 << ExcitationEnergy << " "
639 << collisionCount << " "
640 << theFinalState.size() << " "
641 << theCapturedList.size()<<G4endl;
642#endif
643
644
645 if ( ExcitationEnergy < 0. )
646 {
647 #ifdef debug_G4BinaryCascade
648 G4cerr << "G4BinaryCascade-Warning: negative excitation energy ";
649 G4cerr <<ExcitationEnergy<<G4endl;
650 PrintKTVector(&theFinalState,std::string("FinalState"));
651 PrintKTVector(&theCapturedList,std::string("captured"));
652 G4cout << "negative ExE:Final 4Momentum .mag: " << GetFinal4Momentum()
653 << " "<< GetFinal4Momentum().mag()<< G4endl
654 << "negative ExE:FinalNucleusMom .mag: " << GetFinalNucleusMomentum()
655 << " "<< GetFinalNucleusMomentum().mag()<< G4endl;
656 #endif
657 #ifdef debug_BIC_return
658 G4cout << " negative Excitation E return empty products " << products << G4endl;
659 G4cout << "return 4, excit < 0 "<< G4endl;
660 #endif
661
662 ClearAndDestroy(products);
663 return products; // return empty products- FixMe
664 }
665
666 G4ReactionProductVector * precompoundProducts=DeExcite();
667
668
669 G4DecayKineticTracks decay(&theFinalState);
670 _DebugEpConservation("decayed");
671
672 products= ProductsAddFinalState(products, theFinalState);
673
674 products= ProductsAddPrecompound(products, precompoundProducts);
675
676// products=ProductsAddFakeGamma(products);
677
678
679 thePrimaryEscape = true;
680
681 #ifdef debug_BIC_return
682 G4cout << "BIC: return @end, all ok "<< G4endl;
683 //G4cout << " return products " << products << G4endl;
684 #endif
685
686 return products;
687}
688
689//----------------------------------------------------------------------------
690G4double G4BinaryCascade::GetExcitationEnergy()
691//----------------------------------------------------------------------------
692{
693
694 // get A and Z for the residual nucleus
695#if defined(debug_G4BinaryCascade) || defined(debug_BIC_GetExcitationEnergy)
696 G4int finalA = theTargetList.size()+theCapturedList.size();
697 G4int finalZ = GetTotalCharge(theTargetList)+GetTotalCharge(theCapturedList);
698 if ( (currentA - finalA) != 0 || (currentZ - finalZ) != 0 )
699 {
700 G4cerr << "G4BIC:GetExcitationEnergy(): Nucleon counting error current/final{A,Z} "
701 << "("<< currentA << "," << finalA << ") ("<< currentZ << "," << finalZ << ")" << G4endl;
702 }
703
704#endif
705
706 G4double excitationE(0);
707 G4double nucleusMass(0);
708 if(currentZ>.5)
709 {
710 nucleusMass = GetIonMass(currentZ,currentA);
711 }
712 else if (currentZ==0 ) // Uzhi && currentA==1 ) // Uzhi
713 { // Uzhi
714 if(currentA == 1) {nucleusMass = G4Neutron::Neutron()->GetPDGMass();}// Uzhi
715 else {nucleusMass = GetFinalNucleusMomentum().mag() // Uzhi
716 - 3.*MeV*currentA;} // Uzhi
717 } // Uzhi
718 else
719 {
720#ifdef debug_G4BinaryCascade
721 G4cout << "G4BinaryCascade::GetExcitationEnergy(): Warning - invalid nucleus (A,Z)=("
722 << currentA << "," << currentZ << ")" << G4endl;
723#endif
724 return 0;
725 }
726
727#ifdef debug_BIC_GetExcitationEnergy
728 G4ping debug("debug_ExcitationEnergy");
729 debug.push_back("====> current A, Z");
730 debug.push_back(currentZ);
731 debug.push_back(currentA);
732 debug.push_back("====> final A, Z");
733 debug.push_back(finalZ);
734 debug.push_back(finalA);
735 debug.push_back(nucleusMass);
736 debug.push_back(GetFinalNucleusMomentum().mag());
737 debug.dump();
738 // PrintKTVector(&theTargetList, std::string(" current target list info"));
739 //PrintKTVector(&theCapturedList, std::string(" current captured list info"));
740#endif
741
742 excitationE = GetFinalNucleusMomentum().mag() - nucleusMass;
743
744 //G4double exE2 = GetFinal4Momentum().mag() - nucleusMass;
745
746 //G4cout << "old/new excitE " << excitationE << " / "<< exE2 << G4endl;
747
748#ifdef debug_BIC_GetExcitationEnergy
749 // ------ debug
750 if ( excitationE < 0 )
751 {
752 G4cout << "negative ExE final Ion mass " <<nucleusMass<< G4endl;
753 G4LorentzVector Nucl_mom=GetFinalNucleusMomentum();
754 if(finalZ>.5) G4cout << " Final nuclmom/mass " << Nucl_mom << " " << Nucl_mom.mag()
755 << " (A,Z)=("<< finalA <<","<<finalZ <<")"
756 << " mass " << nucleusMass << " "
757 << " excitE " << excitationE << G4endl;
758
759
762 G4double initialExc(0);
763 if(Z>.5)
764 {
765 initialExc = theInitial4Mom.mag()- GetIonMass(Z, A);
766 G4cout << "GetExcitationEnergy: Initial nucleus A Z " << A << " " << Z << " " << initialExc << G4endl;
767 }
768 }
769
770#endif
771
772 return excitationE;
773}
774
775
776//----------------------------------------------------------------------------
777//
778// P R I V A T E M E M B E R F U N C T I O N S
779//
780//----------------------------------------------------------------------------
781
782//----------------------------------------------------------------------------
783void G4BinaryCascade::BuildTargetList()
784//----------------------------------------------------------------------------
785{
786
787 if(!the3DNucleus->StartLoop())
788 {
789 // G4cerr << "G4BinaryCascade::BuildTargetList(): StartLoop() error!"
790 // << G4endl;
791 return;
792 }
793
794 ClearAndDestroy(&theTargetList); // clear theTargetList before rebuilding
795
797 const G4ParticleDefinition * definition;
799 G4LorentzVector mom;
800 // if there are nucleon hit by higher energy models, then SUM(momenta) != 0
801 initialZ=the3DNucleus->GetCharge();
802 initialA=the3DNucleus->GetMassNumber();
803 initial_nuclear_mass=GetIonMass(initialZ,initialA);
804 theInitial4Mom = G4LorentzVector(0,0,0,initial_nuclear_mass);
805 currentA=0;
806 currentZ=0;
807 while((nucleon = the3DNucleus->GetNextNucleon()) != NULL) /* Loop checking, 31.08.2015, G.Folger */
808 {
809 // check if nucleon is hit by higher energy model.
810 if ( ! nucleon->AreYouHit() )
811 {
812 definition = nucleon->GetDefinition();
813 pos = nucleon->GetPosition();
814 mom = nucleon->GetMomentum();
815 // G4cout << "Nucleus " << pos.mag()/fermi << " " << mom.e() << G4endl;
816 //theInitial4Mom += mom;
817 // the potential inside the nucleus is taken into account, and nucleons are on mass shell.
818 mom.setE( std::sqrt( mom.vect().mag2() + sqr(definition->GetPDGMass()) ) );
819 G4KineticTrack * kt = new G4KineticTrack(definition, 0., pos, mom);
821 kt->SetNucleon(nucleon);
822 theTargetList.push_back(kt);
823 ++currentA;
824 if (definition->GetPDGCharge() > .5 ) ++currentZ;
825 }
826
827#ifdef debug_BIC_BuildTargetList
828 else { G4cout << "nucleon is hit" << nucleon << G4endl;}
829#endif
830 }
831 massInNucleus = 0;
832 if(currentZ>.5)
833 {
834 massInNucleus = GetIonMass(currentZ,currentA);
835 } else if (currentZ==0 && currentA>=1 )
836 {
837 massInNucleus = currentA * G4Neutron::Neutron()->GetPDGMass();
838 } else
839 {
840 G4cerr << "G4BinaryCascade::BuildTargetList(): Fatal Error - invalid nucleus (A,Z)=("
841 << currentA << "," << currentZ << ")" << G4endl;
842 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCasacde::BuildTargetList()");
843 }
844 currentInitialEnergy= theInitial4Mom.e() + theProjectile4Momentum.e();
845
846#ifdef debug_BIC_BuildTargetList
847 G4cout << "G4BinaryCascade::BuildTargetList(): nucleus (A,Z)=("
848 << currentA << "," << currentZ << ") mass: " << massInNucleus <<
849 ", theInitial4Mom " << theInitial4Mom <<
850 ", currentInitialEnergy " << currentInitialEnergy << G4endl;
851#endif
852
853}
854
855//----------------------------------------------------------------------------
856G4bool G4BinaryCascade::BuildLateParticleCollisions(G4KineticTrackVector * secondaries)
857//----------------------------------------------------------------------------
858{
859 G4bool success(false);
860 std::vector<G4KineticTrack *>::iterator iter;
861
862 lateA=lateZ=0;
863 projectileA=projectileZ=0;
864
865 G4double StartingTime=DBL_MAX; // Search for minimal formation time
866 for(iter = secondaries->begin(); iter != secondaries->end(); ++iter)
867 {
868 if((*iter)->GetFormationTime() < StartingTime)
869 StartingTime = (*iter)->GetFormationTime();
870 }
871
872 //PrintKTVector(secondaries, "initial late particles ");
873 G4LorentzVector lateParticles4Momentum(0,0,0,0);
874 for(iter = secondaries->begin(); iter != secondaries->end(); ++iter)
875 {
876 // G4cout << " Formation time : " << (*iter)->GetDefinition()->GetParticleName() << " "
877 // << (*iter)->GetFormationTime() << G4endl;
878 G4double FormTime = (*iter)->GetFormationTime() - StartingTime;
879 (*iter)->SetFormationTime(FormTime);
880 if( (*iter)->GetState() == G4KineticTrack::undefined ) // particles from high energy generator
881 {
882 FindLateParticleCollision(*iter);
883 lateParticles4Momentum += (*iter)->GetTrackingMomentum();
884 lateA += (*iter)->GetDefinition()->GetBaryonNumber();
885 lateZ += G4lrint((*iter)->GetDefinition()->GetPDGCharge()/eplus);
886 //PrintKTVector(*iter, "late particle ");
887 } else
888 {
889 theSecondaryList.push_back(*iter);
890 //PrintKTVector(*iter, "incoming particle ");
891 theProjectile4Momentum += (*iter)->GetTrackingMomentum();
892 projectileA += (*iter)->GetDefinition()->GetBaryonNumber();
893 projectileZ += G4lrint((*iter)->GetDefinition()->GetPDGCharge()/eplus);
894#ifdef debug_BIC_Propagate
895 G4cout << " Adding initial secondary " << *iter
896 << " time" << (*iter)->GetFormationTime()
897 << ", state " << (*iter)->GetState() << G4endl;
898#endif
899 }
900 }
901 //theCollisionMgr->Print();
902 const G4HadProjectile * primary = GetPrimaryProjectile(); // check for primary from TheoHE model
903
904 if (primary){
905 G4LorentzVector mom=primary->Get4Momentum();
906 theProjectile4Momentum += mom;
907 projectileA = primary->GetDefinition()->GetBaryonNumber();
908 projectileZ = G4lrint(primary->GetDefinition()->GetPDGCharge()/eplus);
909 // now check if "excitation" energy left by TheoHE model
910 G4double excitation= theProjectile4Momentum.e() + initial_nuclear_mass - lateParticles4Momentum.e() - massInNucleus;
911#ifdef debug_BIC_GetExcitationEnergy
912 G4cout << "BIC: Proj.e, nucl initial, nucl final, lateParticles"
913 << theProjectile4Momentum << ", "
914 << initial_nuclear_mass<< ", " << massInNucleus << ", "
915 << lateParticles4Momentum << G4endl;
916 G4cout << "BIC: Proj.e / initial excitation: " << theProjectile4Momentum.e() << " / " << excitation << G4endl;
917#endif
918 success = excitation > 0;
919#ifdef debug_G4BinaryCascade
920 if ( ! success ) {
921 G4cout << "G4BinaryCascade::BuildLateParticleCollisions(): Proj.e / initial excitation: " << theProjectile4Momentum.e() << " / " << excitation << G4endl;
922 //PrintKTVector(secondaries);
923 }
924#endif
925 } else {
926 // no primary from HE model -> cascade
927 success=true;
928 }
929
930 if (success) {
931 secondaries->clear(); // Don't leave "G4KineticTrack *"s in two vectors
932 delete secondaries;
933 }
934 return success;
935}
936
937//----------------------------------------------------------------------------
938G4ReactionProductVector * G4BinaryCascade::DeExcite()
939//----------------------------------------------------------------------------
940{
941 // find a fragment and call the precompound model.
942 G4Fragment * fragment = 0;
943 G4ReactionProductVector * precompoundProducts = 0;
944
945 G4LorentzVector pFragment(0);
946 // G4cout << " final4mon " << GetFinal4Momentum() /MeV << G4endl;
947
948 // if ( ExcitationEnergy >= 0 ) // closed by Uzhi
949 // { // closed by Uzhi
950 fragment = FindFragments();
951
952
953 if(fragment) // Uzhi
954 { // Uzhi
955 if(fragment->GetA_asInt() >1) // Uzhi
956 {
957 pFragment=fragment->GetMomentum();
958 // G4cout << " going to preco with fragment 4 mom " << pFragment << G4endl;
959 if (theDeExcitation) // pre-compound
960 {
961 precompoundProducts= theDeExcitation->DeExcite(*fragment);
962 }
963 else if (theExcitationHandler) // de-excitation
964 {
965 precompoundProducts=theExcitationHandler->BreakItUp(*fragment);
966 }
967
968 } else
969 { // fragment->GetA_asInt() <= 1, so a single proton, as a fragment must have Z>0
970 if (theTargetList.size() + theCapturedList.size() > 1 ) {
971 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCasacde:: Invalid Fragment");
972 }
973
974 std::vector<G4KineticTrack *>::iterator i;
975 if ( theTargetList.size() == 1 ) {i=theTargetList.begin();}
976 if ( theCapturedList.size() == 1 ) {i=theCapturedList.begin();} // Uzhi
977 G4ReactionProduct * aNew = new G4ReactionProduct((*i)->GetDefinition());
978 aNew->SetTotalEnergy((*i)->GetDefinition()->GetPDGMass());
979 aNew->SetCreatorModel(theBIC_ID);
980 aNew->SetMomentum(G4ThreeVector(0));// see boost for preCompoundProducts below..
981 precompoundProducts = new G4ReactionProductVector();
982 precompoundProducts->push_back(aNew);
983 } // End of fragment->GetA() < 1.5
984 delete fragment;
985 fragment=0;
986
987 } else // End of if(fragment)
988 { // No fragment, can be neutrons only // Uzhi
989
990 precompoundProducts = DecayVoidNucleus();
991 }
992 #ifdef debug_BIC_DeexcitationProducts
993
994 G4LorentzVector fragment_momentum=GetFinalNucleusMomentum();
995 G4LorentzVector Preco_momentum;
996 if ( precompoundProducts )
997 {
998 std::vector<G4ReactionProduct *>::iterator j;
999 for(j = precompoundProducts->begin(); j != precompoundProducts->end(); ++j)
1000 {
1001 G4LorentzVector pProduct((*j)->GetMomentum(),(*j)->GetTotalEnergy());
1002 Preco_momentum += pProduct;
1003 }
1004 }
1005 G4cout << "finalNuclMom / sum preco products" << fragment_momentum << " / " << Preco_momentum
1006 << " delta E "<< fragment_momentum.e() - Preco_momentum.e() << G4endl;
1007
1008 #endif
1009
1010 return precompoundProducts;
1011}
1012
1013//----------------------------------------------------------------------------
1014G4ReactionProductVector * G4BinaryCascade::DecayVoidNucleus()
1015//----------------------------------------------------------------------------
1016{
1017 G4ReactionProductVector * result=0;
1018 if ( (theTargetList.size()+theCapturedList.size()) > 0 )
1019 {
1020 result = new G4ReactionProductVector;
1021 std::vector<G4KineticTrack *>::iterator aNuc;
1022 G4LorentzVector aVec;
1023 std::vector<G4double> masses;
1024 G4double sumMass(0);
1025
1026 if ( theTargetList.size() != 0) // Uzhi
1027 {
1028 for ( aNuc=theTargetList.begin(); aNuc != theTargetList.end(); aNuc++)
1029 {
1030 G4double mass=(*aNuc)->GetDefinition()->GetPDGMass();
1031 masses.push_back(mass);
1032 sumMass += mass;
1033 }
1034 } // Uzhi
1035
1036 if ( theCapturedList.size() != 0) // Uzhi
1037 { // Uzhi
1038 for(aNuc = theCapturedList.begin(); // Uzhi
1039 aNuc != theCapturedList.end(); aNuc++) // Uzhi
1040 { // Uzhi
1041 G4double mass=(*aNuc)->GetDefinition()->GetPDGMass(); // Uzhi
1042 masses.push_back(mass); // Uzhi
1043 sumMass += mass; // Uzhi
1044 }
1045 }
1046
1047 G4LorentzVector finalP=GetFinal4Momentum();
1049 // G4cout << " some neutrons? " << masses.size() <<" " ;
1050 // G4cout<< theTargetList.size()<<" "<<finalP <<" " << finalP.mag()<<G4endl;
1051
1052 G4double eCMS=finalP.mag();
1053 if ( eCMS < sumMass ) // @@GF --- Cheat!!
1054 {
1055 eCMS=sumMass + 2*MeV*masses.size();
1056 finalP.setE(std::sqrt(finalP.vect().mag2() + sqr(eCMS)));
1057 }
1058
1059 precompoundLorentzboost.set(finalP.boostVector());
1060 std::vector<G4LorentzVector*> * momenta=decay.Decay(eCMS,masses);
1061 std::vector<G4LorentzVector*>::iterator aMom=momenta->begin();
1062
1063
1064 if ( theTargetList.size() != 0)
1065 {
1066 for ( aNuc=theTargetList.begin();
1067 (aNuc != theTargetList.end()) && (aMom!=momenta->end());
1068 aNuc++, aMom++ )
1069 {
1070 G4ReactionProduct * aNew = new G4ReactionProduct((*aNuc)->GetDefinition());
1071 aNew->SetTotalEnergy((*aMom)->e());
1072 aNew->SetMomentum((*aMom)->vect());
1073 aNew->SetCreatorModel(theBIC_ID);
1074 result->push_back(aNew);
1075
1076 delete *aMom;
1077 }
1078 }
1079
1080 if ( theCapturedList.size() != 0) // Uzhi
1081 { // Uzhi
1082 for ( aNuc=theCapturedList.begin(); // Uzhi
1083 (aNuc != theCapturedList.end()) && (aMom!=momenta->end()); // Uzhi
1084 aNuc++, aMom++ ) // Uzhi
1085 { // Uzhi
1086 G4ReactionProduct * aNew = new G4ReactionProduct( // Uzhi
1087 (*aNuc)->GetDefinition()); // Uzhi
1088 aNew->SetTotalEnergy((*aMom)->e()); // Uzhi
1089 aNew->SetMomentum((*aMom)->vect()); // Uzhi
1090 aNew->SetCreatorModel(theBIC_ID);
1091 result->push_back(aNew); // Uzhi
1092 delete *aMom; // Uzhi
1093 } // Uzhi
1094 } // Uzhi
1095
1096 delete momenta;
1097 }
1098 return result;
1099} // End if(!fragment)
1100
1101//----------------------------------------------------------------------------
1102G4ReactionProductVector * G4BinaryCascade::ProductsAddFinalState(G4ReactionProductVector * products, G4KineticTrackVector & fs)
1103//----------------------------------------------------------------------------
1104{
1105// fill in products the outgoing particles
1106 size_t i(0);
1107#ifdef debug_BIC_Propagate_finals
1108 G4LorentzVector mom_fs;
1109#endif
1110 for(i = 0; i< fs.size(); i++)
1111 {
1112 G4KineticTrack * kt = fs[i];
1114 aNew->SetMomentum(kt->Get4Momentum().vect());
1115 aNew->SetTotalEnergy(kt->Get4Momentum().e());
1116 aNew->SetNewlyAdded(kt->IsParticipant());
1117 aNew->SetCreatorModel(theBIC_ID);
1118 products->push_back(aNew);
1119
1120#ifdef debug_BIC_Propagate_finals
1121 mom_fs += kt->Get4Momentum();
1123 G4cout << " Particle Ekin " << aNew->GetKineticEnergy();
1124 G4cout << ", is " << (kt->GetDefinition()->GetPDGStable() ? "stable" :
1125 (kt->GetDefinition()->IsShortLived() ? "short lived " : "non stable")) ;
1126 G4cout << G4endl;
1127#endif
1128
1129 }
1130#ifdef debug_BIC_Propagate_finals
1131 G4cout << " Final state momentum " << mom_fs << G4endl;
1132#endif
1133
1134 return products;
1135}
1136//----------------------------------------------------------------------------
1137G4ReactionProductVector * G4BinaryCascade::ProductsAddPrecompound(G4ReactionProductVector * products, G4ReactionProductVector * precompoundProducts)
1138//----------------------------------------------------------------------------
1139{
1140 G4LorentzVector pSumPreco(0), pPreco(0);
1141
1142 if ( precompoundProducts )
1143 {
1144 std::vector<G4ReactionProduct *>::iterator j;
1145 for(j = precompoundProducts->begin(); j != precompoundProducts->end(); ++j)
1146 {
1147 // boost back to system of moving nucleus
1148 G4LorentzVector pProduct((*j)->GetMomentum(),(*j)->GetTotalEnergy());
1149 pPreco+= pProduct;
1150#ifdef debug_BIC_Propagate_finals
1151 G4cout << "BIC: pProduct be4 boost " <<pProduct << G4endl;
1152#endif
1153 pProduct *= precompoundLorentzboost;
1154#ifdef debug_BIC_Propagate_finals
1155 G4cout << "BIC: pProduct aft boost " <<pProduct << G4endl;
1156#endif
1157 pSumPreco += pProduct;
1158 (*j)->SetTotalEnergy(pProduct.e());
1159 (*j)->SetMomentum(pProduct.vect());
1160 (*j)->SetNewlyAdded(true);
1161 products->push_back(*j);
1162 }
1163 // G4cout << " unboosted preco result mom " << pPreco / MeV << " ..- fragmentMom " << (pPreco - pFragment)/MeV<< G4endl;
1164 // G4cout << " preco result mom " << pSumPreco / MeV << " ..-file4Mom " << (pSumPreco - GetFinal4Momentum())/MeV<< G4endl;
1165 precompoundProducts->clear();
1166 delete precompoundProducts;
1167 }
1168 return products;
1169}
1170//----------------------------------------------------------------------------
1171void G4BinaryCascade::FindCollisions(G4KineticTrackVector * secondaries)
1172//----------------------------------------------------------------------------
1173{
1174 for(std::vector<G4KineticTrack *>::iterator i = secondaries->begin();
1175 i != secondaries->end(); ++i)
1176 {
1177 for(std::vector<G4BCAction *>::iterator j = theImR.begin();
1178 j!=theImR.end(); j++)
1179 {
1180 // G4cout << "G4BinaryCascade::FindCollisions: at action " << *j << G4endl;
1181 const std::vector<G4CollisionInitialState *> & aCandList
1182 = (*j)->GetCollisions(*i, theTargetList, theCurrentTime);
1183 for(size_t count=0; count<aCandList.size(); count++)
1184 {
1185 theCollisionMgr->AddCollision(aCandList[count]);
1186 //4cout << "====================== New Collision ================="<<G4endl;
1187 //theCollisionMgr->Print();
1188 }
1189 }
1190 }
1191}
1192
1193
1194//----------------------------------------------------------------------------
1195void G4BinaryCascade::FindDecayCollision(G4KineticTrack * secondary)
1196//----------------------------------------------------------------------------
1197{
1198 const std::vector<G4CollisionInitialState *> & aCandList
1199 = theDecay->GetCollisions(secondary, theTargetList, theCurrentTime);
1200 for(size_t count=0; count<aCandList.size(); count++)
1201 {
1202 theCollisionMgr->AddCollision(aCandList[count]);
1203 }
1204}
1205
1206//----------------------------------------------------------------------------
1207void G4BinaryCascade::FindLateParticleCollision(G4KineticTrack * secondary)
1208//----------------------------------------------------------------------------
1209{
1210
1211 G4double tin=0., tout=0.;
1212 if (((G4RKPropagation*)thePropagator)->GetSphereIntersectionTimes(secondary,tin,tout))
1213 {
1214 if ( tin > 0 )
1215 {
1217 } else if ( tout > 0 )
1218 {
1219 secondary->SetState(G4KineticTrack::inside);
1220 } else {
1221 //G4cout << "G4BC set miss , tin, tout " << tin << " , " << tout <<G4endl;
1223 }
1224 } else {
1226 //G4cout << "G4BC set miss ,no intersect tin, tout " << tin << " , " << tout <<G4endl;
1227 }
1228
1229
1230#ifdef debug_BIC_FindCollision
1231 G4cout << "FindLateP Particle, 4-mom, times newState "
1232 << secondary->GetDefinition()->GetParticleName() << " "
1233 << secondary->Get4Momentum()
1234 << " times " << tin << " " << tout << " "
1235 << secondary->GetState() << G4endl;
1236#endif
1237
1238 const std::vector<G4CollisionInitialState *> & aCandList
1239 = theLateParticle->GetCollisions(secondary, theTargetList, theCurrentTime);
1240 for(size_t count=0; count<aCandList.size(); count++)
1241 {
1242#ifdef debug_BIC_FindCollision
1243 G4cout << " Adding a late Col : " << aCandList[count] << G4endl;
1244#endif
1245 theCollisionMgr->AddCollision(aCandList[count]);
1246 }
1247}
1248
1249
1250//----------------------------------------------------------------------------
1251G4bool G4BinaryCascade::ApplyCollision(G4CollisionInitialState * collision)
1252//----------------------------------------------------------------------------
1253{
1254 G4KineticTrack * primary = collision->GetPrimary();
1255
1256#ifdef debug_BIC_ApplyCollision
1257 G4cerr << "G4BinaryCascade::ApplyCollision start"<<G4endl;
1258 theCollisionMgr->Print();
1259 G4cout << "ApplyCollisions : projte 4mom " << primary->GetTrackingMomentum()<< G4endl;
1260#endif
1261
1262 G4KineticTrackVector target_collection=collision->GetTargetCollection();
1263 G4bool haveTarget=target_collection.size()>0;
1264 if( haveTarget && (primary->GetState() != G4KineticTrack::inside) )
1265 {
1266#ifdef debug_G4BinaryCascade
1267 G4cout << "G4BinaryCasacde::ApplyCollision(): StateError " << primary << G4endl;
1268 PrintKTVector(primary,std::string("primay- ..."));
1269 PrintKTVector(&target_collection,std::string("... targets"));
1270 collision->Print();
1271 G4cout << G4endl;
1272 theCollisionMgr->Print();
1273 //*GF* throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCasacde::ApplyCollision()");
1274#endif
1275 return false;
1276// } else {
1277// G4cout << "G4BinaryCasacde::ApplyCollision(): decay " << G4endl;
1278// PrintKTVector(primary,std::string("primay- ..."));
1279// G4double tin=0., tout=0.;
1280// if (((G4RKPropagation*)thePropagator)->GetSphereIntersectionTimes(primary,tin,tout))
1281// {
1282// G4cout << "tin tout: " << tin << " " << tout << G4endl;
1283// }
1284
1285 }
1286
1287 G4LorentzVector mom4Primary=primary->Get4Momentum();
1288
1289 G4int initialBaryon(0);
1290 G4int initialCharge(0);
1291 if (primary->GetState() == G4KineticTrack::inside)
1292 {
1293 initialBaryon = primary->GetDefinition()->GetBaryonNumber();
1294 initialCharge = G4lrint(primary->GetDefinition()->GetPDGCharge()/eplus);
1295 }
1296
1297 // for primary resonances, subtract neutron ( = proton) field ( ie. add std::abs(field))
1298 G4double initial_Efermi=CorrectShortlivedPrimaryForFermi(primary,target_collection);
1299 //****************************************
1300
1301
1302 G4KineticTrackVector * products = collision->GetFinalState();
1303
1304#ifdef debug_BIC_ApplyCollision
1305 DebugApplyCollisionFail(collision, products);
1306#endif
1307
1308 // reset primary to initial state, in case there is a veto...
1309 primary->Set4Momentum(mom4Primary);
1310
1311 G4bool lateParticleCollision= (!haveTarget) && products && products->size() == 1;
1312 G4bool decayCollision= (!haveTarget) && products && products->size() > 1;
1313 G4bool Success(true);
1314
1315
1316#ifdef debug_G4BinaryCascade
1317 G4int lateBaryon(0), lateCharge(0);
1318#endif
1319
1320 if ( lateParticleCollision )
1321 { // for late particles, reset charges
1322 //G4cout << "lateP, initial B C state " << initialBaryon << " "
1323 // << initialCharge<< " " << primary->GetState() << " "<< primary->GetDefinition()->GetParticleName()<< G4endl;
1324#ifdef debug_G4BinaryCascade
1325 lateBaryon = initialBaryon;
1326 lateCharge = initialCharge;
1327#endif
1328 initialBaryon=initialCharge=0;
1329 lateA -= primary->GetDefinition()->GetBaryonNumber();
1330 lateZ -= G4lrint(primary->GetDefinition()->GetPDGCharge()/eplus);
1331 }
1332
1333 initialBaryon += collision->GetTargetBaryonNumber();
1334 initialCharge += G4lrint(collision->GetTargetCharge());
1335 if (!lateParticleCollision)
1336 {
1337 if( !products || products->size()==0 || !CheckPauliPrinciple(products) )
1338 {
1339#ifdef debug_BIC_ApplyCollision
1340 if (products) G4cout << " ======Failed Pauli =====" << G4endl;
1341 G4cerr << "G4BinaryCascade::ApplyCollision blocked"<<G4endl;
1342#endif
1343 Success=false;
1344 }
1345
1346
1347
1348 if (Success && primary->GetState() == G4KineticTrack::inside ) { // if the primary was outside, nothing to correct
1349 if (! CorrectShortlivedFinalsForFermi(products, initial_Efermi)){
1350 Success=false;
1351 }
1352 }
1353 }
1354
1355#ifdef debug_BIC_ApplyCollision
1356 DebugApplyCollision(collision, products);
1357#endif
1358
1359 if ( ! Success ){
1360 if (products) ClearAndDestroy(products);
1361 if ( decayCollision ) FindDecayCollision(primary); // for decay, sample new decay
1362 delete products;
1363 products=0;
1364 return false;
1365 }
1366
1367 G4int finalBaryon(0);
1368 G4int finalCharge(0);
1369 G4KineticTrackVector toFinalState;
1370 for(std::vector<G4KineticTrack *>::iterator i =products->begin(); i != products->end(); i++)
1371 {
1372 if ( ! lateParticleCollision )
1373 {
1374 (*i)->SetState(primary->GetState()); // decay may be anywhere!
1375 if ( (*i)->GetState() == G4KineticTrack::inside ){
1376 finalBaryon+=(*i)->GetDefinition()->GetBaryonNumber();
1377 finalCharge+=G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus);
1378 } else {
1379 G4double tin=0., tout=0.;
1380 if (((G4RKPropagation*)thePropagator)->GetSphereIntersectionTimes((*i),tin,tout) &&
1381 tin < 0 && tout > 0 )
1382 {
1383 PrintKTVector((*i),"particle inside marked not-inside");
1384 G4cout << "tin tout: " << tin << " " << tout << G4endl;
1385 }
1386 }
1387 } else {
1388 G4double tin=0., tout=0.;
1389 if (((G4RKPropagation*)thePropagator)->GetSphereIntersectionTimes((*i),tin,tout))
1390 {
1391 //G4cout << "tin tout: " << tin << " " << tout << G4endl;
1392 if ( tin > 0 )
1393 {
1394 (*i)->SetState(G4KineticTrack::outside);
1395 }
1396 else if ( tout > 0 )
1397 {
1398 (*i)->SetState(G4KineticTrack::inside);
1399 finalBaryon+=(*i)->GetDefinition()->GetBaryonNumber();
1400 finalCharge+=G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus);
1401 }
1402 else
1403 {
1404 (*i)->SetState(G4KineticTrack::gone_out);
1405 toFinalState.push_back((*i));
1406 }
1407 } else
1408 {
1409 (*i)->SetState(G4KineticTrack::miss_nucleus);
1410 //G4cout << " G4BC - miss -late Part- no intersection found " << G4endl;
1411 toFinalState.push_back((*i));
1412 }
1413
1414 }
1415 }
1416 if(!toFinalState.empty())
1417 {
1418 theFinalState.insert(theFinalState.end(),
1419 toFinalState.begin(),toFinalState.end());
1420 std::vector<G4KineticTrack *>::iterator iter1, iter2;
1421 for(iter1 = toFinalState.begin(); iter1 != toFinalState.end();
1422 ++iter1)
1423 {
1424 iter2 = std::find(products->begin(), products->end(),
1425 *iter1);
1426 if ( iter2 != products->end() ) products->erase(iter2);
1427 }
1428 theCollisionMgr->RemoveTracksCollisions(&toFinalState);
1429 }
1430
1431 //G4cout << " currentA, Z be4: " << currentA << " " << currentZ << G4endl;
1432 currentA += finalBaryon-initialBaryon;
1433 currentZ += finalCharge-initialCharge;
1434 //G4cout << " ApplyCollision currentA, Z aft: " << currentA << " " << currentZ << G4endl;
1435
1436 G4KineticTrackVector oldSecondaries;
1437 oldSecondaries.push_back(primary);
1438 primary->Hit();
1439
1440#ifdef debug_G4BinaryCascade
1441 if ( (finalBaryon-initialBaryon-lateBaryon) != 0 || (finalCharge-initialCharge-lateCharge) != 0 )
1442 {
1443 G4cout << "G4BinaryCascade: Error in Balancing: " << G4endl;
1444 G4cout << "initial/final baryon number, initial/final Charge "
1445 << initialBaryon <<" "<< finalBaryon <<" "
1446 << initialCharge <<" "<< finalCharge <<" "
1447 << " in Collision type: "<< typeid(*collision->GetGenerator()).name()
1448 << ", with number of products: "<< products->size() <<G4endl;
1449 G4cout << G4endl<<"Initial condition are these:"<<G4endl;
1450 G4cout << "proj: "<<collision->GetPrimary()->GetDefinition()->GetParticleName()<<G4endl;
1451 for(size_t it=0; it<collision->GetTargetCollection().size(); it++)
1452 {
1453 G4cout << "targ: "
1454 <<collision->GetTargetCollection()[it]->GetDefinition()->GetParticleName()<<G4endl;
1455 }
1456 PrintKTVector(&collision->GetTargetCollection(),std::string(" Target particles"));
1457 G4cout << G4endl<<G4endl;
1458 }
1459#endif
1460
1461 G4KineticTrackVector oldTarget = collision->GetTargetCollection();
1462 for(size_t ii=0; ii< oldTarget.size(); ii++)
1463 {
1464 oldTarget[ii]->Hit();
1465 }
1466
1467 UpdateTracksAndCollisions(&oldSecondaries, &oldTarget, products);
1468 std::for_each(oldSecondaries.begin(), oldSecondaries.end(), Delete<G4KineticTrack>());
1469 std::for_each(oldTarget.begin(), oldTarget.end(), Delete<G4KineticTrack>());
1470
1471 delete products;
1472 return true;
1473}
1474
1475
1476//----------------------------------------------------------------------------
1477G4bool G4BinaryCascade::Absorb()
1478//----------------------------------------------------------------------------
1479{
1480 // Do it in two step: cannot change theSecondaryList inside the first loop.
1481 G4Absorber absorber(theCutOnPAbsorb);
1482
1483 // Build the vector of G4KineticTracks that must be absorbed
1484 G4KineticTrackVector absorbList;
1485 std::vector<G4KineticTrack *>::iterator iter;
1486 // PrintKTVector(&theSecondaryList, " testing for Absorb" );
1487 for(iter = theSecondaryList.begin();
1488 iter != theSecondaryList.end(); ++iter)
1489 {
1490 G4KineticTrack * kt = *iter;
1491 if(kt->GetState() == G4KineticTrack::inside)// absorption happens only inside the nucleus
1492 {
1493 if(absorber.WillBeAbsorbed(*kt))
1494 {
1495 absorbList.push_back(kt);
1496 }
1497 }
1498 }
1499
1500 if(absorbList.empty())
1501 return false;
1502
1503 G4KineticTrackVector toDelete;
1504 for(iter = absorbList.begin(); iter != absorbList.end(); ++iter)
1505 {
1506 G4KineticTrack * kt = *iter;
1507 if(!absorber.FindAbsorbers(*kt, theTargetList))
1508 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::Absorb(): Cannot absorb a particle.");
1509
1510 if(!absorber.FindProducts(*kt))
1511 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::Absorb(): Cannot absorb a particle.");
1512
1513 G4KineticTrackVector * products = absorber.GetProducts();
1514 G4int maxLoopCount = 1000;
1515 while(!CheckPauliPrinciple(products) && --maxLoopCount>0) /* Loop checking, 31.08.2015, G.Folger */
1516 {
1517 ClearAndDestroy(products);
1518 if(!absorber.FindProducts(*kt))
1519 throw G4HadronicException(__FILE__, __LINE__,
1520 "G4BinaryCascade::Absorb(): Cannot absorb a particle.");
1521 }
1522 if ( --maxLoopCount < 0 ) throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::Absorb(): Cannot absorb a particle.");
1523 // ------ debug
1524 // G4cerr << "Absorb CheckPauliPrinciple count= " << maxLoopCount << G4endl;
1525 // ------ end debug
1526 G4KineticTrackVector toRemove; // build a vector for UpdateTrack...
1527 toRemove.push_back(kt);
1528 toDelete.push_back(kt); // delete the track later
1529 G4KineticTrackVector * absorbers = absorber.GetAbsorbers();
1530 UpdateTracksAndCollisions(&toRemove, absorbers, products);
1531 ClearAndDestroy(absorbers);
1532 }
1533 ClearAndDestroy(&toDelete);
1534 return true;
1535}
1536
1537
1538
1539// Capture all p and n with Energy < theCutOnP
1540//----------------------------------------------------------------------------
1541G4bool G4BinaryCascade::Capture(G4bool verbose)
1542//----------------------------------------------------------------------------
1543{
1544 G4KineticTrackVector captured;
1545 G4bool capture = false;
1546 std::vector<G4KineticTrack *>::iterator i;
1547
1548 G4RKPropagation * RKprop=(G4RKPropagation *)thePropagator;
1549
1550 G4double capturedEnergy = 0;
1551 G4int particlesAboveCut=0;
1552 G4int particlesBelowCut=0;
1553 if ( verbose ) G4cout << " Capture: secondaries " << theSecondaryList.size() << G4endl;
1554 for(i = theSecondaryList.begin(); i != theSecondaryList.end(); ++i)
1555 {
1556 G4KineticTrack * kt = *i;
1557 if (verbose) G4cout << "Capture position, radius, state " <<kt->GetPosition().mag()<<" "<<theOuterRadius<<" "<<kt->GetState()<<G4endl;
1558 if(kt->GetState() == G4KineticTrack::inside) // capture happens only inside the nucleus
1559 {
1560 if((kt->GetDefinition() == G4Proton::Proton()) ||
1561 (kt->GetDefinition() == G4Neutron::Neutron()))
1562 {
1563 //GF cut on kinetic energy if(kt->Get4Momentum().vect().mag() >= theCutOnP)
1564 G4double field=RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition())
1565 -RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding());
1566 G4double energy= kt->Get4Momentum().e() - kt->GetActualMass() + field;
1567 if (verbose ) G4cout << "Capture: .e(), mass, field, energy" << kt->Get4Momentum().e() <<" "<<kt->GetActualMass()<<" "<<field<<" "<<energy<< G4endl;
1568 // if( energy < theCutOnP )
1569 // {
1570 capturedEnergy+=energy;
1571 ++particlesBelowCut;
1572 // } else
1573 // {
1574 // ++particlesAboveCut;
1575 // }
1576 }
1577 }
1578 }
1579 if (verbose) G4cout << "Capture particlesAboveCut,particlesBelowCut, capturedEnergy,capturedEnergy/particlesBelowCut <? 0.2*theCutOnP "
1580 << particlesAboveCut << " " << particlesBelowCut << " " << capturedEnergy
1581 << " " << G4endl;
1582// << " " << (particlesBelowCut>0) ? (capturedEnergy/particlesBelowCut) : (capturedEnergy) << " " << 0.2*theCutOnP << G4endl;
1583 // if(particlesAboveCut==0 && particlesBelowCut>0 && capturedEnergy/particlesBelowCut<0.2*theCutOnP)
1584 if(particlesBelowCut>0 && capturedEnergy/particlesBelowCut<0.2*theCutOnP)
1585 {
1586 capture=true;
1587 for(i = theSecondaryList.begin(); i != theSecondaryList.end(); ++i)
1588 {
1589 G4KineticTrack * kt = *i;
1590 if(kt->GetState() == G4KineticTrack::inside) // capture happens only inside the nucleus
1591 {
1592 if((kt->GetDefinition() == G4Proton::Proton()) ||
1593 (kt->GetDefinition() == G4Neutron::Neutron()))
1594 {
1595 captured.push_back(kt);
1596 kt->Hit(); //
1597 theCapturedList.push_back(kt);
1598 }
1599 }
1600 }
1601 UpdateTracksAndCollisions(&captured, NULL, NULL);
1602 }
1603
1604 return capture;
1605}
1606
1607
1608//----------------------------------------------------------------------------
1609G4bool G4BinaryCascade::CheckPauliPrinciple(G4KineticTrackVector * products)
1610//----------------------------------------------------------------------------
1611{
1614
1615 G4FermiMomentum fermiMom;
1616 fermiMom.Init(A, Z);
1617
1619
1620 G4KineticTrackVector::iterator i;
1621 const G4ParticleDefinition * definition;
1622
1623 // ------ debug
1624 G4bool myflag = true;
1625 // ------ end debug
1626 // G4ThreeVector xpos(0);
1627 for(i = products->begin(); i != products->end(); ++i)
1628 {
1629 definition = (*i)->GetDefinition();
1630 if((definition == G4Proton::Proton()) ||
1631 (definition == G4Neutron::Neutron()))
1632 {
1633 G4ThreeVector pos = (*i)->GetPosition();
1634 G4double d = density->GetDensity(pos);
1635 // energy correspondiing to fermi momentum
1636 G4double eFermi = std::sqrt( sqr(fermiMom.GetFermiMomentum(d)) + (*i)->Get4Momentum().mag2() );
1637 if( definition == G4Proton::Proton() )
1638 {
1639 eFermi -= the3DNucleus->CoulombBarrier();
1640 }
1641 G4LorentzVector mom = (*i)->Get4Momentum();
1642 // ------ debug
1643 /*
1644 * G4cout << "p:[" << (1/MeV)*mom.x() << " " << (1/MeV)*mom.y() << " "
1645 * << (1/MeV)*mom.z() << "] |p3|:"
1646 * << (1/MeV)*mom.vect().mag() << " E:" << (1/MeV)*mom.t() << " ] m: "
1647 * << (1/MeV)*mom.mag() << " pos["
1648 * << (1/fermi)*pos.x() << " "<< (1/fermi)*pos.y() << " "
1649 * << (1/fermi)*pos.z() << "] |Dpos|: "
1650 * << (1/fermi)*(pos-xpos).mag() << " Pfermi:"
1651 * << (1/MeV)*p << G4endl;
1652 * xpos=pos;
1653 */
1654 // ------ end debug
1655 if(mom.e() < eFermi )
1656 {
1657 // ------ debug
1658 myflag = false;
1659 // ------ end debug
1660 // return false;
1661 }
1662 }
1663 }
1664#ifdef debug_BIC_CheckPauli
1665 if ( myflag )
1666 {
1667 for(i = products->begin(); i != products->end(); ++i)
1668 {
1669 definition = (*i)->GetDefinition();
1670 if((definition == G4Proton::Proton()) ||
1671 (definition == G4Neutron::Neutron()))
1672 {
1673 G4ThreeVector pos = (*i)->GetPosition();
1674 G4double d = density->GetDensity(pos);
1675 G4double pFermi = fermiMom.GetFermiMomentum(d);
1676 G4LorentzVector mom = (*i)->Get4Momentum();
1677 G4double field =((G4RKPropagation*)thePropagator)->GetField(definition->GetPDGEncoding(),pos);
1678 if ( mom.e()-mom.mag()+field > 160*MeV )
1679 {
1680 G4cout << "momentum problem pFermi=" << pFermi
1681 << " mom, mom.m " << mom << " " << mom.mag()
1682 << " field " << field << G4endl;
1683 }
1684 }
1685 }
1686 }
1687#endif
1688
1689 return myflag;
1690}
1691
1692//----------------------------------------------------------------------------
1693void G4BinaryCascade::StepParticlesOut()
1694//----------------------------------------------------------------------------
1695{
1696 G4int counter=0;
1697 G4int countreset=0;
1698 //G4cout << " nucl. Radius " << radius << G4endl;
1699 // G4cerr <<"pre-while- theSecondaryList "<<G4endl;
1700 while( theSecondaryList.size() > 0 ) /* Loop checking, 31.08.2015, G.Folger */
1701 // if countreset reaches limit, there is a break from while, see below.
1702 {
1703 G4int nsec=0;
1704 G4double minTimeStep = 1.e-12*ns; // about 30*fermi/(0.1*c_light);1.e-12*ns
1705 // i.e. a big step
1706 std::vector<G4KineticTrack *>::iterator i;
1707 for(i = theSecondaryList.begin(); i != theSecondaryList.end(); ++i)
1708 {
1709 G4KineticTrack * kt = *i;
1710 if( kt->GetState() == G4KineticTrack::inside )
1711 {
1712 nsec++;
1713 G4double tStep(0), tdummy(0);
1714 G4bool intersect =
1715 ((G4RKPropagation*)thePropagator)->GetSphereIntersectionTimes(kt,tdummy,tStep);
1716#ifdef debug_BIC_StepParticlesOut
1717 G4cout << " minTimeStep, tStep Particle " <<minTimeStep << " " <<tStep
1718 << " " <<kt->GetDefinition()->GetParticleName()
1719 << " 4mom " << kt->GetTrackingMomentum()<<G4endl;
1720 if ( ! intersect );
1721 {
1722 PrintKTVector(&theSecondaryList, std::string(" state ERROR....."));
1723 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::StepParticlesOut() particle not in nucleus");
1724 }
1725#endif
1726 if(intersect && tStep<minTimeStep && tStep> 0 )
1727 {
1728 minTimeStep = tStep;
1729 }
1730 } else if ( kt->GetState() != G4KineticTrack::outside ){
1731 PrintKTVector(&theSecondaryList, std::string(" state ERROR....."));
1732 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::StepParticlesOut() particle not in nucleus");
1733 }
1734 }
1735 minTimeStep *= 1.2;
1736 // G4cerr << "CaptureCount = "<<counter<<" "<<nsec<<" "<<minTimeStep<<" "<<1*ns<<G4endl;
1737 G4double timeToCollision=DBL_MAX;
1738 G4CollisionInitialState * nextCollision=0;
1739 if(theCollisionMgr->Entries() > 0)
1740 {
1741 nextCollision = theCollisionMgr->GetNextCollision();
1742 timeToCollision = nextCollision->GetCollisionTime()-theCurrentTime;
1743 // G4cout << " NextCollision * , Time= " << nextCollision << " " <<timeToCollision<< G4endl;
1744 }
1745 if ( timeToCollision > minTimeStep )
1746 {
1747 DoTimeStep(minTimeStep);
1748 ++counter;
1749 } else
1750 {
1751 if (!DoTimeStep(timeToCollision) )
1752 {
1753 // Check if nextCollision is still valid, ie. partcile did not leave nucleus
1754 if (theCollisionMgr->GetNextCollision() != nextCollision )
1755 {
1756 nextCollision = 0;
1757 }
1758 }
1759 // G4cerr <<"post- DoTimeStep 3"<<G4endl;
1760
1761 if(nextCollision)
1762 {
1763 if ( ApplyCollision(nextCollision))
1764 {
1765 // G4cout << "ApplyCollision sucess " << G4endl;
1766 } else
1767 {
1768 theCollisionMgr->RemoveCollision(nextCollision);
1769 }
1770 }
1771 }
1772
1773 if(countreset>100)
1774 {
1775#ifdef debug_G4BinaryCascade
1776 G4cerr << "G4BinaryCascade.cc: Warning - aborting looping particle(s)" << G4endl;
1777 PrintKTVector(&theSecondaryList," looping particles added to theFinalState");
1778#endif
1779
1780 // add left secondaries to FinalSate
1781 std::vector<G4KineticTrack *>::iterator iter;
1782 for ( iter =theSecondaryList.begin(); iter != theSecondaryList.end(); ++iter)
1783 {
1784 theFinalState.push_back(*iter);
1785 }
1786 theSecondaryList.clear();
1787
1788 break;
1789 }
1790
1791 if(Absorb())
1792 {
1793 // haveProducts = true;
1794 // G4cout << "Absorb sucess " << G4endl;
1795 }
1796
1797 if(Capture(false))
1798 {
1799 // haveProducts = true;
1800#ifdef debug_BIC_StepParticlesOut
1801 G4cout << "Capture sucess " << G4endl;
1802#endif
1803 }
1804 if ( counter > 100 && theCollisionMgr->Entries() == 0) // no collision, and stepping for some time....
1805 {
1806#ifdef debug_BIC_StepParticlesOut
1807 PrintKTVector(&theSecondaryList,std::string("stepping 100 steps"));
1808#endif
1809 FindCollisions(&theSecondaryList);
1810 counter=0;
1811 ++countreset;
1812 }
1813 //G4cout << "currentZ @ end loop " << currentZ << G4endl;
1814 if ( ! currentZ ){
1815 // nucleus completely destroyed, fill in ReactionProductVector
1816 // products = FillVoidNucleusProducts(products);
1817 #ifdef debug_BIC_return
1818 G4cout << "return @ Z=0 after collision loop "<< G4endl;
1819 PrintKTVector(&theSecondaryList,std::string(" theSecondaryList"));
1820 G4cout << "theTargetList size: " << theTargetList.size() << G4endl;
1821 PrintKTVector(&theTargetList,std::string(" theTargetList"));
1822 PrintKTVector(&theCapturedList,std::string(" theCapturedList"));
1823
1824 G4cout << " ExcitE be4 Correct : " <<GetExcitationEnergy() << G4endl;
1825 G4cout << " Mom Transfered to nucleus : " << theMomentumTransfer << " " << theMomentumTransfer.mag() << G4endl;
1826 PrintKTVector(&theFinalState,std::string(" FinalState uncorrected"));
1827 // G4cout << "returned products: " << products->size() << G4endl;
1828 #endif
1829 }
1830
1831 }
1832 // G4cerr <<"Finished capture loop "<<G4endl;
1833
1834 //G4cerr <<"pre- DoTimeStep 4"<<G4endl;
1835 DoTimeStep(DBL_MAX);
1836 //G4cerr <<"post- DoTimeStep 4"<<G4endl;
1837
1838
1839}
1840
1841//----------------------------------------------------------------------------
1842G4double G4BinaryCascade::CorrectShortlivedPrimaryForFermi(
1843 G4KineticTrack* primary,G4KineticTrackVector target_collection)
1844//----------------------------------------------------------------------------
1845{
1846 G4double Efermi(0);
1847 if (primary->GetState() == G4KineticTrack::inside ) {
1848 G4int PDGcode=primary->GetDefinition()->GetPDGEncoding();
1849 Efermi=((G4RKPropagation *)thePropagator)->GetField(PDGcode,primary->GetPosition());
1850
1851 if ( std::abs(PDGcode) > 1000 && PDGcode != 2112 && PDGcode != 2212 )
1852 {
1853 Efermi = ((G4RKPropagation *)thePropagator)->GetField(G4Neutron::Neutron()->GetPDGEncoding(),primary->GetPosition());
1854 G4LorentzVector mom4Primary=primary->Get4Momentum();
1855 primary->Update4Momentum(mom4Primary.e() - Efermi);
1856 }
1857
1858 std::vector<G4KineticTrack *>::iterator titer;
1859 for ( titer=target_collection.begin() ; titer!=target_collection.end(); ++titer)
1860 {
1861 const G4ParticleDefinition * aDef=(*titer)->GetDefinition();
1862 G4int aCode=aDef->GetPDGEncoding();
1863 G4ThreeVector aPos=(*titer)->GetPosition();
1864 Efermi+= ((G4RKPropagation *)thePropagator)->GetField(aCode, aPos);
1865 }
1866 }
1867 return Efermi;
1868}
1869
1870//----------------------------------------------------------------------------
1871G4bool G4BinaryCascade::CorrectShortlivedFinalsForFermi(G4KineticTrackVector * products,
1872 G4double initial_Efermi)
1873//----------------------------------------------------------------------------
1874{
1875 G4double final_Efermi(0);
1876 G4KineticTrackVector resonances;
1877 for ( std::vector<G4KineticTrack *>::iterator i =products->begin(); i != products->end(); i++)
1878 {
1879 G4int PDGcode=(*i)->GetDefinition()->GetPDGEncoding();
1880 // G4cout << " PDGcode, state " << PDGcode << " " << (*i)->GetState()<<G4endl;
1881 final_Efermi+=((G4RKPropagation *)thePropagator)->GetField(PDGcode,(*i)->GetPosition());
1882 if ( std::abs(PDGcode) > 1000 && PDGcode != 2112 && PDGcode != 2212 )
1883 {
1884 resonances.push_back(*i);
1885 }
1886 }
1887 if ( resonances.size() > 0 )
1888 {
1889 G4double delta_Fermi= (initial_Efermi-final_Efermi)/resonances.size();
1890 for (std::vector<G4KineticTrack *>::iterator res=resonances.begin(); res != resonances.end(); res++)
1891 {
1892 G4LorentzVector mom=(*res)->Get4Momentum();
1893 G4double mass2=mom.mag2();
1894 G4double newEnergy=mom.e() + delta_Fermi;
1895 G4double newEnergy2= newEnergy*newEnergy;
1896 //G4cout << "mom = " << mom <<" newE " << newEnergy<< G4endl;
1897 if ( newEnergy2 < mass2 )
1898 {
1899 return false;
1900 }
1901 G4ThreeVector mom3=std::sqrt(newEnergy2 - mass2) * mom.vect().unit();
1902 (*res)->Set4Momentum(G4LorentzVector(mom3,newEnergy));
1903 //G4cout << " correct resonance from /to " << mom.e() << " / " << newEnergy<<
1904 // " 3mom from/to " << mom.vect() << " / " << mom3 << G4endl;
1905 }
1906 }
1907 return true;
1908}
1909
1910//----------------------------------------------------------------------------
1911void G4BinaryCascade::CorrectFinalPandE()
1912//----------------------------------------------------------------------------
1913//
1914// Modify momenta of outgoing particles.
1915// Assume two body decay, nucleus(@nominal mass) + sum of final state particles(SFSP).
1916// momentum of SFSP shall be less than momentum for two body decay.
1917//
1918{
1919#ifdef debug_BIC_CorrectFinalPandE
1920 G4cerr << "BIC: -CorrectFinalPandE called" << G4endl;
1921#endif
1922
1923 if ( theFinalState.size() == 0 ) return;
1924
1925 G4KineticTrackVector::iterator i;
1926 G4LorentzVector pNucleus=GetFinal4Momentum();
1927 if ( pNucleus.e() == 0 ) return; // check against explicit 0 from GetNucleus4Momentum()
1928#ifdef debug_BIC_CorrectFinalPandE
1929 G4cerr << " -CorrectFinalPandE 3" << G4endl;
1930#endif
1931 G4LorentzVector pFinals(0);
1932 G4int nFinals(0);
1933 for(i = theFinalState.begin(); i != theFinalState.end(); ++i)
1934 {
1935 pFinals += (*i)->Get4Momentum();
1936 ++nFinals;
1937#ifdef debug_BIC_CorrectFinalPandE
1938 G4cout <<"CorrectFinalPandE a final " << (*i)->GetDefinition()->GetParticleName()
1939 << " 4mom " << (*i)->Get4Momentum()<< G4endl;
1940#endif
1941 }
1942#ifdef debug_BIC_CorrectFinalPandE
1943 G4cout << "CorrectFinalPandE pN pF: " <<pNucleus << " " <<pFinals << G4endl;
1944#endif
1945 G4LorentzVector pCM=pNucleus + pFinals;
1946
1947 G4LorentzRotation toCMS(-pCM.boostVector());
1948 pFinals *=toCMS;
1949#ifdef debug_BIC_CorrectFinalPandE
1950 G4cout << "CorrectFinalPandE pCM, CMS pCM " << pCM << " " <<toCMS*pCM<< G4endl;
1951 G4cout << "CorrectFinal CMS pN pF " <<toCMS*pNucleus << " "
1952 <<pFinals << G4endl
1953 << " nucleus initial mass : " <<GetFinal4Momentum().mag()
1954 <<" massInNucleus m(nucleus) m(finals) std::sqrt(s): " << massInNucleus << " " <<pNucleus.mag()<< " "
1955 << pFinals.mag() << " " << pCM.mag() << G4endl;
1956#endif
1957
1958 G4LorentzRotation toLab = toCMS.inverse();
1959
1960 G4double s0 = pCM.mag2();
1961 G4double m10 = GetIonMass(currentZ,currentA);
1962 G4double m20 = pFinals.mag();
1963 if( s0-(m10+m20)*(m10+m20) < 0 )
1964 {
1965#ifdef debug_BIC_CorrectFinalPandE
1966 G4cout << "G4BinaryCascade::CorrectFinalPandE() : error! " << G4endl;
1967
1968 G4cout << "not enough mass to correct: mass^2, A,Z, mass(nucl), mass(finals) "
1969 << (s0-(m10+m20)*(m10+m20)) << " "
1970 << currentA << " " << currentZ << " "
1971 << m10 << " " << m20
1972 << G4endl;
1973 G4cerr << " -CorrectFinalPandE 4" << G4endl;
1974
1975 PrintKTVector(&theFinalState," mass problem");
1976#endif
1977 return;
1978 }
1979
1980 // Three momentum in cm system
1981 G4double pInCM = std::sqrt((s0-(m10+m20)*(m10+m20))*(s0-(m10-m20)*(m10-m20))/(4.*s0));
1982#ifdef debug_BIC_CorrectFinalPandE
1983 G4cout <<" CorrectFinalPandE pInCM new, CURRENT, ratio : " << pInCM
1984 << " " << (pFinals).vect().mag()<< " " << pInCM/(pFinals).vect().mag() << G4endl;
1985#endif
1986 if ( pFinals.vect().mag() > pInCM )
1987 {
1988 G4ThreeVector p3finals=pInCM*pFinals.vect().unit();
1989
1990 // G4ThreeVector deltap=(p3finals - pFinals.vect() ) / nFinals;
1991 G4double factor=std::max(0.98,pInCM/pFinals.vect().mag()); // small correction
1992 G4LorentzVector qFinals(0);
1993 for(i = theFinalState.begin(); i != theFinalState.end(); ++i)
1994 {
1995 // G4ThreeVector p3((toCMS*(*i)->Get4Momentum()).vect() + deltap);
1996 G4ThreeVector p3(factor*(toCMS*(*i)->Get4Momentum()).vect());
1997 G4LorentzVector p(p3,std::sqrt((*i)->Get4Momentum().mag2() + p3.mag2()));
1998 qFinals += p;
1999 p *= toLab;
2000#ifdef debug_BIC_CorrectFinalPandE
2001 G4cout << " final p corrected: " << p << G4endl;
2002#endif
2003 (*i)->Set4Momentum(p);
2004 }
2005#ifdef debug_BIC_CorrectFinalPandE
2006 G4cout << "CorrectFinalPandE nucleus corrected mass : " << GetFinal4Momentum() << " "
2007 <<GetFinal4Momentum().mag() << G4endl
2008 << " CMS pFinals , mag, 3.mag : " << qFinals << " " << qFinals.mag() << " " << qFinals.vect().mag()<< G4endl;
2009 G4cerr << " -CorrectFinalPandE 5 " << factor << G4endl;
2010#endif
2011 }
2012#ifdef debug_BIC_CorrectFinalPandE
2013 else { G4cerr << " -CorrectFinalPandE 6 - no correction done" << G4endl; }
2014#endif
2015
2016}
2017
2018//----------------------------------------------------------------------------
2019void G4BinaryCascade::UpdateTracksAndCollisions(
2020 //----------------------------------------------------------------------------
2021 G4KineticTrackVector * oldSecondaries,
2022 G4KineticTrackVector * oldTarget,
2023 G4KineticTrackVector * newSecondaries)
2024{
2025 std::vector<G4KineticTrack *>::iterator iter1, iter2;
2026
2027 // remove old secondaries from the secondary list
2028 if(oldSecondaries)
2029 {
2030 if(!oldSecondaries->empty())
2031 {
2032 for(iter1 = oldSecondaries->begin(); iter1 != oldSecondaries->end();
2033 ++iter1)
2034 {
2035 iter2 = std::find(theSecondaryList.begin(), theSecondaryList.end(),
2036 *iter1);
2037 if ( iter2 != theSecondaryList.end() ) theSecondaryList.erase(iter2);
2038 }
2039 theCollisionMgr->RemoveTracksCollisions(oldSecondaries);
2040 }
2041 }
2042
2043 // remove old target from the target list
2044 if(oldTarget)
2045 {
2046 // G4cout << "################## Debugging 0 "<<G4endl;
2047 if(oldTarget->size()!=0)
2048 {
2049
2050 // G4cout << "################## Debugging 1 "<<oldTarget->size()<<G4endl;
2051 for(iter1 = oldTarget->begin(); iter1 != oldTarget->end(); ++iter1)
2052 {
2053 iter2 = std::find(theTargetList.begin(), theTargetList.end(),
2054 *iter1);
2055 theTargetList.erase(iter2);
2056 }
2057 theCollisionMgr->RemoveTracksCollisions(oldTarget);
2058 }
2059 }
2060
2061 if(newSecondaries)
2062 {
2063 if(!newSecondaries->empty())
2064 {
2065 // insert new secondaries in the secondary list
2066 for(iter1 = newSecondaries->begin(); iter1 != newSecondaries->end();
2067 ++iter1)
2068 {
2069 theSecondaryList.push_back(*iter1);
2070 if ((*iter1)->GetState() == G4KineticTrack::undefined)
2071 {
2072 PrintKTVector(*iter1, "undefined in FindCollisions");
2073 }
2074
2075
2076 }
2077 // look for collisions of new secondaries
2078 FindCollisions(newSecondaries);
2079 }
2080 }
2081 // G4cout << "Exiting ... "<<oldTarget<<G4endl;
2082}
2083
2084
2086{
2087private:
2089 G4KineticTrack::CascadeState wanted_state;
2090public:
2092 :
2093 ktv(out), wanted_state(astate)
2094 {};
2095 void operator() (G4KineticTrack *& kt) const
2096 {
2097 if ( (kt)->GetState() == wanted_state ) ktv->push_back(kt);
2098 };
2099};
2100
2101
2102
2103//----------------------------------------------------------------------------
2104G4bool G4BinaryCascade::DoTimeStep(G4double theTimeStep)
2105//----------------------------------------------------------------------------
2106{
2107
2108#ifdef debug_BIC_DoTimeStep
2109 G4ping debug("debug_G4BinaryCascade");
2110 debug.push_back("======> DoTimeStep 1"); debug.dump();
2111 G4cerr <<"G4BinaryCascade::DoTimeStep: enter step="<< theTimeStep
2112 << " , time="<<theCurrentTime << G4endl;
2113 PrintKTVector(&theSecondaryList, std::string("DoTimeStep - theSecondaryList"));
2114 //PrintKTVector(&theTargetList, std::string("DoTimeStep - theTargetList"));
2115#endif
2116
2117 G4bool success=true;
2118 std::vector<G4KineticTrack *>::iterator iter;
2119
2120 G4KineticTrackVector * kt_outside = new G4KineticTrackVector;
2121 std::for_each( theSecondaryList.begin(),theSecondaryList.end(),
2123 //PrintKTVector(kt_outside, std::string("DoTimeStep - found outside"));
2124
2126 std::for_each( theSecondaryList.begin(),theSecondaryList.end(),
2128 // PrintKTVector(kt_inside, std::string("DoTimeStep - found inside"));
2129 //-----
2130 G4KineticTrackVector dummy; // needed for re-usability
2131#ifdef debug_BIC_DoTimeStep
2132 G4cout << "NOW WE ARE ENTERING THE TRANSPORT"<<G4endl;
2133#endif
2134
2135 // =================== Here we move the particles ===================
2136
2137 thePropagator->Transport(theSecondaryList, dummy, theTimeStep);
2138
2139 // =================== Here we move the particles ===================
2140
2141 //------
2142
2143 theMomentumTransfer += thePropagator->GetMomentumTransfer();
2144#ifdef debug_BIC_DoTimeStep
2145 G4cout << "DoTimeStep : theMomentumTransfer = " << theMomentumTransfer << G4endl;
2146 PrintKTVector(&theSecondaryList, std::string("DoTimeStep - secondaries aft trsprt"));
2147#endif
2148
2149 //_DebugEpConservation(" after stepping");
2150
2151 // Partclies which went INTO nucleus
2152
2153 G4KineticTrackVector * kt_gone_in = new G4KineticTrackVector;
2154 std::for_each( kt_outside->begin(),kt_outside->end(),
2156 // PrintKTVector(kt_gone_in, std::string("DoTimeStep - gone in"));
2157
2158
2159 // Partclies which went OUT OF nucleus
2160 G4KineticTrackVector * kt_gone_out = new G4KineticTrackVector;
2161 std::for_each( kt_inside->begin(),kt_inside->end(),
2163
2164 // PrintKTVector(kt_gone_out, std::string("DoTimeStep - gone out"));
2165
2166 G4KineticTrackVector *fail=CorrectBarionsOnBoundary(kt_gone_in,kt_gone_out);
2167
2168 if ( fail )
2169 {
2170 // some particle(s) supposed to enter/leave were miss_nucleus/captured by the correction
2171 kt_gone_in->clear();
2172 std::for_each( kt_outside->begin(),kt_outside->end(),
2174
2175 kt_gone_out->clear();
2176 std::for_each( kt_inside->begin(),kt_inside->end(),
2178
2179#ifdef debug_BIC_DoTimeStep
2180 PrintKTVector(fail,std::string(" Failed to go in/out -> miss_nucleus/captured"));
2181 PrintKTVector(kt_gone_in, std::string("recreated kt_gone_in"));
2182 PrintKTVector(kt_gone_out, std::string("recreated kt_gone_out"));
2183#endif
2184 delete fail;
2185 }
2186
2187 // Add tracks missing nucleus and tracks going straight though to addFinals
2188 std::for_each( kt_outside->begin(),kt_outside->end(),
2190 //PrintKTVector(kt_gone_out, std::string("miss to append to final state.."));
2191 std::for_each( kt_outside->begin(),kt_outside->end(),
2193
2194#ifdef debug_BIC_DoTimeStep
2195 PrintKTVector(kt_gone_out, std::string("append gone_outs to final state.. theFinalState"));
2196#endif
2197
2198 theFinalState.insert(theFinalState.end(),
2199 kt_gone_out->begin(),kt_gone_out->end());
2200
2201 // Partclies which could not leave nucleus, captured...
2202 G4KineticTrackVector * kt_captured = new G4KineticTrackVector;
2203 std::for_each( theSecondaryList.begin(),theSecondaryList.end(),
2205
2206 // Check no track is part in next collision, ie.
2207 // this step was to far, and collisions should not occur any more
2208
2209 if ( theCollisionMgr->Entries()> 0 )
2210 {
2211 if (kt_gone_out->size() )
2212 {
2213 G4KineticTrack * nextPrimary = theCollisionMgr->GetNextCollision()->GetPrimary();
2214 iter = std::find(kt_gone_out->begin(),kt_gone_out->end(),nextPrimary);
2215 if ( iter != kt_gone_out->end() )
2216 {
2217 success=false;
2218#ifdef debug_BIC_DoTimeStep
2219 G4cout << " DoTimeStep - WARNING: deleting current collision!" << G4endl;
2220#endif
2221 }
2222 }
2223 if ( kt_captured->size() )
2224 {
2225 G4KineticTrack * nextPrimary = theCollisionMgr->GetNextCollision()->GetPrimary();
2226 iter = std::find(kt_captured->begin(),kt_captured->end(),nextPrimary);
2227 if ( iter != kt_captured->end() )
2228 {
2229 success=false;
2230#ifdef debug_BIC_DoTimeStep
2231 G4cout << " DoTimeStep - WARNING: deleting current collision!" << G4endl;
2232#endif
2233 }
2234 }
2235
2236 }
2237 // PrintKTVector(kt_gone_out," kt_gone_out be4 updatetrack...");
2238 UpdateTracksAndCollisions(kt_gone_out,0 ,0);
2239
2240
2241 if ( kt_captured->size() )
2242 {
2243 theCapturedList.insert(theCapturedList.end(),
2244 kt_captured->begin(),kt_captured->end());
2245 //should be std::for_each(kt_captured->begin(),kt_captured->end(),
2246 // std::mem_fun(&G4KineticTrack::Hit));
2247 // but VC 6 requires:
2248 std::vector<G4KineticTrack *>::iterator i_captured;
2249 for(i_captured=kt_captured->begin();i_captured!=kt_captured->end();i_captured++)
2250 {
2251 (*i_captured)->Hit();
2252 }
2253 // PrintKTVector(kt_captured," kt_captured be4 updatetrack...");
2254 UpdateTracksAndCollisions(kt_captured, NULL, NULL);
2255 }
2256
2257#ifdef debug_G4BinaryCascade
2258 delete kt_inside;
2259 kt_inside = new G4KineticTrackVector;
2260 std::for_each( theSecondaryList.begin(),theSecondaryList.end(),
2262 if ( currentZ != (GetTotalCharge(theTargetList)
2263 + GetTotalCharge(theCapturedList)
2264 + GetTotalCharge(*kt_inside)) )
2265 {
2266 G4cout << " error-DoTimeStep aft, A, Z: " << currentA << " " << currentZ
2267 << " sum(tgt,capt,active) "
2268 << GetTotalCharge(theTargetList) + GetTotalCharge(theCapturedList) + GetTotalCharge(*kt_inside)
2269 << " targets: " << GetTotalCharge(theTargetList)
2270 << " captured: " << GetTotalCharge(theCapturedList)
2271 << " active: " << GetTotalCharge(*kt_inside)
2272 << G4endl;
2273 }
2274#endif
2275
2276 delete kt_inside;
2277 delete kt_outside;
2278 delete kt_captured;
2279 delete kt_gone_in;
2280 delete kt_gone_out;
2281
2282 // G4cerr <<"G4BinaryCascade::DoTimeStep: exit "<<G4endl;
2283 theCurrentTime += theTimeStep;
2284
2285 //debug.push_back("======> DoTimeStep 2"); debug.dump();
2286 return success;
2287
2288}
2289
2290//----------------------------------------------------------------------------
2291G4KineticTrackVector* G4BinaryCascade::CorrectBarionsOnBoundary(
2294//----------------------------------------------------------------------------
2295{
2296 G4KineticTrackVector * kt_fail(0);
2297 std::vector<G4KineticTrack *>::iterator iter;
2298 // G4cout << "CorrectBarionsOnBoundary,currentZ,currentA,"
2299 // << currentZ << " "<< currentA << G4endl;
2300 if (in->size())
2301 {
2302 G4int secondaries_in(0);
2303 G4int secondaryBarions_in(0);
2304 G4int secondaryCharge_in(0);
2305 G4double secondaryMass_in(0);
2306
2307 for ( iter =in->begin(); iter != in->end(); ++iter)
2308 {
2309 ++secondaries_in;
2310 secondaryCharge_in += G4lrint((*iter)->GetDefinition()->GetPDGCharge()/eplus);
2311 if ((*iter)->GetDefinition()->GetBaryonNumber()!=0 )
2312 {
2313 secondaryBarions_in += (*iter)->GetDefinition()->GetBaryonNumber();
2314 if((*iter)->GetDefinition() == G4Neutron::Neutron() ||
2315 (*iter)->GetDefinition() == G4Proton::Proton() )
2316 {
2317 secondaryMass_in += (*iter)->GetDefinition()->GetPDGMass();
2318 } else {
2319 secondaryMass_in += G4Proton::Proton()->GetPDGMass();
2320 }
2321 }
2322 }
2323 G4double mass_initial= GetIonMass(currentZ,currentA);
2324
2325 currentZ += secondaryCharge_in;
2326 currentA += secondaryBarions_in;
2327
2328 // G4cout << "CorrectBarionsOnBoundary,secondaryCharge_in, secondaryBarions_in "
2329 // << secondaryCharge_in << " "<< secondaryBarions_in << G4endl;
2330
2331 G4double mass_final= GetIonMass(currentZ,currentA);
2332
2333 G4double correction= secondaryMass_in + mass_initial - mass_final;
2334 if (secondaries_in>1)
2335 {correction /= secondaries_in;}
2336
2337#ifdef debug_BIC_CorrectBarionsOnBoundary
2338 G4cout << "CorrectBarionsOnBoundary,currentZ,currentA,"
2339 << "secondaryCharge_in,secondaryBarions_in,"
2340 << "energy correction,m_secondry,m_nucl_init,m_nucl_final "
2341 << currentZ << " "<< currentA <<" "
2342 << secondaryCharge_in<<" "<<secondaryBarions_in<<" "
2343 << correction << " "
2344 << secondaryMass_in << " "
2345 << mass_initial << " "
2346 << mass_final << " "
2347 << G4endl;
2348 PrintKTVector(in,std::string("in be4 correction"));
2349#endif
2350 for ( iter = in->begin(); iter != in->end(); ++iter)
2351 {
2352 if ((*iter)->GetTrackingMomentum().e()+correction > (*iter)->GetActualMass())
2353 {
2354 (*iter)->UpdateTrackingMomentum((*iter)->GetTrackingMomentum().e() + correction);
2355 } else {
2356 //particle cannot go in, put to miss_nucleus
2357 G4RKPropagation * RKprop=(G4RKPropagation *)thePropagator;
2358 (*iter)->SetState(G4KineticTrack::miss_nucleus);
2359 // Undo correction for Colomb Barrier
2360 G4double barrier=RKprop->GetBarrier((*iter)->GetDefinition()->GetPDGEncoding());
2361 (*iter)->UpdateTrackingMomentum((*iter)->GetTrackingMomentum().e() + barrier);
2362 if ( ! kt_fail ) kt_fail=new G4KineticTrackVector;
2363 kt_fail->push_back(*iter);
2364 currentZ -= G4lrint((*iter)->GetDefinition()->GetPDGCharge()/eplus);
2365 currentA -= (*iter)->GetDefinition()->GetBaryonNumber();
2366
2367 }
2368
2369 }
2370#ifdef debug_BIC_CorrectBarionsOnBoundary
2371 G4cout << " CorrectBarionsOnBoundary, aft, Z, A, sec-Z,A,m,m_in_nucleus "
2372 << currentZ << " " << currentA << " "
2373 << secondaryCharge_in << " " << secondaryBarions_in << " "
2374 << secondaryMass_in << " "
2375 << G4endl;
2376 PrintKTVector(in,std::string("in AFT correction"));
2377#endif
2378
2379 }
2380 //----------------------------------------------
2381 if (out->size())
2382 {
2383 G4int secondaries_out(0);
2384 G4int secondaryBarions_out(0);
2385 G4int secondaryCharge_out(0);
2386 G4double secondaryMass_out(0);
2387
2388 for ( iter =out->begin(); iter != out->end(); ++iter)
2389 {
2390 ++secondaries_out;
2391 secondaryCharge_out += G4lrint((*iter)->GetDefinition()->GetPDGCharge()/eplus);
2392 if ((*iter)->GetDefinition()->GetBaryonNumber() !=0 )
2393 {
2394 secondaryBarions_out += (*iter)->GetDefinition()->GetBaryonNumber();
2395 if((*iter)->GetDefinition() == G4Neutron::Neutron() ||
2396 (*iter)->GetDefinition() == G4Proton::Proton() )
2397 {
2398 secondaryMass_out += (*iter)->GetDefinition()->GetPDGMass();
2399 } else {
2400 secondaryMass_out += G4Neutron::Neutron()->GetPDGMass();
2401 }
2402 }
2403 }
2404
2405 G4double mass_initial= GetIonMass(currentZ,currentA);
2406 currentA -=secondaryBarions_out;
2407 currentZ -=secondaryCharge_out;
2408
2409 // G4cout << "CorrectBarionsOnBoundary,secondaryCharge_out, secondaryBarions_out "
2410 // << secondaryCharge_out << " "<< secondaryBarions_out << G4endl;
2411
2412 // a delta minus will do currentZ < 0 in light nuclei
2413 // if (currentA < 0 || currentZ < 0 )
2414 if (currentA < 0 )
2415 {
2416 G4cerr << "G4BinaryCascade - secondaryBarions_out,secondaryCharge_out " <<
2417 secondaryBarions_out << " " << secondaryCharge_out << G4endl;
2418 PrintKTVector(&theTargetList,"CorrectBarionsOnBoundary Target");
2419 PrintKTVector(&theCapturedList,"CorrectBarionsOnBoundary Captured");
2420 PrintKTVector(&theSecondaryList,"CorrectBarionsOnBoundary Secondaries");
2421 G4cerr << "G4BinaryCascade - currentA, currentZ " << currentA << " " << currentZ << G4endl;
2422 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::CorrectBarionsOnBoundary() - fatal error");
2423 }
2424 G4double mass_final=GetIonMass(currentZ,currentA);
2425 G4double correction= mass_initial - mass_final - secondaryMass_out;
2426 // G4cout << "G4BinaryCascade::CorrectBarionsOnBoundary() total out correction: " << correction << G4endl;
2427
2428 if (secondaries_out>1) correction /= secondaries_out;
2429#ifdef debug_BIC_CorrectBarionsOnBoundary
2430 G4cout << "DoTimeStep,(current Z,A),"
2431 << "(secondaries out,Charge,Barions),"
2432 <<"* energy correction,(m_secondry,m_nucl_init,m_nucl_final) "
2433 << "("<< currentZ << ","<< currentA <<") ("
2434 << secondaries_out << ","
2435 << secondaryCharge_out<<","<<secondaryBarions_out<<") * "
2436 << correction << " ("
2437 << secondaryMass_out << ", "
2438 << mass_initial << ", "
2439 << mass_final << ")"
2440 << G4endl;
2441 PrintKTVector(out,std::string("out be4 correction"));
2442#endif
2443
2444 for ( iter = out->begin(); iter != out->end(); ++iter)
2445 {
2446 if ((*iter)->GetTrackingMomentum().e()+correction > (*iter)->GetActualMass())
2447 {
2448 (*iter)->UpdateTrackingMomentum((*iter)->GetTrackingMomentum().e() + correction);
2449 } else
2450 {
2451 // particle cannot go out due to change of nuclear potential!
2452 // capture protons and neutrons;
2453 if(((*iter)->GetDefinition() == G4Proton::Proton()) ||
2454 ((*iter)->GetDefinition() == G4Neutron::Neutron()))
2455 {
2456 (*iter)->SetState(G4KineticTrack::captured);
2457 // Undo correction for Colomb Barrier
2458 G4double barrier=((G4RKPropagation *)thePropagator)->GetBarrier((*iter)->GetDefinition()->GetPDGEncoding());
2459 (*iter)->UpdateTrackingMomentum((*iter)->GetTrackingMomentum().e() - barrier);
2460 if ( kt_fail == 0 ) kt_fail=new G4KineticTrackVector;
2461 kt_fail->push_back(*iter);
2462 currentZ += G4lrint((*iter)->GetDefinition()->GetPDGCharge()/eplus);
2463 currentA += (*iter)->GetDefinition()->GetBaryonNumber();
2464 }
2465#ifdef debug_BIC_CorrectBarionsOnBoundary
2466 else
2467 {
2468 G4cout << "Not correcting outgoing " << *iter << " "
2469 << (*iter)->GetDefinition()->GetPDGEncoding() << " "
2470 << (*iter)->GetDefinition()->GetParticleName() << G4endl;
2471 PrintKTVector(out,std::string("outgoing, one not corrected"));
2472 }
2473#endif
2474 }
2475 }
2476
2477#ifdef debug_BIC_CorrectBarionsOnBoundary
2478 PrintKTVector(out,std::string("out AFTER correction"));
2479 G4cout << " DoTimeStep, nucl-update, A, Z, sec-Z,A,m,m_in_nucleus, table-mass, delta "
2480 << currentA << " "<< currentZ << " "
2481 << secondaryCharge_out << " "<< secondaryBarions_out << " "<<
2482 secondaryMass_out << " "
2483 << massInNucleus << " "
2484 << GetIonMass(currentZ,currentA)
2485 << " " << massInNucleus - GetIonMass(currentZ,currentA)
2486 << G4endl;
2487#endif
2488 }
2489
2490 return kt_fail;
2491}
2492
2493
2494//----------------------------------------------------------------------------
2495
2496G4Fragment * G4BinaryCascade::FindFragments()
2497//----------------------------------------------------------------------------
2498{
2499
2500#ifdef debug_BIC_FindFragments
2501 G4cout << "target, captured, secondary: "
2502 << theTargetList.size() << " "
2503 << theCapturedList.size()<< " "
2504 << theSecondaryList.size()
2505 << G4endl;
2506#endif
2507
2508 G4int a = theTargetList.size()+theCapturedList.size();
2509 G4int zTarget = 0;
2510 G4KineticTrackVector::iterator i;
2511 for(i = theTargetList.begin(); i != theTargetList.end(); ++i)
2512 {
2513 if(G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus) == 1 )
2514 {
2515 zTarget++;
2516 }
2517 }
2518
2519 G4int zCaptured = 0;
2520 G4LorentzVector CapturedMomentum(0.,0.,0.,0.);
2521 for(i = theCapturedList.begin(); i != theCapturedList.end(); ++i)
2522 {
2523 CapturedMomentum += (*i)->Get4Momentum();
2524 if(G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus) == 1 )
2525 {
2526 zCaptured++;
2527 }
2528 }
2529
2530 G4int z = zTarget+zCaptured;
2531
2532#ifdef debug_G4BinaryCascade
2533 if ( z != (GetTotalCharge(theTargetList) + GetTotalCharge(theCapturedList)) )
2534 {
2535 G4cout << " FindFragment Counting error z a " << z << " " <<a << " "
2536 << GetTotalCharge(theTargetList) << " " << GetTotalCharge(theCapturedList)<<
2537 G4endl;
2538 PrintKTVector(&theTargetList, std::string("theTargetList"));
2539 PrintKTVector(&theCapturedList, std::string("theCapturedList"));
2540 }
2541#endif
2542 //debug
2543 /*
2544 * G4cout << " Fragment mass table / real "
2545 * << GetIonMass(z, a)
2546 * << " / " << GetFinal4Momentum().mag()
2547 * << " difference "
2548 * << GetFinal4Momentum().mag() - GetIonMass(z, a)
2549 * << G4endl;
2550 */
2551 //
2552 // if(getenv("BCDEBUG") ) G4cerr << "Fragment A, Z "<< a <<" "<< z<<G4endl;
2553 if ( z < 1 ) return 0;
2554
2555 G4int holes = the3DNucleus->GetMassNumber() - theTargetList.size();
2556 G4int excitons = theCapturedList.size();
2557#ifdef debug_BIC_FindFragments
2558 G4cout << "Fragment: a= " << a << " z= " << z << " particles= " << excitons
2559 << " Charged= " << zCaptured << " holes= " << holes
2560 << " excitE= " <<GetExcitationEnergy()
2561 << " Final4Momentum= " << GetFinalNucleusMomentum() << " capturMomentum= " << CapturedMomentum
2562 << G4endl;
2563#endif
2564
2565 G4Fragment * fragment = new G4Fragment(a,z,GetFinalNucleusMomentum());
2566 fragment->SetNumberOfHoles(holes);
2567
2568 //GF fragment->SetNumberOfParticles(excitons-holes);
2569 fragment->SetNumberOfParticles(excitons);
2570 fragment->SetNumberOfCharged(zCaptured);
2571
2572 return fragment;
2573}
2574
2575//----------------------------------------------------------------------------
2576
2577G4LorentzVector G4BinaryCascade::GetFinal4Momentum()
2578//----------------------------------------------------------------------------
2579// Return momentum of reminder nulceus;
2580// ie. difference of (initial state(primaries+nucleus) - final state) particles, ignoring remnant nucleus
2581{
2582 G4LorentzVector final4Momentum = theInitial4Mom + theProjectile4Momentum;
2583 G4LorentzVector finals(0,0,0,0);
2584 for(G4KineticTrackVector::iterator i = theFinalState.begin(); i != theFinalState.end(); ++i)
2585 {
2586 final4Momentum -= (*i)->Get4Momentum();
2587 finals += (*i)->Get4Momentum();
2588 }
2589
2590 if(final4Momentum.e()> 0 && (final4Momentum.vect()/final4Momentum.e()).mag()>1.0 && currentA > 0)
2591 {
2592#ifdef debug_BIC_Final4Momentum
2593 G4cerr << G4endl;
2594 G4cerr << "G4BinaryCascade::GetFinal4Momentum - Fatal"<<G4endl;
2595 G4KineticTrackVector::iterator i;
2596 G4cerr <<"Total initial 4-momentum " << theProjectile4Momentum << G4endl;
2597 G4cerr <<" GetFinal4Momentum: Initial nucleus "<<theInitial4Mom<<G4endl;
2598 for(i = theFinalState.begin(); i != theFinalState.end(); ++i)
2599 {
2600 G4cerr <<" Final state: "<<(*i)->Get4Momentum()<<(*i)->GetDefinition()->GetParticleName()<<G4endl;
2601 }
2602 G4cerr << "Sum( 4-mom ) finals " << finals << G4endl;
2603 G4cerr<< " Final4Momentum = "<<final4Momentum <<" "<<final4Momentum.m()<<G4endl;
2604 G4cerr <<" current A, Z = "<< currentA<<", "<<currentZ<<G4endl;
2605 G4cerr << G4endl;
2606#endif
2607
2608 final4Momentum=G4LorentzVector(0,0,0,0);
2609 }
2610 return final4Momentum;
2611}
2612
2613//----------------------------------------------------------------------------
2614G4LorentzVector G4BinaryCascade::GetFinalNucleusMomentum()
2615//----------------------------------------------------------------------------
2616{
2617 // return momentum of nucleus for use with precompound model; also keep transformation to
2618 // apply to precompoud products.
2619
2620 G4LorentzVector CapturedMomentum(0,0,0,0);
2621 G4KineticTrackVector::iterator i;
2622 // G4cout << "GetFinalNucleusMomentum Captured size: " <<theCapturedList.size() << G4endl;
2623 for(i = theCapturedList.begin(); i != theCapturedList.end(); ++i)
2624 {
2625 CapturedMomentum += (*i)->Get4Momentum();
2626 }
2627 //G4cout << "GetFinalNucleusMomentum CapturedMomentum= " <<CapturedMomentum << G4endl;
2628 // G4cerr << "it 9"<<G4endl;
2629
2630 G4LorentzVector NucleusMomentum = GetFinal4Momentum();
2631 if ( NucleusMomentum.e() > 0 )
2632 {
2633 // G4cout << "GetFinalNucleusMomentum GetFinal4Momentum= " <<NucleusMomentum <<" "<<NucleusMomentum.mag()<<G4endl;
2634 // boost nucleus to a frame such that the momentum of nucleus == momentum of Captured
2635 G4ThreeVector boost= (NucleusMomentum.vect() -CapturedMomentum.vect())/NucleusMomentum.e();
2636 if(boost.mag2()>1.0)
2637 {
2638# ifdef debug_BIC_FinalNucleusMomentum
2639 G4cerr << "G4BinaryCascade::GetFinalNucleusMomentum - Fatal"<<G4endl;
2640 G4cerr << "it 0"<<boost <<G4endl;
2641 G4cerr << "it 01"<<NucleusMomentum<<" "<<CapturedMomentum<<" "<<G4endl;
2642 G4cout <<" testing boost "<<boost<<" "<<boost.mag()<<G4endl;
2643# endif
2644 boost=G4ThreeVector(0,0,0);
2645 NucleusMomentum=G4LorentzVector(0,0,0,0);
2646 }
2647 G4LorentzRotation nucleusBoost( -boost );
2648 precompoundLorentzboost.set( boost );
2649#ifdef debug_debug_BIC_FinalNucleusMomentum
2650 G4cout << "GetFinalNucleusMomentum be4 boostNucleusMomentum, CapturedMomentum"<<NucleusMomentum<<" "<<CapturedMomentum<<" "<<G4endl;
2651#endif
2652 NucleusMomentum *= nucleusBoost;
2653#ifdef debug_BIC_FinalNucleusMomentum
2654 G4cout << "GetFinalNucleusMomentum aft boost GetFinal4Momentum= " <<NucleusMomentum <<G4endl;
2655#endif
2656 }
2657 return NucleusMomentum;
2658}
2659
2660//----------------------------------------------------------------------------
2661G4ReactionProductVector * G4BinaryCascade::Propagate1H1(
2662 //----------------------------------------------------------------------------
2663 G4KineticTrackVector * secondaries, G4V3DNucleus * nucleus)
2664{
2667 if (nucleus->GetCharge() == 0) aHTarg = G4Neutron::NeutronDefinition();
2668 G4double mass = aHTarg->GetPDGMass();
2669 G4KineticTrackVector * secs = 0;
2670 G4ThreeVector pos(0,0,0);
2671 G4LorentzVector mom(mass);
2672 G4KineticTrack aTarget(aHTarg, 0., pos, mom);
2673 G4bool done(false);
2674 std::vector<G4KineticTrack *>::iterator iter, jter;
2675 // data member static G4Scatterer theH1Scatterer;
2676 //G4cout << " start 1H1 for " << (*secondaries).front()->GetDefinition()->GetParticleName()
2677 // << " on " << aHTarg->GetParticleName() << G4endl;
2678 G4int tryCount(0);
2679 while(!done && tryCount++ <200) /* Loop checking, 31.08.2015, G.Folger */
2680 {
2681 if(secs)
2682 {
2683 std::for_each(secs->begin(), secs->end(), DeleteKineticTrack());
2684 delete secs;
2685 }
2686 secs = theH1Scatterer->Scatter(*(*secondaries).front(), aTarget);
2687#ifdef debug_H1_BinaryCascade
2688 PrintKTVector(secs," From Scatter");
2689#endif
2690 for(size_t ss=0; secs && ss<secs->size(); ss++)
2691 {
2692 // must have one resonance in final state, or it was elastic, not allowed here.
2693 if((*secs)[ss]->GetDefinition()->IsShortLived()) done = true;
2694 }
2695 }
2696
2697 ClearAndDestroy(&theFinalState);
2698 ClearAndDestroy(secondaries);
2699 delete secondaries;
2700
2701 for(size_t current=0; secs && current<secs->size(); current++)
2702 {
2703 if((*secs)[current]->GetDefinition()->IsShortLived())
2704 {
2705 done = true; // must have one resonance in final state, elastic not allowed here!
2706 G4KineticTrackVector * dec = (*secs)[current]->Decay();
2707 for(jter=dec->begin(); jter != dec->end(); jter++)
2708 {
2709 //G4cout << "Decay"<<G4endl;
2710 secs->push_back(*jter);
2711 //G4cout << "decay "<<(*jter)->GetDefinition()->GetParticleName()<<G4endl;
2712 }
2713 delete (*secs)[current];
2714 delete dec;
2715 }
2716 else
2717 {
2718 //G4cout << "FS "<<G4endl;
2719 //G4cout << "FS "<<(*secs)[current]->GetDefinition()->GetParticleName()<<G4endl;
2720 theFinalState.push_back((*secs)[current]);
2721 }
2722 }
2723
2724 delete secs;
2725#ifdef debug_H1_BinaryCascade
2726 PrintKTVector(&theFinalState," FinalState");
2727#endif
2728 for(iter = theFinalState.begin(); iter != theFinalState.end(); ++iter)
2729 {
2730 G4KineticTrack * kt = *iter;
2732 aNew->SetMomentum(kt->Get4Momentum().vect());
2733 aNew->SetTotalEnergy(kt->Get4Momentum().e());
2734 aNew->SetCreatorModel(theBIC_ID);
2735 products->push_back(aNew);
2736#ifdef debug_H1_BinaryCascade
2737 if (! kt->GetDefinition()->GetPDGStable() )
2738 {
2739 if (kt->GetDefinition()->IsShortLived())
2740 {
2741 G4cout << "final shortlived : ";
2742 } else
2743 {
2744 G4cout << "final un stable : ";
2745 }
2747 }
2748#endif
2749 delete kt;
2750 }
2751 theFinalState.clear();
2752 return products;
2753
2754}
2755
2756//----------------------------------------------------------------------------
2757G4ThreeVector G4BinaryCascade::GetSpherePoint(
2758 G4double r, const G4LorentzVector & mom4)
2759//----------------------------------------------------------------------------
2760{
2761 // Get a point outside radius.
2762 // point is random in plane (circle of radius r) orthogonal to mom,
2763 // plus -1*r*mom->vect()->unit();
2764 G4ThreeVector o1, o2;
2765 G4ThreeVector mom = mom4.vect();
2766
2767 o1= mom.orthogonal(); // we simply need any vector non parallel
2768 o2= mom.cross(o1); // o2 is now orthogonal to mom and o1, ie. o1 and o2 define plane.
2769
2770 G4double x2, x1;
2771
2772 do
2773 {
2774 x1=(G4UniformRand()-.5)*2;
2775 x2=(G4UniformRand()-.5)*2;
2776 } while (sqr(x1) +sqr(x2) > 1.); /* Loop checking, 31.08.2015, G.Folger */ // or random is badly broken.....
2777
2778 return G4ThreeVector(r*(x1*o1.unit() + x2*o2.unit() - 1.5* mom.unit()));
2779
2780
2781
2782 /*
2783 * // Get a point uniformly distributed on the surface of a sphere,
2784 * // with z < 0.
2785 * G4double b = r*G4UniformRand(); // impact parameter
2786 * G4double phi = G4UniformRand()*2*pi;
2787 * G4double x = b*std::cos(phi);
2788 * G4double y = b*std::sin(phi);
2789 * G4double z = -std::sqrt(r*r-b*b);
2790 * z *= 1.001; // Get position a little bit out of the sphere...
2791 * point.setX(x);
2792 * point.setY(y);
2793 * point.setZ(z);
2794 */
2795}
2796
2797//----------------------------------------------------------------------------
2798
2799void G4BinaryCascade::ClearAndDestroy(G4KineticTrackVector * ktv)
2800//----------------------------------------------------------------------------
2801{
2802 std::vector<G4KineticTrack *>::iterator i;
2803 for(i = ktv->begin(); i != ktv->end(); ++i)
2804 delete (*i);
2805 ktv->clear();
2806}
2807
2808//----------------------------------------------------------------------------
2809void G4BinaryCascade::ClearAndDestroy(G4ReactionProductVector * rpv)
2810//----------------------------------------------------------------------------
2811{
2812 std::vector<G4ReactionProduct *>::iterator i;
2813 for(i = rpv->begin(); i != rpv->end(); ++i)
2814 delete (*i);
2815 rpv->clear();
2816}
2817
2818//----------------------------------------------------------------------------
2819void G4BinaryCascade::PrintKTVector(G4KineticTrackVector * ktv, std::string comment)
2820//----------------------------------------------------------------------------
2821{
2822 if (comment.size() > 0 ) G4cout << "G4BinaryCascade::PrintKTVector() " << comment << G4endl;
2823 if (ktv) {
2824 G4cout << " vector: " << ktv << ", number of tracks: " << ktv->size()
2825 << G4endl;
2826 std::vector<G4KineticTrack *>::iterator i;
2827 G4int count;
2828
2829 for(count = 0, i = ktv->begin(); i != ktv->end(); ++i, ++count)
2830 {
2831 G4KineticTrack * kt = *i;
2832 G4cout << " track n. " << count;
2833 PrintKTVector(kt);
2834 }
2835 } else {
2836 G4cout << "G4BinaryCascade::PrintKTVector():No KineticTrackVector given " << G4endl;
2837 }
2838}
2839//----------------------------------------------------------------------------
2840void G4BinaryCascade::PrintKTVector(G4KineticTrack * kt, std::string comment)
2841//----------------------------------------------------------------------------
2842{
2843 if (comment.size() > 0 ) G4cout << "G4BinaryCascade::PrintKTVector() "<< comment << G4endl;
2844 if ( kt ){
2845 G4cout << ", id: " << kt << G4endl;
2847 G4LorentzVector mom = kt->Get4Momentum();
2849 const G4ParticleDefinition * definition = kt->GetDefinition();
2850 G4cout << " definition: " << definition->GetPDGEncoding() << " pos: "
2851 << 1/fermi*pos << " R: " << 1/fermi*pos.mag() << " 4mom: "
2852 << 1/MeV*mom <<"Tr_mom" << 1/MeV*tmom << " P: " << 1/MeV*mom.vect().mag()
2853 << " M: " << 1/MeV*mom.mag() << G4endl;
2854 G4cout <<" trackstatus: "<<kt->GetState() << " isParticipant " << (kt->IsParticipant()?"T":"F") <<G4endl;
2855 } else {
2856 G4cout << "G4BinaryCascade::PrintKTVector(): No Kinetictrack given" << G4endl;
2857 }
2858}
2859
2860
2861//----------------------------------------------------------------------------
2862G4double G4BinaryCascade::GetIonMass(G4int Z, G4int A)
2863//----------------------------------------------------------------------------
2864{
2865 G4double mass(0);
2866 if ( Z > 0 && A >= Z )
2867 {
2869
2870 } else if ( A > 0 && Z>0 )
2871 {
2872 // charge Z > A; will happen for light nuclei with pions involved.
2874
2875 } else if ( A >= 0 && Z<=0 )
2876 {
2877 // all neutral, or empty nucleus
2878 mass = A * G4Neutron::Neutron()->GetPDGMass();
2879
2880 } else if ( A == 0 )
2881 {
2882 // empty nucleus, except maybe pions
2883 mass = 0;
2884
2885 } else
2886 {
2887 G4cerr << "G4BinaryCascade::GetIonMass() - invalid (A,Z) = ("
2888 << A << "," << Z << ")" <<G4endl;
2889 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCascade::GetIonMass() - giving up");
2890
2891 }
2892 // G4cout << "G4BinaryCascade::GetIonMass() Z, A, mass " << Z << " " << A << " " << mass << G4endl;
2893 return mass;
2894}
2895G4ReactionProductVector * G4BinaryCascade::FillVoidNucleusProducts(G4ReactionProductVector * products)
2896{
2897 // return product when nucleus is destroyed, i.e. charge=0, or theTargetList.size()=0
2898 G4double Esecondaries(0.);
2899 G4LorentzVector psecondaries;
2900 std::vector<G4KineticTrack *>::iterator iter;
2901 std::vector<G4ReactionProduct *>::iterator rpiter;
2902 decayKTV.Decay(&theFinalState);
2903
2904 for(iter = theFinalState.begin(); iter != theFinalState.end(); ++iter)
2905 {
2906 G4ReactionProduct * aNew = new G4ReactionProduct((*iter)->GetDefinition());
2907 aNew->SetMomentum((*iter)->Get4Momentum().vect());
2908 aNew->SetTotalEnergy((*iter)->Get4Momentum().e());
2909 aNew->SetCreatorModel(theBIC_ID);
2910 Esecondaries +=(*iter)->Get4Momentum().e();
2911 psecondaries +=(*iter)->Get4Momentum();
2912 aNew->SetNewlyAdded(true);
2913 //G4cout << " Particle Ekin " << aNew->GetKineticEnergy() << G4endl;
2914 products->push_back(aNew);
2915 }
2916
2917 // pull out late particles from collisions
2918 //theCollisionMgr->Print();
2919 while(theCollisionMgr->Entries() > 0) /* Loop checking, 31.08.2015, G.Folger */
2920 {
2922 collision = theCollisionMgr->GetNextCollision();
2923
2924 if ( ! collision->GetTargetCollection().size() ){
2925 G4KineticTrackVector * lates = collision->GetFinalState();
2926 if ( lates->size() == 1 ) {
2927 G4KineticTrack * atrack=*(lates->begin());
2928 //PrintKTVector(atrack, " late particle @ void Nucl ");
2929
2930 G4ReactionProduct * aNew = new G4ReactionProduct(atrack->GetDefinition());
2931 aNew->SetMomentum(atrack->Get4Momentum().vect());
2932 aNew->SetTotalEnergy(atrack->Get4Momentum().e());
2933 // FIXME: should take creator model from atrack:
2934 // aNew->SetCreatorModel(atrack->GetCreatorModel());
2935 Esecondaries +=atrack->Get4Momentum().e();
2936 psecondaries +=atrack->Get4Momentum();
2937 aNew->SetNewlyAdded(true);
2938 products->push_back(aNew);
2939
2940 }
2941 }
2942 theCollisionMgr->RemoveCollision(collision);
2943
2944 }
2945
2946 // decay must be after loop on Collisions, and Decay() will delete entries in theSecondaryList, refered
2947 // to by Collisions.
2948 decayKTV.Decay(&theSecondaryList);
2949
2950 // Correct for momentum transfered to Nucleus
2951 G4ThreeVector transferCorrection(0);
2952 if ( (theSecondaryList.size() + theCapturedList.size()) > 0)
2953 {
2954 transferCorrection= theMomentumTransfer /(theSecondaryList.size() + theCapturedList.size());
2955 }
2956
2957 for(iter = theSecondaryList.begin(); iter != theSecondaryList.end(); ++iter)
2958 {
2959 G4ReactionProduct * aNew = new G4ReactionProduct((*iter)->GetDefinition());
2960 (*iter)->Update4Momentum((*iter)->Get4Momentum().vect()+transferCorrection);
2961 aNew->SetMomentum((*iter)->Get4Momentum().vect());
2962 aNew->SetTotalEnergy((*iter)->Get4Momentum().e());
2963 aNew->SetCreatorModel(theBIC_ID);
2964 Esecondaries +=(*iter)->Get4Momentum().e();
2965 psecondaries +=(*iter)->Get4Momentum();
2966 if ( (*iter)->IsParticipant() ) aNew->SetNewlyAdded(true);
2967 products->push_back(aNew);
2968 }
2969
2970
2971 for(iter = theCapturedList.begin(); iter != theCapturedList.end(); ++iter)
2972 {
2973 G4ReactionProduct * aNew = new G4ReactionProduct((*iter)->GetDefinition());
2974 (*iter)->Update4Momentum((*iter)->Get4Momentum().vect()+transferCorrection);
2975 aNew->SetMomentum((*iter)->Get4Momentum().vect());
2976 aNew->SetTotalEnergy((*iter)->Get4Momentum().e());
2977 aNew->SetCreatorModel(theBIC_ID);
2978 Esecondaries +=(*iter)->Get4Momentum().e();
2979 psecondaries +=(*iter)->Get4Momentum();
2980 aNew->SetNewlyAdded(true);
2981 products->push_back(aNew);
2982 }
2983
2984 G4double SumMassNucleons(0.);
2985 G4LorentzVector pNucleons(0.);
2986 for(iter = theTargetList.begin(); iter != theTargetList.end(); ++iter)
2987 {
2988 SumMassNucleons += (*iter)->GetDefinition()->GetPDGMass();
2989 pNucleons += (*iter)->Get4Momentum();
2990 }
2991
2992 G4double Ekinetic=theProjectile4Momentum.e() + initial_nuclear_mass - Esecondaries - SumMassNucleons;
2993 #ifdef debug_BIC_FillVoidnucleus
2994 G4LorentzVector deltaP=theProjectile4Momentum + G4LorentzVector(initial_nuclear_mass) -
2995 psecondaries - pNucleons;
2996 //G4cout << "BIC::FillVoidNucleus() nucleons : "<<theTargetList.size() << " , T: " << Ekinetic <<
2997 // ", deltaP " << deltaP << " deltaPNoNucl " << deltaP + pNucleons << G4endl;
2998 #endif
2999 if (Ekinetic > 0. && theTargetList.size()){
3000 Ekinetic /= theTargetList.size();
3001 } else {
3002 G4double Ekineticrdm(0);
3003 if (theTargetList.size()) Ekineticrdm = ( 0.1 + G4UniformRand()*5.) * MeV; // leave some Energy for Nucleons
3004 G4double TotalEkin(Ekineticrdm);
3005 for (rpiter=products->begin(); rpiter!=products->end(); ++rpiter){
3006 TotalEkin+=(*rpiter)->GetKineticEnergy();
3007 }
3008 G4double correction(1.);
3009 if ( std::abs(Ekinetic) < 20*perCent * TotalEkin ){
3010 correction=1. + (Ekinetic-Ekineticrdm)/TotalEkin; // Ekinetic < 0 == IS < FS, need to reduce energies
3011 }
3012 #ifdef debug_G4BinaryCascade
3013 else {
3014 G4cout << "BLIC::FillVoidNucleus() fail correction, Ekinetic, TotalEkin " << Ekinetic << ""<< TotalEkin << G4endl;
3015 }
3016 #endif
3017
3018 for (rpiter=products->begin(); rpiter!=products->end(); ++rpiter){
3019 (*rpiter)->SetKineticEnergy((*rpiter)->GetKineticEnergy()*correction); // this sets kinetic & total energy
3020 (*rpiter)->SetMomentum((*rpiter)->GetTotalMomentum() * (*rpiter)->GetMomentum().unit());
3021
3022 }
3023
3024 Ekinetic=Ekineticrdm*correction;
3025 if (theTargetList.size())Ekinetic /= theTargetList.size();
3026
3027 }
3028
3029 for(iter = theTargetList.begin(); iter != theTargetList.end(); ++iter) {
3030 // set Nucleon it to be hit - as it is in fact
3031 (*iter)->Hit();
3032 G4ReactionProduct * aNew = new G4ReactionProduct((*iter)->GetDefinition());
3033 aNew->SetKineticEnergy(Ekinetic);
3034 aNew->SetMomentum(aNew->GetTotalMomentum() * ((*iter)->Get4Momentum().vect().unit()));
3035 aNew->SetNewlyAdded(true);
3036 aNew->SetCreatorModel(theBIC_ID);
3037 products->push_back(aNew);
3038 Esecondaries += aNew->GetTotalEnergy();
3039 psecondaries += G4LorentzVector(aNew->GetMomentum(),aNew->GetTotalEnergy() );
3040 }
3041 psecondaries=G4LorentzVector(0);
3042 for (rpiter=products->begin(); rpiter!=products->end(); ++rpiter){
3043 psecondaries += G4LorentzVector((*rpiter)->GetMomentum(),(*rpiter)->GetTotalEnergy() );
3044 }
3045
3046
3047
3048 G4LorentzVector initial4Mom=theProjectile4Momentum + G4LorentzVector(initial_nuclear_mass);
3049
3050 //G4cout << "::FillVoidNucleus()final e/p conservation initial" <<initial4Mom
3051 // << " final " << psecondaries << " delta " << initial4Mom-psecondaries << G4endl;
3052
3053 G4ThreeVector SumMom=psecondaries.vect();
3054
3055 SumMom=initial4Mom.vect()-SumMom;
3056 G4int loopcount(0);
3057
3058 std::vector<G4ReactionProduct *>::reverse_iterator reverse; // start to correct last added first
3059 while ( SumMom.mag() > 0.1*MeV && loopcount++ < 10) /* Loop checking, 31.08.2015, G.Folger */
3060 {
3061 G4int index=products->size();
3062 for (reverse=products->rbegin(); reverse!=products->rend(); ++reverse, --index){
3063 SumMom=initial4Mom.vect();
3064 for (rpiter=products->begin(); rpiter!=products->end(); ++rpiter){
3065 SumMom-=(*rpiter)->GetMomentum();
3066 }
3067
3068 G4double p=((*reverse)->GetMomentum()).mag();
3069 (*reverse)->SetMomentum( p*(((*reverse)->GetMomentum()+SumMom).unit()));
3070
3071 }
3072 }
3073
3074
3075 return products;
3076}
3077G4ReactionProductVector * G4BinaryCascade::HighEnergyModelFSProducts(G4ReactionProductVector * products,
3078 G4KineticTrackVector * secondaries)
3079{
3080 std::vector<G4KineticTrack *>::iterator iter;
3081 for(iter = secondaries->begin(); iter != secondaries->end(); ++iter)
3082 {
3083 G4ReactionProduct * aNew = new G4ReactionProduct((*iter)->GetDefinition());
3084 aNew->SetMomentum((*iter)->Get4Momentum().vect());
3085 aNew->SetTotalEnergy((*iter)->Get4Momentum().e());
3086 aNew->SetNewlyAdded(true);
3087 // FixMe: should take creator model from atrack:
3088 // aNew->SetCreatorModel(atrack->GetCreatorModel());
3089
3090 //G4cout << " Particle Ekin " << aNew->GetKineticEnergy() << G4endl;
3091 products->push_back(aNew);
3092 }
3093 const G4ParticleDefinition* fragment = 0;
3094 if (currentA == 1 && currentZ == 0) {
3095 fragment = G4Neutron::NeutronDefinition();
3096 } else if (currentA == 1 && currentZ == 1) {
3097 fragment = G4Proton::ProtonDefinition();
3098 } else if (currentA == 2 && currentZ == 1) {
3099 fragment = G4Deuteron::DeuteronDefinition();
3100 } else if (currentA == 3 && currentZ == 1) {
3101 fragment = G4Triton::TritonDefinition();
3102 } else if (currentA == 3 && currentZ == 2) {
3103 fragment = G4He3::He3Definition();
3104 } else if (currentA == 4 && currentZ == 2) {
3105 fragment = G4Alpha::AlphaDefinition();;
3106 } else {
3107 fragment =
3108 G4ParticleTable::GetParticleTable()->GetIonTable()->GetIon(currentZ,currentA,0.0);
3109 }
3110 if (fragment != 0) {
3111 G4ReactionProduct * theNew = new G4ReactionProduct(fragment);
3112 theNew->SetMomentum(G4ThreeVector(0,0,0));
3113 theNew->SetTotalEnergy(massInNucleus);
3114 // FixMe: should take creator model from ???:
3115 // aNew->SetCreatorModel(???->GetCreatorModel());
3116 //theNew->SetFormationTime(??0.??);
3117 //G4cout << " Nucleus (" << currentZ << ","<< currentA << "), mass "<< massInNucleus << G4endl;
3118 products->push_back(theNew);
3119 }
3120 return products;
3121}
3122
3123void G4BinaryCascade::PrintWelcomeMessage()
3124{
3125 G4cout <<"Thank you for using G4BinaryCascade. "<<G4endl;
3126}
3127
3128//----------------------------------------------------------------------------
3129void G4BinaryCascade::DebugApplyCollisionFail(G4CollisionInitialState * collision,
3130 G4KineticTrackVector * products)
3131{
3132 G4bool havePion=false;
3133 if (products)
3134 {
3135 for ( std::vector<G4KineticTrack *>::iterator i =products->begin(); i != products->end(); i++)
3136 {
3137 G4int PDGcode=std::abs((*i)->GetDefinition()->GetPDGEncoding());
3138 if (std::abs(PDGcode)==211 || PDGcode==111 ) havePion=true;
3139 }
3140 }
3141 if ( !products || havePion)
3142 {
3143 const G4BCAction &action= *collision->GetGenerator();
3144 G4cout << " Collision " << collision << ", type: "<< typeid(action).name()
3145 << ", with NO products! " <<G4endl;
3146 G4cout << G4endl<<"Initial condition are these:"<<G4endl;
3147 G4cout << "proj: "<<collision->GetPrimary()->GetDefinition()->GetParticleName()<<G4endl;
3148 PrintKTVector(collision->GetPrimary());
3149 for(size_t it=0; it<collision->GetTargetCollection().size(); it++)
3150 {
3151 G4cout << "targ: "
3152 <<collision->GetTargetCollection()[it]->GetDefinition()->GetParticleName()<<G4endl;
3153 }
3154 PrintKTVector(&collision->GetTargetCollection(),std::string(" Target particles"));
3155 }
3156 // if ( lateParticleCollision ) G4cout << " Added late particle--------------------------"<<G4endl;
3157 // if ( lateParticleCollision && products ) PrintKTVector(products, " reaction products");
3158}
3159
3160//----------------------------------------------------------------------------
3161
3162G4bool G4BinaryCascade::CheckChargeAndBaryonNumber(G4String where)
3163{
3164 static G4int lastdA(0), lastdZ(0);
3165 G4int iStateA = the3DNucleus->GetMassNumber() + projectileA;
3166 G4int iStateZ = the3DNucleus->GetCharge() + projectileZ;
3167
3168 G4int fStateA(0);
3169 G4int fStateZ(0);
3170
3171 std::vector<G4KineticTrack *>::iterator i;
3172 G4int CapturedA(0), CapturedZ(0);
3173 G4int secsA(0), secsZ(0);
3174 for ( i=theCapturedList.begin(); i!=theCapturedList.end(); ++i) {
3175 CapturedA += (*i)->GetDefinition()->GetBaryonNumber();
3176 CapturedZ += G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus);
3177 }
3178
3179 for ( i=theSecondaryList.begin(); i!=theSecondaryList.end(); ++i) {
3180 if ( (*i)->GetState() != G4KineticTrack::inside ) {
3181 secsA += (*i)->GetDefinition()->GetBaryonNumber();
3182 secsZ += G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus);
3183 }
3184 }
3185
3186 for ( i=theFinalState.begin(); i!=theFinalState.end(); ++i) {
3187 fStateA += (*i)->GetDefinition()->GetBaryonNumber();
3188 fStateZ += G4lrint((*i)->GetDefinition()->GetPDGCharge()/eplus);
3189 }
3190
3191 G4int deltaA= iStateA - secsA - fStateA -currentA - lateA;
3192 G4int deltaZ= iStateZ - secsZ - fStateZ -currentZ - lateZ;
3193
3194#ifdef debugCheckChargeAndBaryonNumberverbose
3195 G4cout << where <<" A: iState= "<< iStateA<<", secs= "<< secsA<< ", fState= "<< fStateA<< ", current= "<<currentA<< ", late= " <<lateA << G4endl;
3196 G4cout << where <<" Z: iState= "<< iStateZ<<", secs= "<< secsZ<< ", fState= "<< fStateZ<< ", current= "<<currentZ<< ", late= " <<lateZ << G4endl;
3197#endif
3198
3199 if (deltaA != 0 || deltaZ!=0 ) {
3200 if (deltaA != lastdA || deltaZ != lastdZ ) {
3201 G4cout << "baryon/charge imbalance - " << where << G4endl
3202 << "deltaA " <<deltaA<<", iStateA "<<iStateA<< ", CapturedA "<<CapturedA <<", secsA "<<secsA
3203 << ", fStateA "<<fStateA << ", currentA "<<currentA << ", lateA "<<lateA << G4endl
3204 << "deltaZ "<<deltaZ<<", iStateZ "<<iStateZ<< ", CapturedZ "<<CapturedZ <<", secsZ "<<secsZ
3205 << ", fStateZ "<<fStateZ << ", currentZ "<<currentZ << ", lateZ "<<lateZ << G4endl<< G4endl;
3206 lastdA=deltaA;
3207 lastdZ=deltaZ;
3208 }
3209 } else { lastdA=lastdZ=0;}
3210
3211 return true;
3212}
3213//----------------------------------------------------------------------------
3214void G4BinaryCascade::DebugApplyCollision(G4CollisionInitialState * collision,
3215 G4KineticTrackVector * products)
3216{
3217
3218 PrintKTVector(collision->GetPrimary(),std::string(" Primary particle"));
3219 PrintKTVector(&collision->GetTargetCollection(),std::string(" Target particles"));
3220 PrintKTVector(products,std::string(" Scatterer products"));
3221
3222#ifdef dontUse
3223 G4double thisExcitation(0);
3224 // excitation energy from this collision
3225 // initial state:
3226 G4double initial(0);
3227 G4KineticTrack * kt=collision->GetPrimary();
3228 initial += kt->Get4Momentum().e();
3229
3230 G4RKPropagation * RKprop=(G4RKPropagation *)thePropagator;
3231
3232 initial += RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition());
3233 initial -= RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding());
3234 G4cout << "prim. E/field/Barr/Sum " << kt->Get4Momentum().e()
3235 << " " << RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition())
3236 << " " << RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding())
3237 << " " << initial << G4endl;;
3238
3240 for ( unsigned int it=0; it < ktv.size(); it++)
3241 {
3242 kt=ktv[it];
3243 initial += kt->Get4Momentum().e();
3244 thisExcitation += kt->GetDefinition()->GetPDGMass()
3245 - kt->Get4Momentum().e()
3246 - RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition());
3247 // initial += RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition());
3248 // initial -= RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding());
3249 G4cout << "Targ. def/E/field/Barr/Sum " << kt->GetDefinition()->GetPDGEncoding()
3250 << " " << kt->Get4Momentum().e()
3251 << " " << RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition())
3252 << " " << RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding())
3253 << " " << initial <<" Excit " << thisExcitation << G4endl;;
3254 }
3255
3256 G4double final(0);
3257 G4double mass_out(0);
3258 G4int product_barions(0);
3259 if ( products )
3260 {
3261 for ( unsigned int it=0; it < products->size(); it++)
3262 {
3263 kt=(*products)[it];
3264 final += kt->Get4Momentum().e();
3265 final += RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition());
3266 final += RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding());
3267 if ( kt->GetDefinition()->GetBaryonNumber()==1 ) product_barions++;
3268 mass_out += kt->GetDefinition()->GetPDGMass();
3269 G4cout << "sec. def/E/field/Barr/Sum " << kt->GetDefinition()->GetPDGEncoding()
3270 << " " << kt->Get4Momentum().e()
3271 << " " << RKprop->GetField(kt->GetDefinition()->GetPDGEncoding(),kt->GetPosition())
3272 << " " << RKprop->GetBarrier(kt->GetDefinition()->GetPDGEncoding())
3273 << " " << final << G4endl;;
3274 }
3275 }
3276
3277
3278 G4int finalA = currentA;
3279 G4int finalZ = currentZ;
3280 if ( products )
3281 {
3282 finalA -= product_barions;
3283 finalZ -= GetTotalCharge(*products);
3284 }
3285 G4double delta = GetIonMass(currentZ,currentA) - (GetIonMass(finalZ,finalA) + mass_out);
3286 G4cout << " current/final a,z " << currentA << " " << currentZ << " "<< finalA<< " "<< finalZ
3287 << " delta-mass " << delta<<G4endl;
3288 final+=delta;
3289 mass_out = GetIonMass(finalZ,finalA);
3290 G4cout << " initE/ E_out/ Mfinal/ Excit " << currentInitialEnergy
3291 << " " << final << " "
3292 << mass_out<<" "
3293 << currentInitialEnergy - final - mass_out
3294 << G4endl;
3295 currentInitialEnergy-=final;
3296#endif
3297}
3298
3299//----------------------------------------------------------------------------
3300G4bool G4BinaryCascade::DebugFinalEpConservation(const G4HadProjectile & aTrack,
3301 G4ReactionProductVector* products)
3302//----------------------------------------------------------------------------
3303{
3304 G4ReactionProductVector::iterator iter;
3305 G4double Efinal(0);
3306 G4ThreeVector pFinal(0);
3307 if (std::abs(theParticleChange.GetWeightChange() -1 ) > 1e-5 )
3308 {
3309 G4cout <<" BIC-weight change " << theParticleChange.GetWeightChange()<< G4endl;
3310 }
3311
3312 for(iter = products->begin(); iter != products->end(); ++iter)
3313 {
3314
3315 G4cout << " Secondary E - Ekin / p " <<
3316 (*iter)->GetDefinition()->GetParticleName() << " " <<
3317 (*iter)->GetTotalEnergy() << " - " <<
3318 (*iter)->GetKineticEnergy()<< " / " <<
3319 (*iter)->GetMomentum().x() << " " <<
3320 (*iter)->GetMomentum().y() << " " <<
3321 (*iter)->GetMomentum().z() << G4endl;
3322 Efinal += (*iter)->GetTotalEnergy();
3323 pFinal += (*iter)->GetMomentum();
3324 }
3325
3326 G4cout << "e outgoing/ total : " << Efinal << " " << Efinal+GetFinal4Momentum().e()<< G4endl;
3327 G4cout << "BIC E/p delta " <<
3328 (aTrack.Get4Momentum().e()+theInitial4Mom.e() - Efinal)/MeV <<
3329 " MeV / mom " << (aTrack.Get4Momentum() - pFinal ) /MeV << G4endl;
3330
3331 return (aTrack.Get4Momentum().e() + theInitial4Mom.e() - Efinal)/aTrack.Get4Momentum().e() < perCent;
3332
3333}
3334//----------------------------------------------------------------------------
3335G4bool G4BinaryCascade::DebugEpConservation(const G4String where)
3336//----------------------------------------------------------------------------
3337{
3338 G4cout << where << G4endl;
3339 G4LorentzVector psecs, ptgts, pcpts, pfins;
3340 if (std::abs(theParticleChange.GetWeightChange() -1 ) > 1e-5 )
3341 {
3342 G4cout <<" BIC-weight change " << theParticleChange.GetWeightChange()<< G4endl;
3343 }
3344
3345 std::vector<G4KineticTrack *>::iterator ktiter;
3346 for(ktiter = theSecondaryList.begin(); ktiter != theSecondaryList.end(); ++ktiter)
3347 {
3348
3349 G4cout << " Secondary E - Ekin / p " <<
3350 (*ktiter)->GetDefinition()->GetParticleName() << " " <<
3351 (*ktiter)->Get4Momentum().e() << " - " <<
3352 (*ktiter)->Get4Momentum().e() - (*ktiter)->Get4Momentum().mag() << " / " <<
3353 (*ktiter)->Get4Momentum().vect() << G4endl;
3354 psecs += (*ktiter)->Get4Momentum();
3355 }
3356
3357 for(ktiter = theTargetList.begin(); ktiter != theTargetList.end(); ++ktiter)
3358 {
3359
3360 G4cout << " Target E - Ekin / p " <<
3361 (*ktiter)->GetDefinition()->GetParticleName() << " " <<
3362 (*ktiter)->Get4Momentum().e() << " - " <<
3363 (*ktiter)->Get4Momentum().e() - (*ktiter)->Get4Momentum().mag() << " / " <<
3364 (*ktiter)->Get4Momentum().vect() << G4endl;
3365 ptgts += (*ktiter)->Get4Momentum();
3366 }
3367
3368 for(ktiter = theCapturedList.begin(); ktiter != theCapturedList.end(); ++ktiter)
3369 {
3370
3371 G4cout << " Captured E - Ekin / p " <<
3372 (*ktiter)->GetDefinition()->GetParticleName() << " " <<
3373 (*ktiter)->Get4Momentum().e() << " - " <<
3374 (*ktiter)->Get4Momentum().e() - (*ktiter)->Get4Momentum().mag() << " / " <<
3375 (*ktiter)->Get4Momentum().vect() << G4endl;
3376 pcpts += (*ktiter)->Get4Momentum();
3377 }
3378
3379 for(ktiter = theFinalState.begin(); ktiter != theFinalState.end(); ++ktiter)
3380 {
3381
3382 G4cout << " Finals E - Ekin / p " <<
3383 (*ktiter)->GetDefinition()->GetParticleName() << " " <<
3384 (*ktiter)->Get4Momentum().e() << " - " <<
3385 (*ktiter)->Get4Momentum().e() - (*ktiter)->Get4Momentum().mag() << " / " <<
3386 (*ktiter)->Get4Momentum().vect() << G4endl;
3387 pfins += (*ktiter)->Get4Momentum();
3388 }
3389
3390 G4cout << " Secondaries " << psecs << ", Targets " << ptgts << G4endl
3391 <<" Captured " << pcpts << ", Finals " << pfins << G4endl
3392 <<" Sum " << psecs + ptgts + pcpts + pfins << " PTransfer " << theMomentumTransfer
3393 <<" Sum+PTransfer " << psecs + ptgts + pcpts + pfins + theMomentumTransfer
3394 << G4endl<< G4endl;
3395
3396
3397 return true;
3398
3399}
3400
3401//----------------------------------------------------------------------------
3402G4ReactionProductVector * G4BinaryCascade::ProductsAddFakeGamma(G4ReactionProductVector *products )
3403//----------------------------------------------------------------------------
3404{
3405 // else
3406// {
3407// G4ReactionProduct * aNew=0;
3408// // return nucleus e and p
3409// if (fragment != 0 ) {
3410// aNew = new G4ReactionProduct(G4Gamma::GammaDefinition()); // we only want to pass e/p
3411// aNew->SetMomentum(fragment->GetMomentum().vect());
3412// aNew->SetTotalEnergy(fragment->GetMomentum().e());
3413// delete fragment;
3414// fragment=0;
3415// } else if (products->size() == 0) {
3416// // FixMe GF: for testing without precompound, return 1 gamma of 0.01 MeV in +x
3417//#include "G4Gamma.hh"
3418// aNew = new G4ReactionProduct(G4Gamma::GammaDefinition());
3419// aNew->SetMomentum(G4ThreeVector(0.01*MeV,0,0));
3420// aNew->SetTotalEnergy(0.01*MeV);
3421// }
3422// if ( aNew != 0 ) products->push_back(aNew);
3423// }
3424 return products;
3425}
3426
3427//----------------------------------------------------------------------------
#define _CheckChargeAndBaryonNumber_(val)
#define _DebugEpConservation(val)
double A(double temperature)
@ isAlive
@ stopAndKill
CLHEP::HepLorentzVector G4LorentzVector
std::vector< G4ReactionProduct * > G4ReactionProductVector
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:251
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:254
std::mutex G4Mutex
Definition: G4Threading.hh:81
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
Hep3Vector unit() const
Hep3Vector orthogonal() const
double mag2() const
Hep3Vector cross(const Hep3Vector &) const
double mag() const
HepLorentzRotation inverse() const
HepLorentzRotation & set(double bx, double by, double bz)
Hep3Vector boostVector() const
Hep3Vector vect() const
static G4Alpha * AlphaDefinition()
Definition: G4Alpha.cc:83
virtual const std::vector< G4CollisionInitialState * > & GetCollisions(G4KineticTrack *aProjectile, std::vector< G4KineticTrack * > &, G4double theCurrentTime)
Definition: G4BCDecay.hh:41
virtual const std::vector< G4CollisionInitialState * > & GetCollisions(G4KineticTrack *aProjectile, std::vector< G4KineticTrack * > &, G4double theCurrentTime)
virtual void PropagateModelDescription(std::ostream &) const
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
virtual G4ReactionProductVector * Propagate(G4KineticTrackVector *, G4V3DNucleus *)
G4BinaryCascade(G4VPreCompoundModel *ptr=0)
virtual void ModelDescription(std::ostream &) const
virtual ~G4BinaryCascade()
G4KineticTrackVector & GetTargetCollection(void)
G4KineticTrackVector * GetFinalState()
const G4BCAction * GetGenerator()
G4KineticTrack * GetPrimary(void)
void RemoveCollision(G4CollisionInitialState *collision)
void RemoveTracksCollisions(G4KineticTrackVector *ktv)
void AddCollision(G4double time, G4KineticTrack *proj, G4KineticTrack *target=NULL)
G4CollisionInitialState * GetNextCollision()
void Decay(G4KineticTrackVector *tracks) const
static G4Deuteron * DeuteronDefinition()
Definition: G4Deuteron.cc:88
void ModelDescription(std::ostream &outFile) const
G4ReactionProductVector * BreakItUp(const G4Fragment &theInitialState)
G4double GetFermiMomentum(G4double density)
void Init(G4int anA, G4int aZ)
void SetNumberOfCharged(G4int value)
Definition: G4Fragment.hh:381
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:299
void SetNumberOfHoles(G4int valueTot, G4int valueP=0)
Definition: G4Fragment.hh:367
void SetNumberOfParticles(G4int value)
Definition: G4Fragment.hh:376
G4int GetA_asInt() const
Definition: G4Fragment.hh:258
void SetStatusChange(G4HadFinalStateStatus aS)
void AddSecondary(G4DynamicParticle *aP, G4int mod=-1)
void SetEnergyChange(G4double anEnergy)
void SetMomentumChange(const G4ThreeVector &aV)
G4double GetWeightChange() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
G4double GetGlobalTime() const
void SetTime(G4double aT)
void SetCreatorModelType(G4int idx)
G4HadronicInteraction * FindModel(const G4String &name)
static G4HadronicInteractionRegistry * Instance()
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)
void SetMinEnergy(G4double anEnergy)
const G4String & GetModelName() const
void SetEnergyMomentumCheckLevels(G4double relativeLevel, G4double absoluteLevel)
void SetMaxEnergy(const G4double anEnergy)
static G4He3 * He3Definition()
Definition: G4He3.cc:88
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:522
G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1517
CascadeState SetState(const CascadeState new_state)
CascadeState GetState() const
void SetNucleon(G4Nucleon *aN)
void Set4Momentum(const G4LorentzVector &a4Momentum)
const G4ThreeVector & GetPosition() const
const G4ParticleDefinition * GetDefinition() const
G4bool IsParticipant() const
const G4LorentzVector & GetTrackingMomentum() const
void Update4Momentum(G4double aEnergy)
const G4LorentzVector & Get4Momentum() const
G4double GetActualMass() const
static G4Neutron * NeutronDefinition()
Definition: G4Neutron.cc:98
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103
G4int GetA_asInt() const
Definition: G4Nucleus.hh:109
G4int GetZ_asInt() const
Definition: G4Nucleus.hh:115
G4bool GetPDGStable() const
G4double GetPDGCharge() const
const G4String & GetParticleName() const
G4IonTable * GetIonTable() const
static G4ParticleTable * GetParticleTable()
static G4int Register(const G4String &)
static G4PionMinus * PionMinusDefinition()
Definition: G4PionMinus.cc:92
static G4PionPlus * PionPlusDefinition()
Definition: G4PionPlus.cc:92
static G4Proton * ProtonDefinition()
Definition: G4Proton.cc:87
static G4Proton * Proton()
Definition: G4Proton.cc:92
G4double GetField(G4int encoding, G4ThreeVector pos)
G4double GetBarrier(G4int encoding)
virtual void Transport(G4KineticTrackVector &theActive, const G4KineticTrackVector &theSpectators, G4double theTimeStep)
G4ThreeVector GetMomentumTransfer() const
void SetMomentum(const G4double x, const G4double y, const G4double z)
void SetTotalEnergy(const G4double en)
G4double GetTotalMomentum() const
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
void SetNewlyAdded(const G4bool f)
G4ThreeVector GetMomentum() const
void SetCreatorModel(const G4int mod)
void SetKineticEnergy(const G4double en)
virtual G4KineticTrackVector * Scatter(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
Definition: G4Scatterer.cc:283
static G4Triton * TritonDefinition()
Definition: G4Triton.cc:89
virtual G4double CoulombBarrier()=0
virtual G4double GetOuterRadius()=0
virtual const G4VNuclearDensity * GetNuclearDensity() const =0
virtual G4Nucleon * GetNextNucleon()=0
virtual G4int GetCharge()=0
virtual G4bool StartLoop()=0
virtual void Init(G4int theA, G4int theZ)=0
virtual G4double GetMass()=0
virtual G4int GetMassNumber()=0
virtual void Init(G4V3DNucleus *theNucleus)=0
G4VPreCompoundModel * GetDeExcitation() const
const G4HadProjectile * GetPrimaryProjectile() const
void SetDeExcitation(G4VPreCompoundModel *ptr)
G4double GetDensity(const G4ThreeVector &aPosition) const
virtual void DeExciteModelDescription(std::ostream &outFile) const =0
virtual G4ReactionProductVector * DeExcite(G4Fragment &aFragment)=0
G4ExcitationHandler * GetExcitationHandler() const
Definition: G4ping.hh:35
SelectFromKTV(G4KineticTrackVector *out, G4KineticTrack::CascadeState astate)
void operator()(G4KineticTrack *&kt) const
ParticleList decay(Cluster *const c)
Carries out a cluster decay.
G4double energy(const ThreeVector &p, const G4double m)
const char * name(G4int ptype)
G4bool nucleon(G4int ityp)
int G4lrint(double ad)
Definition: templates.hh:134
T sqr(const T &x)
Definition: templates.hh:128
#define DBL_MAX
Definition: templates.hh:62
#define ns
Definition: xmlparse.cc:614