GWOLLUM 4.2.0
Tools for gravitational-wave analyses
Loading...
Searching...
No Matches
Spectrum.h
Go to the documentation of this file.
1
6#ifndef __Spectrum__
7#define __Spectrum__
8
9#include <TMath.h>
10#include <TRandom.h>
11#include <TH1.h>
12#include <TGraph.h>
13#include <TFile.h>
14#include "FFT.h"
15#include "Monitor.h"
16
17using namespace std;
18
59
60 public:
61
77 Spectrum(const unsigned int aSpectrumSize,
78 const unsigned int aDataDuration,
79 const unsigned int aDataSamplingFrequency,
80 const unsigned int aVerbosity=0);
81
85 virtual ~Spectrum(void);
93 inline bool GetStatus(void){ return mon->GetStatus(); };
94
99 void Reset(void);
100
119 bool AddData(const unsigned int aDataSize,
120 const double *aData,
121 const unsigned int aDataStart=0,
122 const bool aMute=false);
123
133 bool LoadData(const unsigned int aDataSize,
134 const double *aData,
135 const unsigned int aDataStart=0,
136 const bool aMute=false);
137
142 bool IsBufferFull(void);
143
153 double GetPower(const double aFrequency);
154
160 inline double GetPower(const unsigned int aFrequencyIndex){
161 return fft_psd->GetRe_f(aFrequencyIndex);
162 };
163
169 inline double GetAmplitude(const double aFrequency){
170 return TMath::Sqrt(GetPower(aFrequency));
171 };
172
177 TGraph* GetPSD(void);
178
185 TGraph* GetPSD(const double aFrequencyMin, const double aFrequencyMax);
186
191 TGraph* GetASD(void);
192
199 TGraph* GetASD(const double aFrequencyMin, const double aFrequencyMax);
200
207 TGraph* GetPeriodogram(const unsigned int aParity, const unsigned int aIndex);
208
215 TGraph* GetAmplitudePeriodogram(const unsigned int aParity, const unsigned int aIndex);
216
222 bool WritePeriodogram(const string aOutFileName);
223
227 inline unsigned int GetSpectrumSize(void){ return fft_psd->GetSize_f(); };
228
233 inline double GetSpectrumFrequency(const unsigned int aIndex){
234 return (double)aIndex*(double)sampling/(double)fft_psd->GetSize_t();
235 };
236
240 inline double GetSpectrumResolution(void){ return GetSpectrumFrequency(1); };
241
245 inline unsigned int GetSpectrumNyquist(void){
246 return (unsigned int)(GetSpectrumResolution()*(double)fft_psd->GetSize_f()); };
247
252 inline unsigned int GetNSubSegmentsMax(const unsigned int aParity){
253 return nSubSegments[aParity%2];
254 };
255
259 inline unsigned int GetDataBufferLength(void){ return (double)nSubSegments[0]/GetSpectrumResolution(); };
260
261 private:
262
264 unsigned int sampling;
265
266 // derived parameters
267 unsigned int nSubSegments[2];
268
269 // containers
270 double *HannWindow;
271 double **periodogram[2];
272 unsigned int write_index[2];
273
275
281 void ComputeMedianMean(const bool aMute=false);
282
283 ClassDef(Spectrum,0)
284};
285
286#endif
287
288
Fast Fourier transform wrapper for FFTW.
Process monitoring.
Monitor a GWOLLUM processing.
Definition Monitor.h:39
bool GetStatus(void)
Returns the object status.
Definition Monitor.h:109
Compute the noise power spectral density.
Definition Spectrum.h:58
double GetPower(const double aFrequency)
Returns the current PSD value at a given frequency.
Definition Spectrum.cc:132
unsigned int sampling
Data sampling frequency [Hz].
Definition Spectrum.h:264
TGraph * GetPSD(void)
Returns a copy of the current PSD as a TGraph.
Definition Spectrum.cc:344
void Reset(void)
Resets the current PSD and the periodogram circular buffer.
Definition Spectrum.cc:107
TGraph * GetAmplitudePeriodogram(const unsigned int aParity, const unsigned int aIndex)
Returns a copy of a given (amplitude) periodogram.
Definition Spectrum.cc:441
TGraph * GetASD(void)
Returns a copy of the current ASD as a TGraph.
Definition Spectrum.cc:383
unsigned int GetSpectrumNyquist(void)
Returns the Nyquist frequency of the spectrum [Hz].
Definition Spectrum.h:245
Monitor * mon
Class monitor.
Definition Spectrum.h:263
double GetSpectrumResolution(void)
Returns the frequency resolution of the spectrum [Hz]: .
Definition Spectrum.h:240
double ** periodogram[2]
Buffer for periodograms.
Definition Spectrum.h:271
void ComputeMedianMean(const bool aMute=false)
Computes the median-mean PSD.
Definition Spectrum.cc:252
double * HannWindow
Hann window vector.
Definition Spectrum.h:270
bool AddData(const unsigned int aDataSize, const double *aData, const unsigned int aDataStart=0, const bool aMute=false)
Loads a data vector and updates the current PSD.
Definition Spectrum.cc:172
unsigned int GetDataBufferLength(void)
Returns the effective circular buffer length [s] used to compute the PSD.
Definition Spectrum.h:259
Spectrum(const unsigned int aSpectrumSize, const unsigned int aDataDuration, const unsigned int aDataSamplingFrequency, const unsigned int aVerbosity=0)
Constructor of the Spectrum class.
bool WritePeriodogram(const string aOutFileName)
Writes periodograms and the resulting PSD in a ROOT file.
Definition Spectrum.cc:455
TGraph * GetPeriodogram(const unsigned int aParity, const unsigned int aIndex)
Returns a copy of a given periodogram.
Definition Spectrum.cc:422
double GetAmplitude(const double aFrequency)
Returns the current ASD value at a given frequency.
Definition Spectrum.h:169
bool GetStatus(void)
Returns the class status.
Definition Spectrum.h:93
virtual ~Spectrum(void)
Destructor of the Spectrum class.
Definition Spectrum.cc:93
bool LoadData(const unsigned int aDataSize, const double *aData, const unsigned int aDataStart=0, const bool aMute=false)
Loads a data vector and computes a new PSD.
Definition Spectrum.cc:235
double GetPower(const unsigned int aFrequencyIndex)
Returns the current PSD value at a given frequency index.
Definition Spectrum.h:160
unsigned int GetNSubSegmentsMax(const unsigned int aParity)
Returns the maximum number of sub-segments in the buffer.
Definition Spectrum.h:252
unsigned int write_index[2]
Write index in the buffer.
Definition Spectrum.h:272
double GetSpectrumFrequency(const unsigned int aIndex)
Returns the frequency of a given spectrum frequency index [Hz].
Definition Spectrum.h:233
bool IsBufferFull(void)
Tests if the buffer of periodograms is full.
Definition Spectrum.cc:326
unsigned int GetSpectrumSize(void)
Returns the number of points in the spectrum: .
Definition Spectrum.h:227
fft * fft_psd
FFT plan to compute the PSD.
Definition Spectrum.h:274
unsigned int nSubSegments[2]
Number of even/odd sub-subsegments.
Definition Spectrum.h:267
Wrap and optimize FFTW.
Definition FFT.h:19
unsigned int GetSize_f(void)
Returns the size of the frequency-domain vector.
Definition FFT.h:266
double GetRe_f(const unsigned int aIndex)
Returns the real part of a frequency-domain data vector element.
Definition FFT.h:141
unsigned int GetSize_t(void)
Returns the size of the time-domain vector.
Definition FFT.h:261