-
Notifications
You must be signed in to change notification settings - Fork 605
Extend ParticleProductionFilter to support multiple particle types #3780
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
base: develop
Are you sure you want to change the base?
Conversation
pshriwise
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!! New valuable capability fits pretty cleanly into the tally system.
A few minor inline comments from me and one larger thought:
On the C++ side the ParticleProductionFilter inherits from EnergyFilter, but we re-implement almost every method of the parent class. From what I can see, what is reused from the EnergyFilter class is the bins_ vector and use of the set_bins method, which sets the matches_transport_groups attribute that isn't used in the new class. In contrast to the EnergyOutFilter that re-implements only a couple of methods of the EnergyFilter, this inheritance feels more awkward and like it might warrant it's own set of source files. Not a deal breaker for me on merging this, just sharing observations and something to consider.
|
@pshriwise Your comments have been addressed. Let me know if you have any further requests! |
Description
This PR extends
ParticleProductionFilterto allow tallying production of multiple secondary particle types in a single filter, avoiding the need for multiple tallies when tracking different secondary particles. The constructor has been changed fromParticleProductionFilter(particle, bins)toParticleProductionFilter(particles, energies=None), whereparticlesaccepts a single particle or list of particles, andenergiesis now optional (defaulting toNonefor no energy binning). The filter becomes two-dimensional with shape(n_particles, n_energy_bins)and bins are flattened asparticle_index * n_energy_bins + energy_bin. Using the filter to get particle production rates looks like:One issue that needed to be fixed was that the "events" score was hard-coded to be a value of 1.0 per tally contribution regardless of filter weights. Because
ParticleProductionFiltersets the filter weight to the weight of the secondary particle, that needs to be accounted for. I've updated the logic so that the unity value gets multiplied by the filter weight before accumulation.Checklist