diff --git a/PeakOTron.py b/PeakOTron.py index a410070b5105c03a0d6299205debb17fd102a3e6..29ab033f827c047a2ead7c138c59b99e942a127e 100644 --- a/PeakOTron.py +++ b/PeakOTron.py @@ -1226,14 +1226,19 @@ class PeakOTron: if(self._verbose): print("Fitting...") - m_DRM.strategy=1 + m_DRM.strategy=2 m_DRM.errordef=m_DRM.LIKELIHOOD m_DRM.migrad(ncall = self._n_call_minuit, iterate= self._n_iterations_minuit) + ######################################################################################################## + ##Make a copy of the basic fit. + ######################################################################################################## + + + m_DRM_GP = deepcopy(m_DRM) - - + ######################################################################################################## ##Perform second fit under hypothesis there are dark counts, afterpulses. ######################################################################################################## @@ -1246,6 +1251,19 @@ class PeakOTron: m_DRM.strategy=2 m_DRM.migrad(ncall = self._n_call_minuit, iterate= self._n_iterations_minuit) + + + ######################################################################################################## + ## If the basic GP fit performs best, it means there isn't enough information between the peaks to fit dark counts/correlated noise. This fit is used + ## in preference. + ######################################################################################################## + + if(m_DRM_GP.fval < m_DRM.fval): + if(self._verbose): + print("Standard GP model fitted better than GP+DCR+AP. Implies peaks are too close to resolve inter-peak regions. DCR and pAp set to 0.") + m_DRM = m_DRM_GP + + m_DRM.hesse() self._m_DRM = m_DRM