FFTtools.h
1 
2 #ifndef FFTTOOLS_H
3 #define FFTTOOLS_H
4 
5 
6 
7 // If the following is uncommented, in and out arrays for FFTW are allocated contiguously.
8 #define FFTTOOLS_ALLOCATE_CONTIGUOUS
9 //#define FFTTOOLS_THREAD_SAFE
10 //
11 
12 
13 // You may choose to define FFTTOOLS_COMPAT_MODE
14 // to get FFTtools to behave like it did several years ago (where it was a class with static methods).
15 // This might help with legacy code.
16 
17 
18 // c++ libraries thingies
19 #include <map>
20 #include <algorithm>
21 #include <iostream>
22 #include <fstream>
23 
24 // ROOT
25 #include "TGraph.h"
26 #include "TROOT.h"
27 #include "TMath.h"
28 #include "TString.h"
29 #include "TSystem.h"
30 #include "TMath.h"
31 #include "Math/Interpolator.h"
32 #include "Math/InterpolationTypes.h"
33 
34 #ifdef FFTTOOLS_COMPAT_MODE
35 #define FFTTOOLS_METHOD static
36 #else
37 #define FFTTOOLS_METHOD
38 #include "FFTWindow.h"
39 #endif
40 
41 
42 //My includes
43 #include "FFTWComplex.h"
44 #include "RFSignal.h"
45 
46 class TRandom;
47 class TH2;
48 
49 // FFTW
50 #include <complex>
51 
76 #ifdef FFTTOOLS_COMPAT_MODE
77 class
78 #else
79 namespace
80 #endif
82 {
83 
84 #ifdef FFTTOOLS_COMPAT_MODE
85  public:
86 #endif
87 
89 
94  FFTTOOLS_METHOD TGraph *getInterpolatedGraph(const TGraph *grIn, Double_t deltaT);
95 
97 
102  FFTTOOLS_METHOD TGraph *getInterpolatedGraphFreqDom(const TGraph *grIn, Double_t deltaT);
103 
105 
110  FFTTOOLS_METHOD TGraph *getConvolution(const TGraph *grA, const TGraph *grB);
112 
117  FFTTOOLS_METHOD RFSignal *getConvolution(RFSignal *grA, RFSignal *grB);
118 
120 
124  FFTTOOLS_METHOD double getAbs(FFTWComplex &theNum);
125 
127 
132  FFTTOOLS_METHOD double *doInvFFT(int length, const FFTWComplex *theInput);
134 
139  FFTTOOLS_METHOD FFTWComplex *doFFT(int length,const double *theInput);
140 
141 
142 
144  FFTTOOLS_METHOD void doFFT(int length, const double * properly_aligned_input, FFTWComplex * properly_aligned_output);
145 
147  FFTTOOLS_METHOD void doInvFFTClobber(int length, FFTWComplex * properly_aligned_input_that_will_likely_be_clobbered, double * properly_aligned_output);
148 
157  FFTTOOLS_METHOD void doInvFFTNoClobber(int length, const FFTWComplex * properly_aligned_input, double * properly_aligned_output);
158 
160 
164  FFTTOOLS_METHOD TGraph *convertMagnitudeToTimeDomain(const TGraph *inputMag);
165 
167 
174  FFTTOOLS_METHOD double *getCorrelation(const TGraph *gr1, const TGraph *gr2,int firstIndex,int lastIndex);
176 
182  FFTTOOLS_METHOD double *getCorrelation(int length,const float *oldY1, const float *oldY2);
184 
190  FFTTOOLS_METHOD double *getCorrelation(int length,const double *oldY1,const double *oldY2);
191 
192 
194 
199  FFTTOOLS_METHOD TGraph *correlateAndAverage(Int_t numGraphs, TGraph **grPtrPtr);
200 
204 
213  FFTTOOLS_METHOD TGraph *correlateAndAveragePredeterminedZone(Int_t numGraphs, TGraph **grPtrPtr, Int_t *correlationBinPtr, Int_t binWiggleRoom);
214 
216 
223  FFTTOOLS_METHOD TGraph *interpolateCorrelateAndAverage(Double_t deltaTInt,
224  Int_t numGraphs,
225  TGraph **grPtrPtr);
226 
228 
234  FFTTOOLS_METHOD Double_t *combineValuesUsingFFTs(Int_t numArrays, Double_t **thePtrPtr, Int_t eachLength);
235 
236  //Higher level functions that take and return TGraphs
238 
242  FFTTOOLS_METHOD TGraph *makePowerSpectrum(const TGraph *grWave);
244 
248  FFTTOOLS_METHOD TGraph *makePowerSpectrumPeriodogram(const TGraph *grWave);
250 
254  FFTTOOLS_METHOD TGraph *makePowerSpectrumVoltsSeconds(const TGraph *grWave);
256 
260  FFTTOOLS_METHOD TGraph *makePowerSpectrumVoltsSecondsBartlett(const TGraph *grWave);
262 
268  FFTTOOLS_METHOD TGraph *makePSVSBartlettPaddedOverlap(const TGraph *grWave, Int_t padFactor=4, Int_t numFreqs=64);
269 
271 
275  FFTTOOLS_METHOD TGraph *makePowerSpectrumVoltsSecondsdB(const TGraph *grWave);
277 
281  FFTTOOLS_METHOD TGraph *makePowerSpectrumMilliVoltsNanoSeconds(const TGraph *grWave);
282  FFTTOOLS_METHOD TGraph *makePowerSpectrumMilliVoltsNanoSecondsdB(const TGraph *grWave);
284 
289  FFTTOOLS_METHOD TGraph *makePowerSpectrumVoltsSecondsPadded(const TGraph *grWave, Int_t padFactor=4);
291 
296  FFTTOOLS_METHOD TGraph *makePowerSpectrumVoltsSecondsPaddeddB(const TGraph *grWave, Int_t padFactor=4);
297 
299 
303  FFTTOOLS_METHOD TGraph *makeRawPowerSpectrum(const TGraph *grWave);
304 
306 
311  FFTTOOLS_METHOD TGraph *getCorrelationGraph(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0);
312 
313 
314 
316 
321  FFTTOOLS_METHOD TGraph *getNormalisedCorrelationGraph(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0);
322 
324 
332  FFTTOOLS_METHOD TGraph *getNormalisedCorrelationGraphTimeDomain(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0, Int_t useDtRange=0, Double_t dtMin=-1000, Double_t dtMax=1000);
333 
335 
341  FFTTOOLS_METHOD TGraph *getInterpolatedCorrelationGraph(const TGraph *grIn1, const TGraph *grIn2, Double_t deltaT);
343 
347  FFTTOOLS_METHOD TGraph *makeInverseInverseSpectrum(const TGraph *grWave);
348 
350 
356  FFTTOOLS_METHOD TGraph *combineGraphsUsingFFTs(Int_t numGraphs, TGraph **grPtr,const double *theWeights=0);
357 
359 
364  FFTTOOLS_METHOD TGraph *getBoxCar(const TGraph *grWave, Int_t halfWidth);
366 
370  FFTTOOLS_METHOD TGraph *getHilbertTransform(const TGraph *grWave);
371 
372 
374  FFTTOOLS_METHOD double * getHilbertTransform(int N, const double * y) ;
375 
376 
378 
382  FFTTOOLS_METHOD TGraph *getHilbertEnvelope(const TGraph *grWave);
383 
384  //Utility functions (not necessarily FFT related but they'll live here for now
385 
387 
393  FFTTOOLS_METHOD Double_t sumPower(const TGraph *gr,Int_t firstBin=-1,Int_t lastBin=-1);
395 
401  FFTTOOLS_METHOD Double_t integratePower(const TGraph *gr,Int_t firstBin=-1,Int_t lastBin=-1);
403 
409  FFTTOOLS_METHOD Double_t sumVoltageSquared(const TGraph *gr,Int_t firstBin,Int_t lastBin);
411 
417  FFTTOOLS_METHOD Double_t integrateVoltageSquared(const TGraph *gr,Int_t firstBin=-1,Int_t lastBin=-1);
419 
423  FFTTOOLS_METHOD Int_t getPeakBin(const TGraph *gr);
425 
431  FFTTOOLS_METHOD Int_t getPeakBin(const TGraph *gr, Int_t firstBin, Int_t lastBin);
433 
437  FFTTOOLS_METHOD Double_t getPeakXvalue(const TGraph *gr);
439 
444  FFTTOOLS_METHOD Double_t getPeakVal(const TGraph *gr, int *index=0);
446 
453  FFTTOOLS_METHOD Double_t getPeakVal(const TGraph *gr, Int_t firstBin, Int_t lastBin, int *index=0);
455 
461  FFTTOOLS_METHOD Double_t getPeakSqVal(const TGraph *gr, int *index=0);
463 
469  FFTTOOLS_METHOD void getPeakRmsSqVal(const TGraph *gr, Double_t &peak, Double_t &rms, Int_t *index=0);
470 
472 
478  FFTTOOLS_METHOD void getPeakRmsRectified(const TGraph *gr, Double_t &peak, Double_t &rms, Int_t *index=0);
479 
480  //Graph returning utility funcs
482 
486  FFTTOOLS_METHOD TGraph *getSimplePowerEnvelopeGraph(const TGraph *gr);
488 
493  FFTTOOLS_METHOD TGraph *smoothFFT(const TGraph *gr,Int_t factor) ;
495 
500  FFTTOOLS_METHOD TGraph *subtractGraphs(const TGraph *grA, const TGraph *grB);
502 
507  FFTTOOLS_METHOD TGraph *divideGraphs(const TGraph *grA, const TGraph *grB);
508 
509 
511 
516  FFTTOOLS_METHOD TGraph *translateGraph(const TGraph *grWave, const Double_t deltaT);
517 
519 
524  FFTTOOLS_METHOD TGraph *ratioSubtractOneGraphs(const TGraph *grA, const TGraph *grB) ;
526 
531  FFTTOOLS_METHOD TGraph *dbGraphs(const TGraph *grA, const TGraph *grB);
533 
538  FFTTOOLS_METHOD TGraph *padWave(const TGraph *grA, Int_t padFactor);
540 
545  FFTTOOLS_METHOD TGraph *padWaveToLength(const TGraph *grA, Int_t newLength);
547 
552  FFTTOOLS_METHOD TGraph *rectifyWave(const TGraph *gr, Int_t makeNeg=0);
553 
554  //Window functions
556 
561  FFTTOOLS_METHOD Double_t bartlettWindow(Int_t j, Int_t n);
563 
568  FFTTOOLS_METHOD Double_t welchWindow(Int_t j, Int_t n);
569 
570 
571 
573 
580  FFTTOOLS_METHOD void takeDerivative(Int_t numPoints, const Double_t *inputX, const Double_t *inputY, Double_t *outputX, Double_t *outputY);
581 
583 
587  FFTTOOLS_METHOD TGraph *getDerviative(const TGraph *grIn);
589 
593  FFTTOOLS_METHOD TGraph *getDerivative(const TGraph *grIn);
594 
596 
602  FFTTOOLS_METHOD TGraph *simplePassBandFilter(const TGraph *grWave, Double_t minFreq, Double_t maxFreq);
603 
605 
611  FFTTOOLS_METHOD TGraph *simpleNotchFilter(const TGraph *grWave, Double_t minFreq, Double_t maxFreq);
612 
613 
615 
622  FFTTOOLS_METHOD TGraph *multipleSimpleNotchFilters(const TGraph *grWave, Int_t numNotches, const Double_t minFreq[], const Double_t maxFreq[]);
623 
625 
631  FFTTOOLS_METHOD TGraph *cropWave(const TGraph *grWave, Double_t minTime, Double_t maxTime);
632 
633 
635 
639  FFTTOOLS_METHOD Double_t getWaveformSNR(const TGraph *gr);
641 
647  FFTTOOLS_METHOD Double_t getWaveformSNR(const TGraph *gr,Double_t &peakToPeak,Double_t &rms);
648 
650 
654  FFTTOOLS_METHOD Double_t getWaveformPeak(const TGraph *gr);
655  FFTTOOLS_METHOD Double_t getEnvelopeSNR(const TGraph *gr);
656  FFTTOOLS_METHOD Double_t getEnvelopeSNR(const TGraph *gr,Double_t &peakToPeak,Double_t &rms,Double_t &timeOfPeak);
657 
658 
660 
668  FFTTOOLS_METHOD Double_t simpleInterploate(Double_t x1, Double_t y1, Double_t x2, Double_t y2,Double_t x);
669 
675  FFTTOOLS_METHOD double * FFTCorrelation(int waveformlength, const FFTWComplex * A, const FFTWComplex * B, FFTWComplex * work = 0,
676  int min_i = 0, int max_i =0, int order=1);
677 
678 
681  FFTTOOLS_METHOD void inPlaceShift(int N, double *x);
682 
683 
685  FFTTOOLS_METHOD void rotate(TGraph * g, int rot);
686 
688  FFTTOOLS_METHOD void polySubtract(TGraph *g, int order=1);
689 
690 
691 
694  {
695  ZEROES_OUTSIDE,
696  REPEAT_OUTSIDE
697  };
698 
699 
703  FFTTOOLS_METHOD double * directConvolve(int N, const double *x, int M, const double * h, double *y = 0, int delay = 0, DirectConvolveEdgeBehavior edge_behavior = ZEROES_OUTSIDE);
704 
705 
707  FFTTOOLS_METHOD void wrap(size_t N, double * vals, double period = 360);
708 
710  FFTTOOLS_METHOD void wrap(size_t N, double * vals, double period, double center);
711 
713  FFTTOOLS_METHOD void wrap(size_t N, float * vals, float period, float center);
714 
716  FFTTOOLS_METHOD void wrap(size_t N, float * vals, float period = 360);
717 
718 
721  FFTTOOLS_METHOD inline int fast_floor(double val) { return (int) val - (val < (int) val); }
722 
728  FFTTOOLS_METHOD inline double wrap(double val, double period, double center)
729  { return val - period * fast_floor((val-center+period/2)/period); }
730 
732  FFTTOOLS_METHOD inline double wrap(double val, double period = 360)
733  { return wrap(val,period,period/2); }
734 
735 
737  FFTTOOLS_METHOD void unwrap(size_t N, double * vals, double period = 360);
738 
739 
741  FFTTOOLS_METHOD void unwrap(size_t N, float * vals, float period = 360);
742 
743 
745  FFTTOOLS_METHOD double getDt(const TGraph * g, int realN = 0);
746 
748  FFTTOOLS_METHOD double evalEvenGraph(const TGraph * g, double x);
749 
750 
751 
752 #ifndef FFTTOOLS_COMPAT_MODE
753 
754  void applyWindow(TGraph *g, const FFTWindowType *w);
755 #endif
756 
757 
759  FFTTOOLS_METHOD double randomRayleigh(double sigma=1, TRandom * rng = 0);
760 
762  FFTTOOLS_METHOD double sinc(double x, double eps = 0);
763 
764  FFTTOOLS_METHOD int loadWisdom(const char * file);
765  FFTTOOLS_METHOD int saveWisdom(const char * file);
766 
767 #ifndef FFTTOOLS_COMPAT_MODE
768 
780  TGraph * welchPeriodogram(const TGraph * gin, int segment_size, double overlap_fraction = 0.5, const FFTWindowType * window = &GAUSSIAN_WINDOW , bool truncate_extra = true, TGraph * gout = 0);
781 
782 
783 
784 
786  FFTTOOLS_METHOD double * lombScarglePeriodogramSlow(int N, const double *x, const double * y, int nfreqs, const double * freqs, double * answer = 0);
787 
789  FFTTOOLS_METHOD TGraph * lombScarglePeriodogram(const TGraph * g, double dt = 0, double oversample_factor = 4 ,
790  double high_factor = 2, TGraph * replaceme = 0, int extirpolation_factor =4) ;
791  FFTTOOLS_METHOD TGraph * lombScarglePeriodogram(int N, double dt, const double * __restrict x,
792  const double * __restrict y, double oversample_factor = 4 ,
793  double high_factor = 2, TGraph * replaceme = 0, int extirpolation_factor = 4) ;
794 
795 
796 #endif
797 
798 // TH2 * getPowerVsTimeUsingLombScargle(const TGraph * g, int nbins, double sampling_dt = 0, double oversample_factor = 4, double high_factor = 2, TH2 * useme = 0);
799 
800  /* Compute Stokes parameters from hpol / vpol and their hilbert transforms
801  *
802  * This computes either the average, as well as optionally the instantaneous values.
803  *
804  *
805  * @param N number of samples
806  * @param hpol hpol waveform (evenly sampled)
807  * @param hpol_hat hilbert transform of hpol waveform (evenly sampled)
808  * @param vpol vpol waveform (evenly sampled)
809  * @param vpol_hat hilbert transform of vpol waveform (evenly sampled)
810  * @param Iavg pointer to where Stokes I integral average will be stored (or null to not store).
811  * @param Qavg pointer to where Stokes Q integral average will be stored (or null to not store).
812  * @param Uavg pointer to where Stokes U integral average will be stored (or null to not store).
813  * @param Vavg pointer to where Stokes V integral average will be stored (or null to not store).
814  * @param Iins pointer to where Stokes I instantaneous value will be stored (or null to not store). Must be of length N unless only_store_max_instantaneous is true
815  * @param Qins pointer to where Stokes Q instantaneous value will be stored (or null to not store). Must be of length N unless only_store_max_instantaneous is true
816  * @param Uins pointer to where Stokes U instantaneous value will be stored (or null to not store). Must be of length N unless only_store_max_instantaneous is true
817  * @param Vins pointer to where Stokes V instantaneous value will be stored (or null to not store). Must be of length N unless only_store_max_instantaneous is true
818  * @param only_max_instantaneous if true, only returns the maximum of the instantaneous quantities (at the maximum I in the range)
819  */
820  FFTTOOLS_METHOD void stokesParameters(int N, const double * hpol, const double * hpol_hat, const double * vpol, const double * vpol_hat,
821  double * Iavg = 0, double * Qavg = 0, double * Uavg = 0, double * Vavg = 0,
822  double * Iins = 0, double * Qins = 0, double * Uins = 0, double * Vins = 0 ,
823  bool only_max_instantaneous = true );
824 
825 
826 
838  FFTTOOLS_METHOD void dftAtFreq(const TGraph * g, double freq, double * phase, double * amp = 0, double * real = 0, double * imag = 0);
839 
840 
851  FFTTOOLS_METHOD void dftAtFreqAndMultiples(const TGraph * g, double freq, int nmultiples, double * phase, double * amp = 0, double * real = 0, double * imag = 0);
852 
853 
861  FFTTOOLS_METHOD FFTWComplex * makeMinimumPhase(int N, const double * G, double mindb = -100);
862 
863 
870  FFTTOOLS_METHOD TGraph * makeMinimumPhase(const TGraph *g, double mindb=-100);
871 
872 
879  FFTTOOLS_METHOD TGraph * makeFixedDelay(const TGraph *g, double delay = 1);
880 
881 
885  FFTTOOLS_METHOD double checkCausality(int N, const FFTWComplex * signal) ;
886 
887 
899  FFTTOOLS_METHOD double * rmsEnvelope(int N, double W, const double * x, const double * y, double * out = 0);
900 
911  FFTTOOLS_METHOD double * peakEnvelope(int N, double min_distance, const double * x, const double *y, double * out = 0);
912 #ifdef FFTTOOLS_COMPAT_MODE
913 };
914 #else
915 }
916 #endif
917 
918 #endif //FFTTOOLS_H
void rotate(TGraph *g, int rot)
Definition: FFTtools.cxx:2627
TGraph * getNormalisedCorrelationGraphTimeDomain(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0, Int_t useDtRange=0, Double_t dtMin=-1000, Double_t dtMax=1000)
Returns the normalised correlation of two TGraphs.
Definition: FFTtools.cxx:627
Double_t getPeakVal(const TGraph *gr, int *index=0)
Find the peak (maximum positive) in a TGraph.
Definition: FFTtools.cxx:1510
DirectConvolveEdgeBehavior
Definition: FFTtools.h:693
Double_t getPeakSqVal(const TGraph *gr, int *index=0)
Find the peak (v^2) in a TGraph.
Definition: FFTtools.cxx:1550
TGraph * combineGraphsUsingFFTs(Int_t numGraphs, TGraph **grPtr, const double *theWeights=0)
Returns the time domain result of a frequency domain sum of a number of TGraphs. In the sum each TGra...
Definition: FFTtools.cxx:570
TGraph * multipleSimpleNotchFilters(const TGraph *grWave, Int_t numNotches, const Double_t minFreq[], const Double_t maxFreq[])
This returns a TGraph which has had N simple notch band filters applied.
Definition: FFTtools.cxx:2038
Double_t integratePower(const TGraph *gr, Int_t firstBin=-1, Int_t lastBin=-1)
The integral of the power in a TGraph (normally a PSD) (i.e the sum of bin content*bin width) ...
Definition: FFTtools.cxx:1406
TGraph * makePowerSpectrumPeriodogram(const TGraph *grWave)
Returns the power spectral density. Note the PSD returned is the periodogram (or if you prefer is nor...
Definition: FFTtools.cxx:1070
TGraph * makePowerSpectrumMilliVoltsNanoSeconds(const TGraph *grWave)
Returns the power spectral density in dB units. Note the PSD returned is normalised and divided by fr...
Definition: FFTtools.cxx:1147
TGraph * makePowerSpectrumVoltsSecondsPaddeddB(const TGraph *grWave, Int_t padFactor=4)
Returns the power spectral density in dB units of the input waveform zero-padded by some factor...
Definition: FFTtools.cxx:1346
Double_t welchWindow(Int_t j, Int_t n)
The Welch window function similar to the Bartlett window except that it falls off from the middle as ...
Definition: FFTtools.cxx:27
Double_t getWaveformSNR(const TGraph *gr)
This returns the SNR ratio of the input waveform.
Definition: FFTtools.cxx:2081
void doInvFFTClobber(int length, FFTWComplex *properly_aligned_input_that_will_likely_be_clobbered, double *properly_aligned_output)
Definition: FFTtools.cxx:408
TGraph * smoothFFT(const TGraph *gr, Int_t factor)
Returns a smoothed FFT where N-bins are averaged to reduce variance.
Definition: FFTtools.cxx:1715
TGraph * getHilbertEnvelope(const TGraph *grWave)
The Hilbert envelope of the input TGraph. This is defined as e_i=sqrt(v_i^2 + h_i^2), where e_i, v_i and h_i are the i-th sample of the envelope, input graph and hilbert transform of the input graph repsectively.
Definition: FFTtools.cxx:964
double * FFTCorrelation(int waveformlength, const FFTWComplex *A, const FFTWComplex *B, FFTWComplex *work=0, int min_i=0, int max_i=0, int order=1)
Definition: FFTtools.cxx:2641
TGraph * divideGraphs(const TGraph *grA, const TGraph *grB)
Returns the ratio between two graphs (A/B).
Definition: FFTtools.cxx:1632
TGraph * correlateAndAverage(Int_t numGraphs, TGraph **grPtrPtr)
This is designed for when you want to average a number of graphs of the same thing together...
Definition: FFTtools.cxx:2461
TGraph * cropWave(const TGraph *grWave, Double_t minTime, Double_t maxTime)
This returns a TGraph which has been cropped in.
Definition: FFTtools.cxx:2012
TGraph * getDerviative(const TGraph *grIn)
This returns a TGraph which is the derivative of the input graph.
Definition: FFTtools.cxx:1917
TGraph * padWaveToLength(const TGraph *grA, Int_t newLength)
Zero pad a wave making it up to newLength points.
Definition: FFTtools.cxx:1769
This is a wrapper class for an RF Signal.
Definition: RFSignal.h:12
TGraph * simpleNotchFilter(const TGraph *grWave, Double_t minFreq, Double_t maxFreq)
This returns a TGraph which has had a simple notch band filter applied.
Definition: FFTtools.cxx:1975
TGraph * subtractGraphs(const TGraph *grA, const TGraph *grB)
Returns the difference between two graphs (A-B).
Definition: FFTtools.cxx:1599
void polySubtract(TGraph *g, int order=1)
Definition: FFTtools.cxx:2745
Double_t sumPower(const TGraph *gr, Int_t firstBin=-1, Int_t lastBin=-1)
The linear sum of the power in a TGraph (normally a PSD)
Definition: FFTtools.cxx:1393
double * getCorrelation(const TGraph *gr1, const TGraph *gr2, int firstIndex, int lastIndex)
Computes the correlation of two subsets of TGraphs.
Definition: FFTtools.cxx:902
TGraph * makePowerSpectrumVoltsSecondsPadded(const TGraph *grWave, Int_t padFactor=4)
Returns the power spectral density of the input waveform zero-padded by some factor. Note the PSD returned is normalised and divided by frequency bin width (or if you prefer it is normalised to the time-integral squared amplitude of the time domain and then divided by frequency bin width). See this short note for my terminology. As the name suggests this function expects the input waveform to be a volts-seconds one.
Definition: FFTtools.cxx:1336
void inPlaceShift(int N, double *x)
Definition: FFTtools.cxx:2721
TGraph * convertMagnitudeToTimeDomain(const TGraph *inputMag)
Converts inputMag (linear units) to time domain by means of hilbert transform assuming R_signal = 1/s...
Definition: FFTtools.cxx:2256
void doInvFFTNoClobber(int length, const FFTWComplex *properly_aligned_input, double *properly_aligned_output)
Definition: FFTtools.cxx:372
double getAbs(FFTWComplex &theNum)
Returns the magnitude of a complex number.
Definition: FFTtools.cxx:1388
TGraph * translateGraph(const TGraph *grWave, const Double_t deltaT)
Returns a graph translated by deltaT. Such that t&#39;=t+dt.
Definition: FFTtools.cxx:1619
TGraph * getNormalisedCorrelationGraph(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0)
Returns the normalised correlation of two TGraphs.
Definition: FFTtools.cxx:709
TGraph * ratioSubtractOneGraphs(const TGraph *grA, const TGraph *grB)
Returns the one minus the ratio between two graphs (A/B).
Definition: FFTtools.cxx:1652
TGraph * getSimplePowerEnvelopeGraph(const TGraph *gr)
Returns the simple power envelope of a waveform. The waveform is first squared and then only local pe...
Definition: FFTtools.cxx:1817
This is a wrapper class for a complex number.
Definition: FFTWComplex.h:12
TGraph * getInterpolatedCorrelationGraph(const TGraph *grIn1, const TGraph *grIn2, Double_t deltaT)
Returns the correlation of two interpolated TGraphs.
Definition: FFTtools.cxx:838
void getPeakRmsRectified(const TGraph *gr, Double_t &peak, Double_t &rms, Int_t *index=0)
Find the peak (v) and RMS (of v) of a rectified TGraph.
Definition: FFTtools.cxx:1586
Double_t getWaveformPeak(const TGraph *gr)
This returns the largest (i.e most positive, or least negative) value.
Definition: FFTtools.cxx:2176
TGraph * interpolateCorrelateAndAverage(Double_t deltaTInt, Int_t numGraphs, TGraph **grPtrPtr)
This is designed for when you want to average a number of graphs of the same thing together...
Definition: FFTtools.cxx:2447
Double_t simpleInterploate(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t x)
Linear interpolate to find the value at some point near two known points.
Definition: FFTtools.cxx:2304
TGraph * makePowerSpectrumVoltsSeconds(const TGraph *grWave)
Returns the power spectral density. Note the PSD returned is normalised and divided by frequency bin ...
Definition: FFTtools.cxx:1106
TGraph * makePowerSpectrumVoltsSecondsBartlett(const TGraph *grWave)
Returns the power spectral density of the input waveform convolved with a Bartlett Window...
Definition: FFTtools.cxx:1017
Double_t * combineValuesUsingFFTs(Int_t numArrays, Double_t **thePtrPtr, Int_t eachLength)
Returns the time domain result of a frequency domain sum of a number of arrays. As of writing this do...
Definition: FFTtools.cxx:538
TGraph * rectifyWave(const TGraph *gr, Int_t makeNeg=0)
Rectify a waveform, optionally returning an all negative waveform.
Definition: FFTtools.cxx:1799
TGraph * getCorrelationGraph(const TGraph *gr1, const TGraph *gr2, Int_t *zeroOffset=0)
Returns the correlation of two TGraphs.
Definition: FFTtools.cxx:754
void getPeakRmsSqVal(const TGraph *gr, Double_t &peak, Double_t &rms, Int_t *index=0)
Find the peak (v^2) and RMS (of v^2) in a TGraph.
Definition: FFTtools.cxx:1570
TGraph * getInterpolatedGraphFreqDom(const TGraph *grIn, Double_t deltaT)
Interpolation Routines that zeropads the FFT.
Definition: FFTtools.cxx:84
TGraph * makePowerSpectrum(const TGraph *grWave)
Returns the power spectral density. Note the PSD is unormalised (or if you prefer is normalised to th...
Definition: FFTtools.cxx:1031
TGraph * makeRawPowerSpectrum(const TGraph *grWave)
Returns the power spectral density in completely unormalised unit (as in Parseval&#39;s theorem is not ob...
Definition: FFTtools.cxx:1354
TGraph * getBoxCar(const TGraph *grWave, Int_t halfWidth)
Smooth graph using box car smoothing.
Definition: FFTtools.cxx:984
Int_t getPeakBin(const TGraph *gr)
Find the peak (maximum positive) bin in a TGraph.
Definition: FFTtools.cxx:1456
TGraph * makePowerSpectrumVoltsSecondsdB(const TGraph *grWave)
Returns the power spectral density in dB units. Note the PSD returned is normalised and divided by fr...
Definition: FFTtools.cxx:1286
int fast_floor(double val)
Definition: FFTtools.h:721
void wrap(size_t N, double *vals, double period=360)
Definition: FFTtools.cxx:2851
TGraph * correlateAndAveragePredeterminedZone(Int_t numGraphs, TGraph **grPtrPtr, Int_t *correlationBinPtr, Int_t binWiggleRoom)
Definition: FFTtools.cxx:2535
TGraph * makeInverseInverseSpectrum(const TGraph *grWave)
Returns the inverse FFT of the FFT of the input TGraph. Seems pointless.
Definition: FFTtools.cxx:919
TGraph * makePSVSBartlettPaddedOverlap(const TGraph *grWave, Int_t padFactor=4, Int_t numFreqs=64)
Returns the power spectral density of the input waveform. In this one we first zero pad the waveform ...
Definition: FFTtools.cxx:1856
TGraph * simplePassBandFilter(const TGraph *grWave, Double_t minFreq, Double_t maxFreq)
This returns a TGraph which has had a simple pass band filter applied.
Definition: FFTtools.cxx:1938
TGraph * getDerivative(const TGraph *grIn)
This returns a TGraph which is the derivative of the input graph.
Definition: FFTtools.cxx:1922
TGraph * getConvolution(const TGraph *grA, const TGraph *grB)
Convolution.
Definition: FFTtools.cxx:2309
Double_t bartlettWindow(Int_t j, Int_t n)
The Bartlett window function (it&#39;s basically a triangle that peaks in the middle at 1 and goes to zer...
Definition: FFTtools.cxx:21
TGraph * padWave(const TGraph *grA, Int_t padFactor)
Zero pad a wave making it a factor of N longer.
Definition: FFTtools.cxx:1745
Double_t integrateVoltageSquared(const TGraph *gr, Int_t firstBin=-1, Int_t lastBin=-1)
The integral of the v^2*dt in a waveform. Now works for unevenly sampled waeforms.
Definition: FFTtools.cxx:1436
Double_t sumVoltageSquared(const TGraph *gr, Int_t firstBin, Int_t lastBin)
The sum of the voltage squared in a waveform.
Definition: FFTtools.cxx:1423
Double_t getPeakXvalue(const TGraph *gr)
Find the x value associated with the peak (maximum positive) in a TGraph.
Definition: FFTtools.cxx:1473
TGraph * getHilbertTransform(const TGraph *grWave)
The Hilbert transform of the input TGraph.
Definition: FFTtools.cxx:951
void takeDerivative(Int_t numPoints, const Double_t *inputX, const Double_t *inputY, Double_t *outputX, Double_t *outputY)
This fucntions just calculates the simple bin by bin dv/dt derivative of the input data...
Definition: FFTtools.cxx:1905
TGraph * dbGraphs(const TGraph *grA, const TGraph *grB)
Returns the ratio of two graphs as 10 *log(A/B)
Definition: FFTtools.cxx:1682