18 #include "Geant4/G4VParticleChange.hh" 20 #include "Geant4/G4DynamicParticle.hh" 21 #include "Geant4/G4KaonZeroLong.hh" 22 #include "Geant4/G4KaonZeroShort.hh" 23 #include "Geant4/G4LorentzVector.hh" 24 #include "Geant4/G4ParticleDefinition.hh" 25 #include "Geant4/G4String.hh" 26 #include "Geant4/G4ThreeVector.hh" 27 #include "Geant4/G4Track.hh" 28 #include "Geant4/G4VProcess.hh" 29 #include "Geant4/Randomize.hh" 39 G4VParticleChange* particleChange =
new G4VParticleChange();
41 std::vector<G4Track*> secondaries;
47 for (
unsigned int ii = 0; ii < (
unsigned int)
fNSplit; ii++) {
48 particleChange = pRegProcess->PostStepDoIt(track, step);
50 throw std::runtime_error(
"MuNuclearSplittingProcess::PostStepDoIt(): no particle change");
52 G4int numSec(particleChange->GetNumberOfSecondaries());
53 for (j = 0; j < numSec; j++) {
54 G4Track* newSec =
new G4Track(*(particleChange->GetSecondary(j)));
55 G4String pdgstr = newSec->GetParticleDefinition()->GetParticleName();
56 G4double ke = newSec->GetKineticEnergy() / CLHEP::GeV;
57 G4int pdg = newSec->GetParticleDefinition()->GetPDGEncoding();
58 if (
abs(pdg) == 310 ||
abs(pdg) == 311 ||
abs(pdg) == 3122 ||
abs(pdg) == 2112) {
61 if (pdg == G4KaonZeroShort::KaonZeroShort()->GetPDGEncoding() && G4UniformRand() < 0.50) {
62 pdg = G4KaonZeroLong::KaonZeroLong()->GetPDGEncoding();
63 pdgstr = G4KaonZeroLong::KaonZeroLong()->GetParticleName();
65 newSec->GetMomentum(),
66 TMath::Sqrt(TMath::Power(G4KaonZeroLong::KaonZeroLong()->GetPDGMass(), 2) +
67 TMath::Power(newSec->GetMomentum().mag(), 2)));
68 G4DynamicParticle* newK0L =
new G4DynamicParticle(G4KaonZeroLong::KaonZeroLong(), pK0L);
70 G4Track* newSecK0L =
new G4Track(newK0L, track.GetGlobalTime(), track.GetPosition());
71 secondaries.push_back(newSecK0L);
74 secondaries.push_back(newSec);
77 if (
abs(pdg) == 130 ||
abs(pdg) == 310 ||
abs(pdg) == 311 ||
abs(pdg) == 3122) {
80 std::cout <<
"MuNuclSplProc: Creating " << pdgstr <<
" of Kinetic Energy " << ke
81 <<
" GeV. numSec is " << j << std::endl;
87 particleChange->SetNumberOfSecondaries(secondaries.size());
88 particleChange->SetSecondaryWeightByProcess(
true);
91 while (iter != secondaries.end()) {
92 G4Track* myTrack = *iter;
93 G4String pdgstr = myTrack->GetParticleDefinition()->GetParticleName();
95 G4int pdg = myTrack->GetParticleDefinition()->GetPDGEncoding();
96 if (
abs(pdg) == 130 ||
abs(pdg) == 310 ||
abs(pdg) == 311 ||
abs(pdg) == 3122 ||
100 myTrack->SetWeight(weight);
101 particleChange->AddSecondary(myTrack);
104 return particleChange;
constexpr auto abs(T v)
Returns the absolute value of the argument.
Check of Geant4 to run the LArSoft detector simulation.
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step)