Skip to content

Commit

Permalink
Fix bug in which samples to correct peaks for energy calibration.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
wcjohns committed May 3, 2024
1 parent 79374bf commit 5d39b61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions InterSpec/EnergyCalTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<MeasToApplyCoefChangeTo> measurementsToApplyCoeffChangeTo();

Expand Down
20 changes: 16 additions & 4 deletions src/EnergyCalTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2600,8 +2600,14 @@ void EnergyCalTool::applyCalChange( std::shared_ptr<const SpecUtils::EnergyCalib
for( const set<int> &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 );
Expand All @@ -2610,8 +2616,14 @@ void EnergyCalTool::applyCalChange( std::shared_ptr<const SpecUtils::EnergyCalib
for( const set<int> &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 );
Expand Down

0 comments on commit 5d39b61

Please sign in to comment.