print("Minimum 3 peaks covering a threshold {0} events required. Too few events in peaks to proceed. Setting fit fail status and continuing...".format(min_n_peak_evts))
self._failed=True
return
elif(self._peak_data["n_peak_s"][0]>0):
if(self._verbose):
print("Estimated Pedestal had fewer than threshold {0} events. Shifting the pedestal forward...")
print("Fitting peak widths via bootstrap resampling...")
self.PreFitSigmaAndGain(data,n_bootstrap)
if(notself._failed):
if(self._verbose):
print("Estimating DCR from interpeak region...")
self.PreFitDCR(data,
tau,
tgate,
r_fast,
t_0,
ppf_mainfit,
kernel_kde,
bandwidth_kde,
n_bootstrap_kde)
if(notself._failed):
if(self._verbose):
print("Prefitting complete.")
# FIT
defFit(self,
data,
**kwargs):
kwargs_fit=self._default_fit_kwargs.copy()
kwargs_fit.update(kwargs)
if(notisinstance(data,np.ndarray)):
raiseException("Data is in {0} format. Please provide data in the format of a NumPy array.".format(type(data)))
else:
if(data.ndim==1):
if(self._verbose):
print("Data is 1D. Assuming list of charges as input...")
self._is_histogram=False
elif(data.ndim==2):
if(self._verbose):
print("Data is 2D. Assuming histogram as input...")
self._is_histogram=True
else:
raiseException("Please provide data in the format of either a list of charges (1D) or a histogram (2D)")
if(kwargs_fit["t_0"]isNone):
raiseException("t_0 is not set. Please set t_0 as a keyword argument to be the integration period before gate in nanoseconds.")
if(kwargs_fit["tgate"]isNone):
raiseException("tgate is not set. Please set tgate as a keyword argument to be the integration gate length in nanoseconds.")
if(kwargs_fit["tau"]isNone):
raiseException("tau is not set. Please set tau as a keyword argument to be the slow component of the SiPM pulse in nanoseconds.")
if(kwargs_fit["r_fast"]isNone):
raiseException("r_fast is not set. Please set r_fast as a keyword argument to be the fraction of the fast component of the SiPM pulse in nanoseconds.")
if(kwargs_fit["pedestal"]isNone):
raiseException("pedestal is not set. Please set pedestal to be the pedestal position in units of the input charge spectrum being fitted.")