Skip to content

Commit 8a2c502

Browse files
author
bhgomes
committed
add soft process
1 parent ef56a2a commit 8a2c502

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

src/physics/PythiaGenerator.cc

+35-12
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,43 @@ Pythia8::Pythia* _create_pythia(std::vector<std::string>* settings,
118118
}
119119
//----------------------------------------------------------------------------------------------
120120

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______________________________________________________
122147
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) {
124151
ParticleVector out;
152+
for (int i = 0; i < process.size(); ++i)
153+
_push_back_convert_if(out, process[i], predicate);
125154
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);
135158
}
136159
return out;
137160
}
@@ -151,7 +174,7 @@ void PythiaGenerator::GeneratePrimaryVertex(G4Event* event) {
151174
++_counter;
152175
_pythia->next();
153176

154-
_last_event = _convert_pythia_event(_pythia->process, [&](const auto& next) {
177+
_last_event = _convert_pythia_event(_pythia->process, _pythia->event, [&](const auto& next) {
155178
for (const auto& entry : _propagation_list)
156179
if (next.id == entry.id)
157180
return true;

0 commit comments

Comments
 (0)