Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented propagation of input particle ID in the List modus #54

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ build*
.cproject
.project
.settings/
.idea
cmake-build-debug/

# Convenience directory for your own files that should not be tracked
tmp
2 changes: 1 addition & 1 deletion input/list/example_list0
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
5 0.637583 -1.16592 0.82217 0.938 1.19144658 -0.059522985 -0.195290853 -0.705704936 2212 21 1
5 -1.89993 1.91771 1.7204 0.938 1.15430337 -0.629265864 0.0114317572 0.237625871 2112 29 0
5 1.55926 0.103756 -1.06588 0.938 1.10036086 -0.146263801 -0.149655463 -0.535873276 2212 23 1
5 -1.92134 -2.26889 -1.12867 0.138 0.380250275 -0.345997406 -0.0467484962 0.0603874561 111 27 0
5 -1.92134 -2.26889 -1.12867 0.138 0.380250275 -0.345997406 -0.0467484962 0.0603874561 111 123027 0
5 -0.96148 1.48135 0.447194 0.138 0.229317536 -0.0529681583 0.110554043 -0.13606877 211 31 1
# event 1 end 0 impact 0.000
# event 2 out 28
Expand Down
3 changes: 2 additions & 1 deletion src/include/smash/listmodus.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ class ListModus : public ModusDefault {
* \param[in] px x-component of momentum of added particle
* \param[in] py y-component of momentum of added particle
* \param[in] pz z-component of momentum of added particle
* \param[in] id id of added particle
* \param[out] particles structure, to which the particle is added
*/
void try_create_particle(Particles &particles, PdgCode pdgcode, double t,
double x, double y, double z, double mass, double E,
double px, double py, double pz);
double px, double py, double pz, int id);

/** \ingroup exception
* Used when external particle list cannot be found.
Expand Down
3 changes: 3 additions & 0 deletions src/include/smash/particledata.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ class ParticleData {
dst.initial_xsec_scaling_factor_ = initial_xsec_scaling_factor_;
dst.begin_formation_time_ = begin_formation_time_;
dst.belongs_to_ = belongs_to_;
if (id_ >= 0) {
dst.id_ = id_;
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/listmodus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ void ListModus::backpropagate_to_same_time(Particles &particles) {
void ListModus::try_create_particle(Particles &particles, PdgCode pdgcode,
double t, double x, double y, double z,
double mass, double E, double px, double py,
double pz) {
double pz, int id) {
try {
ParticleData new_particle =
create_valid_smash_particle_matching_provided_quantities(
pdgcode, mass, {t, x, y, z}, {E, px, py, pz}, LList,
warn_about_mass_discrepancy_, warn_about_off_shell_particles_);
new_particle.set_id(id);
particles.insert(new_particle);
} catch (ParticleType::PdgNotFoundFailure &) {
logg[LList].warn() << "SMASH does not recognize pdg code " << pdgcode
Expand Down Expand Up @@ -158,7 +159,8 @@ double ListModus::initial_conditions(Particles *particles,
logg[LList].error() << "Charge of pdg = " << pdgcode << " != " << charge;
throw std::invalid_argument("Inconsistent input (charge).");
}
try_create_particle(*particles, pdgcode, t, x, y, z, mass, E, px, py, pz);
try_create_particle(*particles, pdgcode, t, x, y, z, mass, E, px, py, pz,
id);
}
if (particles->size() > 0) {
backpropagate_to_same_time(*particles);
Expand Down
7 changes: 4 additions & 3 deletions src/tests/listmodus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ TEST(try_create_particle_func) {
FourVector r = smashon.position(), p = smashon.momentum();
PdgCode pdg = smashon.pdgcode();
list_modus.try_create_particle(particles, pdg, r.x0(), r.x1(), r.x2(),
r.x3(), m0, p.x0(), p.x1(), p.x2(), p.x3());
r.x3(), m0, p.x0(), p.x1(), p.x2(), p.x3(),
i);
}
plist_fin = particles.copy_to_vector();
for (int i = 0; i < npart; i++) {
Expand Down Expand Up @@ -500,7 +501,7 @@ TEST(try_create_particle_func) {
const auto creation_energy = p.x0() + (i >= npart);
list_modus.try_create_particle(particles, pdg, r.x0(), r.x1(), r.x2(),
r.x3(), creation_mass, creation_energy,
p.x1(), p.x2(), p.x3());
p.x1(), p.x2(), p.x3(), i);
}
plist_fin = particles.copy_to_vector();
for (int i = 0; i < npart; i++) {
Expand Down Expand Up @@ -530,5 +531,5 @@ TEST_CATCH(create_particle_with_nan, std::invalid_argument) {
// Create a particle with either a NAN value in the position
// to trigger an invalid_argument error.
list_modus.try_create_particle(particles, pdg, NAN, r.x1(), r.x2(), r.x3(),
m0, p.x0(), p.x1(), p.x2(), p.x3());
m0, p.x0(), p.x1(), p.x2(), p.x3(), 0);
}
Loading