Skip to content

Commit

Permalink
Change SecondaryParticleRecord::Finalize so that it is finalizing the…
Browse files Browse the repository at this point in the history
… secondary particle properties in the parent InteractionRecord. Use the SecondaryParticleRecord::Finalize within CrossSectionDistributionRecord::Finalize
  • Loading branch information
austinschneider committed Feb 24, 2024
1 parent 9163ede commit cbb6e76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
27 changes: 12 additions & 15 deletions projects/dataclasses/private/InteractionRecord.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ void PrimaryDistributionRecord::Finalize(InteractionRecord & record) const {
/////////////////////////////////////////

SecondaryParticleRecord::SecondaryParticleRecord(InteractionRecord const & record, size_t secondary_index) :
secondary_index(secondary_index),
id((record.secondary_ids.size() > secondary_index and record.secondary_ids.at(secondary_index)) ? (record.secondary_ids.at(secondary_index)) : (ParticleID::GenerateID())),
type(record.signature.secondary_types.at(secondary_index)),
initial_position(record.interaction_vertex)
Expand Down Expand Up @@ -548,12 +549,11 @@ void SecondaryParticleRecord::UpdateMomentum() const {
}

void SecondaryParticleRecord::Finalize(InteractionRecord & record) const {
record.primary_id = id;
record.signature.primary_type = type;
record.primary_initial_position = initial_position;
record.primary_mass = GetMass();
record.primary_momentum = GetFourMomentum();
record.primary_helicity = GetHelicity();
assert(record.signature.secondary_types.at(secondary_index) == type);
record.secondary_ids.at(secondary_index) = GetID();
record.secondary_masses.at(secondary_index) = GetMass();
record.secondary_momenta.at(secondary_index) = GetFourMomentum();
record.secondary_helicities.at(secondary_index) = GetHelicity();
}

/////////////////////////////////////////
Expand Down Expand Up @@ -678,16 +678,13 @@ void CrossSectionDistributionRecord::Finalize(InteractionRecord & record) const

record.interaction_parameters = interaction_parameters;

record.secondary_ids.clear();
record.secondary_masses.clear();
record.secondary_momenta.clear();
record.secondary_helicities.clear();
record.secondary_ids.resize(secondary_particles.size());
record.secondary_masses.resize(secondary_particles.size());
record.secondary_momenta.resize(secondary_particles.size());
record.secondary_helicities.resize(secondary_particles.size());

for(SecondaryParticleRecord const & secondary: secondary_particles) {
record.secondary_ids.push_back(secondary.GetID());
record.secondary_masses.push_back(secondary.GetMass());
record.secondary_momenta.push_back(secondary.GetFourMomentum());
record.secondary_helicities.push_back(secondary.GetHelicity());
for(SecondaryParticleRecord const & secondary : secondary_particles) {
secondary.Finalize(record);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class PrimaryDistributionRecord {

class SecondaryParticleRecord {
public:
size_t const secondary_index;
ParticleID const id;
ParticleType const & type;
std::array<double, 3> const & initial_position;
Expand Down

0 comments on commit cbb6e76

Please sign in to comment.