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

New record types and new injector inheritance #49

Merged
merged 147 commits into from
Feb 26, 2024
Merged

Conversation

austinschneider
Copy link
Collaborator

@austinschneider austinschneider commented Jan 26, 2024

Apologies in advance because this is another one of those (unfathomably large) PRs.

The original goal of this PR was to add serialization tests.

PR goals

The goal of this PR is to add new record types that:

  1. restrict what can be modified in the interaction record by an injection distribution or cross section
  2. and allow properties of the InteractionRecord to be less restricted in what order they are set by injection distributions

New record classes

This resulted in the creation of four new record classes:

  1. PrimaryDistributionRecord: passed to Sample method of primary injection distributions
  2. SecondaryParticleRecord: to be used within the next record type
  3. CrossSectionDistributionRecord: to be passed to the SampleFinalState method of the cross section and decay classes
  4. SecondaryDistributionRecord: to be passed to the Sample method of secondary injection distributions

These classes provide methods to set the appropriate properties of InteractionRecord at each stage of the injection.
For example:

  • PrimaryDistributionRecord is constructed with a primary particle type, and has methods for setting various properties of the primary particle
  • Getter methods of PrimaryDistributionRecord first check if that property has been set previously, attempt to compute the property from other set properties, and finally throw an error if the property has not been set and cannot be computed
  • Multiple avenues are offered for setting properties, for example, the four-momentum, direction, energy, and mass all have setter/getter methods.

This behavior allows primary injection distributions to be ordered irrespective of the internal representation used by InteractionRecord, and now throws an error when un-available information is requested instead of silently returning uninitialized data.

Injection distribution inheritance

Originally the primary and secondary injection distribution both inherited from WeightableDistribution had Sample methods that accepted an InteractionRecord to modify directly. Switching to the new record types (PrimaryDistributionRecord and SecondaryDistributionRecord) requires changing this inheritance structure to enforce the Sample methods accepting the new record types.

Primary and secondary injection distributions now inherit from PrimaryInjectionDistribution and SecondaryInjectionDistribution, respectively, which require the implementation of Sample methods that accept the correct types.

Process changes

Splitting the inheritance structure for the injection distributions also required splitting other types:

  • InjectionProcess --> PrimaryInjectionProcess + SecondaryInjectionProcess
  • LeptonProcessWeighter --> PrimaryProcessWeighter + SecondaryProcessWeighter
    The primary_type set in PrimaryInjectionProcess is now used to set the primary type in PrimaryDistributionRecord

Injection changes

Other small changes have been made to the Injector class

  • The stopping condition function now accepts a parent InteractionTreeDatum and an integer corresponding to the proposed secondary
  • Population of secondary interactions has been simplified
  • Injector constructs new record classes before passing them to primary/secondary injection distributions and CrossSection/Decay classes
  • Injector calls the Finalize method of the new record classes to copy information from the new record classes into the InteractionRecord
  • Removed SampleNeutrissimoDecay

Cross section changes

The CrossSection class now implements a TotalCrossSectionAllFinalStates method to support cross section instances that have multiple final states

Distribution changes

  • SecondaryVertexDistribution moved and split into SecondaryPhysicalVertexDistribution and SecondaryBoundedVertexDistribution which inherit from SecondaryInjectionDistribution and SecondaryVertexPositionDistribution
  • The SamplePosition method of the primary VertexPositionDistribution now returns both the initial position and vertex of the primary particle so they can both be set in the Sample method
  • PrimaryInjector removed in favor of a PrimaryMass distribution. We might want to consider changing the generation probability to always return 1.0 so we can support weighting between mass dependent cross sections.

Particle changes

  • The Particle class has been re-written to store information in a useful format, and is now used as an interface for SecondaryParticleRecord
  • The ParticleType enum is now defined outside of the Particle class so it is not necessary to write LI::dataclasses::Particle::ParticleType
  • Added some convenience maps for converting to/from strings
  • The ParticleType enum is now defined using X-macros so that the enum definition, pybindings, and convenience maps are always consistent
  • Defined a new ParticleID class to uniquely identify particles and added a particle id field to InteractionRecord

Record changes

  • Removed DecayRecord
  • Added ParticleID id; and std::array<double, 3> primary_initial_position; to InteractionRecord

@austinschneider austinschneider added the enhancement New feature or request label Jan 26, 2024
@austinschneider austinschneider self-assigned this Jan 26, 2024
@austinschneider austinschneider marked this pull request as ready for review February 14, 2024 18:38
@austinschneider
Copy link
Collaborator Author

@nickkamp1 this PR should be good to go now. The weighting/assertion issue was caused by a mistake I made in adding the secondary particle records to the InteractionTree. I was calling the .add_entry method without passing in the parent...

Copy link
Collaborator

@nickkamp1 nickkamp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks mostly good to go up to the handful of comments I left. Once those are addressed, I think this is ready to merge

@austinschneider
Copy link
Collaborator Author

@nickkamp1 the new commits have a few fixes related to your comments which should all be addressed now. The only other change I made is removing the Particle interface from SecondaryParticleRecord and CrossSectionDistributionRecord. I submitted a couple issues that I noticed which checking things, but I think those are likely out of scope for this PR.

@nickkamp1
Copy link
Collaborator

@nickkamp1 the new commits have a few fixes related to your comments which should all be addressed now. The only other change I made is removing the Particle interface from SecondaryParticleRecord and CrossSectionDistributionRecord. I submitted a couple issues that I noticed which checking things, but I think those are likely out of scope for this PR.

Looks good, approving!

Copy link
Collaborator

@nickkamp1 nickkamp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the last updates, approved!

@austinschneider austinschneider merged commit ffe1881 into main Feb 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DarkNews outputs nan momenta for secondaries of FermionSinglePhotonDecay
2 participants