2 #include "G4ProcessManager.hh" 3 #include "G4ParticleTable.hh" 5 #include "G4FermiPhaseSpaceDecay.hh" 7 #include "SimG4Core/CustomPhysics/interface/ToyModelHadronicProcess.hh" 10 #include "SimG4Core/CustomPhysics/interface/HadronicProcessHelper.hh" 15 using namespace CLHEP;
17 ToyModelHadronicProcess::ToyModelHadronicProcess(HadronicProcessHelper * aHelper,
19 G4VDiscreteProcess(processName), m_verboseLevel(0), m_helper(aHelper), m_detachCloud(
true)
21 m_decay =
new G4FermiPhaseSpaceDecay();
24 G4bool ToyModelHadronicProcess::IsApplicable(
const G4ParticleDefinition& aP)
26 return m_helper->applicabilityTester(aP);
29 G4double ToyModelHadronicProcess::GetMicroscopicCrossSection(
const G4DynamicParticle *particle,
30 const G4Element *element,
34 G4double inclusiveCrossSection = m_helper->inclusiveCrossSection(particle,element);
36 if(m_verboseLevel >= 3) {
37 G4cout <<
"ToyModelHadronicProcess: Return cross section " << inclusiveCrossSection
40 return inclusiveCrossSection;
43 G4double ToyModelHadronicProcess::GetMeanFreePath(
const G4Track& aTrack, G4double,
46 G4Material *aMaterial = aTrack.GetMaterial();
47 const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
50 G4int nElements = aMaterial->GetNumberOfElements();
52 const G4double *theAtomicNumDensityVector =
53 aMaterial->GetAtomicNumDensityVector();
54 G4double aTemp = aMaterial->GetTemperature();
56 for( G4int
i=0;
i<nElements; ++
i )
60 sigma += theAtomicNumDensityVector[
i] * xSection;
63 if(sigma > 0.0) { x = 1./sigma; }
67 G4VParticleChange* ToyModelHadronicProcess::PostStepDoIt(
const G4Track&
track,
70 const G4TouchableHandle& thisTouchable(track.GetTouchableHandle());
73 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
74 m_particleChange.Initialize(track);
77 const G4DynamicParticle* incidentRHadron = track.GetDynamicParticle();
82 G4DynamicParticle* cloudParticle =
new G4DynamicParticle();
85 if(CustomIncident==
nullptr) {
86 G4cout <<
"ToyModelHadronicProcess::PostStepDoIt Definition of particle cloud not available!" 89 cloudParticle->SetDefinition(CustomIncident->
GetCloud());
93 double scale = cloudParticle->GetDefinition()->GetPDGMass()
94 /incidentRHadron->GetDefinition()->GetPDGMass();
95 G4LorentzVector cloudMomentum(incidentRHadron->GetMomentum()*
scale,
96 cloudParticle->GetDefinition()->GetPDGMass());
97 G4LorentzVector gluinoMomentum(incidentRHadron->GetMomentum()*(1.-
scale),
100 cloudParticle->Set4Momentum(cloudMomentum);
102 const G4DynamicParticle *incidentParticle;
103 if(! m_detachCloud) { incidentParticle = incidentRHadron; }
104 else { incidentParticle = cloudParticle; }
106 if(m_verboseLevel >= 3)
108 G4cout <<
"ToyModelHadronicProcess::PostStepDoIt After scaling " << G4endl;
109 G4cout <<
" RHadron "<<incidentRHadron->GetDefinition()->GetParticleName()
110 <<
" pdgmass= " << incidentRHadron->GetDefinition()->GetPDGMass() /
GeV 111 <<
" P= " << incidentRHadron->Get4Momentum() /
GeV<<
" mass= " 112 << incidentRHadron->Get4Momentum().m() /
GeV <<G4endl;
113 G4cout <<
" Cloud "<<cloudParticle->GetDefinition()->GetParticleName()
114 <<
" pdgmass= " << cloudParticle->GetDefinition()->GetPDGMass() /
GeV 115 <<
" P= " << cloudParticle->Get4Momentum() /
GeV<<
" mass= " 116 << cloudParticle->Get4Momentum().m() /
GeV <<G4endl;
117 G4cout <<
" Incident pdgmass= " 118 << incidentParticle->GetDefinition()->GetPDGMass() /
GeV 119 <<
" P= " << incidentParticle->Get4Momentum() /
GeV<<
" mass= " 120 << incidentParticle->Get4Momentum().m() /
GeV <<G4endl;
123 const G4ThreeVector&
position = track.GetPosition();
124 std::vector<G4ParticleDefinition*> newParticles;
125 std::vector<G4ParticleDefinition*> newParticlesRHadron;
128 G4ParticleDefinition* targetParticle;
129 HadronicProcessHelper::ReactionProduct reactionProduct =
130 m_helper->finalState(incidentRHadron,track.GetMaterial(),targetParticle);
133 for(HadronicProcessHelper::ReactionProduct::iterator it = reactionProduct.begin();
134 it != reactionProduct.end() ;
137 G4ParticleDefinition * productDefinition =theParticleTable->FindParticle(*it);
138 newParticlesRHadron.push_back(productDefinition);
141 if( cProd!=
nullptr && m_detachCloud)
142 productDefinition=cProd->
GetCloud();
144 newParticles.push_back(productDefinition);
147 int numberOfSecondaries = reactionProduct.size();
149 if(m_verboseLevel >= 2) {
150 G4cout <<
"ToyModelHadronicProcess::PostStepDoIt N secondaries: " 151 << numberOfSecondaries << G4endl;
155 G4LorentzVector sum4Momentum = incidentParticle->Get4Momentum();
156 G4LorentzVector target4Momentum(0,0,0,targetParticle->GetPDGMass());
157 sum4Momentum += target4Momentum;
158 G4ThreeVector cmBoost = sum4Momentum.boostVector();
159 G4double M = sum4Momentum.m();
161 if(m_verboseLevel >= 2) {
162 G4cout <<
"ToyModelHadronicProcess::PostStepDoIt Kinematics in GeV: " << G4endl
163 <<
" Boost = " << cmBoost /
GeV<< G4endl
164 <<
" 4P Lab = " << sum4Momentum /
GeV << G4endl
165 <<
" Ecm = " << M /
GeV << G4endl;
167 std::vector<G4double>
m;
170 for(
int ip=0; ip<numberOfSecondaries; ++ip)
172 m.push_back(newParticles[ip]->GetPDGMass());
175 std::vector<G4LorentzVector*>* fourMomenta = m_decay->Decay(M, m);
180 m_particleChange.SetNumberOfSecondaries(numberOfSecondaries);
181 m_particleChange.ProposeTrackStatus(fStopAndKill);
182 if(m_verboseLevel >= 3) {
183 G4cout <<
"Incident does not survive: stopAndKill + set num secondaries to " 184 << numberOfSecondaries << G4endl;
187 for (
int ip=0; ip <numberOfSecondaries; ++ip) {
189 (*fourMomenta)[ip]->boost(cmBoost);
192 if (newParticlesRHadron[ip]==incidentRHadron->GetDefinition()) {
194 if(m_verboseLevel >= 3) {
195 G4cout <<
"ToyModelHadronicProcess::PostStepDoIt Add gluino momentum " 196 << *((*fourMomenta)[ip])/
GeV <<
"(m="<< (*fourMomenta)[ip]->m()/
GeV 197 <<
") + " <<gluinoMomentum/
GeV<<G4endl;
199 G4LorentzVector p4_new = gluinoMomentum + *((*fourMomenta)[ip]);
200 G4ThreeVector momentum = p4_new.vect();
201 double rhMass = newParticlesRHadron[ip]->GetPDGMass();
202 (*fourMomenta)[ip]->setVectM(momentum,rhMass);
203 if(m_verboseLevel >= 3) {
204 G4cout <<
" = " << *((*fourMomenta)[ip])/
GeV <<
"(m="<< (*fourMomenta)[ip]->m() /
GeV 205 <<
") vs. "<<rhMass/
GeV 211 G4DynamicParticle* productDynParticle =
new G4DynamicParticle();
213 productDynParticle->SetDefinition(newParticlesRHadron[ip]);
215 productDynParticle->Set4Momentum(*((*fourMomenta)[ip]));
217 if(m_verboseLevel >= 3) {
218 G4cout <<
"ToyModelHadronicProcess::PostStepDoIt: " << *((*fourMomenta)[ip])/
GeV 219 <<
"(m="<< (*fourMomenta)[ip]->m()/
GeV<<
") " 220 << newParticlesRHadron[ip]->GetParticleName()
224 G4Track* productTrack =
new G4Track(productDynParticle,
225 track.GetGlobalTime(),
227 productTrack->SetTouchableHandle(thisTouchable);
228 m_particleChange.AddSecondary(productTrack);
229 delete (*fourMomenta)[ip];
234 ClearNumberOfInteractionLengthLeft();
235 return &m_particleChange;
G4ParticleDefinition * GetCloud()
G4double GetMicroscopicCrossSection(const G4DynamicParticle *aParticle, const G4Element *anElement, G4double aTemp)
G4ParticleDefinition * GetSpectator()
static int position[264][3]