#include <SineSubtract.h>
Public Types | |
enum | PowerSpectrumEstimator { FFT, LOMBSCARGLE } |
enum | FFT_Params { FFT_NPAD, FFT_NPARAMS } |
enum | LOMBSCARGLE_Params { LS_OVERSAMPLE_FACTOR, LS_NPARAMS } |
enum | PeakFindingOption { GLOBALMAX, NEIGHBORFACTOR, TSPECTRUM, SAVGOLSUB } |
enum | NEIGHBORFACTOR_Params { NF_NEIGHBOR_FACTOR, NF_NPARAMS } |
enum | TSPECTRUM_Params { TS_SIGMA, TS_THRESHOLD, TS_NDECONV_ITERATIONS, TS_AVERAGE_WINDOW, TS_NPARAMS } |
enum | SAVGOLSUB_Params { SGS_ORDER, SGS_WIDTH, SGS_NPARAMS } |
enum | EnvelopeOption { ENV_NONE, ENV_HILBERT, ENV_RMS, ENV_PEAK } |
enum | ENV_HILBERT_Params { ENV_HILBERT_FIT_ORDER, ENV_HILBERT_NPARAMS } |
enum | ENV_RMS_Params { ENV_RMS_FIT_ORDER, ENV_RMS_WINDOW, ENV_RMS_NPARAMS } |
enum | ENV_PEAK_Params { ENV_PEAK_FIT_ORDER, ENV_PEAK_MINDISTANCE, ENV_PEAK_NPARAMS } |
Public Member Functions | |
SineSubtract (int max_iter_without_reduction=3, double min_power_reduction=0.05, bool store=false) | |
SineSubtract (const TGraph *freq_dependent_min_power_reduction, int max_iter_without_reduction=3, bool store=false) | |
virtual | ~SineSubtract () |
TGraph * | subtractCW (const TGraph *g, double dt, const SineSubtractResult *result=NULL) |
double * | subtractCW (int N, const double *y, double dt, double *y_out=NULL, const SineSubtractResult *result=NULL) |
void | subtractCW (int ng, TGraph **g, double dt, const double *w=0, const SineSubtractResult *result=NULL) |
void | setFreqLimits (double min, double max) |
void | setFreqLimits (int nbands, const double *min, const double *max) |
void | unsetFreqLimits () |
void | setVerbose (bool v) |
void | setTraceLimits (int min, int max) |
void | setNFailsExponent (double exp=0.5) |
void | setPowerSpectrumEstimator (PowerSpectrumEstimator estimator, const double *params=0) |
void | setPeakFindingOption (PeakFindingOption peak, const double *params=0) |
void | setEnvelopeOption (EnvelopeOption env, const double *params=0) |
const std::vector< double > * | getPowerSequence () const |
const std::vector< std::vector< TGraph * > > * | getStoredGraphs () const |
const std::vector< TGraph * > * | getStoredSpectra () const |
size_t | nStoredGraphsInChannel () const |
size_t | nChannels () const |
TGraph * | storedGraph (int i, int c) |
TGraph * | storedEnvelope (int i, int c) |
size_t | nStoredSpectra () const |
TGraph * | storedSpectra (int i) |
int | getNSines () const |
int | getNGraphs () const |
const double * | getPhases (int g) const |
const double * | getFreqs () const |
const double * | getAmps (int g) const |
const double * | getPhaseErrs (int g) const |
const double * | getFreqErrs () const |
const double * | getAmpErrs (int g) const |
const SineSubtractResult * | getResult () const |
void | setMaxIterationsWithoutReduction (int max) |
void | setAbsoluteMaxIterations (int max) |
void | setMaxSuccessfulIterations (int max) |
void | setMinPowerReduction (double min) |
void | setMinPowerReduction (const TGraph *g) |
void | setStore (bool s) |
void | setFitterLimitOptions (const SineFitterLimits *lims) |
void | makePlots (TCanvas *cpower=0, TCanvas *cspectra=0, int ncols=4) const |
void | makeSlides (const char *title="SineSubtract", const char *prefix="sinsub", const char *outdir=".", const char *format="png", bool standalone=true) const |
SineFitter * | sineFitter () |
The SineSubtract class handles the number of iterations and initialization of the fitter.
Definition at line 391 of file SineSubtract.h.
Enumerator | |
---|---|
ENV_HILBERT |
No envelope is used. |
Definition at line 584 of file SineSubtract.h.
The parameters for PowerSpectrumEstimator FFT
Enumerator | |
---|---|
FFT_NPARAMS |
default =0 |
Definition at line 514 of file SineSubtract.h.
The parameters for PowerSpectrumEstimator LOMBSCARGLE
Enumerator | |
---|---|
LS_NPARAMS |
default =2 |
Definition at line 521 of file SineSubtract.h.
Enumerator | |
---|---|
NF_NPARAMS |
default = 0.15 |
Definition at line 553 of file SineSubtract.h.
These are the algorithms for finding the peak of the power spectrum.
Definition at line 544 of file SineSubtract.h.
These are the algorithms for estimating the power spectrum, used to help estimate the starting parameters.
Definition at line 506 of file SineSubtract.h.
Enumerator | |
---|---|
SGS_WIDTH |
default = 3 (treated as int) |
SGS_NPARAMS |
default = 5 , really halfwidth, (treated as int) |
Definition at line 571 of file SineSubtract.h.
Enumerator | |
---|---|
TS_THRESHOLD |
default = 2 |
TS_NDECONV_ITERATIONS |
default = 0.05 |
Definition at line 562 of file SineSubtract.h.
FFTtools::SineSubtract::SineSubtract | ( | int | max_iter_without_reduction = 3 , |
double | min_power_reduction = 0.05 , |
||
bool | store = false |
||
) |
Create a new SineSubtract. A few options may be set here, although they can all be changed by setters later too (and there are other options that can only be set by setters.
max_iter_without_reduction | Set the maximum number of failed iterations before giving up. An iteration fails if the subtraction does not produce the required power reduction. |
min_power_reduction | Set the minimum power reduction necessary to keep an iteration. Default is 5 percent. |
store | If true, intermediate steps will be saved. This incurs some overhead, so is mostly useful for making pretty plots and diagnostics. |
Definition at line 858 of file SineSubtract.cxx.
FFTtools::SineSubtract::SineSubtract | ( | const TGraph * | freq_dependent_min_power_reduction, |
int | max_iter_without_reduction = 3 , |
||
bool | store = false |
||
) |
Create a new SineSubtract. A few options may be set here, although they can all be changed by setters later too (and there are other options that can only be set by setters.
freq_dependent_min_power_reductionmin_power_reduction | Set the minimum power reduction necessary to keep an iteration, varying with frequency (freq in GHz). |
max_iter_without_reduction | Set the maximum number of failed iterations before giving up. An iteration fails if the subtraction does not produce the required power reduction. |
store | If true, intermediate steps will be saved. This incurs some overhead, so is mostly useful for making pretty plots and diagnostics. |
Definition at line 833 of file SineSubtract.cxx.
|
virtual |
Deallocate everything
Definition at line 1536 of file SineSubtract.cxx.
|
inline |
Get array of fit amplitude errors for the ith trace
Definition at line 666 of file SineSubtract.h.
|
inline |
Get array of fit amplitudes for the ith trace
Definition at line 657 of file SineSubtract.h.
|
inline |
Get array of fit frequnecy errors
Definition at line 663 of file SineSubtract.h.
|
inline |
Get array of fit frequencies
Definition at line 654 of file SineSubtract.h.
int FFTtools::SineSubtract::getNSines | ( | ) | const |
Return the number of sines fit
Definition at line 1385 of file SineSubtract.cxx.
|
inline |
Get array of fit phase errors for the ith trace
Definition at line 660 of file SineSubtract.h.
|
inline |
Get array of fit phases for the ith trace
Definition at line 651 of file SineSubtract.h.
|
inline |
Returns a pointer to a vector of the sequence of powers vs. iteration
Definition at line 619 of file SineSubtract.h.
|
inline |
Get a pointer to the SineSubtract result
Definition at line 669 of file SineSubtract.h.
|
inline |
If storage of graphs is enabled, returns a pointer to a nested vector of stored graphs
Definition at line 622 of file SineSubtract.h.
|
inline |
If storage of graphs is enabled, returns a pointer to a nested vector of stored power spectra
Definition at line 625 of file SineSubtract.h.
void FFTtools::SineSubtract::makePlots | ( | TCanvas * | cpower = 0 , |
TCanvas * | cspectra = 0 , |
||
int | ncols = 4 |
||
) | const |
Generate plots of traces and spectra.
cpower | Pointer to canvas to put traces + fits on. If NULL, new one is created. |
cspectra | Pointer to canvas to put spectra on. If NULL, new one is created. |
ncols | The number of columns per canvas |
Definition at line 1500 of file SineSubtract.cxx.
void FFTtools::SineSubtract::makeSlides | ( | const char * | title = "SineSubtract" , |
const char * | prefix = "sinsub" , |
||
const char * | outdir = "." , |
||
const char * | format = "png" , |
||
bool | standalone = true |
||
) | const |
Make Beamer slides showing all iterations, for those moments when you desperately need slides to show.
title | Used in the frame title |
prefix | Used for naming files (e.g. sinsub will produce sinsub_0, sinsub_1, etc ) |
outdir | Output directory |
format | The format of the plots (e.g. png, pdf) |
standalone | If true, makes a self contained presentation, otherwise, can be copied and pasted in. |
Definition at line 1390 of file SineSubtract.cxx.
|
inline |
If storage of graphs is enabled, returns the number of channels stored (the number of traces that are being simultaneously fit for. Will be 0 if storage disabled.
Definition at line 632 of file SineSubtract.h.
|
inline |
If storage of graphs is enabled, returns the number of stored graphs per channel (basically the number of iterations+1). Will be 0 if storage disabled.
Definition at line 629 of file SineSubtract.h.
|
inline |
If storage of graphs is enabled, returns the number of stored spectra. (Basically the number of iterations+1). Will be 0 if storage disabled.
Definition at line 639 of file SineSubtract.h.
|
inline |
Sets the maximum absolute number of iterations, even if power reduction is still happening. If max <= 0, there is no max
Definition at line 675 of file SineSubtract.h.
void FFTtools::SineSubtract::setEnvelopeOption | ( | EnvelopeOption | env, |
const double * | params = 0 |
||
) |
Set the envelope option used to estimate an envelope to modify the sinusoids. See EnvelopeOption for possibilities. params depends on the particular envelope option you want (or pass 0 for defaults).
Definition at line 1756 of file SineSubtract.cxx.
|
inline |
Makes the fitter use this SineFitterLimits
Definition at line 691 of file SineSubtract.h.
|
inline |
Set limits on the frequencies to try to subtract. If the units of the graph are in ns, the frequencies should be in GHz.
min | The minimum frequency to try to remove |
max | The maximum frequency to try to remove |
Definition at line 465 of file SineSubtract.h.
|
inline |
Set multiple allowed bands of frequencies to try to subtract. If the units of the graph are in ns, the frequencies should be in GHz.
nbands | The number of frequency bands |
min | Array of minima of each band |
max | Array of maxima of each band |
Definition at line 473 of file SineSubtract.h.
|
inline |
Sets the maximum number of successful iterations, useful if you're trying to subtract a particular sinusoid. If max <=0, there is no max
Definition at line 678 of file SineSubtract.h.
|
inline |
Set the threshold for considering an iteration successful. This is a percentage of power reduction.
Definition at line 681 of file SineSubtract.h.
|
inline |
Each time an iteration fails, the power spectrum bin is weighted by 1./(1+nfails)^exp to discourage further usage
Definition at line 530 of file SineSubtract.h.
void FFTtools::SineSubtract::setPeakFindingOption | ( | PeakFindingOption | peak, |
const double * | params = 0 |
||
) |
Set the peak finding option used to seed the sinusoid fitter. See PeakFindingOption for possibilities. params depends on the particular peak finder you want (or pass 0 for defaults).
Definition at line 1725 of file SineSubtract.cxx.
void FFTtools::SineSubtract::setPowerSpectrumEstimator | ( | PowerSpectrumEstimator | estimator, |
const double * | params = 0 |
||
) |
Set the power spectrum estimator used to initialize the SineSubtractFilter. See documentation for PowerSpectrumEstimator for what the types mean (or pass 0 to use the defaults).
Definition at line 1697 of file SineSubtract.cxx.
|
inline |
Togggle storage of intermediate traces
Definition at line 688 of file SineSubtract.h.
|
inline |
In some cases, it may make sense to use only part of the trace for subtraction. For example, one may want to avoid using the part near the trigger to avoid subtracting off a pulse. If trace limits are enabled, only the portion of the trace within limits is used for estimating the spectrum and finding sinusoids that reduce the power, however, once those sinusoids are found, the entire trace has them subtracted.
While in principle, these could be different for each each waveform when subtracting multiple, right now they are all the same.
min | The minimum sample of the trace to use |
max | The maximum sample of the trace to use |
Definition at line 496 of file SineSubtract.h.
|
inline |
Toggle voluminous verbosity. It is a well-known fact that additional lines of text scrolling with great alacrity on your terminal have myriad benefits that this comment is far too brief to expound.
Definition at line 482 of file SineSubtract.h.
|
inline |
Returns the ith graph in the cth trace
Definition at line 635 of file SineSubtract.h.
|
inline |
Returns the power spectra of the ith iteration
Definition at line 642 of file SineSubtract.h.
void FFTtools::SineSubtract::subtractCW | ( | int | ng, |
TGraph ** | g, | ||
double | dt, | ||
const double * | w = 0 , |
||
const SineSubtractResult * | result = NULL |
||
) |
Subtract CW from one or more traces. Sine Subtraction can handle both evenly-spaced and unevenly-spaced waveforms. For evenly spaced waveforms, you should pass dt<-0, otherwise you should pass the nominal average. Right now, all graphs are assumed to have the same sampling, although this limitation could be removed with some work.
The input graphs are touched, you should make a copy if you want to preserve the originals.
ng | the number of graphs |
g | The graphs. Will be modified. |
dt | The nominal sample rate for uneven waveforms. If <=0, then the graphs are assumed to be even and dt is computed from first time step. |
w | Scales for the input values. If the y-axis have different scales (different gains or units) you should pass an array here. If 0, everything is equally-weighted. |
We need padded copies of traces if they don't all have the same length so that the spectrum has the same bins (or if we want to pad for extra resolution)
Definition at line 959 of file SineSubtract.cxx.
|
inline |
Clear all frequency limits
Definition at line 476 of file SineSubtract.h.