2 #include "cetlib_except/exception.h" 9 : fResponseLocked(false)
10 , fFilterLocked(false)
14 , fFFT(new
util::
LArFFTW(fftsize, fFFTPlan->fPlan, fFFTPlan->rPlan, 0))
67 std::vector<std::complex<double>> kern(nticks / 2 + 1);
73 throw cet::exception(
"SignalShaper") << __func__ <<
": inconsistent kernel size, " 76 for (
unsigned int i = 0; i < kern.size(); ++i)
113 std::vector<double> delta(
fFFTSize, 0.);
142 for (
unsigned int i = 0; i <
n; ++i)
144 for (
unsigned int i = n; i <
fFilter.size(); ++i)
154 if ((pol != 1) and (pol != -1)) {
156 << __func__ <<
": DeconvKernelPolarity should be +1 or -1 (got " << pol
157 <<
"). Setting to +1\n";
176 throw cet::exception(
"SignalShaper") <<
"Response has not been configured.\n";
184 << __func__ <<
": inconsistent kernel size, " <<
fResponse.size() <<
" vs. " << n <<
"\n";
187 << __func__ <<
": unexpected FFT size, " << n <<
" vs. expected " 212 throw cet::exception(
"SignalShaper") <<
"Filter function has not been configured.\n";
218 if (2 * (
fFilter.size() - 1) != n)
242 std::vector<double> deconv(n, 0.);
243 fFFT->DoInvFFT(
const_cast<std::vector<std::complex<double>
>&>(
fFilter), deconv);
250 double peak_response = 0;
252 for (
unsigned int i = 0; i <
fResponse.size(); ++i) {
259 if (peak_response <= 0.) {
261 << __func__ <<
": peak should always be positive (got " << peak_response <<
")\n";
267 double peak_deconv = 0.;
268 for (
unsigned int i = 0; i < deconv.size(); ++i) {
269 if (deconv[i] > peak_deconv) peak_deconv = deconv[i];
271 if (peak_deconv <= 0.) {
273 << __func__ <<
": deconvolution peak should always be positive (got " << peak_deconv
280 double ratio = peak_response / peak_deconv;
void CalculateDeconvKernel() const
Namespace for general, non-LArSoft-specific utilities.
void AddFilterFunction(const std::vector< std::complex< double >> &filt)
void ShiftResponseTime(double ticks)
constexpr auto abs(T v)
Returns the absolute value of the argument.
void SetPeakResponseTime(double tick)
tick ticks
Alias for common language habits.
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
void LockResponse() const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< double > fResponse
std::unique_ptr< util::LArFFTW > fFFT
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
int fDeconvKernelPolarity
std::vector< std::complex< double > > fConvKernel
SignalShaper(int fftsize, std::string fftopt)
std::vector< std::complex< double > > fDeconvKernel
void SetDeconvKernelPolarity(int pol)
cet::coded_exception< error, detail::translate > exception
std::vector< std::complex< double > > fFilter