@@ -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 {
0 commit comments