From 9530316dd11c0606de57851a6ed4d435c4579f59 Mon Sep 17 00:00:00 2001 From: Szymon Harabasz Date: Sun, 7 Apr 2024 12:35:09 +0200 Subject: [PATCH 1/4] Implemented propagation of input particle ID in the List modus Particle ID (next-to-last column of input file in the Oscar2013 format) was up to now ignored when reading the file. It is now saved in ParticleData. In addition, the method copy_to of ParticleData now copies particle ID if it is not -1. --- .gitignore | 2 ++ input/list/example_list0 | 2 +- src/include/smash/listmodus.h | 2 +- src/include/smash/particledata.h | 3 +++ src/listmodus.cc | 5 +++-- src/tests/listmodus.cc | 6 +++--- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b8233a27b..c61241526 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ build* .cproject .project .settings/ +.idea +cmake-build-debug/ # Convenience directory for your own files that should not be tracked tmp diff --git a/input/list/example_list0 b/input/list/example_list0 index a4d445ab4..f634c45db 100644 --- a/input/list/example_list0 +++ b/input/list/example_list0 @@ -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 diff --git a/src/include/smash/listmodus.h b/src/include/smash/listmodus.h index a362ccce1..168e08985 100644 --- a/src/include/smash/listmodus.h +++ b/src/include/smash/listmodus.h @@ -135,7 +135,7 @@ class ListModus : public ModusDefault { */ 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. diff --git a/src/include/smash/particledata.h b/src/include/smash/particledata.h index 5ade0d38b..9e9701120 100644 --- a/src/include/smash/particledata.h +++ b/src/include/smash/particledata.h @@ -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_; + } } /** diff --git a/src/listmodus.cc b/src/listmodus.cc index f16102943..209352b19 100644 --- a/src/listmodus.cc +++ b/src/listmodus.cc @@ -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 @@ -158,7 +159,7 @@ 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); diff --git a/src/tests/listmodus.cc b/src/tests/listmodus.cc index 4084ad987..90ec1ef1a 100644 --- a/src/tests/listmodus.cc +++ b/src/tests/listmodus.cc @@ -472,7 +472,7 @@ 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++) { @@ -500,7 +500,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++) { @@ -530,5 +530,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); } From 6f2929cacde5fba1bede93841e970742759baf64 Mon Sep 17 00:00:00 2001 From: Szymon Harabasz Date: Tue, 9 Apr 2024 21:10:37 +0200 Subject: [PATCH 2/4] Fixed a cpplint complain about a line too long --- src/listmodus.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/listmodus.cc b/src/listmodus.cc index 209352b19..8877ba65c 100644 --- a/src/listmodus.cc +++ b/src/listmodus.cc @@ -159,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, id); + try_create_particle(*particles, pdgcode, t, x, y, z, + mass, E, px, py, pz, id); } if (particles->size() > 0) { backpropagate_to_same_time(*particles); From 9a99d03ba612e013d85ca5a91cc318396ee67032 Mon Sep 17 00:00:00 2001 From: Szymon Harabasz Date: Tue, 9 Apr 2024 22:08:35 +0200 Subject: [PATCH 3/4] FIxed complains about badly formatted code --- src/listmodus.cc | 4 ++-- src/tests/listmodus.cc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/listmodus.cc b/src/listmodus.cc index 8877ba65c..704af3630 100644 --- a/src/listmodus.cc +++ b/src/listmodus.cc @@ -159,8 +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, id); + try_create_particle(*particles, pdgcode, t, x, y, z, mass, E, px, py, pz, + id); } if (particles->size() > 0) { backpropagate_to_same_time(*particles); diff --git a/src/tests/listmodus.cc b/src/tests/listmodus.cc index 90ec1ef1a..d83541d40 100644 --- a/src/tests/listmodus.cc +++ b/src/tests/listmodus.cc @@ -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(), i); + 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++) { From 156ac46c5c1fb3cdf8995a01a06f860b29b16a43 Mon Sep 17 00:00:00 2001 From: Szymon Harabasz Date: Wed, 10 Apr 2024 11:14:50 +0200 Subject: [PATCH 4/4] Updated Doxygen string in ListModus --- src/include/smash/listmodus.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/smash/listmodus.h b/src/include/smash/listmodus.h index 168e08985..2542cbafd 100644 --- a/src/include/smash/listmodus.h +++ b/src/include/smash/listmodus.h @@ -131,6 +131,7 @@ 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,