12 #include "cetlib_except/exception.h" 85 std::vector<TComplex> kern(nticks / 2 + 1);
91 throw cet::exception(
"SignalShaping") << __func__ <<
": inconsistent kernel size, " 94 for (
unsigned int i = 0; i < kern.size(); ++i)
139 std::vector<double> delta(fft->
FFTSize(), 0.);
171 unsigned int n = std::min(
fFilter.size(), filt.size());
172 for (
unsigned int i = 0; i <
n; ++i)
174 for (
unsigned int i = n; i <
fFilter.size(); ++i)
184 if ((pol != 1) and (pol != -1)) {
186 << __func__ <<
": DeconvKernelPolarity should be +1 or -1 (got " << pol
187 <<
"). Setting to +1\n";
210 throw cet::exception(
"SignalShaping") <<
"Response has not been configured.\n";
218 << __func__ <<
": inconsistent kernel size, " <<
fResponse.size() <<
" vs. " << n <<
"\n";
221 << __func__ <<
": unexpected FFT size, " << n <<
" vs. expected " 250 throw cet::exception(
"SignalShaping") <<
"Filter function has not been configured.\n";
256 if (2 * (
fFilter.size() - 1) != n)
280 std::vector<double> deconv(n, 0.);
287 double peak_response = 0;
289 for (
unsigned int i = 0; i <
fResponse.size(); ++i) {
296 if (peak_response <= 0.) {
298 << __func__ <<
": peak should always be positive (got " << peak_response <<
")\n";
304 double peak_deconv = 0.;
305 for (
unsigned int i = 0; i < deconv.size(); ++i) {
306 if (deconv[i] > peak_deconv) peak_deconv = deconv[i];
308 if (peak_deconv <= 0.) {
310 << __func__ <<
": deconvolution peak should always be positive (got " << peak_deconv
317 double ratio = peak_response / peak_deconv;
void ShiftData(std::vector< TComplex > &input, double shift)
std::vector< TComplex > fConvKernel
constexpr auto abs(T v)
Returns the absolute value of the argument.
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
void LockResponse() const
std::vector< TComplex > fFilter
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
T PeakCorrelation(std::vector< T > &shape1, std::vector< T > &shape2)
tick ticks
Alias for common language habits.
void DoInvFFT(std::vector< TComplex > &input, std::vector< T > &output)
Generic class for shaping signals on wires.
void CalculateDeconvKernel() const
int fDeconvKernelPolarity
void SetDeconvKernelPolarity(int pol)
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
void ShiftResponseTime(double ticks)
std::vector< TComplex > fDeconvKernel
void SetPeakResponseTime(double tick)
std::vector< double > fResponse
void AddFilterFunction(const std::vector< TComplex > &filt)
cet::coded_exception< error, detail::translate > exception