Skip to content

Commit f5f92e0

Browse files
committed
Fixed Shielding/Source fit issue; a few other minor things.
Fixed issue with shielding/source fit when nuclide ages for an element were selected to have the same age, it would cause all sorts of badness when some of the nuclides for an element were not candidates for aging. Fixed a couple small issues with the testing widget when there was a shielding/source fit test defined. Added some DRF functions to the Math/Terminal tool.
1 parent 76d0773 commit f5f92e0

10 files changed

+308
-72
lines changed

InterSpec/ShieldingSourceDisplay.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class DetectorDisplay;
5555
class PopupDivMenuItem;
5656
class DetectorPeakResponse;
5757
struct ShieldingSourceModel;
58+
#if( INCLUDE_ANALYSIS_TEST_SUITE )
59+
class SpectrumViewerTester;
60+
#endif
5861

5962
namespace SandiaDecay
6063
{
@@ -1050,6 +1053,11 @@ class ShieldingSourceDisplay : public Wt::WContainerWidget
10501053
};//class WCartesianChart
10511054

10521055
static const int sm_xmlSerializationVersion;
1056+
1057+
#if( INCLUDE_ANALYSIS_TEST_SUITE )
1058+
// So the tester can call updateChi2ChartActual
1059+
friend class SpectrumViewerTester;
1060+
#endif
10531061
};//class ShieldingSourceDisplay
10541062

10551063

InterSpec/TerminalModel.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ class TerminalModel {
129129
double gammaMinFor( const std::string& histogram );
130130
double gammaMax();
131131
double gammaMaxFor( const std::string& histogram );
132-
132+
133+
double drfFWHM( const double energy );
134+
double drfIntrinsicEff( const double energy );
135+
double drfGeometricEff( const std::string &distance );
136+
double drfEfficiency( const double energy, const std::string &distance );
137+
133138
protected: /* Command methods (complete actions on Spectrum, cannot be used with parser)
134139
To add a new command in the Terminal tool:
135140
1. Add the corresponding CommandType enum inside the TerminalModel Header file.

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int main( int argc, char **argv )
8282
#endif //#if( ANDROID )
8383

8484
std::cout << std::showbase << std::hex << "Running with Wt version "
85-
<< WT_VERSION << ", from executable compiled on "
85+
<< WT_VERSION << std::dec << ", from executable compiled on "
8686
<< __DATE__ << std::endl;
8787

8888
#if( PERFORM_DEVELOPER_CHECKS )

src/FeatureMarkerWidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ FeatureMarkerWindow::FeatureMarkerWindow( InterSpec *viewer )
6565
//m_feature->setHeight( WLength(100,WLength::Percentage) );
6666

6767
// This next call seems to help resize the window to show all the contents, otherwise "Sum Peak"
68-
// will hang-off the bottom of the window.
69-
// Although definitely not 100% effective...
70-
centerWindow();
68+
// will hang-off the bottom of the window. Definitely a hack.
69+
doJavaScript( "setTimeout( function(){ window.dispatchEvent(new Event('resize')); }, 0 );"
70+
"setTimeout( function(){ window.dispatchEvent(new Event('resize')); }, 50 );" );
7171

7272
show();
7373

src/GammaInteractionCalc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,8 +1816,7 @@ vector< tuple<double,double,double,Wt::WColor,double> >
18161816

18171817

18181818
EnergyCountMap energy_count_map;
1819-
const vector<pair<double,double> > energie_widths
1820-
= observedPeakEnergyWidths( m_peaks );
1819+
const vector<pair<double,double> > energie_widths = observedPeakEnergyWidths( m_peaks );
18211820

18221821
if( allow_multiple_iso_contri )
18231822
{

src/InterSpec.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,14 +4594,9 @@ void InterSpec::loadTestStateFromN42( std::istream &input )
45944594
const xml_node<char> *sourcefit = InterSpecNode->first_node( "ShieldingSourceFit" );
45954595
if( sourcefit )
45964596
{
4597-
if( !m_shieldingSourceFit )
4598-
{
4599-
showShieldingSourceFitWindow();
4600-
if( m_shieldingSourceFitWindow )
4601-
m_shieldingSourceFitWindow->hide();
4602-
}//if( !m_shieldingSourceFit )
4603-
4597+
showShieldingSourceFitWindow();
46044598
m_shieldingSourceFit->deSerialize( sourcefit );
4599+
closeShieldingSourceFitWindow();
46054600
}//if( sourcefit )
46064601

46074602
stringstream msg;

src/ShieldingSourceDisplay.cpp

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,9 @@ void SourceFitModel::setSharredAgeNuclide( const SandiaDecay::Nuclide *dependant
23272327
if( row < 0 )
23282328
return;
23292329

2330+
if( PeakDef::ageFitNotAllowed( dependantNuc ) )
2331+
definingNuc = nullptr;
2332+
23302333
if( definingNuc )
23312334
{
23322335
const int definingRow = nuclideIndex( definingNuc );
@@ -2347,7 +2350,7 @@ void SourceFitModel::setSharredAgeNuclide( const SandiaDecay::Nuclide *dependant
23472350
" defining nuclides must have same atomic number" );
23482351

23492352
iso.ageDefiningNuc = definingNuc;
2350-
dataChanged().emit( createIndex(row,kAge,(void *)0),
2353+
dataChanged().emit( createIndex(row,kFitAge,(void *)0),
23512354
createIndex(row,kAgeUncertainty,(void *)0) );
23522355
}//void makeAgeFitable( const SandiaDecay::Nuclide *nuc, bool fit )
23532356

@@ -2404,13 +2407,13 @@ void SourceFitModel::setUseSameAgeForIsotopes( bool useSame )
24042407
if( !m_sameAgeForIsotopes )
24052408
{
24062409
for( size_t i = 0; i < m_nuclides.size(); ++i )
2407-
setSharredAgeNuclide( m_nuclides[i].nuclide, NULL );
2410+
setSharredAgeNuclide( m_nuclides[i].nuclide, nullptr );
24082411
return;
24092412
}//if( !m_sameAgeForIsotopes )
24102413

24112414
//construct map from element number to isotopes being fit for
24122415
//if there is more than one isotope, choose the youngest age to assign to
2413-
//all of the isotopes. Do the assignemnet and update the chart
2416+
//all of the isotopes. Do the assignment and update the chart
24142417
typedef map< int, vector<const SandiaDecay::Nuclide *> > ElToNucMap_t;
24152418
ElToNucMap_t elToNucMap;
24162419

@@ -2424,29 +2427,46 @@ void SourceFitModel::setUseSameAgeForIsotopes( bool useSame )
24242427
{
24252428
const vector<const SandiaDecay::Nuclide *> &nucs = vt.second;
24262429
if( nucs.size() < 2 )
2430+
{
2431+
if( !nucs.empty() )
2432+
setSharredAgeNuclide( nucs[0], nullptr );
24272433
continue;
2434+
}
24282435

24292436
bool fitAgeWanted = false;
2430-
size_t minIndex = 0;
2437+
size_t minIndex = 0, numSharingAge = 0;
24312438
double minAge = std::numeric_limits<double>::infinity();
24322439
for( size_t i = 0; i < nucs.size(); ++i )
24332440
{
24342441
const SandiaDecay::Nuclide *nuc = nucs[i];
2442+
if( PeakDef::ageFitNotAllowed( nuc ) )
2443+
{
2444+
setSharredAgeNuclide( nuc, nullptr ); // jic, I guess, but not really needed, probably
2445+
continue;
2446+
}
2447+
24352448
const int ind = nuclideIndex( nuc );
24362449
const double thisage = age( ind );
24372450
if( thisage < minAge )
24382451
{
24392452
minIndex = i;
24402453
minAge = thisage;
24412454
}//if( age < minAge )
2455+
2456+
numSharingAge += 1;
24422457
fitAgeWanted = (fitAgeWanted || fitAge(ind));
24432458
}//for( const SandiaDecay::Nuclide *nuc : nucs )
24442459

24452460
for( size_t i = 0; i < nucs.size(); ++i )
24462461
{
24472462
const SandiaDecay::Nuclide *nuc = nucs[i];
2448-
2449-
if( i == minIndex )
2463+
if( PeakDef::ageFitNotAllowed( nuc ) )
2464+
continue;
2465+
2466+
if( numSharingAge < 2 )
2467+
{
2468+
setSharredAgeNuclide( nuc, nullptr );
2469+
}else if( i == minIndex )
24502470
{
24512471
WModelIndex ind = index( nuc, SourceFitModel::kAge );
24522472
setData( ind, fitAgeWanted );
@@ -2486,6 +2506,7 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
24862506
newIso.fitActivity = true;
24872507
newIso.nuclide = peak->parentNuclide();
24882508
newIso.age = PeakDef::defaultDecayTime( newIso.nuclide );
2509+
newIso.ageDefiningNuc = nullptr;
24892510
newIso.fitAge = false;
24902511
newIso.ageIsFittable = !PeakDef::ageFitNotAllowed( newIso.nuclide );
24912512

@@ -2506,13 +2527,13 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
25062527
if( m_previousResults.size() > 100 )
25072528
m_previousResults.clear();
25082529

2509-
if( m_sameAgeForIsotopes )
2530+
if( m_sameAgeForIsotopes && newIso.ageIsFittable )
25102531
{
25112532
vector<size_t> thisElementIndexs;
25122533
for( size_t i = 0; i < m_nuclides.size(); ++i )
25132534
{
25142535
const IsoFitStruct &iso = m_nuclides[i];
2515-
if( iso.nuclide->atomicNumber == newIso.nuclide->atomicNumber )
2536+
if( iso.ageIsFittable && (iso.nuclide->atomicNumber == newIso.nuclide->atomicNumber) )
25162537
{
25172538
thisElementIndexs.push_back( i );
25182539
if( !iso.ageDefiningNuc )
@@ -2531,7 +2552,7 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
25312552
// else
25322553
// newIso.ageDefiningNuc = previso.nuclide;
25332554
}//if( !newIso.ageDefiningNuc && !thisElementIndexs.empty() )
2534-
}//if( m_sameAgeForIsotopes )
2555+
}//if( m_sameAgeForIsotopes && newIso.ageIsFittable )
25352556

25362557

25372558

@@ -2547,6 +2568,7 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
25472568
progeny.insert( trans->parent );
25482569
}
25492570
}//for( loop over peaks)
2571+
25502572
newIso.numProgenyPeaksSelected = progeny.size();
25512573

25522574
std::vector<IsoFitStruct>::iterator pos;
@@ -2756,7 +2778,7 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
27562778
for( const IsoFitStruct &ifs : m_nuclides )
27572779
postisotopes.push_back( ifs.nuclide );
27582780

2759-
if( m_sameAgeForIsotopes && (preisotopes.size()!=postisotopes.size()) )
2781+
if( m_sameAgeForIsotopes && (preisotopes.size() != postisotopes.size()) )
27602782
{
27612783
vector<const SandiaDecay::Nuclide *> removednucs, addednucs;
27622784
for( const SandiaDecay::Nuclide *nuc : preisotopes )
@@ -2779,7 +2801,7 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
27792801

27802802
for( IsoFitStruct &ifs : m_nuclides )
27812803
{
2782-
if( ifs.nuclide->atomicNumber == nuc->atomicNumber )
2804+
if( ifs.ageIsFittable && (ifs.nuclide->atomicNumber == nuc->atomicNumber) )
27832805
{
27842806
if( ifs.age < minage )
27852807
{
@@ -2794,20 +2816,25 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
27942816
{
27952817
for( IsoFitStruct &ifs : m_nuclides )
27962818
{
2797-
if( ifs.nuclide->atomicNumber == nuc->atomicNumber )
2819+
if( ifs.ageIsFittable && (ifs.nuclide->atomicNumber == nuc->atomicNumber) )
27982820
setSharredAgeNuclide( ifs.nuclide, defining );
27992821
}//for( IsoFitStruct &ifs : m_nuclides )
28002822
}//if( removedADefining )
28012823
}//for( const SandiaDecay::Nuclide *nuc : removednucs )
28022824

28032825
for( const SandiaDecay::Nuclide *nuc : addednucs )
28042826
{
2827+
if( PeakDef::ageFitNotAllowed( nuc ) )
2828+
continue;
2829+
28052830
const SandiaDecay::Nuclide *defining = NULL;
28062831
double minage = std::numeric_limits<double>::infinity();
28072832

28082833
for( IsoFitStruct &ifs : m_nuclides )
28092834
{
2810-
if( (ifs.age<minage) && (ifs.nuclide->atomicNumber==nuc->atomicNumber) )
2835+
if( ifs.ageIsFittable
2836+
&& (ifs.age < minage)
2837+
&& (ifs.nuclide->atomicNumber == nuc->atomicNumber) )
28112838
{
28122839
minage = ifs.age;
28132840
defining = ifs.nuclide;
@@ -2818,10 +2845,12 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
28182845
defining = nuc;
28192846

28202847
for( IsoFitStruct &ifs : m_nuclides )
2821-
if( ifs.nuclide->atomicNumber == nuc->atomicNumber )
2848+
{
2849+
if( ifs.ageIsFittable && (ifs.nuclide->atomicNumber == nuc->atomicNumber) )
28222850
setSharredAgeNuclide( ifs.nuclide, defining );
2851+
}
28232852
}//for( const SandiaDecay::Nuclide *nuc : addednucs )
2824-
}//if( m_sameAgeForIsotopes && (preisotopes!=postisotopes) )
2853+
}//if( m_sameAgeForIsotopes && (preisotopes != postisotopes) )
28252854

28262855

28272856
if( npreisotopes == m_nuclides.size() )
@@ -5254,7 +5283,7 @@ std::tuple<int,int,bool> ShieldingSourceDisplay::numTruthValuesForFitValues()
52545283

52555284
if( nQuantitiesCan != nFitQuantities )
52565285
{
5257-
cerr << "Dont have: nQuantitiesCan != nFitQuantities" << nQuantitiesCan << " != " << nFitQuantities << endl;
5286+
cerr << "Dont have: nQuantitiesCan != nFitQuantities (" << nQuantitiesCan << " != " << nFitQuantities << ")" << endl;
52585287
isValid = false;
52595288
}
52605289

@@ -8192,6 +8221,8 @@ ShieldingSourceDisplay::Chi2FcnShrdPtr ShieldingSourceDisplay::shieldingFitnessF
81928221
if( age > 0 )
81938222
ageStep = std::min( 0.1*age, ageStep );
81948223

8224+
// cout << "For nuclide " << nuclide->symbol << " adding age=" << age << ", with step " << ageStep << " and max age " << maxAge << endl;
8225+
81958226
inputPrams.Add( nuclide->symbol + "Age", age, ageStep, 0, maxAge );
81968227
}else if( hasOwnAge )
81978228
{

src/SpectraFileModel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ SpectraFileHeader::~SpectraFileHeader() noexcept(true)
287287
{
288288
saveToDatabaseFromTempFile();
289289
//passMessage ("memObj saveToDatabaseFromTempFile", "", WarningWidget::WarningMsgMedium);
290-
WString msg = "Autosaved previously opened spectra '";
291-
msg += (!!memObj ? memObj->filename() : fileSystemLocation);
292-
msg += "'";
290+
//WString msg = "Autosaved previously opened spectra '";
291+
//msg += (!!memObj ? memObj->filename() : fileSystemLocation);
292+
//msg += "'";
293293
//passMessage( msg, "", WarningWidget::WarningMsgInfo );
294294
}
295295
else //probably shouldnt happen

src/SpectrumViewerTester.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,7 @@ SpectrumViewerTester::Score SpectrumViewerTester::testShieldSourceFit()
19781978
note.m_text = "";
19791979
note.m_title = "Fit Chi2 Graphic";
19801980
note.m_originalImage = make_shared<Wt::WSvgImage>(m_picWidth, m_picHeight);
1981+
disp->updateChi2ChartActual();
19811982
disp->renderChi2Chart( *note.m_originalImage );
19821983

19831984
// Set all the quantities being fit for to some default values, so we wont be starting off in
@@ -1986,7 +1987,7 @@ SpectrumViewerTester::Score SpectrumViewerTester::testShieldSourceFit()
19861987

19871988
shared_ptr<ShieldingSourceDisplay::ModelFitResults> result = disp->doModelFit( false );
19881989

1989-
// Uhg, sometimes users have to hit a coupel times right now - this should be fixed
1990+
// Uhg, sometimes users have to hit a couple times right now - this should be fixed
19901991
result = disp->doModelFit( false );
19911992

19921993
note.m_testImage = make_shared<Wt::WSvgImage>(m_picWidth, m_picHeight);

0 commit comments

Comments
 (0)