1 #include "G4HadReentrentException.hh"
2 #include "G4ProcessManager.hh"
3 #include "G4ParticleTable.hh"
5 #include "SimG4Core/CustomPhysics/interface/FullModelHadronicProcess.hh"
6 #include "SimG4Core/CustomPhysics/interface/G4ProcessHelper.hh"
8 #include "SimG4Core/CustomPhysics/interface/FullModelReactionDynamics.hh"
12 using namespace CLHEP;
14 FullModelHadronicProcess::FullModelHadronicProcess(G4ProcessHelper * aHelper,
const G4String& processName) :
15 G4VDiscreteProcess(processName), theHelper(aHelper)
19 FullModelHadronicProcess::~FullModelHadronicProcess(){}
21 G4bool FullModelHadronicProcess::IsApplicable(
const G4ParticleDefinition& aP)
23 return theHelper->ApplicabilityTester(aP);
26 G4double FullModelHadronicProcess::GetMicroscopicCrossSection(
const G4DynamicParticle *aParticle,
27 const G4Element *anElement,
31 G4double InclXsec = theHelper->GetInclusiveCrossSection(aParticle,anElement);
35 G4double HighestEnergyLimit = 10 * TeV ;
36 G4double LowestEnergyLimit = 1 * eV;
38 G4double ParticleEnergy = aParticle->GetKineticEnergy();
41 if (ParticleEnergy > HighestEnergyLimit || ParticleEnergy < LowestEnergyLimit){
50 G4double FullModelHadronicProcess::GetMeanFreePath(
const G4Track& aTrack, G4double, G4ForceCondition*)
52 G4Material *aMaterial = aTrack.GetMaterial();
53 const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
56 G4int nElements = aMaterial->GetNumberOfElements();
58 const G4double *theAtomicNumDensityVector =
59 aMaterial->GetAtomicNumDensityVector();
60 G4double aTemp = aMaterial->GetTemperature();
62 for( G4int
i=0;
i<nElements; ++
i )
65 GetMicroscopicCrossSection( aParticle, (*aMaterial->GetElementVector())[
i], aTemp);
66 sigma += theAtomicNumDensityVector[
i] * xSection;
73 G4VParticleChange* FullModelHadronicProcess::PostStepDoIt(
const G4Track& aTrack,
78 const G4TouchableHandle thisTouchable(aTrack.GetTouchableHandle());
81 aParticleChange.Initialize(aTrack);
83 G4DynamicParticle* IncidentRhadron =
const_cast<G4DynamicParticle*
>(aTrack.GetDynamicParticle());
85 const G4ThreeVector aPosition = aTrack.GetPosition();
87 const G4int theIncidentPDG = IncidentRhadron->GetDefinition()->GetPDGEncoding();
88 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
89 std::vector<G4ParticleDefinition*> theParticleDefinitions;
91 G4bool IncidentSurvives =
false;
92 G4bool TargetSurvives =
false;
93 G4Nucleus targetNucleus(aTrack.GetMaterial());
94 G4ParticleDefinition* outgoingRhadron=0;
95 G4ParticleDefinition* outgoingCloud=0;
96 G4ParticleDefinition* outgoingTarget=0;
100 G4ThreeVector p_0 = IncidentRhadron->GetMomentum();
104 G4double e_kin_0 = IncidentRhadron->GetKineticEnergy();
107 G4DynamicParticle* cloudParticle =
new G4DynamicParticle();
120 cloudParticle->SetDefinition(CustomIncident->
GetCloud());
122 if(cloudParticle->GetDefinition() == 0)
124 std::cout <<
"FullModelHadronicProcess::PostStepDoIt Definition of particle cloud not available!!" << std::endl;
130 double scale=cloudParticle->GetDefinition()->GetPDGMass()/IncidentRhadron->GetDefinition()->GetPDGMass();
132 G4LorentzVector cloudMomentum;
133 cloudMomentum.setVectM(IncidentRhadron->GetMomentum()*
scale,cloudParticle->GetDefinition()->GetPDGMass());
134 G4LorentzVector gluinoMomentum;
136 gluinoMomentum.setVectM(IncidentRhadron->GetMomentum()*(1.-
scale),CustomIncident->
GetSpectator()->GetPDGMass());
143 G4LorentzVector FullRhadron4Momentum = IncidentRhadron->Get4Momentum();
144 G4LorentzVector Cloud4Momentum = cloudMomentum;
146 cloudParticle->Set4Momentum(cloudMomentum);
148 G4DynamicParticle* OrgPart = cloudParticle;
158 double E_0 = IncidentRhadron->GetKineticEnergy();
161 G4double ek = OrgPart->GetKineticEnergy();
162 G4double amas = OrgPart->GetDefinition()->GetPDGMass();
164 G4double tkin = targetNucleus.Cinema( ek );
166 OrgPart->SetKineticEnergy( ek );
167 G4double et = ek + amas;
169 G4double
pp = OrgPart->GetMomentum().mag();
172 G4ThreeVector momentum = OrgPart->GetMomentum();
173 OrgPart->SetMomentum( momentum * (p/pp) );
177 if(ek > 0.) { tkin = targetNucleus.EvaporationEffects( ek ); ek -= tkin; }
178 if(ek+gluinoMomentum.e()-gluinoMomentum.m()<=0.1*
MeV||ek<=0.) {
180 G4cout<<
"Kinetic energy is sick"<<G4endl;
181 G4cout<<
"Full R-hadron: "<<(ek+gluinoMomentum.e()-gluinoMomentum.m())/
MeV<<
" MeV" <<G4endl;
182 G4cout<<
"Quark system: "<<ek/
MeV<<
" MeV"<<G4endl;
184 aParticleChange.ProposeTrackStatus( fStopButAlive );
185 return &aParticleChange;
187 OrgPart->SetKineticEnergy( ek );
190 pp = OrgPart->GetMomentum().mag();
194 G4ThreeVector momentum = OrgPart->GetMomentum();
195 OrgPart->SetMomentum( momentum * (p/pp) );
202 G4ParticleDefinition* aTarget;
203 ReactionProduct rp = theHelper->GetFinalState(aTrack,aTarget);
204 G4bool force2to2 =
false;
206 while(rp.size()!=2 && force2to2){
207 rp = theHelper->GetFinalState(aTrack,aTarget);
209 G4int NumberOfSecondaries = rp.size();
213 G4LorentzVector Target4Momentum;
214 Target4Momentum.set(0.,0.,0.,aTarget->GetPDGMass());
216 G4LorentzVector psum_full,psum_cloud;
217 psum_full = FullRhadron4Momentum + Target4Momentum;
218 psum_cloud = Cloud4Momentum + Target4Momentum;
219 G4ThreeVector trafo_full_cms = (-1)*psum_full.boostVector();
220 G4ThreeVector trafo_cloud_cms = (-1)*psum_cloud.boostVector();
230 for(ReactionProduct::iterator it = rp.begin();
234 G4ParticleDefinition* tempDef = theParticleTable->FindParticle(*it);
236 if (tempDef==aTarget) TargetSurvives =
true;
241 outgoingRhadron = tempDef;
250 if(outgoingCloud == 0)
252 std::cout <<
"FullModelHadronicProcess::PostStepDoIt Definition of outgoing particle cloud not available!!" << std::endl;
260 if (tempDef==G4Proton::Proton()||tempDef==G4Neutron::Neutron()) outgoingTarget = tempDef;
262 if (tempCust==0&&rp.size()==2) outgoingTarget = tempDef;
263 if (tempDef->GetPDGEncoding()==theIncidentPDG) {
264 IncidentSurvives =
true;
266 theParticleDefinitions.push_back(tempDef);
278 if (outgoingTarget==0) outgoingTarget = theParticleTable->FindParticle(rp[1]);
292 if(IncidentSurvives) NumberOfSecondaries--;
293 aParticleChange.SetNumberOfSecondaries(NumberOfSecondaries);
301 const G4HadProjectile* originalIncident =
new G4HadProjectile(*OrgPart);
305 G4HadProjectile* org2 =
new G4HadProjectile(*OrgPart);
306 G4LorentzRotation
trans = org2->GetTrafoToLab();
330 G4DynamicParticle *originalTarget =
new G4DynamicParticle;
331 originalTarget->SetDefinition(aTarget);
333 G4ReactionProduct targetParticle(aTarget);
336 G4ReactionProduct currentParticle(const_cast<G4ParticleDefinition *>(originalIncident->GetDefinition() ) );
337 currentParticle.SetMomentum( originalIncident->Get4Momentum().vect() );
338 currentParticle.SetKineticEnergy( originalIncident->GetKineticEnergy() );
348 G4ReactionProduct modifiedOriginal = currentParticle;
350 currentParticle.SetSide( 1 );
351 targetParticle.SetSide( -1 );
352 G4bool incidentHasChanged =
false;
353 if (!IncidentSurvives) incidentHasChanged =
true;
354 G4bool targetHasChanged =
false;
355 if (!TargetSurvives) targetHasChanged =
true;
356 G4bool quasiElastic =
false;
357 if (rp.size()==2) quasiElastic =
true;
358 G4FastVector<G4ReactionProduct,GHADLISTSIZE> vec;
367 for (G4int
i = 0;
i!=NumberOfSecondaries;
i++){
368 if(theParticleDefinitions[
i]!=aTarget
369 && theParticleDefinitions[
i]!=originalIncident->GetDefinition()
370 && theParticleDefinitions[
i]!=outgoingRhadron
371 && theParticleDefinitions[
i]!=outgoingTarget)
373 G4ReactionProduct*
pa =
new G4ReactionProduct;
374 pa->SetDefinition( theParticleDefinitions[
i] );
375 (G4UniformRand() < 0.5) ? pa->SetSide( -1 ) : pa->SetSide( 1 );
376 vec.SetElement( vecLen++, pa );
382 if (incidentHasChanged) currentParticle.SetDefinitionAndUpdateE( outgoingCloud );
383 if (incidentHasChanged) modifiedOriginal.SetDefinition( outgoingCloud );
384 if (targetHasChanged) targetParticle.SetDefinitionAndUpdateE( outgoingTarget );
394 CalculateMomenta( vec, vecLen,
395 originalIncident, originalTarget, modifiedOriginal,
396 targetNucleus, currentParticle, targetParticle,
397 incidentHasChanged, targetHasChanged, quasiElastic );
401 G4String cPname = currentParticle.GetDefinition()->GetParticleName();
433 aParticleChange.SetNumberOfSecondaries(vecLen+NumberOfSecondaries);
435 G4LorentzVector cloud_p4_new;
447 cloud_p4_new.setVectM(currentParticle.GetMomentum(),currentParticle.GetMass());
448 cloud_p4_new *=
trans;
450 G4LorentzVector cloud_p4_old_full = Cloud4Momentum;
451 cloud_p4_old_full.boost(trafo_full_cms);
452 G4LorentzVector cloud_p4_old_cloud = Cloud4Momentum;
453 cloud_p4_old_cloud.boost(trafo_cloud_cms);
454 G4LorentzVector cloud_p4_full = cloud_p4_new;
455 cloud_p4_full.boost(trafo_full_cms);
456 G4LorentzVector cloud_p4_cloud = cloud_p4_new;
457 cloud_p4_cloud.boost(trafo_cloud_cms);
459 G4LorentzVector p_g_cms = gluinoMomentum;
460 p_g_cms.boost(trafo_full_cms);
462 G4LorentzVector p4_new;
466 p4_new.setVectM( cloud_p4_new.v() + gluinoMomentum.v(), outgoingRhadron->GetPDGMass() );
470 p_new = p4_new.vect();
472 aParticleChange.ProposeLocalEnergyDeposit((p4_new-cloud_p4_new-gluinoMomentum).
m());
474 if( incidentHasChanged )
476 G4DynamicParticle* p0 =
new G4DynamicParticle;
477 p0->SetDefinition( outgoingRhadron );
478 p0->SetMomentum( p_new );
481 G4Track* Track0 =
new G4Track(p0,
482 aTrack.GetGlobalTime(),
484 Track0->SetTouchableHandle(thisTouchable);
485 aParticleChange.AddSecondary(Track0);
491 if(p0->GetKineticEnergy()>e_kin_0) {
492 G4cout<<
"ALAAAAARM!!! (incident changed from "
493 <<IncidentRhadron->GetDefinition()->GetParticleName()
494 <<
" to "<<p0->GetDefinition()->GetParticleName()<<
")"<<G4endl;
495 G4cout<<
"Energy loss: "<<(e_kin_0-p0->GetKineticEnergy())/
GeV<<
" GeV (should be positive)"<<G4endl;
497 if(rp.size()!=3) G4cout<<
"DOUBLE ALAAAAARM!!!"<<G4endl;
501 if(
std::abs(p0->GetKineticEnergy()-e_kin_0)>100*
GeV) {
502 G4cout<<
"Diff. too big"<<G4endl;
505 aParticleChange.ProposeTrackStatus( fStopAndKill );
510 G4double p = p_new.mag();
512 aParticleChange.ProposeMomentumDirection( p_new.x()/
p, p_new.y()/
p, p_new.z()/
p );
514 aParticleChange.ProposeMomentumDirection( 1.0, 0.0, 0.0 );
516 G4double aE =
sqrt(p*p+(outgoingRhadron->GetPDGMass()*outgoingRhadron->GetPDGMass()) );
517 e_kin = aE - outgoingRhadron->GetPDGMass();
537 if( targetParticle.GetMass() > 0.0 )
539 G4DynamicParticle *
p1 =
new G4DynamicParticle;
540 p1->SetDefinition( targetParticle.GetDefinition() );
542 G4ThreeVector momentum = targetParticle.GetMomentum();
543 momentum = momentum.rotate(cache,what);
544 p1->SetMomentum( momentum );
545 p1->SetMomentum( (trans*p1->Get4Momentum()).vect());
546 G4Track* Track1 =
new G4Track(p1,
547 aTrack.GetGlobalTime(),
549 Track1->SetTouchableHandle(thisTouchable);
550 aParticleChange.AddSecondary(Track1);
552 G4DynamicParticle *
pa;
560 for(
int i=0; i<vecLen; ++
i )
562 pa =
new G4DynamicParticle();
563 pa->SetDefinition( vec[i]->GetDefinition() );
564 pa->SetMomentum( vec[i]->GetMomentum() );
565 pa->Set4Momentum(trans*(pa->Get4Momentum()));
566 G4ThreeVector pvec = pa->GetMomentum();
567 G4Track* Trackn =
new G4Track(pa,
568 aTrack.GetGlobalTime(),
570 Trackn->SetTouchableHandle(thisTouchable);
571 aParticleChange.AddSecondary(Trackn);
586 const G4DynamicParticle* theRhadron = FindRhadron(&aParticleChange);
589 if (theRhadron!=
NULL||IncidentSurvives)
598 E_new = theRhadron->GetKineticEnergy();
615 G4LorentzVector p4_old_full = FullRhadron4Momentum;
616 p4_old_full.boost(trafo_full_cms);
617 G4LorentzVector p4_old_cloud = FullRhadron4Momentum;
618 p4_old_cloud.boost(trafo_cloud_cms);
619 G4LorentzVector p4_full = p4_new;
621 p4_full=p4_full.boost(trafo_full_cms);
623 G4LorentzVector p4_cloud = p4_new;
624 p4_cloud.boost(trafo_cloud_cms);
675 G4double AbsDeltaE = E_0-E_new;
677 if (AbsDeltaE > 10*
GeV) {
678 G4cout<<
"Energy loss larger than 10 GeV..."<<G4endl;
679 G4cout<<
"E_0: "<<E_0/
GeV<<
" GeV"<<G4endl;
680 G4cout<<
"E_new: "<<E_new/
GeV<<
" GeV"<<G4endl;
681 G4cout<<
"Gamma: "<<IncidentRhadron->GetTotalEnergy()/IncidentRhadron->GetDefinition()->GetPDGMass()<<G4endl;
682 G4cout<<
"x: "<<aPosition.x()/cm<<
" cm"<<G4endl;
685 delete originalIncident;
686 delete originalTarget;
691 ClearNumberOfInteractionLengthLeft();
694 return &aParticleChange;
699 void FullModelHadronicProcess::CalculateMomenta(
700 G4FastVector<G4ReactionProduct,GHADLISTSIZE> &vec,
702 const G4HadProjectile *originalIncident,
703 const G4DynamicParticle *originalTarget,
704 G4ReactionProduct &modifiedOriginal,
705 G4Nucleus &targetNucleus,
706 G4ReactionProduct ¤tParticle,
707 G4ReactionProduct &targetParticle,
708 G4bool &incidentHasChanged,
709 G4bool &targetHasChanged,
710 G4bool quasiElastic )
712 FullModelReactionDynamics theReactionDynamics;
715 what = originalIncident->Get4Momentum().vect();
728 theReactionDynamics.TwoBody( vec, vecLen,
729 modifiedOriginal, originalTarget,
730 currentParticle, targetParticle,
731 targetNucleus, targetHasChanged );
737 G4ReactionProduct leadingStrangeParticle;
738 G4bool leadFlag = MarkLeadingStrangeParticle( currentParticle,
740 leadingStrangeParticle );
747 G4bool finishedGenXPt =
false;
748 G4bool annihilation =
false;
749 if( originalIncident->GetDefinition()->GetPDGEncoding() < 0 &&
750 currentParticle.GetMass() == 0.0 && targetParticle.GetMass() == 0.0 )
754 G4double ekcor = 1.0;
755 G4double ek = originalIncident->GetKineticEnergy();
758 const G4double tarmas = originalTarget->GetDefinition()->GetPDGMass();
759 if( ek > 1.0*
GeV )ekcor = 1./(ek/
GeV);
760 const G4double atomicWeight = G4double(targetNucleus.GetN_asInt());
761 ek = 2*tarmas + ek*(1.+ekcor/atomicWeight);
763 G4double tkin = targetNucleus.Cinema( ek );
766 modifiedOriginal.SetKineticEnergy( ekOrg );
769 const G4double twsup[] = { 1.0, 0.7, 0.5, 0.3, 0.2, 0.1 };
770 G4double rand1 = G4UniformRand();
771 G4double rand2 = G4UniformRand();
772 if( (annihilation || (vecLen >= 6) || (modifiedOriginal.GetKineticEnergy()/
GeV >= 1.0)) &&
773 (((originalIncident->GetDefinition() == G4KaonPlus::KaonPlus()) ||
774 (originalIncident->GetDefinition() == G4KaonMinus::KaonMinus()) ||
775 (originalIncident->GetDefinition() == G4KaonZeroLong::KaonZeroLong()) ||
776 (originalIncident->GetDefinition() == G4KaonZeroShort::KaonZeroShort())) &&
777 ((rand1 < 0.5) || (rand2 > twsup[vecLen]))))
779 theReactionDynamics.GenerateXandPt( vec, vecLen,
780 modifiedOriginal, originalIncident,
781 currentParticle, targetParticle,
782 targetNucleus, incidentHasChanged,
783 targetHasChanged, leadFlag,
784 leadingStrangeParticle );
791 G4bool finishedTwoClu =
false;
792 if( modifiedOriginal.GetTotalMomentum()/
MeV < 1.0 )
795 for(G4int i=0; i<vecLen; i++)
delete vec[i];
801 theReactionDynamics.SuppressChargedPions( vec, vecLen,
802 modifiedOriginal, currentParticle,
803 targetParticle, targetNucleus,
804 incidentHasChanged, targetHasChanged );
808 finishedTwoClu = theReactionDynamics.TwoCluster( vec, vecLen,
809 modifiedOriginal, originalIncident,
810 currentParticle, targetParticle,
811 targetNucleus, incidentHasChanged,
812 targetHasChanged, leadFlag,
813 leadingStrangeParticle );
815 catch(G4HadReentrentException aC)
818 throw G4HadReentrentException(__FILE__, __LINE__,
"Failing to calculate momenta");
847 theReactionDynamics.TwoBody( vec, vecLen,
848 modifiedOriginal, originalTarget,
849 currentParticle, targetParticle,
850 targetNucleus, targetHasChanged );
854 G4bool FullModelHadronicProcess::MarkLeadingStrangeParticle(
855 const G4ReactionProduct ¤tParticle,
856 const G4ReactionProduct &targetParticle,
857 G4ReactionProduct &leadParticle )
865 if( (currentParticle.GetMass() >= G4KaonPlus::KaonPlus()->GetPDGMass()) &&
866 (currentParticle.GetDefinition() != G4Proton::Proton()) &&
867 (currentParticle.GetDefinition() != G4Neutron::Neutron()) )
870 leadParticle = currentParticle;
872 else if( (targetParticle.GetMass() >= G4KaonPlus::KaonPlus()->GetPDGMass()) &&
873 (targetParticle.GetDefinition() != G4Proton::Proton()) &&
874 (targetParticle.GetDefinition() != G4Neutron::Neutron()) )
877 leadParticle = targetParticle;
882 void FullModelHadronicProcess::Rotate(G4FastVector<G4ReactionProduct,GHADLISTSIZE> &vec, G4int &vecLen)
887 for( i=0; i<vecLen; ++
i )
889 G4ThreeVector momentum = vec[
i]->GetMomentum();
890 momentum = momentum.rotate(rotation, what);
891 vec[
i]->SetMomentum(momentum);
895 const G4DynamicParticle* FullModelHadronicProcess::FindRhadron(G4ParticleChange* aParticleChange)
897 G4int nsec = aParticleChange->GetNumberOfSecondaries();
898 if (nsec==0)
return 0;
900 G4bool
found =
false;
901 while (i!=nsec && !found){
904 if (dynamic_cast<CustomParticle*>(aParticleChange->GetSecondary(i)->GetDynamicParticle()->GetDefinition())!=0) found =
true;
908 if(found)
return aParticleChange->GetSecondary(i)->GetDynamicParticle();
G4ParticleDefinition * GetCloud()
static bool s_isRMeson(int pdg)
static bool s_isMesonino(int pdg)
Abs< T >::type abs(const T &t)
G4ParticleDefinition * GetSpectator()