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"
11 using namespace CLHEP;
13 FullModelHadronicProcess::FullModelHadronicProcess(G4ProcessHelper * aHelper,
const G4String&
processName) :
14 G4VDiscreteProcess(processName), theHelper(aHelper)
18 FullModelHadronicProcess::~FullModelHadronicProcess(){}
20 G4bool FullModelHadronicProcess::IsApplicable(
const G4ParticleDefinition& aP)
22 return theHelper->ApplicabilityTester(aP);
25 G4double FullModelHadronicProcess::GetMicroscopicCrossSection(
const G4DynamicParticle *aParticle,
26 const G4Element *anElement,
30 G4double InclXsec = theHelper->GetInclusiveCrossSection(aParticle,anElement);
34 G4double HighestEnergyLimit = 10 * TeV ;
35 G4double LowestEnergyLimit = 1 * eV;
37 G4double ParticleEnergy = aParticle->GetKineticEnergy();
40 if (ParticleEnergy > HighestEnergyLimit || ParticleEnergy < LowestEnergyLimit){
49 G4double FullModelHadronicProcess::GetMeanFreePath(
const G4Track& aTrack, G4double, G4ForceCondition*)
51 G4Material *aMaterial = aTrack.GetMaterial();
52 const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
55 G4int nElements = aMaterial->GetNumberOfElements();
57 const G4double *theAtomicNumDensityVector =
58 aMaterial->GetAtomicNumDensityVector();
59 G4double aTemp = aMaterial->GetTemperature();
61 for( G4int
i=0;
i<nElements; ++
i )
64 GetMicroscopicCrossSection( aParticle, (*aMaterial->GetElementVector())[
i], aTemp);
65 sigma += theAtomicNumDensityVector[
i] * xSection;
72 G4VParticleChange* FullModelHadronicProcess::PostStepDoIt(
const G4Track& aTrack,
77 const G4TouchableHandle thisTouchable(aTrack.GetTouchableHandle());
80 aParticleChange.Initialize(aTrack);
82 G4DynamicParticle* IncidentRhadron =
const_cast<G4DynamicParticle*
>(aTrack.GetDynamicParticle());
84 const G4ThreeVector aPosition = aTrack.GetPosition();
86 const G4int theIncidentPDG = IncidentRhadron->GetDefinition()->GetPDGEncoding();
87 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
88 std::vector<G4ParticleDefinition*> theParticleDefinitions;
90 G4bool IncidentSurvives =
false;
91 G4bool TargetSurvives =
false;
92 G4Nucleus targetNucleus(aTrack.GetMaterial());
93 G4ParticleDefinition* outgoingRhadron=0;
94 G4ParticleDefinition* outgoingCloud=0;
95 G4ParticleDefinition* outgoingTarget=0;
99 G4ThreeVector p_0 = IncidentRhadron->GetMomentum();
103 G4double e_kin_0 = IncidentRhadron->GetKineticEnergy();
106 G4DynamicParticle* cloudParticle =
new G4DynamicParticle();
119 cloudParticle->SetDefinition(CustomIncident->
GetCloud());
121 if(cloudParticle->GetDefinition() == 0)
123 std::cout <<
"FullModelHadronicProcess::PostStepDoIt Definition of particle cloud not available!!" << std::endl;
129 double scale=cloudParticle->GetDefinition()->GetPDGMass()/IncidentRhadron->GetDefinition()->GetPDGMass();
131 G4LorentzVector cloudMomentum;
132 cloudMomentum.setVectM(IncidentRhadron->GetMomentum()*
scale,cloudParticle->GetDefinition()->GetPDGMass());
133 G4LorentzVector gluinoMomentum;
135 gluinoMomentum.setVectM(IncidentRhadron->GetMomentum()*(1.-
scale),CustomIncident->
GetSpectator()->GetPDGMass());
142 G4LorentzVector FullRhadron4Momentum = IncidentRhadron->Get4Momentum();
143 G4LorentzVector Cloud4Momentum = cloudMomentum;
145 cloudParticle->Set4Momentum(cloudMomentum);
147 G4DynamicParticle* OrgPart = cloudParticle;
157 double E_0 = IncidentRhadron->GetKineticEnergy();
160 G4double ek = OrgPart->GetKineticEnergy();
161 G4double amas = OrgPart->GetDefinition()->GetPDGMass();
163 G4double tkin = targetNucleus.Cinema( ek );
165 OrgPart->SetKineticEnergy( ek );
166 G4double et = ek + amas;
168 G4double
pp = OrgPart->GetMomentum().mag();
171 G4ThreeVector momentum = OrgPart->GetMomentum();
172 OrgPart->SetMomentum( momentum * (p/pp) );
176 if(ek > 0.) { tkin = targetNucleus.EvaporationEffects( ek ); ek -= tkin; }
177 if(ek+gluinoMomentum.e()-gluinoMomentum.m()<=0.1*
MeV||ek<=0.) {
179 G4cout<<
"Kinetic energy is sick"<<G4endl;
180 G4cout<<
"Full R-hadron: "<<(ek+gluinoMomentum.e()-gluinoMomentum.m())/
MeV<<
" MeV" <<G4endl;
181 G4cout<<
"Quark system: "<<ek/
MeV<<
" MeV"<<G4endl;
183 aParticleChange.ProposeTrackStatus( fStopButAlive );
184 return &aParticleChange;
186 OrgPart->SetKineticEnergy( ek );
189 pp = OrgPart->GetMomentum().mag();
193 G4ThreeVector momentum = OrgPart->GetMomentum();
194 OrgPart->SetMomentum( momentum * (p/pp) );
201 G4ParticleDefinition* aTarget;
202 ReactionProduct rp = theHelper->GetFinalState(aTrack,aTarget);
203 G4bool force2to2 =
false;
205 while(rp.size()!=2 && force2to2){
206 rp = theHelper->GetFinalState(aTrack,aTarget);
208 G4int NumberOfSecondaries = rp.size();
212 G4LorentzVector Target4Momentum;
213 Target4Momentum.set(0.,0.,0.,aTarget->GetPDGMass());
215 G4LorentzVector psum_full,psum_cloud;
216 psum_full = FullRhadron4Momentum + Target4Momentum;
217 psum_cloud = Cloud4Momentum + Target4Momentum;
218 G4ThreeVector trafo_full_cms = (-1)*psum_full.boostVector();
219 G4ThreeVector trafo_cloud_cms = (-1)*psum_cloud.boostVector();
229 for(ReactionProduct::iterator it = rp.begin();
233 G4ParticleDefinition* tempDef = theParticleTable->FindParticle(*it);
235 if (tempDef==aTarget) TargetSurvives =
true;
240 outgoingRhadron = tempDef;
249 if(outgoingCloud == 0)
251 std::cout <<
"FullModelHadronicProcess::PostStepDoIt Definition of outgoing particle cloud not available!!" << std::endl;
259 if (tempDef==G4Proton::Proton()||tempDef==G4Neutron::Neutron()) outgoingTarget = tempDef;
261 if (tempCust==0&&rp.size()==2) outgoingTarget = tempDef;
262 if (tempDef->GetPDGEncoding()==theIncidentPDG) {
263 IncidentSurvives =
true;
265 theParticleDefinitions.push_back(tempDef);
277 if (outgoingTarget==0) outgoingTarget = theParticleTable->FindParticle(rp[1]);
291 if(IncidentSurvives) NumberOfSecondaries--;
292 aParticleChange.SetNumberOfSecondaries(NumberOfSecondaries);
300 const G4HadProjectile* originalIncident =
new G4HadProjectile(*OrgPart);
304 G4HadProjectile* org2 =
new G4HadProjectile(*OrgPart);
305 G4LorentzRotation
trans = org2->GetTrafoToLab();
329 G4DynamicParticle *originalTarget =
new G4DynamicParticle;
330 originalTarget->SetDefinition(aTarget);
332 G4ReactionProduct targetParticle(aTarget);
335 G4ReactionProduct currentParticle(const_cast<G4ParticleDefinition *>(originalIncident->GetDefinition() ) );
336 currentParticle.SetMomentum( originalIncident->Get4Momentum().vect() );
337 currentParticle.SetKineticEnergy( originalIncident->GetKineticEnergy() );
347 G4ReactionProduct modifiedOriginal = currentParticle;
349 currentParticle.SetSide( 1 );
350 targetParticle.SetSide( -1 );
351 G4bool incidentHasChanged =
false;
352 if (!IncidentSurvives) incidentHasChanged =
true;
353 G4bool targetHasChanged =
false;
354 if (!TargetSurvives) targetHasChanged =
true;
355 G4bool quasiElastic =
false;
356 if (rp.size()==2) quasiElastic =
true;
357 G4FastVector<G4ReactionProduct,MYGHADLISTSIZE> vec;
366 for (G4int
i = 0;
i!=NumberOfSecondaries;
i++){
367 if(theParticleDefinitions[
i]!=aTarget
368 && theParticleDefinitions[
i]!=originalIncident->GetDefinition()
369 && theParticleDefinitions[
i]!=outgoingRhadron
370 && theParticleDefinitions[
i]!=outgoingTarget)
372 G4ReactionProduct*
pa =
new G4ReactionProduct;
373 pa->SetDefinition( theParticleDefinitions[
i] );
374 (G4UniformRand() < 0.5) ? pa->SetSide( -1 ) : pa->SetSide( 1 );
375 vec.SetElement( vecLen++, pa );
381 if (incidentHasChanged) currentParticle.SetDefinitionAndUpdateE( outgoingCloud );
382 if (incidentHasChanged) modifiedOriginal.SetDefinition( outgoingCloud );
383 if (targetHasChanged) targetParticle.SetDefinitionAndUpdateE( outgoingTarget );
393 CalculateMomenta( vec, vecLen,
394 originalIncident, originalTarget, modifiedOriginal,
395 targetNucleus, currentParticle, targetParticle,
396 incidentHasChanged, targetHasChanged, quasiElastic );
400 G4String cPname = currentParticle.GetDefinition()->GetParticleName();
432 aParticleChange.SetNumberOfSecondaries(vecLen+NumberOfSecondaries);
434 G4LorentzVector cloud_p4_new;
446 cloud_p4_new.setVectM(currentParticle.GetMomentum(),currentParticle.GetMass());
447 cloud_p4_new *=
trans;
449 G4LorentzVector cloud_p4_old_full = Cloud4Momentum;
450 cloud_p4_old_full.boost(trafo_full_cms);
451 G4LorentzVector cloud_p4_old_cloud = Cloud4Momentum;
452 cloud_p4_old_cloud.boost(trafo_cloud_cms);
453 G4LorentzVector cloud_p4_full = cloud_p4_new;
454 cloud_p4_full.boost(trafo_full_cms);
455 G4LorentzVector cloud_p4_cloud = cloud_p4_new;
456 cloud_p4_cloud.boost(trafo_cloud_cms);
458 G4LorentzVector p_g_cms = gluinoMomentum;
459 p_g_cms.boost(trafo_full_cms);
461 G4LorentzVector p4_new;
465 p4_new.setVectM( cloud_p4_new.v() + gluinoMomentum.v(), outgoingRhadron->GetPDGMass() );
469 p_new = p4_new.vect();
471 aParticleChange.ProposeLocalEnergyDeposit((p4_new-cloud_p4_new-gluinoMomentum).
m());
473 if( incidentHasChanged )
475 G4DynamicParticle* p0 =
new G4DynamicParticle;
476 p0->SetDefinition( outgoingRhadron );
477 p0->SetMomentum( p_new );
480 G4Track* Track0 =
new G4Track(p0,
481 aTrack.GetGlobalTime(),
483 Track0->SetTouchableHandle(thisTouchable);
484 aParticleChange.AddSecondary(Track0);
490 if(p0->GetKineticEnergy()>e_kin_0) {
491 G4cout<<
"ALAAAAARM!!! (incident changed from "
492 <<IncidentRhadron->GetDefinition()->GetParticleName()
493 <<
" to "<<p0->GetDefinition()->GetParticleName()<<
")"<<G4endl;
494 G4cout<<
"Energy loss: "<<(e_kin_0-p0->GetKineticEnergy())/
GeV<<
" GeV (should be positive)"<<G4endl;
496 if(rp.size()!=3) G4cout<<
"DOUBLE ALAAAAARM!!!"<<G4endl;
500 if(
std::abs(p0->GetKineticEnergy()-e_kin_0)>100*
GeV) {
501 G4cout<<
"Diff. too big"<<G4endl;
504 aParticleChange.ProposeTrackStatus( fStopAndKill );
509 G4double p = p_new.mag();
511 aParticleChange.ProposeMomentumDirection( p_new.x()/
p, p_new.y()/
p, p_new.z()/
p );
513 aParticleChange.ProposeMomentumDirection( 1.0, 0.0, 0.0 );
515 G4double aE =
sqrt(p*p+(outgoingRhadron->GetPDGMass()*outgoingRhadron->GetPDGMass()) );
516 e_kin = aE - outgoingRhadron->GetPDGMass();
536 if( targetParticle.GetMass() > 0.0 )
538 G4DynamicParticle *
p1 =
new G4DynamicParticle;
539 p1->SetDefinition( targetParticle.GetDefinition() );
541 G4ThreeVector momentum = targetParticle.GetMomentum();
542 momentum = momentum.rotate(cache,what);
543 p1->SetMomentum( momentum );
544 p1->SetMomentum( (trans*p1->Get4Momentum()).vect());
545 G4Track* Track1 =
new G4Track(p1,
546 aTrack.GetGlobalTime(),
548 Track1->SetTouchableHandle(thisTouchable);
549 aParticleChange.AddSecondary(Track1);
551 G4DynamicParticle *
pa;
559 for(
int i=0; i<vecLen; ++
i )
561 pa =
new G4DynamicParticle();
562 pa->SetDefinition( vec[i]->GetDefinition() );
563 pa->SetMomentum( vec[i]->GetMomentum() );
564 pa->Set4Momentum(trans*(pa->Get4Momentum()));
565 G4ThreeVector pvec = pa->GetMomentum();
566 G4Track* Trackn =
new G4Track(pa,
567 aTrack.GetGlobalTime(),
569 Trackn->SetTouchableHandle(thisTouchable);
570 aParticleChange.AddSecondary(Trackn);
585 const G4DynamicParticle* theRhadron = FindRhadron(&aParticleChange);
588 if (theRhadron!=
NULL||IncidentSurvives)
597 E_new = theRhadron->GetKineticEnergy();
614 G4LorentzVector p4_old_full = FullRhadron4Momentum;
615 p4_old_full.boost(trafo_full_cms);
616 G4LorentzVector p4_old_cloud = FullRhadron4Momentum;
617 p4_old_cloud.boost(trafo_cloud_cms);
618 G4LorentzVector p4_full = p4_new;
620 p4_full=p4_full.boost(trafo_full_cms);
622 G4LorentzVector p4_cloud = p4_new;
623 p4_cloud.boost(trafo_cloud_cms);
674 G4double AbsDeltaE = E_0-E_new;
676 if (AbsDeltaE > 10*
GeV) {
677 G4cout<<
"Energy loss larger than 10 GeV..."<<G4endl;
678 G4cout<<
"E_0: "<<E_0/
GeV<<
" GeV"<<G4endl;
679 G4cout<<
"E_new: "<<E_new/
GeV<<
" GeV"<<G4endl;
680 G4cout<<
"Gamma: "<<IncidentRhadron->GetTotalEnergy()/IncidentRhadron->GetDefinition()->GetPDGMass()<<G4endl;
681 G4cout<<
"x: "<<aPosition.x()/cm<<
" cm"<<G4endl;
684 delete originalIncident;
685 delete originalTarget;
690 ClearNumberOfInteractionLengthLeft();
693 return &aParticleChange;
698 void FullModelHadronicProcess::CalculateMomenta(
699 G4FastVector<G4ReactionProduct,MYGHADLISTSIZE> &vec,
701 const G4HadProjectile *originalIncident,
702 const G4DynamicParticle *originalTarget,
703 G4ReactionProduct &modifiedOriginal,
704 G4Nucleus &targetNucleus,
705 G4ReactionProduct ¤tParticle,
706 G4ReactionProduct &targetParticle,
707 G4bool &incidentHasChanged,
708 G4bool &targetHasChanged,
709 G4bool quasiElastic )
711 FullModelReactionDynamics theReactionDynamics;
714 what = originalIncident->Get4Momentum().vect();
727 theReactionDynamics.TwoBody( vec, vecLen,
728 modifiedOriginal, originalTarget,
729 currentParticle, targetParticle,
730 targetNucleus, targetHasChanged );
736 G4ReactionProduct leadingStrangeParticle;
737 G4bool leadFlag = MarkLeadingStrangeParticle( currentParticle,
739 leadingStrangeParticle );
746 G4bool finishedGenXPt =
false;
747 G4bool annihilation =
false;
748 if( originalIncident->GetDefinition()->GetPDGEncoding() < 0 &&
749 currentParticle.GetMass() == 0.0 && targetParticle.GetMass() == 0.0 )
753 G4double ekcor = 1.0;
754 G4double ek = originalIncident->GetKineticEnergy();
757 const G4double tarmas = originalTarget->GetDefinition()->GetPDGMass();
758 if( ek > 1.0*
GeV )ekcor = 1./(ek/
GeV);
759 const G4double atomicWeight = G4double(targetNucleus.GetN_asInt());
760 ek = 2*tarmas + ek*(1.+ekcor/atomicWeight);
762 G4double tkin = targetNucleus.Cinema( ek );
765 modifiedOriginal.SetKineticEnergy( ekOrg );
768 const G4double twsup[] = { 1.0, 0.7, 0.5, 0.3, 0.2, 0.1 };
769 G4double rand1 = G4UniformRand();
770 G4double rand2 = G4UniformRand();
771 if( (annihilation || (vecLen >= 6) || (modifiedOriginal.GetKineticEnergy()/
GeV >= 1.0)) &&
772 (((originalIncident->GetDefinition() == G4KaonPlus::KaonPlus()) ||
773 (originalIncident->GetDefinition() == G4KaonMinus::KaonMinus()) ||
774 (originalIncident->GetDefinition() == G4KaonZeroLong::KaonZeroLong()) ||
775 (originalIncident->GetDefinition() == G4KaonZeroShort::KaonZeroShort())) &&
776 ((rand1 < 0.5) || (rand2 > twsup[vecLen]))))
778 theReactionDynamics.GenerateXandPt( vec, vecLen,
779 modifiedOriginal, originalIncident,
780 currentParticle, targetParticle,
781 targetNucleus, incidentHasChanged,
782 targetHasChanged, leadFlag,
783 leadingStrangeParticle );
790 G4bool finishedTwoClu =
false;
791 if( modifiedOriginal.GetTotalMomentum()/
MeV < 1.0 )
794 for(G4int i=0; i<vecLen; i++)
delete vec[i];
800 theReactionDynamics.SuppressChargedPions( vec, vecLen,
801 modifiedOriginal, currentParticle,
802 targetParticle, targetNucleus,
803 incidentHasChanged, targetHasChanged );
807 finishedTwoClu = theReactionDynamics.TwoCluster( vec, vecLen,
808 modifiedOriginal, originalIncident,
809 currentParticle, targetParticle,
810 targetNucleus, incidentHasChanged,
811 targetHasChanged, leadFlag,
812 leadingStrangeParticle );
814 catch(G4HadReentrentException aC)
817 throw G4HadReentrentException(__FILE__, __LINE__,
"Failing to calculate momenta");
846 theReactionDynamics.TwoBody( vec, vecLen,
847 modifiedOriginal, originalTarget,
848 currentParticle, targetParticle,
849 targetNucleus, targetHasChanged );
853 G4bool FullModelHadronicProcess::MarkLeadingStrangeParticle(
854 const G4ReactionProduct ¤tParticle,
855 const G4ReactionProduct &targetParticle,
856 G4ReactionProduct &leadParticle )
864 if( (currentParticle.GetMass() >= G4KaonPlus::KaonPlus()->GetPDGMass()) &&
865 (currentParticle.GetDefinition() != G4Proton::Proton()) &&
866 (currentParticle.GetDefinition() != G4Neutron::Neutron()) )
869 leadParticle = currentParticle;
871 else if( (targetParticle.GetMass() >= G4KaonPlus::KaonPlus()->GetPDGMass()) &&
872 (targetParticle.GetDefinition() != G4Proton::Proton()) &&
873 (targetParticle.GetDefinition() != G4Neutron::Neutron()) )
876 leadParticle = targetParticle;
881 void FullModelHadronicProcess::Rotate(G4FastVector<G4ReactionProduct,MYGHADLISTSIZE> &vec, G4int &vecLen)
886 for( i=0; i<vecLen; ++
i )
888 G4ThreeVector momentum = vec[
i]->GetMomentum();
889 momentum = momentum.rotate(rotation, what);
890 vec[
i]->SetMomentum(momentum);
894 const G4DynamicParticle* FullModelHadronicProcess::FindRhadron(G4ParticleChange* aParticleChange)
896 G4int nsec = aParticleChange->GetNumberOfSecondaries();
897 if (nsec==0)
return 0;
899 G4bool
found =
false;
900 while (i!=nsec && !found){
903 if (dynamic_cast<CustomParticle*>(aParticleChange->GetSecondary(i)->GetDynamicParticle()->GetDefinition())!=0) found =
true;
907 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()