69{
71 std::size_t
n = ListOfPrimaryAdjParticles.size();
72 index_particle = std::size_t(evt_id) -
n * (std::size_t(evt_id) /
n);
73
76 if (ListOfPrimaryAdjParticles[index_particle] == nullptr)
78
79 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_proton") {
80 E1 = EminIon;
81 E2 = EmaxIon;
82 }
83 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() == "adjoint_nucleus") {
84 G4int A = ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass();
87 }
88
90
92
96 G4double m0 = ListOfPrimaryFwdParticles[index_particle]->GetPDGMass();
97 G4double ekin = std::sqrt(m0 * m0 + pmag * pmag) - m0;
98
100
102
103 weight_correction = 1.;
104
105 if (ListOfPrimaryFwdParticles[index_particle] ==
G4Gamma::Gamma() && nb_fwd_gammas_per_event > 1)
106 {
107 G4double weight = (1. / nb_fwd_gammas_per_event);
109 for (
G4int i = 0; i < nb_fwd_gammas_per_event - 1; ++i) {
110 auto newFwdPrimVertex = new G4PrimaryVertex();
111 newFwdPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
112 newFwdPrimVertex->SetT0(0.);
113 auto aPrimParticle =
114 new G4PrimaryParticle(ListOfPrimaryFwdParticles[index_particle], p.x(), p.y(), p.z());
115 newFwdPrimVertex->SetPrimary(aPrimParticle);
116 newFwdPrimVertex->SetWeight(weight);
118 }
119 }
120
121
122 auto adjPrimVertex = new G4PrimaryVertex();
123 adjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
124 adjPrimVertex->SetT0(0.);
125 auto aPrimParticle =
126 new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
127
128 adjPrimVertex->SetPrimary(aPrimParticle);
130
131
134 weight_correction * ComputeEnergyDistWeight(ekin, E1, E2) * adjoint_source_area *
pi;
135 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_gamma") {
136
137
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) {
140 auto newAdjPrimVertex = new G4PrimaryVertex();
141 newAdjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
142 newAdjPrimVertex->SetT0(0.);
143 aPrimParticle =
144 new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
145 newAdjPrimVertex->SetPrimary(aPrimParticle);
146 newAdjPrimVertex->SetWeight(adjoint_weight);
148 }
149 }
150 else if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_electron") {
151
152
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) {
155 auto newAdjPrimVertex = new G4PrimaryVertex();
156 newAdjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
157 newAdjPrimVertex->SetT0(0.);
158 aPrimParticle =
159 new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
160 newAdjPrimVertex->SetPrimary(aPrimParticle);
161 newAdjPrimVertex->SetWeight(adjoint_weight);
163 }
164 }
165 adjPrimVertex->SetWeight(adjoint_weight);
166
167
171}
CLHEP::Hep3Vector G4ThreeVector
static G4AdjointPrimaryGenerator * GetInstance()
void GenerateFwdPrimaryVertex(G4Event *anEvt, G4ParticleDefinition *adj_part, G4double E1, G4double E2)
void ClearEndOfAdjointTrackInfoVectors()
void SetAdjointTrackingMode(G4bool aBool)
G4double GetAdjointSourceArea()
void ResetDidOneAdjPartReachExtSourceDuringEvent()
static G4AdjointSimManager * GetInstance()
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
void AddPrimaryVertex(G4PrimaryVertex *aPrimaryVertex)
G4ThreeVector GetMomentum() const
G4ThreeVector GetPosition() const
void SetWeight(G4double w)
G4PrimaryParticle * GetPrimary(G4int i=0) const