Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
AnalysisWaveform Class Reference

This class is intended to be the main storage vessel for ANITA waveforms. It is similar in principle to RFWaveform from FFTtools. . More...

#include <AnalysisWaveform.h>

Classes

struct  InterpolationOptions
 
class  PowerCalculationOptions
 

Public Types

enum  InterpolationType { AKIMA, SPARSE_YEN, REGULARIZED_SPARSE_YEN }
 
enum  EvenEvaluationType { EVAL_LINEAR, EVAL_AKIMA }
 

Public Member Functions

 AnalysisWaveform (int Nt, const double *x, const double *y, double nominal_dt=1./2.6, InterpolationType type=defaultInterpolationType, InterpolationOptions *opt=&defaultInterpolationOptions)
 
 AnalysisWaveform (int Nt, const double *y, double dt, double t0)
 
 AnalysisWaveform (int Nt, const FFTWComplex *f, double df, double t0)
 
 AnalysisWaveform (int Nt=260, double dt=1./2.6, double t0=0)
 
 AnalysisWaveform (const AnalysisWaveform &other)
 
double getRMS () const
 
AnalysisWaveformoperator= (const AnalysisWaveform &other)
 
AnalysisWaveformautoCorrelation (int npadtime=1, int npadfreq=0, double scale=1)
 
bool checkIfPaddedInTime () const
 
const TGraphAligneduneven () const
 
const TGraphAlignedeven () const
 
const FFTWComplexfreq () const
 
const TGraphAlignedpower () const
 
const TGraphAlignedpowerdB () const
 
const TGraphAlignedphase () const
 
const TGraphAlignedgroupDelay () const
 
const TGraphAlignedhilbertEnvelope () const
 
const AnalysisWaveformhilbertTransform () const
 
int Nfreq () const
 
int Neven () const
 
int Nuneven () const
 
double deltaT () const
 
double deltaF () const
 
void forceEvenSize (int size)
 
void drawEven (const char *opt="", int color=-1) const
 
void drawHilbertEnvelope (const char *opt="", int color=-1) const
 
void drawUneven (const char *opt="", int color=-1) const
 
void drawPower (const char *opt="", int color=-1) const
 
void drawPowerdB (const char *opt="", int color=-1) const
 
void drawPhase (const char *opt="", int color=-1) const
 
double evalEven (double t, EvenEvaluationType=EVAL_LINEAR) const
 
void evalEven (int N, const double *__restrict t, double *__restrict v, EvenEvaluationType=EVAL_LINEAR) const
 
FFTWComplexupdateFreq ()
 
void updateFreq (int new_N, const FFTWComplex *new_freq, double new_df=0)
 
TGraphAlignedupdateEven ()
 
void updateEven (const TGraph *replace_even)
 
TGraphAlignedupdateUneven ()
 
void updateUneven (const TGraph *replace_uneven)
 
void padEven (int factor, int where=1)
 
void padFreq (int factor)
 
void padFreqAdd (int npad)
 
void setPowerCalculationOptions (PowerCalculationOptions &opt)
 
void zeroMeanEven ()
 
void setTitle (const char *title)
 
void setColor (int c)
 
void setWidth (int w)
 
void setFreqDisplayRange (double low, double high)
 
void setTimeDisplayRange (double low, double high)
 

Static Public Member Functions

static void enableDebug (bool enable)
 
static void allowEvenToUnevenConversion (bool allow)
 
static AnalysisWaveformmakeWf (const TGraph *g, bool even=true, AnalysisWaveform *replace=0)
 
static AnalysisWaveformcorrelation (const AnalysisWaveform *A, const AnalysisWaveform *B, int npadfreq=0, double scale=1, int window_normalize=0)
 
static AnalysisWaveformconvolution (const AnalysisWaveform *A, const AnalysisWaveform *B, int npadfreq=0, double scale=1)
 
static void setCorrelationNag (bool nag)
 
static void basisChange (AnalysisWaveform *__restrict hpol_or_lcp, AnalysisWaveform *__restrict vpol_or_rcp)
 
static void sumDifference (AnalysisWaveform *__restrict a, AnalysisWaveform *__restrict b)
 

Static Public Attributes

static InterpolationType defaultInterpolationType = AnalysisWaveform::AKIMA
 
static InterpolationOptions defaultInterpolationOptions
 

Detailed Description

This class is intended to be the main storage vessel for ANITA waveforms. It is similar in principle to RFWaveform from FFTtools. .

This class holds 3 coupled versions of the waveform:

Transforming between uneven and even is accomplished via interpolation (which is not strictly invertible) Transforming between even and freq is accomplished via FT (which is more or less invertible, up to machine precision)

Because the transformation between even and uneven is not reversible, it usually only makes sense to access or modify uneven prior to modifying even or freq. If an access to uneven is attempted after modifying even or freq,

There are two types of accessors, const ones which retrieve const data:

And ones which allow modification of the data and will then recompute the other two versions the next time they're requested:

Those have two versions, one where you modify the return value and one where you replace the value.

In order to make it seem magic, there is a lot of internal state that is complicated to reason about. Hopefully there are no bugs...

Cosmin Deaconu cozzy.nosp@m.d@ki.nosp@m.cp.uc.nosp@m.hica.nosp@m.go.ed.nosp@m.u

Definition at line 47 of file AnalysisWaveform.h.

Collaboration diagram for AnalysisWaveform:
Collaboration graph
[legend]

Member Enumeration Documentation

The interpolation method used in e.g. evalEven

Definition at line 70 of file AnalysisWaveform.h.

The interpolation method used to transform in between evenly-sampled and unevenly-sampled waveforms

Definition at line 62 of file AnalysisWaveform.h.

Constructor & Destructor Documentation

AnalysisWaveform::AnalysisWaveform ( int  Nt,
const double *  x,
const double *  y,
double  nominal_dt = 1./2.6,
InterpolationType  type = defaultInterpolationType,
InterpolationOptions opt = &defaultInterpolationOptions 
)

Constructor for unevenly sampled waveform

Parameters
Ntthe number of samples
xthe time values
ythe voltage values
nominal_dtthe mean sample rate, defaults to ANITA rate
typethe InterpolationType used, defaults to defaultInterpolationType (which is probalby what you want to change to influence e.g. FilteredAnitaEvent).
optthe InterpolationOptions used, defaults to defaultInterpolationOptions (which is probably what you want to change to influence e.g. FilteredAnitaEvent).

Definition at line 98 of file AnalysisWaveform.cc.

AnalysisWaveform::AnalysisWaveform ( int  Nt,
const double *  y,
double  dt,
double  t0 
)

Constructor for evenly sampled waveform. Uneven waveform is set to even.

Definition at line 146 of file AnalysisWaveform.cc.

AnalysisWaveform::AnalysisWaveform ( int  Nt,
const FFTWComplex f,
double  df,
double  t0 
)

Constructor from frequency domain (and uneven is set to be the same)

Definition at line 191 of file AnalysisWaveform.cc.

AnalysisWaveform::AnalysisWaveform ( int  Nt = 260,
double  dt = 1./2.6,
double  t0 = 0 
)

empty, even constructor

Definition at line 168 of file AnalysisWaveform.cc.

AnalysisWaveform::AnalysisWaveform ( const AnalysisWaveform other)

Copy constructor. Will not blindly copy everything (like it won't bother copying anything that will have to be recalculated on its next access

Definition at line 998 of file AnalysisWaveform.cc.

Member Function Documentation

void AnalysisWaveform::allowEvenToUnevenConversion ( bool  allow)
static

Enable (or disable) conversion from even to uneven. The default is that it's not allowed, which means that as soon as some transformation is done on the evenly-sampled waveform or in the frequency domain, the uneven waveform is set equal to the even waveform.

Definition at line 41 of file AnalysisWaveform.cc.

AnalysisWaveform * AnalysisWaveform::autoCorrelation ( int  npadtime = 1,
int  npadfreq = 0,
double  scale = 1 
)

Compute the (circular) autocorrelation of this waveform.

If you want non-circular correlation, you can pass 1 (or more) to npadtime. No scaling is applied, but you can set a scale by passing a scale parameter. User responsible for deleting returned value;

Definition at line 1487 of file AnalysisWaveform.cc.

void AnalysisWaveform::basisChange ( AnalysisWaveform *__restrict  hpol_or_lcp,
AnalysisWaveform *__restrict  vpol_or_rcp 
)
static

change between vpol / hpol and lcp / rcp

Definition at line 1428 of file AnalysisWaveform.cc.

bool AnalysisWaveform::checkIfPaddedInTime ( ) const

Checks if the even waveform is zeropadded (by comparing second half to zero)

Definition at line 1386 of file AnalysisWaveform.cc.

AnalysisWaveform * AnalysisWaveform::correlation ( const AnalysisWaveform A,
const AnalysisWaveform B,
int  npadfreq = 0,
double  scale = 1,
int  window_normalize = 0 
)
static

Computes the (circular) correlation (in the frequency domain) of the two waveforms as a new waveform. Note that if you want to correlate two traces, they should be padded first. This does not pad them for you, but will complain if they are not! To turn off the nagging, see below function. It is also assumed the two are of the same length.

By default is no normalization done at all, the frequency values are simply multiplied appropriately and then everything is divided by 1/scale.

If window_normalize is non-zero, then the total power of the overlapping window of at least size window_normalize at each point is used to scale. Smaller window sizes will use the smallest window size power ot normalize. An overall factor of scale is still applied.

Definition at line 1116 of file AnalysisWaveform.cc.

double AnalysisWaveform::deltaF ( ) const
inline

Return the spacing between frequencies in the frequency domain

Definition at line 228 of file AnalysisWaveform.h.

double AnalysisWaveform::deltaT ( ) const
inline

Return the mean sampling period

Definition at line 225 of file AnalysisWaveform.h.

void AnalysisWaveform::drawEven ( const char *  opt = "",
int  color = -1 
) const

Draw even

Definition at line 1413 of file AnalysisWaveform.cc.

void AnalysisWaveform::drawHilbertEnvelope ( const char *  opt = "",
int  color = -1 
) const

Draw Hilbert envelope

Definition at line 1418 of file AnalysisWaveform.cc.

void AnalysisWaveform::drawPhase ( const char *  opt = "",
int  color = -1 
) const

Draw phase

Definition at line 1417 of file AnalysisWaveform.cc.

void AnalysisWaveform::drawPower ( const char *  opt = "",
int  color = -1 
) const

Draw power

Definition at line 1415 of file AnalysisWaveform.cc.

void AnalysisWaveform::drawPowerdB ( const char *  opt = "",
int  color = -1 
) const

Draw power in dB

Definition at line 1416 of file AnalysisWaveform.cc.

void AnalysisWaveform::drawUneven ( const char *  opt = "",
int  color = -1 
) const

Draw uneven

Definition at line 1414 of file AnalysisWaveform.cc.

void AnalysisWaveform::enableDebug ( bool  enable)
static

Enable (or disable) a bunch of debugging crap. Only possible with ANITA_ANALYSIS_DEBUG defined to avoid slow branches

Definition at line 36 of file AnalysisWaveform.cc.

double AnalysisWaveform::evalEven ( double  t,
EvenEvaluationType  typ = EVAL_LINEAR 
) const

Evaluate the even waveform at a point.

Definition at line 918 of file AnalysisWaveform.cc.

void AnalysisWaveform::evalEven ( int  N,
const double *__restrict  t,
double *__restrict  v,
EvenEvaluationType  type = EVAL_LINEAR 
) const

Evaluate the even waveform at the specified points.

Definition at line 788 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::even ( ) const

Constant accessor for even waveform. Dont' coerce into non-const unless you know what you're doing

Definition at line 228 of file AnalysisWaveform.cc.

void AnalysisWaveform::forceEvenSize ( int  size)

Forces the even waveform to be a particular size. This is equivalent to updateEven()->Set() (with padding) with the exception that it may be deferred if even waveform needs to be (re)calculated.

Definition at line 777 of file AnalysisWaveform.cc.

const FFTWComplex * AnalysisWaveform::freq ( ) const

Constant accessor for frequency domain waveform. Dont' coerce into non-const unless you know what you're doing

Definition at line 250 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::groupDelay ( ) const

Get the group delay

Definition at line 635 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::hilbertEnvelope ( ) const

Get the hilbert envelope

Definition at line 700 of file AnalysisWaveform.cc.

const AnalysisWaveform * AnalysisWaveform::hilbertTransform ( ) const

Get the Hilbert Transform

Definition at line 675 of file AnalysisWaveform.cc.

AnalysisWaveform * AnalysisWaveform::makeWf ( const TGraph *  g,
bool  even = true,
AnalysisWaveform replace = 0 
)
static

Constructor from TGraph. If even is true, it will assume it's evenly sampled, otherwise will check

Definition at line 1585 of file AnalysisWaveform.cc.

int AnalysisWaveform::Neven ( ) const
inline

Return the number of samples in the even waveform

Definition at line 219 of file AnalysisWaveform.h.

int AnalysisWaveform::Nfreq ( ) const

Return the length of the frequency domain complex waveform

Definition at line 1421 of file AnalysisWaveform.cc.

int AnalysisWaveform::Nuneven ( ) const
inline

Return the number of samples in the uneven waveform

Definition at line 222 of file AnalysisWaveform.h.

void AnalysisWaveform::padEven ( int  factor,
int  where = 1 
)

pad the even waveform (equivalent to upsampling the frequency).

if where > 0, zeroes will be added at the end if where < 0, zeroes will be added at the beginning if where == 0, zeroes will be padded before and after

Definition at line 1336 of file AnalysisWaveform.cc.

void AnalysisWaveform::padFreq ( int  factor)

pad the frequency (equivalent to upsampling the even values)

Definition at line 1220 of file AnalysisWaveform.cc.

void AnalysisWaveform::padFreqAdd ( int  npad)

pad the frequency with a specific number of points (equivalent to upsampling the even values)

Definition at line 1273 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::phase ( ) const

Get the phase

Definition at line 617 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::power ( ) const

Get the power

Definition at line 723 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::powerdB ( ) const

Get the power in dB

Definition at line 660 of file AnalysisWaveform.cc.

void AnalysisWaveform::setPowerCalculationOptions ( PowerCalculationOptions opt)

Change the options for calculating the power. This obviously will invalidate power() and powerdB()

Definition at line 1329 of file AnalysisWaveform.cc.

void AnalysisWaveform::sumDifference ( AnalysisWaveform *__restrict  a,
AnalysisWaveform *__restrict  b 
)
static

Change between a ,b -> (a + b)/2, (a - b)/2

Definition at line 1461 of file AnalysisWaveform.cc.

const TGraphAligned * AnalysisWaveform::uneven ( ) const

Constant accessor for uneven waveform. Dont' coerce into non-const unless you know what you're doing

Definition at line 220 of file AnalysisWaveform.cc.

TGraphAligned * AnalysisWaveform::updateEven ( )

Update the even graph by modifying return value

Definition at line 294 of file AnalysisWaveform.cc.

void AnalysisWaveform::updateEven ( const TGraph *  replace_even)

Update the even graph by replacing with argument

Definition at line 270 of file AnalysisWaveform.cc.

FFTWComplex * AnalysisWaveform::updateFreq ( )

Update frequency graph by modifying return value

Definition at line 331 of file AnalysisWaveform.cc.

void AnalysisWaveform::updateFreq ( int  new_N,
const FFTWComplex new_freq,
double  new_df = 0 
)

Update frequency graph by replacing with argumetnts

Definition at line 579 of file AnalysisWaveform.cc.

TGraphAligned * AnalysisWaveform::updateUneven ( )

Update the uneven graph by modifying return value

Definition at line 313 of file AnalysisWaveform.cc.

void AnalysisWaveform::updateUneven ( const TGraph *  replace_uneven)

Update the uneven graph by replacing with argument

Definition at line 390 of file AnalysisWaveform.cc.

void AnalysisWaveform::zeroMeanEven ( )

Zero mean even graph

Definition at line 1500 of file AnalysisWaveform.cc.

Member Data Documentation

AnalysisWaveform::InterpolationOptions AnalysisWaveform::defaultInterpolationOptions
static

Default interpolation options, may be changed by user

Definition at line 112 of file AnalysisWaveform.h.

AnalysisWaveform::InterpolationType AnalysisWaveform::defaultInterpolationType = AnalysisWaveform::AKIMA
static

The default type used. May be changed by user

Definition at line 77 of file AnalysisWaveform.h.


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