@@ -2672,56 +2672,49 @@ void score_pulse_height_tally(Particle& p, const vector<int>& tallies)
26722672 for (auto i_tally : tallies) {
26732673 auto & tally {*model::tallies[i_tally]};
26742674
2675- // Determine all CellFilter in the tally
2676- for (const auto & filter : tally.filters ()) {
2677- auto cell_filter =
2678- dynamic_cast <CellFilter*>(model::tally_filters[filter].get ());
2679- if (cell_filter != nullptr ) {
2680-
2681- const auto & cells = cell_filter->cells ();
2682- // Loop over all cells in the CellFilter
2683- for (auto cell_index = 0 ; cell_index < cells.size (); ++cell_index) {
2684- int cell_id = cells[cell_index];
2685-
2686- // Temporarily change cell of particle
2687- p.n_coord () = 1 ;
2688- p.coord (0 ).cell () = cell_id;
2689-
2690- // Determine index of cell in model::pulse_height_cells
2691- auto it = std::find (model::pulse_height_cells.begin (),
2692- model::pulse_height_cells.end (), cell_id);
2693- int index = std::distance (model::pulse_height_cells.begin (), it);
2694-
2695- // Temporarily change energy of particle to pulse-height value
2696- p.E_last () = p.pht_storage ()[index];
2697-
2698- // Initialize an iterator over valid filter bin combinations. If
2699- // there are no valid combinations, use a continue statement to ensure
2700- // we skip the assume_separate break below.
2701- auto filter_iter = FilterBinIter (tally, p);
2702- auto end = FilterBinIter (tally, true , &p.filter_matches ());
2703- if (filter_iter == end)
2704- continue ;
2675+ // Find CellFilter in the tally (if any) to determine cells to loop over
2676+ const auto * cell_filter = tally.get_filter <CellFilter>();
2677+ const auto & cells =
2678+ cell_filter ? cell_filter->cells () : model::pulse_height_cells;
2679+
2680+ for (auto cell_id : cells) {
2681+ // Temporarily change cell of particle
2682+ p.n_coord () = 1 ;
2683+ p.coord (0 ).cell () = cell_id;
2684+
2685+ // Determine index of cell in model::pulse_height_cells
2686+ auto it = std::find (model::pulse_height_cells.begin (),
2687+ model::pulse_height_cells.end (), cell_id);
2688+ int index = std::distance (model::pulse_height_cells.begin (), it);
2689+
2690+ // Temporarily change energy of particle to pulse-height value
2691+ p.E_last () = p.pht_storage ()[index];
2692+
2693+ // Initialize an iterator over valid filter bin combinations. If
2694+ // there are no valid combinations, use a continue statement to ensure
2695+ // we skip the assume_separate break below.
2696+ auto filter_iter = FilterBinIter (tally, p);
2697+ auto end = FilterBinIter (tally, true , &p.filter_matches ());
2698+ if (filter_iter == end)
2699+ continue ;
27052700
2706- // Loop over filter bins.
2707- for (; filter_iter != end; ++filter_iter) {
2708- auto filter_index = filter_iter.index_ ;
2709- auto filter_weight = filter_iter.weight_ ;
2701+ // Loop over filter bins.
2702+ for (; filter_iter != end; ++filter_iter) {
2703+ auto filter_index = filter_iter.index_ ;
2704+ auto filter_weight = filter_iter.weight_ ;
27102705
2711- // Loop over scores.
2712- for (auto score_index = 0 ; score_index < tally.scores_ .size ();
2713- ++score_index) {
2706+ // Loop over scores.
2707+ for (auto score_index = 0 ; score_index < tally.scores_ .size ();
2708+ ++score_index) {
27142709#pragma omp atomic
2715- tally.results_ (filter_index, score_index, TallyResult::VALUE) +=
2716- filter_weight;
2717- }
2718- }
2719-
2720- // Reset all the filter matches for the next tally event.
2721- for (auto & match : p.filter_matches ())
2722- match.bins_present_ = false ;
2710+ tally.results_ (filter_index, score_index, TallyResult::VALUE) +=
2711+ filter_weight;
27232712 }
27242713 }
2714+
2715+ // Reset all the filter matches for the next tally event.
2716+ for (auto & match : p.filter_matches ())
2717+ match.bins_present_ = false ;
27252718 }
27262719 // Restore cell/energy
27272720 p.n_coord () = orig_n_coord;
0 commit comments