Commit 0870c12cd7a73b28f030bd255430f4243c5740f7
1 parent
af12a60b
Update Monte Carlo cache when the normalization value of the light curve model has changed
Showing
2 changed files
with
10 additions
and
3 deletions
include/GModelTemporalLightCurve.hpp
| ... | ... | @@ -112,6 +112,7 @@ protected: |
| 112 | 112 | // Cached members for MC |
| 113 | 113 | mutable GTime m_mc_tmin; //!< Minimum time |
| 114 | 114 | mutable GTime m_mc_tmax; //!< Maximum time |
| 115 | + mutable double m_mc_norm; //!< Light curve normalisation | |
| 115 | 116 | mutable double m_mc_eff_duration; //!< Effective duration |
| 116 | 117 | mutable std::vector<double> m_mc_cum; //!< Cumulative distribution |
| 117 | 118 | mutable std::vector<double> m_mc_slope; //!< Slope of interval | ... | ... |
src/model/GModelTemporalLightCurve.cpp
| ... | ... | @@ -518,6 +518,7 @@ void GModelTemporalLightCurve::init_members(void) |
| 518 | 518 | // Initialise cache |
| 519 | 519 | m_mc_tmin.clear(); |
| 520 | 520 | m_mc_tmax.clear(); |
| 521 | + m_mc_norm = 0.0; | |
| 521 | 522 | m_mc_eff_duration = 0.0; |
| 522 | 523 | m_mc_cum.clear(); |
| 523 | 524 | m_mc_slope.clear(); |
| ... | ... | @@ -549,6 +550,7 @@ void GModelTemporalLightCurve::copy_members(const GModelTemporalLightCurve& mode |
| 549 | 550 | // Copy cache |
| 550 | 551 | m_mc_tmin = model.m_mc_tmin; |
| 551 | 552 | m_mc_tmax = model.m_mc_tmax; |
| 553 | + m_mc_norm = model.m_mc_norm; | |
| 552 | 554 | m_mc_eff_duration = model.m_mc_eff_duration; |
| 553 | 555 | m_mc_cum = model.m_mc_cum; |
| 554 | 556 | m_mc_slope = model.m_mc_slope; |
| ... | ... | @@ -697,12 +699,16 @@ void GModelTemporalLightCurve::load_nodes(const GFilename& filename) |
| 697 | 699 | void GModelTemporalLightCurve::mc_update(const GTime& tmin, |
| 698 | 700 | const GTime& tmax) const |
| 699 | 701 | { |
| 700 | - // Update the cache only if the time interval has changed | |
| 701 | - if (tmin != m_mc_tmin || tmax != m_mc_tmax) { | |
| 702 | + // Get light curve normalisation value to see whether it has changed | |
| 703 | + double norm = m_norm.value(); | |
| 704 | + | |
| 705 | + // Update the cache only if the time interval or normalisation has changed | |
| 706 | + if (tmin != m_mc_tmin || tmax != m_mc_tmax || norm != m_mc_norm) { | |
| 702 | 707 | |
| 703 | - // Store new time interval | |
| 708 | + // Store new time interval and normalisation value | |
| 704 | 709 | m_mc_tmin = tmin; |
| 705 | 710 | m_mc_tmax = tmax; |
| 711 | + m_mc_norm = norm; | |
| 706 | 712 | |
| 707 | 713 | // Initialise cache |
| 708 | 714 | m_mc_eff_duration = 0.0; | ... | ... |