WaveformAnalysisLucyDDM Class Reference

Ratpac-two: RAT::WaveformAnalysisLucyDDM Class Reference
Ratpac-two

Perform PMT waveform analysis using Richard-Lucy Direct Demodulation (LucyDDM). More...

#include <WaveformAnalysisLucyDDM.hh>

Inheritance diagram for RAT::WaveformAnalysisLucyDDM:
RAT::WaveformAnalyzerBase RAT::Processor

Public Member Functions

 WaveformAnalysisLucyDDM (std::string config_name)
 
void Configure (const std::string &config_name) override
 
- Public Member Functions inherited from RAT::WaveformAnalyzerBase
 WaveformAnalyzerBase ()=delete
 
 WaveformAnalyzerBase (std::string _procname, std::string config_name)
 
virtual void SetS (std::string param, std::string value) override
 
virtual void SetD (std::string param, double value) override
 
virtual void SetI (std::string param, int value) override
 
virtual void RunAnalysis (DS::DigitPMT *digitpmt, int pmtID, Digitizer *fDigitizer)
 
virtual void RunAnalysis (DS::DigitPMT *digitpmt, int pmtID, DS::Digit *dsdigit)
 
Processor::Result Event (DS::Root *ds, DS::EV *ev) override
 
virtual std::string GetAnalyzerName () const
 
- Public Member Functions inherited from RAT::Processor
 Processor (std::string _name)
 
virtual ~Processor ()
 
std::string GetName () const
 
virtual void SetF (std::string param, float value)
 
virtual Processor::Result DSEvent (DS::Root *ds)
 
virtual void BeginOfRun (DS::Run *run)
 
virtual void EndOfRun (DS::Run *run)
 

Protected Member Functions

void DoAnalysis (DS::DigitPMT *pmt, const std::vector< UShort_t > &digitWfm) override
 Main analysis function entry point, provided by WaveformAnalyzerBase.
 
void RequestFFTSize (size_t size)
 Ensure that hte requested size can be done with the existing transformers. If the transformers are too small or doesnt exist, create a new one that is big enough to acocmodate the request.
 
std::vector< double > ConvolveFFT (const std::vector< double > &a, const std::vector< std::complex< double >> &b, size_t conv_size, double dt) const
 convolve a real waveform with the FFT of a kernel.
 
std::vector< double > Deconvolve (const std::vector< double > &wfm, size_t &iterations_ran) const
 performs Richard-Lucy deconvolution of the waveform. More...
 
void FindHits (const std::vector< double > &phi, std::vector< double > &out_times, std::vector< double > &out_charges, std::vector< double > &out_time_errors, std::vector< double > &out_charge_errors, double &chi2ndf) const
 Find hits in the deconvolved waveform. More...
 
void MergeClosePeaks (std::vector< double > &times, std::vector< double > &charges, std::vector< double > &time_errors, std::vector< double > &charge_errors)
 Perform post processing on the hits. Occasionally LucyDDM will resolve a single PE into two peaks. This function merges peaks that are too close to each other, and adjust time and charge accordingly.
 
void ClampBelowThreshold (std::vector< double > &wfm, double thresh=-9999) const
 Clamp all samples of a waveform below a threashold to epsilon (a positive value close to zero). More...
 
std::vector< double > ReblurWaveform (const std::vector< double > &phi) const
 convolve phi with the SPE template, effectively "reblurring" the deconvolved waveform. More...
 
std::vector< double > Resample (const std::vector< double > &wfm, size_t n_samples) const
 Resample a waveform to a different sampling period using linear interpolation. More...
 
double PoissonNLL (const std::vector< double > &wfm, const std::vector< double > &reblurred_wfm) const
 
double GaussianPulseTrain (double *x, double *p, size_t N) const
 

Protected Attributes

DBLinkPtr fDigit
 
double vpe_scale
 
double vpe_shape
 
double vpe_charge
 
double vpe_integral
 
double ds
 
size_t vpe_nsamples
 
std::vector< double > vpe_norm
 
std::vector< double > vpe_norm_flipped
 
std::vector< std::complex< double > > vpe_norm_fft
 
std::vector< std::complex< double > > vpe_norm_flipped_fft
 
double roi_threshold
 
double epsilon = 1e-10
 
size_t max_iterations
 
double stopping_nll_diff
 
double peak_height_threshold
 
double charge_threshold
 
double min_peak_distance
 
bool npe_estimate
 
bool npe_estimate_charge_width
 
size_t npe_estimate_max_pes
 
std::unique_ptr< FFTW1DTransformerfft = nullptr
 
std::unique_ptr< FFTW1DTransformerifft = nullptr
 
- Protected Attributes inherited from RAT::WaveformAnalyzerBase
double fTimeStep
 
double fVoltageRes
 
double fTermOhms
 
double fMinTotalCharge = std::numeric_limits<double>::lowest()
 
double fMaxTotalCharge = std::numeric_limits<double>::max()
 
- Protected Attributes inherited from RAT::Processor
std::string name
 

Additional Inherited Members

- Public Types inherited from RAT::Processor
enum  Result { OK = 0 , FAIL = 1 , ABORT = 2 }
 

Detailed Description

Perform PMT waveform analysis using Richard-Lucy Direct Demodulation (LucyDDM).

Reconstruct multiple photoelectrons in a single PMT waveform using direct deconvolution. Method is mainly based on the discussion Sec. 3.3.2 of https://arxiv.org/abs/2112.06913

The waveform analysis is carreid out in three stages: 1) Deconvolution. Utilyzing Richard-Lucy Direct Demoulation to deconvolve the waveform using a lognormal single PE kernel. 2) Wave packect identification. In the decononvovled waveform, determine local maximum as the peaks of wave packets. Perform a gaussian fit around each peak to determine the time and charge of each wave packet. 3) (optional) NPE estimation. If enabled, use a gaussian single-PE charge distribution PDF to estimate the number of PEs in each resolved wave packet.

Member Function Documentation

◆ ClampBelowThreshold()

void RAT::WaveformAnalysisLucyDDM::ClampBelowThreshold ( std::vector< double > &  wfm,
double  thresh = -9999 
) const
protected

Clamp all samples of a waveform below a threashold to epsilon (a positive value close to zero).

Parameters
wfmwaveform to clamp (modified in place).
threshthreshold value. If a sample is below this value, it will be set to epsilon. If thresh is not specified, use roi_threshold.

◆ Configure()

void RAT::WaveformAnalysisLucyDDM::Configure ( const std::string &  config_name)
overridevirtual

Configure the processor. This method will be called upon processor instantiation.

Parameters
config_nameAn index that is typically used to index table DIGITIZER_ANALYSIS in ratdb. Although technically you can use it for anything. In the base class this does nothing for now. But stuff can be added in the future if we would like to set parameters for all processors.

Reimplemented from RAT::WaveformAnalyzerBase.

◆ Deconvolve()

std::vector< double > RAT::WaveformAnalysisLucyDDM::Deconvolve ( const std::vector< double > &  wfm,
size_t &  iterations_ran 
) const
protected

performs Richard-Lucy deconvolution of the waveform.

Parameters
wfmwaveform to deconvolve. @out iterations_ran number of iterations ran in the deconvolution.
Returns
deconvolved waveform.

◆ FindHits()

void RAT::WaveformAnalysisLucyDDM::FindHits ( const std::vector< double > &  phi,
std::vector< double > &  out_times,
std::vector< double > &  out_charges,
std::vector< double > &  out_time_errors,
std::vector< double > &  out_charge_errors,
double &  chi2ndf 
) const
protected

Find hits in the deconvolved waveform.

Parameters
phideconvolved waveform. @out out_times output hit times. @out out_charges output hit charges. @out out_time_errors output hit time errors, as reported by Minuit. @out out_charge_errors output hit charge errors, as reported by Minuit. @out chi2ndf output chi2/ndf of the fit.

◆ GaussianPulseTrain()

double RAT::WaveformAnalysisLucyDDM::GaussianPulseTrain ( double *  x,
double *  p,
size_t  N 
) const
protected

Fit function that represents a series of gaussian pulses. To be fed to ROOT for minimization. The parameters are in groups of 3, representing the amplitude, time, and width

◆ PoissonNLL()

double RAT::WaveformAnalysisLucyDDM::PoissonNLL ( const std::vector< double > &  wfm,
const std::vector< double > &  reblurred_wfm 
) const
protected

A Poisson negative log-likelihood between the original waveform and the reblurred waveform. Used as a cost function to evaluate the quality of the deconvolution.

Parameters
wfmoriginal waveform.
reblurred_wfmdeconvolved waveform, re-blurred by the spingle PE template.

◆ ReblurWaveform()

std::vector< double > RAT::WaveformAnalysisLucyDDM::ReblurWaveform ( const std::vector< double > &  phi) const
protected

convolve phi with the SPE template, effectively "reblurring" the deconvolved waveform.

Parameters
phideconvolved waveform.
Returns
reblurred waveform.

◆ Resample()

std::vector< double > RAT::WaveformAnalysisLucyDDM::Resample ( const std::vector< double > &  wfm,
size_t  n_samples 
) const
protected

Resample a waveform to a different sampling period using linear interpolation.

Parameters
wfmwaveform to resample.
n_samplesnumber of samples in the resampled waveform.

Member Data Documentation

◆ vpe_integral

double RAT::WaveformAnalysisLucyDDM::vpe_integral
protected
Initial value:
=
-9999

The documentation for this class was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/daq/include/RAT/WaveformAnalysisLucyDDM.hh
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/daq/src/WaveformAnalysisLucyDDM.cc