Correctly score pulse height tally when no cell filter is present#3821
Correctly score pulse height tally when no cell filter is present#3821paulromano merged 4 commits intoopenmc-dev:developfrom
Conversation
|
Thanks for your work again. I am not sure if we need this. Why would you want to know the pulse-height over the entire geometry when no CellFilter is provided? |
|
I discovered this unexpected behavior while trying to test a simple example containing one cell. This can be useful for example when you have a model of one cell that is the detector vacuum boundary conditions and a fixed source. Now you have to specifiy a cell filter with that one cell as a workaround. |
|
Each filter must have the default "neutral" form |
…in tally_scoring.cpp
paulromano
left a comment
There was a problem hiding this comment.
Thanks @GuySten. I've made three refinements to improve code clarity and correctness:
- Eliminated code duplication in the
SCORE_PULSE_HEIGHTcase by consolidating the two branches into a single loop with a ternary operator for the cell index. - Fixed a bug in
tally_scoring.cppwhere assigning to a mutable reference was inadvertently mutatingmodel::pulse_height_cells, which could corrupt scoring for multiple pulse-height tallies. This now uses a const reference to safely bind either the filter's cells or the global vector. - Changed
pulse_height_cellsfromvector<int>tovector<int32_t>to matchCellFilter::cells()for consistency.
Description
Currently when no CellFilter is specified, pulse height tally results are always 0.
This PR fix that and now when no cell filter is specified, all the geometry is scored to.
Checklist
I have followed the style guidelines for Python source files (if applicable)I have made corresponding changes to the documentation (if applicable)