wavecatcher-analysis
Loading...
Searching...
No Matches
Filters Class Reference

#include <Filters.h>

Static Public Member Functions

static void Bilateral2Filter (double *&, int, int, double, double, double)
 Nonlinear filter based on bilateral filter.
 
static void BilateralFilter (double *&, int, double, double, double)
 Bilateral filter (non-linear) with 3 sigma kernel.
 
static void BoxFilter (double *&, int, int)
 Simple running average (box) filter.
 
static void Convolute (double *&, double *, double *, int)
 Helper to perform convolution of two 1D arrays.
 
static void Convolute (double *&, double *, int)
 Helper to perform convolution of two 1D arrays.
 
static void Deconvolute (double *&, double *, double *, int, double, double=0., double=0.)
 Helper to perform partial deconvolution of two 1D arrays.
 
static void GausFFTFilter (double *&, int, double, double)
 Gaussian smoothing with FFT convolution.
 
static void GausFilter (double *&, int, double, double)
 Gaussian smoothing with simple 3 sigma kernel.
 
static void MedianFilter (double *&ar, int, int)
 Median filter.
 
static void ResponseFilter (double *&, int, double=.4, double=1.2, double=.25, double=.3125)
 Custom filter emulating primitive response function.
 
static void SecondOrderUnderdampedFilter (double *&, int, double, double, double, double=.3125, bool=false)
 Shifted second order underdamped filter.
 
static void SecondOrderUnderdampedFilter (TH1F *&, int, double, double, double, double=.3125, bool=false)
 Shifted second order underdamped filter See above for details.
 
static void SmoothArray (double *&, int, double, int, double=.3125, double=1.5)
 Apply smoothing array of double with length nbins.
 
static void SmoothArray (double *&, int, double=.625, string="Gaus", double=.3125, double=1.5)
 Apply smoothing array of double with length nbins.
 

Detailed Description

Definition at line 21 of file Filters.h.

Member Function Documentation

◆ Bilateral2Filter()

void Filters::Bilateral2Filter ( double *&  ar,
int  nbins,
int  sigma_x,
double  sigma_y,
double  sigma_slope,
double  bin_size 
)
static

Nonlinear filter based on bilateral filter.

Uses data and slope of data to weight the smoothing. x is not used. Very slow.

Parameters
arArray to be smoothed.
nbinsNumber of bins of input.
sigma_xWindow along x in bins.
sigma_ySigma along y in mV.
sigma_slopeSigma of slope in mV.
bin_sizeBin size in ns.

Definition at line 338 of file Filters.cc.

◆ BilateralFilter()

void Filters::BilateralFilter ( double *&  ar,
int  nbins,
double  sigma_x,
double  sigma_y,
double  bin_size 
)
static

Bilateral filter (non-linear) with 3 sigma kernel.

For noise reduction while preserving edges, i .e. for baseline correction. Slow.

Parameters
arArray to be smoothed.
nbinsNumber of bins of input.
sigma_xGauss sigma along x in ns.
sigma_yGauss sigma along y in mV.
bin_sizeBin size in ns.

Definition at line 299 of file Filters.cc.

◆ BoxFilter()

void Filters::BoxFilter ( double *&  ar,
int  nbins,
int  sigma 
)
static

Simple running average (box) filter.

Parameters
arArray to be smoothed.
nbinsNumber of bins of input.
sigmaNumber of bins before and after central bin.

Definition at line 207 of file Filters.cc.

◆ Convolute() [1/2]

void Filters::Convolute ( double *&  result,
double *  first,
double *  second,
int  size 
)
static

Helper to perform convolution of two 1D arrays.

WARNING: All arrays must be of the same size.

Used for smoothing etc.

Parameters
[in,out]resultArray containing convolution result
firstFirst array for convolution
secondSecond array for convolution
sizeSize of arrays

Definition at line 12 of file Filters.cc.

◆ Convolute() [2/2]

void Filters::Convolute ( double *&  first,
double *  second,
int  size 
)
static

Helper to perform convolution of two 1D arrays.

WARNING: All arrays must be of the same size.

Used for smoothing etc.

Parameters
[in,out]firstArray to be convoluted
secondSecond array for convolution
sizeSize of arrays

Definition at line 65 of file Filters.cc.

◆ Deconvolute()

void Filters::Deconvolute ( double *&  result,
double *  first,
double *  second,
int  size,
double  sigma,
double  x0 = 0.,
double  bin_size = 0. 
)
static

Helper to perform partial deconvolution of two 1D arrays.

WARNING: All arrays must be of the same size.

Parameters
[in,out]resultArray containing deconvolution result
firstFirst array for deconvolution
secondSecond array for deconvolution
sizeSize of arrays
sigmaGaussian sigma in ns
x0Gaussian center in ns
bin_sizeBin size in ns

Definition at line 80 of file Filters.cc.

◆ GausFFTFilter()

void Filters::GausFFTFilter ( double *&  ar,
int  nbins,
double  sigma,
double  bin_size 
)
static

Gaussian smoothing with FFT convolution.

Parameters
arArray to be smoothed.
nbinsNumber of bins of input.
sigmaGauss sigma in ns.
bin_sizeBin size in ns.

Definition at line 266 of file Filters.cc.

◆ GausFilter()

void Filters::GausFilter ( double *&  ar,
int  nbins,
double  sigma,
double  bin_size 
)
static

Gaussian smoothing with simple 3 sigma kernel.

Parameters
arArray to be smoothed.
nbinsNumber of bins of input.
sigmaGauss sigma in ns.
bin_sizeBin size in ns.

Definition at line 230 of file Filters.cc.

◆ MedianFilter()

void Filters::MedianFilter ( double *&  ar,
int  nbins,
int  window_size 
)
static

Median filter.

Parameters
arArray to be smoothed.
nbinsNumber of bins of input.
window_sizeWindow size for median in bins.

Definition at line 378 of file Filters.cc.

◆ ResponseFilter()

void Filters::ResponseFilter ( double *&  ar,
int  nbins,
double  sigma1 = .4,
double  sigma2 = 1.2,
double  factor = .25,
double  bin_size = .3125 
)
static

Custom filter emulating primitive response function.

Can be used to highlight peaks and suppress long tails (see pole-zero cancellation). Emulates response function of an amplifier setup.
Uses constant padding to avoid edge effects.
Use Filter_test.ipynb to test parameters.

Parameters
[in,out]arArray to be filtered.
nbinsNumber of bins of input.
sigma1First.
sigma2Second.
factorFactor for negative part (<=1).
bin_sizeBin width. Default is .3125. Set to 1 to get sigma in units of bins.

Definition at line 421 of file Filters.cc.

◆ SecondOrderUnderdampedFilter() [1/2]

void Filters::SecondOrderUnderdampedFilter ( double *&  ar,
int  nbins,
double  period,
double  damping,
double  shift,
double  bin_size = .3125,
bool  do_plot = false 
)
static

Shifted second order underdamped filter.

Emulating 2nd order underdamped response (simple damped harmonic oscillator).
Will only consider 3 periods of the response function.
In development, for testing only.

Parameters
[in,out]arArray to be filtered.
nbinsNumber of bins of input.
periodPeriod of response function in ns.
dampingDamping time constant of the response function in ns. Needs to be > 0.
shiftShift of response function in ns.
bin_sizeBin width of the input.
do_plotPlot response function and save to file.

Definition at line 466 of file Filters.cc.

◆ SecondOrderUnderdampedFilter() [2/2]

void Filters::SecondOrderUnderdampedFilter ( TH1F *&  his,
int  nbins,
double  period,
double  damping,
double  shift,
double  bin_size = .3125,
bool  do_plot = false 
)
static

Shifted second order underdamped filter See above for details.

Parameters
[in,out]hisHistogram to be filtered.

Definition at line 547 of file Filters.cc.

◆ SmoothArray() [1/2]

void Filters::SmoothArray ( double *&  ar,
int  nbins,
double  sigma,
int  method,
double  bin_size = .3125,
double  sigma2 = 1.5 
)
static

Apply smoothing array of double with length nbins.

Parameters
methodIf 0: Use running average (box kernel smoothing). Simple, very fast.
If 1: Use 5 sigma FFT gaussian smoothing. This method is not central and will shift peaks. Very slow.
Else: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.

Definition at line 179 of file Filters.cc.

◆ SmoothArray() [2/2]

void Filters::SmoothArray ( double *&  ar,
int  nbins,
double  sigma = .625,
string  method = "Gaus",
double  bin_size = .3125,
double  sigma2 = 1.5 
)
static

Apply smoothing array of double with length nbins.

Use with care. Method="Gaus" is preferred.

Please note that if you want to use gaussian smoothing for data with a binning different from 0.3125 ns/bin you need to set the variable bin_size to the new bin size.

Gaussian smoothing of a simple array with 15 entries. Code in example.
Parameters
[in,out]arArray to be smoothed.
nbinsNumber of bins of input.
sigmaNumber of bins before and after central bin for "Box" and "Median".
Gaussian sigma in ns for "Gaus" and "GausFFT".
Sigma in x for "Bilateral" and "Bilateral2".
method"Box": Use running average (box kernel smoothing). Simple, very fast.
"GausFFT": Use 5 sigma FFT gaussian smoothing. This method is not central and will shift peaks. Very slow.
"Gaus": Use 3 sigma gaussian kernel smoothing. Preferred method, fast. "Median": Use median filter. Fast.
"Bilateral": Use bilateral filter. Slow.
"Bilateral2": Use bilateral filter with different kernel. Slow.
bin_sizeBin width of the array to smooth for gauss sigma. Default is .3125 for wavecatcher sampling rate. Set to 1 to change sigma unit to number of bins.
sigma2Sigma in y for "Bilateral" and "Bilateral2".
Examples
use_functions_wo_measurement.cc.

Definition at line 160 of file Filters.cc.


The documentation for this class was generated from the following files: