71 std::size_t n = ListOfPrimaryAdjParticles.size();
72 index_particle = std::size_t(evt_id) - n * (std::size_t(evt_id) / n);
76 if (ListOfPrimaryAdjParticles[index_particle] ==
nullptr)
79 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
"adj_proton") {
83 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() ==
"adjoint_nucleus") {
84 G4int A = ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass();
96 G4double m0 = ListOfPrimaryFwdParticles[index_particle]->GetPDGMass();
97 G4double ekin = std::sqrt(m0 * m0 + pmag * pmag) - m0;
103 weight_correction = 1.;
105 if (ListOfPrimaryFwdParticles[index_particle] ==
G4Gamma::Gamma() && nb_fwd_gammas_per_event > 1)
107 G4double weight = (1. / nb_fwd_gammas_per_event);
109 for (
G4int i = 0; i < nb_fwd_gammas_per_event - 1; ++i) {
111 newFwdPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
112 newFwdPrimVertex->SetT0(0.);
114 new G4PrimaryParticle(ListOfPrimaryFwdParticles[index_particle], p.x(), p.y(), p.z());
115 newFwdPrimVertex->SetPrimary(aPrimParticle);
116 newFwdPrimVertex->SetWeight(weight);
123 adjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
124 adjPrimVertex->SetT0(0.);
126 new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
128 adjPrimVertex->SetPrimary(aPrimParticle);
134 weight_correction * ComputeEnergyDistWeight(ekin, E1, E2) * adjoint_source_area * pi;
135 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
"adj_gamma") {
138 adjoint_weight = adjoint_weight / nb_adj_primary_gammas_per_event;
139 for (
G4int i = 0; i < nb_adj_primary_gammas_per_event - 1; ++i) {
141 newAdjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
142 newAdjPrimVertex->SetT0(0.);
144 new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
145 newAdjPrimVertex->SetPrimary(aPrimParticle);
146 newAdjPrimVertex->SetWeight(adjoint_weight);
150 else if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
"adj_electron") {
153 adjoint_weight = adjoint_weight / nb_adj_primary_electrons_per_event;
154 for (
G4int i = 0; i < nb_adj_primary_electrons_per_event - 1; ++i) {
156 newAdjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
157 newAdjPrimVertex->SetT0(0.);
159 new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
160 newAdjPrimVertex->SetPrimary(aPrimParticle);
161 newAdjPrimVertex->SetWeight(adjoint_weight);
165 adjPrimVertex->SetWeight(adjoint_weight);
271 ListOfPrimaryFwdParticles.clear();
272 ListOfPrimaryAdjParticles.clear();
273 for (
const auto& iter : PrimariesConsideredInAdjointSim) {
275 G4String fwd_particle_name = iter.first;
276 if (fwd_particle_name !=
"ion") {
278 ListOfPrimaryFwdParticles.push_back(theParticleTable->
FindParticle(fwd_particle_name));
279 ListOfPrimaryAdjParticles.push_back(theParticleTable->
FindParticle(adj_particle_name));
282 if (fwd_ion !=
nullptr) {
283 ion_name = fwd_ion->GetParticleName();
285 ListOfPrimaryFwdParticles.push_back(fwd_ion);
286 ListOfPrimaryAdjParticles.push_back(adj_ion);
289 ListOfPrimaryFwdParticles.push_back(
nullptr);
290 ListOfPrimaryAdjParticles.push_back(
nullptr);
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4ThreeVector GetMomentum() const