@@ -2327,6 +2327,9 @@ void SourceFitModel::setSharredAgeNuclide( const SandiaDecay::Nuclide *dependant
2327
2327
if ( row < 0 )
2328
2328
return ;
2329
2329
2330
+ if ( PeakDef::ageFitNotAllowed ( dependantNuc ) )
2331
+ definingNuc = nullptr ;
2332
+
2330
2333
if ( definingNuc )
2331
2334
{
2332
2335
const int definingRow = nuclideIndex ( definingNuc );
@@ -2347,7 +2350,7 @@ void SourceFitModel::setSharredAgeNuclide( const SandiaDecay::Nuclide *dependant
2347
2350
" defining nuclides must have same atomic number" );
2348
2351
2349
2352
iso.ageDefiningNuc = definingNuc;
2350
- dataChanged ().emit ( createIndex (row,kAge ,(void *)0 ),
2353
+ dataChanged ().emit ( createIndex (row,kFitAge ,(void *)0 ),
2351
2354
createIndex (row,kAgeUncertainty ,(void *)0 ) );
2352
2355
}// void makeAgeFitable( const SandiaDecay::Nuclide *nuc, bool fit )
2353
2356
@@ -2404,13 +2407,13 @@ void SourceFitModel::setUseSameAgeForIsotopes( bool useSame )
2404
2407
if ( !m_sameAgeForIsotopes )
2405
2408
{
2406
2409
for ( size_t i = 0 ; i < m_nuclides.size (); ++i )
2407
- setSharredAgeNuclide ( m_nuclides[i].nuclide , NULL );
2410
+ setSharredAgeNuclide ( m_nuclides[i].nuclide , nullptr );
2408
2411
return ;
2409
2412
}// if( !m_sameAgeForIsotopes )
2410
2413
2411
2414
// construct map from element number to isotopes being fit for
2412
2415
// 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
2414
2417
typedef map< int , vector<const SandiaDecay::Nuclide *> > ElToNucMap_t;
2415
2418
ElToNucMap_t elToNucMap;
2416
2419
@@ -2424,29 +2427,46 @@ void SourceFitModel::setUseSameAgeForIsotopes( bool useSame )
2424
2427
{
2425
2428
const vector<const SandiaDecay::Nuclide *> &nucs = vt.second ;
2426
2429
if ( nucs.size () < 2 )
2430
+ {
2431
+ if ( !nucs.empty () )
2432
+ setSharredAgeNuclide ( nucs[0 ], nullptr );
2427
2433
continue ;
2434
+ }
2428
2435
2429
2436
bool fitAgeWanted = false ;
2430
- size_t minIndex = 0 ;
2437
+ size_t minIndex = 0 , numSharingAge = 0 ;
2431
2438
double minAge = std::numeric_limits<double >::infinity ();
2432
2439
for ( size_t i = 0 ; i < nucs.size (); ++i )
2433
2440
{
2434
2441
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
+
2435
2448
const int ind = nuclideIndex ( nuc );
2436
2449
const double thisage = age ( ind );
2437
2450
if ( thisage < minAge )
2438
2451
{
2439
2452
minIndex = i;
2440
2453
minAge = thisage;
2441
2454
}// if( age < minAge )
2455
+
2456
+ numSharingAge += 1 ;
2442
2457
fitAgeWanted = (fitAgeWanted || fitAge (ind));
2443
2458
}// for( const SandiaDecay::Nuclide *nuc : nucs )
2444
2459
2445
2460
for ( size_t i = 0 ; i < nucs.size (); ++i )
2446
2461
{
2447
2462
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 )
2450
2470
{
2451
2471
WModelIndex ind = index ( nuc, SourceFitModel::kAge );
2452
2472
setData ( ind, fitAgeWanted );
@@ -2486,6 +2506,7 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
2486
2506
newIso.fitActivity = true ;
2487
2507
newIso.nuclide = peak->parentNuclide ();
2488
2508
newIso.age = PeakDef::defaultDecayTime ( newIso.nuclide );
2509
+ newIso.ageDefiningNuc = nullptr ;
2489
2510
newIso.fitAge = false ;
2490
2511
newIso.ageIsFittable = !PeakDef::ageFitNotAllowed ( newIso.nuclide );
2491
2512
@@ -2506,13 +2527,13 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
2506
2527
if ( m_previousResults.size () > 100 )
2507
2528
m_previousResults.clear ();
2508
2529
2509
- if ( m_sameAgeForIsotopes )
2530
+ if ( m_sameAgeForIsotopes && newIso. ageIsFittable )
2510
2531
{
2511
2532
vector<size_t > thisElementIndexs;
2512
2533
for ( size_t i = 0 ; i < m_nuclides.size (); ++i )
2513
2534
{
2514
2535
const IsoFitStruct &iso = m_nuclides[i];
2515
- if ( iso.nuclide ->atomicNumber == newIso.nuclide ->atomicNumber )
2536
+ if ( iso.ageIsFittable && (iso. nuclide ->atomicNumber == newIso.nuclide ->atomicNumber ) )
2516
2537
{
2517
2538
thisElementIndexs.push_back ( i );
2518
2539
if ( !iso.ageDefiningNuc )
@@ -2531,7 +2552,7 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
2531
2552
// else
2532
2553
// newIso.ageDefiningNuc = previso.nuclide;
2533
2554
}// if( !newIso.ageDefiningNuc && !thisElementIndexs.empty() )
2534
- }// if( m_sameAgeForIsotopes )
2555
+ }// if( m_sameAgeForIsotopes && newIso.ageIsFittable )
2535
2556
2536
2557
2537
2558
@@ -2547,6 +2568,7 @@ void SourceFitModel::insertPeak( const PeakShrdPtr peak )
2547
2568
progeny.insert ( trans->parent );
2548
2569
}
2549
2570
}// for( loop over peaks)
2571
+
2550
2572
newIso.numProgenyPeaksSelected = progeny.size ();
2551
2573
2552
2574
std::vector<IsoFitStruct>::iterator pos;
@@ -2756,7 +2778,7 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
2756
2778
for ( const IsoFitStruct &ifs : m_nuclides )
2757
2779
postisotopes.push_back ( ifs.nuclide );
2758
2780
2759
- if ( m_sameAgeForIsotopes && (preisotopes.size ()!= postisotopes.size ()) )
2781
+ if ( m_sameAgeForIsotopes && (preisotopes.size () != postisotopes.size ()) )
2760
2782
{
2761
2783
vector<const SandiaDecay::Nuclide *> removednucs, addednucs;
2762
2784
for ( const SandiaDecay::Nuclide *nuc : preisotopes )
@@ -2779,7 +2801,7 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
2779
2801
2780
2802
for ( IsoFitStruct &ifs : m_nuclides )
2781
2803
{
2782
- if ( ifs.nuclide ->atomicNumber == nuc->atomicNumber )
2804
+ if ( ifs.ageIsFittable && (ifs. nuclide ->atomicNumber == nuc->atomicNumber ) )
2783
2805
{
2784
2806
if ( ifs.age < minage )
2785
2807
{
@@ -2794,20 +2816,25 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
2794
2816
{
2795
2817
for ( IsoFitStruct &ifs : m_nuclides )
2796
2818
{
2797
- if ( ifs.nuclide ->atomicNumber == nuc->atomicNumber )
2819
+ if ( ifs.ageIsFittable && (ifs. nuclide ->atomicNumber == nuc->atomicNumber ) )
2798
2820
setSharredAgeNuclide ( ifs.nuclide , defining );
2799
2821
}// for( IsoFitStruct &ifs : m_nuclides )
2800
2822
}// if( removedADefining )
2801
2823
}// for( const SandiaDecay::Nuclide *nuc : removednucs )
2802
2824
2803
2825
for ( const SandiaDecay::Nuclide *nuc : addednucs )
2804
2826
{
2827
+ if ( PeakDef::ageFitNotAllowed ( nuc ) )
2828
+ continue ;
2829
+
2805
2830
const SandiaDecay::Nuclide *defining = NULL ;
2806
2831
double minage = std::numeric_limits<double >::infinity ();
2807
2832
2808
2833
for ( IsoFitStruct &ifs : m_nuclides )
2809
2834
{
2810
- if ( (ifs.age <minage) && (ifs.nuclide ->atomicNumber ==nuc->atomicNumber ) )
2835
+ if ( ifs.ageIsFittable
2836
+ && (ifs.age < minage)
2837
+ && (ifs.nuclide ->atomicNumber == nuc->atomicNumber ) )
2811
2838
{
2812
2839
minage = ifs.age ;
2813
2840
defining = ifs.nuclide ;
@@ -2818,10 +2845,12 @@ void SourceFitModel::peakModelDataChangedCallback( Wt::WModelIndex topLeft,
2818
2845
defining = nuc;
2819
2846
2820
2847
for ( IsoFitStruct &ifs : m_nuclides )
2821
- if ( ifs.nuclide ->atomicNumber == nuc->atomicNumber )
2848
+ {
2849
+ if ( ifs.ageIsFittable && (ifs.nuclide ->atomicNumber == nuc->atomicNumber ) )
2822
2850
setSharredAgeNuclide ( ifs.nuclide , defining );
2851
+ }
2823
2852
}// for( const SandiaDecay::Nuclide *nuc : addednucs )
2824
- }// if( m_sameAgeForIsotopes && (preisotopes!= postisotopes) )
2853
+ }// if( m_sameAgeForIsotopes && (preisotopes != postisotopes) )
2825
2854
2826
2855
2827
2856
if ( npreisotopes == m_nuclides.size () )
@@ -5254,7 +5283,7 @@ std::tuple<int,int,bool> ShieldingSourceDisplay::numTruthValuesForFitValues()
5254
5283
5255
5284
if ( nQuantitiesCan != nFitQuantities )
5256
5285
{
5257
- cerr << " Dont have: nQuantitiesCan != nFitQuantities" << nQuantitiesCan << " != " << nFitQuantities << endl;
5286
+ cerr << " Dont have: nQuantitiesCan != nFitQuantities ( " << nQuantitiesCan << " != " << nFitQuantities << " ) " << endl;
5258
5287
isValid = false ;
5259
5288
}
5260
5289
@@ -8192,6 +8221,8 @@ ShieldingSourceDisplay::Chi2FcnShrdPtr ShieldingSourceDisplay::shieldingFitnessF
8192
8221
if ( age > 0 )
8193
8222
ageStep = std::min ( 0.1 *age, ageStep );
8194
8223
8224
+ // cout << "For nuclide " << nuclide->symbol << " adding age=" << age << ", with step " << ageStep << " and max age " << maxAge << endl;
8225
+
8195
8226
inputPrams.Add ( nuclide->symbol + " Age" , age, ageStep, 0 , maxAge );
8196
8227
}else if ( hasOwnAge )
8197
8228
{
0 commit comments