From 5d39b61bbdc39fc2c1cdb98810d51d361b3a69d1 Mon Sep 17 00:00:00 2001 From: William Johnson Date: Fri, 3 May 2024 13:33:16 -0700 Subject: [PATCH] Fix bug in which samples to correct peaks for energy calibration. Previously, for multi-record files, was checking if all the affected sample numbers were in the peaks samples numbers. But now checks for all the peaks sample numbers, that they are being energy adjusted (an inversion of check). --- InterSpec/EnergyCalTool.h | 6 +++--- src/EnergyCalTool.cpp | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/InterSpec/EnergyCalTool.h b/InterSpec/EnergyCalTool.h index 8f5ac498..d81cb3ba 100644 --- a/InterSpec/EnergyCalTool.h +++ b/InterSpec/EnergyCalTool.h @@ -146,8 +146,8 @@ enum class MoreActionsIndex : int NumMoreActionsIndex };//enum MoreActionsIndex -/** A struct that indicates what SpecUtils::Measurement's to apply a coefficent change to. - \TODO: if (or hopefully when) the InterSpec class allows selecting detectors seperately for +/** A struct that indicates what SpecUtils::Measurement's to apply a coefficient change to. + \TODO: if (or hopefully when) the InterSpec class allows selecting detectors separately for foreground/back/sec., we will need to consider upgrading how we indicate things \ because there is an edge-case where detectors wanted will differ by sample number @@ -251,7 +251,7 @@ class EnergyCalTool : public Wt::WContainerWidget std::string applyToSummaryTxt() const; /** Returns which SpecUtils::Measurement need to be updated, based on what files are loaded and - what options the user has choosen. + what options the user has chosen. */ std::vector measurementsToApplyCoeffChangeTo(); diff --git a/src/EnergyCalTool.cpp b/src/EnergyCalTool.cpp index bb1a24cb..e17e4e86 100644 --- a/src/EnergyCalTool.cpp +++ b/src/EnergyCalTool.cpp @@ -2600,8 +2600,14 @@ void EnergyCalTool::applyCalChange( std::shared_ptr &samples : samples_with_peaks ) { bool all_samples = true; - for( const int sample : change.sample_numbers ) - all_samples = (all_samples && samples.count(sample)); + + // Check if the peaks sample numbers are all getting re-calibrated + for( auto sample_num_iter = begin(samples); + all_samples && (sample_num_iter != end(samples)); + ++sample_num_iter ) + { + all_samples = (change.sample_numbers.count(*sample_num_iter) != 0u); + } if( all_samples ) peaksamples.insert( samples ); @@ -2610,8 +2616,14 @@ void EnergyCalTool::applyCalChange( std::shared_ptr &samples : samples_with_hint_peaks ) { bool all_samples = true; - for( const int sample : change.sample_numbers ) - all_samples = (all_samples && samples.count(sample)); + + // Check if the peaks sample numbers are all getting re-calibrated + for( auto sample_num_iter = begin(samples); + all_samples && (sample_num_iter != end(samples)); + ++sample_num_iter ) + { + all_samples = (change.sample_numbers.count(*sample_num_iter) != 0u); + } if( all_samples ) hintPeakSamples.insert( samples );