@@ -118,20 +118,43 @@ Pythia8::Pythia* _create_pythia(std::vector<std::string>* settings,
118
118
}
119
119
// ----------------------------------------------------------------------------------------------
120
120
121
- // __Find Particle in Event______________________________________________________________________
121
+ // __Convert Pythia Particle to Particle_________________________________________________________
122
+ Particle _convert_particle (Pythia8::Particle& particle) {
123
+ Particle out{particle.id (),
124
+ particle.tProd () * mm / c_light,
125
+ particle.zProd () * mm,
126
+ particle.yProd () * mm,
127
+ -particle.xProd () * mm + 81 *m};
128
+ out.set_pseudo_lorentz_triplet (particle.pT () * GeVperC, particle.eta (), particle.phi () * rad);
129
+ return out;
130
+ }
131
+ // ----------------------------------------------------------------------------------------------
132
+
133
+ // __Convert and Pushback Pythia8 Particle if Predicate__________________________________________
134
+ template <class Predicate >
135
+ bool _push_back_convert_if (ParticleVector& out,
136
+ Pythia8::Particle& particle,
137
+ Predicate predicate) {
138
+ const auto next = _convert_particle (particle);
139
+ const auto passed_selection = predicate (next);
140
+ if (passed_selection)
141
+ out.push_back (next);
142
+ return passed_selection;
143
+ }
144
+ // ----------------------------------------------------------------------------------------------
145
+
146
+ // __Convert Pythia Hard and Soft Processes______________________________________________________
122
147
template <class Predicate >
123
- ParticleVector _convert_pythia_event (Pythia8::Event& event, Predicate predicate) {
148
+ ParticleVector _convert_pythia_event (Pythia8::Event& process,
149
+ Pythia8::Event& event,
150
+ Predicate predicate) {
124
151
ParticleVector out;
152
+ for (int i = 0 ; i < process.size (); ++i)
153
+ _push_back_convert_if (out, process[i], predicate);
125
154
for (int i = 0 ; i < event.size (); ++i) {
126
- const auto & particle = event[i];
127
- Particle next{particle.id (),
128
- particle.tProd () * mm / c_light,
129
- particle.zProd () * mm,
130
- particle.yProd () * mm,
131
- -particle.xProd () * mm + 81 *m};
132
- next.set_pseudo_lorentz_triplet (particle.pT () * GeVperC, particle.eta (), particle.phi () * rad);
133
- if (predicate (next))
134
- out.push_back (next);
155
+ if (!event[i].isFinal ())
156
+ continue ;
157
+ _push_back_convert_if (out, event[i], predicate);
135
158
}
136
159
return out;
137
160
}
@@ -151,7 +174,7 @@ void PythiaGenerator::GeneratePrimaryVertex(G4Event* event) {
151
174
++_counter;
152
175
_pythia->next ();
153
176
154
- _last_event = _convert_pythia_event (_pythia->process , [&](const auto & next) {
177
+ _last_event = _convert_pythia_event (_pythia->process , _pythia-> event , [&](const auto & next) {
155
178
for (const auto & entry : _propagation_list)
156
179
if (next.id == entry.id )
157
180
return true ;
0 commit comments