Skip to content

Commit

Permalink
Add accounting for nuclide decay during measurement for "Isotopics fr…
Browse files Browse the repository at this point in the history
…om peaks" tool.

Option to account for nuclide decay is enabled on a nuclide-by-nuclide basis, and only becomes present if the measurement time exceeds 0.5% of nuclide half-life; if measurement time exceed 5% of a nuclides half-life, then accounting for the decay will be checked by default.
  • Loading branch information
wcjohns committed Jan 12, 2024
1 parent 7c0ddfe commit 8c7e5c4
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 216 deletions.
20 changes: 14 additions & 6 deletions InterSpec/GammaInteractionCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@

#include "Minuit2/FCNBase.h"

#include "SandiaDecay/SandiaDecay.h"

#include "InterSpec/ShieldingSourceFitCalc.h"

class PeakDef;
struct Material;
class DetectorPeakResponse;

namespace SandiaDecay
{
struct Nuclide;
class NuclideMixture;
}

namespace GammaInteractionCalc
{
Expand Down Expand Up @@ -140,7 +137,18 @@ double mass_attenuation_coef( float atomic_number, float energy );
double transmition_coefficient_generic( float atomic_number, float areal_density,
float energy );


/** Returns the average gammas per second during a measurement, when the decay of the input nuclides is accounted for.
@param mixture The nuclide mixture - currently may only have a single parent nuclide.
@param intial_age The mixture nuclides age when the measurement is started.
@param measurement_duration The duration of the measurement.
@returns The average rates for each of the energies, ordered by energy.
*/
std::vector<SandiaDecay::EnergyRatePair> decay_during_meas_corrected_gammas(
const SandiaDecay::NuclideMixture &mixture,
const double initial_age,
const double measurement_duration );

void example_integration();

// When debugging we will grab a static mutex so we dont get jumbled stdout
Expand Down
45 changes: 39 additions & 6 deletions InterSpec/RelActCalcManual.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,17 @@ struct SandiaDecayNuc
{
const SandiaDecay::Nuclide *nuclide = nullptr;
double age = -1;

bool correct_for_decay_during_meas = false;
const ReactionGamma::Reaction *reaction = nullptr;
};//struct SandiaDecayNucRelAct
};//struct SandiaDecayNuc


/** Information about a SandiaDecay defined nuclide for input into relative efficiency calculation.
*/
struct SandiaDecayNucRelAct
{
const SandiaDecay::Nuclide *nuclide = nullptr;
/** Age at start of measurement. */
double age = -1.0;
double rel_activity = -1.0;
};//struct SandiaDecayNucRelAct
Expand Down Expand Up @@ -162,9 +163,18 @@ struct GenericPeakInfo
};//struct GenericPeakInfo



/** Adds the `GenericLineInfo` info (e.g. nuclides and their BR) to input `peaks` by clustering gamma lines of
provided nuclides.
@param peaks Input peaks, with all info except `GenericPeakInfo::m_source_gammas` filled out
@param nuclides The input nuclides to cluster and assign to peaks
@param real_time The real time of the measurement - only used if correcting for the nuclides decay during measurement
\sa `SandiaDecayNuc::correct_for_decay_during_meas`
@param cluster_sigma The number of peak sigma to cluster gamma energies as being responsible for the peaks.
*/
std::vector<GenericPeakInfo> add_nuclides_to_peaks( const std::vector<GenericPeakInfo> &peaks,
const std::vector<SandiaDecayNuc> &nuclides,
const double real_time,
const double cluster_sigma = 1.5
);

Expand Down Expand Up @@ -358,6 +368,16 @@ struct RelEffSolution
/** The input peaks that were used to create the solution. */
std::vector<GenericPeakInfo> m_input_peak;

/** Peaks with un-decay-corrected yields; useful only to note the effect of the decay correction.
Only includes peaks that have at least one correction, and the only entries in
`GenericPeakInfo::m_source_gammas`, are the ones with corrections.
Note: these are not filled out by `solve_relative_efficiency(...)`, like the rest of this struct,
but rather must be filled out after finding a solution. Not super clean, but these are informational
only.
*/
std::vector<GenericPeakInfo> m_input_peaks_before_decay_corr;

/////////////////////////////////////////////////////////////////////////////////////////////////
// Below here are member functions for simplified access to information //
Expand Down Expand Up @@ -550,6 +570,12 @@ struct NucMatchResults
any of the peaks fit in data.
*/
std::vector<NuclideInfo> source_gammas_not_used;

/** The non-decay-corrected values for peaks that received decay-during-measurement corrections.
Will only have entries in `RelActCalcManual::GenericPeakInfo::m_source_gammas`
that received corrections.
*/
std::vector<RelActCalcManual::GenericPeakInfo> not_decay_corrected_peaks;
};//struct NucMatchResults


Expand All @@ -565,9 +591,13 @@ struct NucAndAge
/** Age of nuclide; a negative value will cause the default age for the nuclide to be used. */
double age = -1.0;

NucAndAge( const std::string &nuc, const double the_age )
/** If the nuclides decay during the measurement should be accounted for. */
bool decay_during_measurement;

NucAndAge( const std::string &nuc, const double the_age, const bool decay_correct_during_meas )
: nuclide(nuc),
age( the_age )
age( the_age ),
decay_during_measurement( decay_correct_during_meas )
{}
};//NucAndAge

Expand All @@ -584,13 +614,16 @@ struct NucAndAge
this energy range of the peak mean will be attributed to the peak. A value of 0.57 will
include all gammas within 1.5 sigma of the mean.
@param excluded_peak_energies Peaks to explicitly exclude from the analysis.
@param measurement_duration The duration of the measurement; only used if correcting activities for decay during measurement.
\sa `NucAndAge::decay_during_measurement`
*/
NucMatchResults fill_in_nuclide_info( const std::vector<RelActCalcManual::GenericPeakInfo> peaks,
const NucDataSrc nuc_data_src,
const std::vector<std::pair<float,float>> energy_ranges,
std::vector<NucAndAge> isotopes,
const float energy_tolerance_sigma,
const std::vector<float> excluded_peak_energies );
const std::vector<float> excluded_peak_energies,
const float measurement_duration );
}//namespace PeakCsvInput

}//namespace RelActCalcManual
Expand Down
4 changes: 3 additions & 1 deletion InterSpec/RelActManualGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ class RelActManualGui : public Wt::WContainerWidget

/// Keep a cache of nuclide ages around incase the user removes a nuclide, but adds it in later.
std::map<std::string,double> m_nucAge;
/// Keep a cache of if we should decay-correct the nuclide incase the user removes a nuclide, but adds it in later.
std::map<std::string,bool> m_nucDecayCorrect;

Wt::WMenu *m_resultMenu;

Expand All @@ -227,7 +229,7 @@ class RelActManualGui : public Wt::WContainerWidget
float m_matchToleranceValue = -1.0f;
int m_addUncertIndex = -1;
bool m_backgroundSubtract = false;
std::vector<std::pair<std::string,double>> m_nucAges;
std::vector<std::tuple<std::string,double,bool>> m_nucAgesAndDecayCorrect;
// TODO: could track nuclide WPanel collapse un-collapse
int m_resultTab = 0; //Not currently having in for undo/redo steps, but will track

Expand Down
Loading

0 comments on commit 8c7e5c4

Please sign in to comment.