#include "LArFFTW.h"
|
| LArFFTW (int transformSize, const void *fplan, const void *rplan, int fitbins) |
|
| ~LArFFTW () |
|
template<class T > |
void | DoFFT (std::vector< T > &input) |
|
template<class T > |
void | DoFFT (std::vector< T > &input, ComplexVector &output) |
|
template<class T > |
void | DoInvFFT (std::vector< T > &output) |
|
template<class T > |
void | DoInvFFT (ComplexVector &input, std::vector< T > &output) |
|
template<class T > |
void | Convolute (std::vector< T > &func, const ComplexVector &kern) |
|
template<class T > |
void | Convolute (std::vector< T > &func, std::vector< T > &resp) |
|
template<class T > |
void | Deconvolute (std::vector< T > &func, const ComplexVector &kern) |
|
template<class T > |
void | Deconvolute (std::vector< T > &func, std::vector< T > &resp) |
|
template<class T > |
void | Correlate (std::vector< T > &func, const ComplexVector &kern) |
|
template<class T > |
void | Correlate (std::vector< T > &func, std::vector< T > &resp) |
|
void | ShiftData (ComplexVector &input, double shift) |
|
template<class T > |
void | ShiftData (std::vector< T > &input, double shift) |
|
template<class T > |
void | AlignedSum (std::vector< T > &input, std::vector< T > &output, bool add=true) |
|
template<class T > |
T | PeakCorrelation (std::vector< T > &shape1, std::vector< T > &shape2) |
|
Definition at line 18 of file LArFFTW.h.
util::LArFFTW::LArFFTW |
( |
int |
transformSize, |
|
|
const void * |
fplan, |
|
|
const void * |
rplan, |
|
|
int |
fitbins |
|
) |
| |
util::LArFFTW::~LArFFTW |
( |
| ) |
|
template<class T >
void util::LArFFTW::AlignedSum |
( |
std::vector< T > & |
input, |
|
|
std::vector< T > & |
output, |
|
|
bool |
add = true |
|
) |
| |
|
inline |
Definition at line 364 of file LArFFTW.h.
References fSize, PeakCorrelation(), and ShiftData().
371 for (
int i = 0; i <
fSize; i++)
372 shape1[i] += shape2[i];
T PeakCorrelation(std::vector< T > &shape1, std::vector< T > &shape2)
void ShiftData(ComplexVector &input, double shift)
template<class T >
void util::LArFFTW::Convolute |
( |
std::vector< T > & |
func, |
|
|
const ComplexVector & |
kern |
|
) |
| |
|
inline |
Definition at line 170 of file LArFFTW.h.
References DoFFT(), DoInvFFT(), fFreqSize, fOut, fSize, n, and rIn.
175 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad time series size = " << n <<
"\n"; }
183 double re = ((fftw_complex*)
fOut)[i][0];
184 double im = ((fftw_complex*)
fOut)[i][1];
185 ((fftw_complex*)
rIn)[i][0] = re * kern[i].real() - im * kern[i].imag();
186 ((fftw_complex*)
rIn)[i][1] = re * kern[i].imag() + im * kern[i].real();
void DoInvFFT(std::vector< T > &output)
void DoFFT(std::vector< T > &input)
cet::coded_exception< error, detail::translate > exception
template<class T >
void util::LArFFTW::Convolute |
( |
std::vector< T > & |
func, |
|
|
std::vector< T > & |
resp |
|
) |
| |
|
inline |
Definition at line 196 of file LArFFTW.h.
References DoFFT(), DoInvFFT(), fFreqSize, fKern, fOut, fSize, n, and rIn.
201 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad 1st time series size = " << n <<
"\n"; }
203 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad 2nd time series size = " << n <<
"\n"; }
207 fKern[i].real(((fftw_complex*)
fOut)[i][0]);
208 fKern[i].imag(((fftw_complex*)
fOut)[i][1]);
214 double re = ((fftw_complex*)
fOut)[i][0];
215 double im = ((fftw_complex*)
fOut)[i][1];
216 ((fftw_complex*)
rIn)[i][0] = re *
fKern[i].real() - im *
fKern[i].imag();
217 ((fftw_complex*)
rIn)[i][1] = re *
fKern[i].imag() + im *
fKern[i].real();
void DoInvFFT(std::vector< T > &output)
void DoFFT(std::vector< T > &input)
cet::coded_exception< error, detail::translate > exception
template<class T >
void util::LArFFTW::Correlate |
( |
std::vector< T > & |
func, |
|
|
const ComplexVector & |
kern |
|
) |
| |
|
inline |
Definition at line 292 of file LArFFTW.h.
References DoFFT(), DoInvFFT(), fFreqSize, fOut, fSize, n, and rIn.
Referenced by PeakCorrelation().
297 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad time series size = " << n <<
"\n"; }
305 double re = ((fftw_complex*)
fOut)[i][0];
306 double im = ((fftw_complex*)
fOut)[i][1];
307 ((fftw_complex*)
rIn)[i][0] = re * kern[i].real() + im * kern[i].imag();
308 ((fftw_complex*)
rIn)[i][1] = -re * kern[i].imag() + im * kern[i].real();
void DoInvFFT(std::vector< T > &output)
void DoFFT(std::vector< T > &input)
cet::coded_exception< error, detail::translate > exception
template<class T >
void util::LArFFTW::Correlate |
( |
std::vector< T > & |
func, |
|
|
std::vector< T > & |
resp |
|
) |
| |
|
inline |
Definition at line 318 of file LArFFTW.h.
References DoFFT(), DoInvFFT(), fFreqSize, fKern, fOut, fSize, n, and rIn.
323 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad 1st time series size = " << n <<
"\n"; }
325 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad 2nd time series size = " << n <<
"\n"; }
329 fKern[i].real(((fftw_complex*)
fOut)[i][0]);
330 fKern[i].imag(((fftw_complex*)
fOut)[i][1]);
336 double re = ((fftw_complex*)
fOut)[i][0];
337 double im = ((fftw_complex*)
fOut)[i][1];
338 ((fftw_complex*)
rIn)[i][0] = re *
fKern[i].real() + im *
fKern[i].imag();
339 ((fftw_complex*)
rIn)[i][1] = -re *
fKern[i].imag() + im *
fKern[i].real();
void DoInvFFT(std::vector< T > &output)
void DoFFT(std::vector< T > &input)
cet::coded_exception< error, detail::translate > exception
template<class T >
void util::LArFFTW::Deconvolute |
( |
std::vector< T > & |
func, |
|
|
const ComplexVector & |
kern |
|
) |
| |
|
inline |
Definition at line 227 of file LArFFTW.h.
References d, DoFFT(), DoInvFFT(), e, fFreqSize, fOut, fSize, n, and rIn.
232 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad time series size = " << n <<
"\n"; }
239 double a, b, c,
d,
e;
241 a = ((fftw_complex*)
fOut)[i][0];
242 b = ((fftw_complex*)
fOut)[i][1];
245 e = 1. / (c * c + d *
d);
246 ((fftw_complex*)
rIn)[i][0] = (a * c + b *
d) * e;
247 ((fftw_complex*)
rIn)[i][1] = (b * c - a *
d) * e;
void DoInvFFT(std::vector< T > &output)
void DoFFT(std::vector< T > &input)
cet::coded_exception< error, detail::translate > exception
template<class T >
void util::LArFFTW::Deconvolute |
( |
std::vector< T > & |
func, |
|
|
std::vector< T > & |
resp |
|
) |
| |
|
inline |
Definition at line 257 of file LArFFTW.h.
References d, DoFFT(), DoInvFFT(), e, fFreqSize, fKern, fOut, fSize, n, and rIn.
262 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad 1st time series size = " << n <<
"\n"; }
264 if (n !=
fSize) {
throw cet::exception(
"LArFFTW") <<
"Bad 2nd time series size = " << n <<
"\n"; }
268 fKern[i].real(((fftw_complex*)
fOut)[i][0]);
269 fKern[i].imag(((fftw_complex*)
fOut)[i][1]);
274 double a, b, c,
d,
e;
276 a = ((fftw_complex*)
fOut)[i][0];
277 b = ((fftw_complex*)
fOut)[i][1];
280 e = 1. / (c * c + d *
d);
281 ((fftw_complex*)
rIn)[i][0] = (a * c + b *
d) * e;
282 ((fftw_complex*)
rIn)[i][1] = (b * c - a *
d) * e;
void DoInvFFT(std::vector< T > &output)
void DoFFT(std::vector< T > &input)
cet::coded_exception< error, detail::translate > exception
template<class T >
void util::LArFFTW::DoFFT |
( |
std::vector< T > & |
input | ) |
|
|
inline |
template<class T >
void util::LArFFTW::DoFFT |
( |
std::vector< T > & |
input, |
|
|
ComplexVector & |
output |
|
) |
| |
|
inline |
Definition at line 104 of file LArFFTW.h.
References fFreqSize, fIn, fOut, and fPlan.
107 for (
size_t p = 0; p < input.size(); ++p) {
108 ((
double*)
fIn)[p] = input[p];
112 fftw_execute_dft_r2c((fftw_plan)
fPlan, (
double*)
fIn, (fftw_complex*)
fOut);
115 output[i].real(((fftw_complex*)
fOut)[i][0]);
116 output[i].imag(((fftw_complex*)
fOut)[i][1]);
template<class T >
void util::LArFFTW::DoInvFFT |
( |
std::vector< T > & |
output | ) |
|
|
inline |
template<class T >
void util::LArFFTW::DoInvFFT |
( |
ComplexVector & |
input, |
|
|
std::vector< T > & |
output |
|
) |
| |
|
inline |
Definition at line 145 of file LArFFTW.h.
References lar::dump::array(), fFreqSize, fSize, rIn, rOut, and rPlan.
149 ((fftw_complex*)
rIn)[i][0] = input[i].real();
150 ((fftw_complex*)
rIn)[i][1] = input[i].imag();
154 fftw_execute_dft_c2r((fftw_plan)
rPlan, (fftw_complex*)
rIn, (
double*)
rOut);
157 double factor = 1.0 / (double)
fSize;
158 const double*
array = (
const double*)(
rOut);
159 for (
int i = 0; i <
fSize; ++i) {
160 output[i] = factor * array[i];
auto array(Array const &a)
Returns a manipulator which will print the specified array.
template<class T >
T util::LArFFTW::PeakCorrelation |
( |
std::vector< T > & |
shape1, |
|
|
std::vector< T > & |
shape2 |
|
) |
| |
|
inline |
Definition at line 382 of file LArFFTW.h.
References Correlate(), e, fConvHist, fFitBins, fMarqFitAlg, fSize, and gshf::MarqFitAlg::mrqdtfit().
Referenced by AlignedSum().
384 float chiSqr = std::numeric_limits<float>::max();
385 float dchiSqr = std::numeric_limits<float>::max();
386 const float chiCut = 1
e-3;
387 float lambda = 0.001;
388 std::vector<float> p;
390 std::vector<T> holder = shape1;
393 int maxT = max_element(holder.begin(), holder.end()) - holder.begin();
397 for (
int i = 0; i <
fFitBins; i++) {
400 else if (startT + i >
fSize)
404 if (holder[i + startT + offset] <= 0.) {
fConvHist[i] = 0.; }
406 fConvHist[i] = holder[i + startT + offset];
425 else if (trial > 100) {
428 }
while (fabs(dchiSqr) >= chiCut);
429 if (!fitResult) p1 = p[1];
431 return p1 + 0.5 + startT;
int mrqdtfit(float &lambda, float p[], float y[], const int nParam, const int nData, float &chiSqr, float &dchiSqr)
std::vector< float > fConvHist
void Correlate(std::vector< T > &func, const ComplexVector &kern)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
gshf::MarqFitAlg * fMarqFitAlg
void util::LArFFTW::ShiftData |
( |
ComplexVector & |
input, |
|
|
double |
shift |
|
) |
| |
template<class T >
void util::LArFFTW::ShiftData |
( |
std::vector< T > & |
input, |
|
|
double |
shift |
|
) |
| |
|
inline |
std::vector<float> util::LArFFTW::fConvHist |
|
private |
int util::LArFFTW::fFitBins |
|
private |
int util::LArFFTW::fFreqSize |
|
private |
void* util::LArFFTW::fOut |
|
private |
const void* util::LArFFTW::fPlan |
|
private |
void* util::LArFFTW::rOut |
|
private |
const void* util::LArFFTW::rPlan |
|
private |
The documentation for this class was generated from the following files:
- lardata/v09_16_03/source/lardata/Utilities/LArFFTW.h
- lardata/v09_16_03/source/lardata/Utilities/LArFFTW.cxx