All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SignalShaper.h
Go to the documentation of this file.
1 #ifndef SIGNALSHAPER_H
2 #define SIGNALSHAPER_H
3 
4 #include <vector>
5 #include <complex>
6 
7 #include "art/Framework/Services/Registry/ServiceHandle.h"
10 
11 namespace util {
12 
13 class SignalShaper {
14 public:
15 
16  // Constructor, destructor.
17  SignalShaper(int fftsize,std::string fftopt);
18  virtual ~SignalShaper();
19 
20  // Accessors.
21  const std::vector<double>& Response() const {return fResponse;}
22  const std::vector<double>& Response_save() const {return fResponse_save;}
23  const std::vector<std::complex<double>>& ConvKernel() const {return fConvKernel;}
24  const std::vector<std::complex<double>>& Filter() const {return fFilter;}
25  const std::vector<std::complex<double>>& DeconvKernel() const {return fDeconvKernel;}
26 
27  // Signal shaping methods.
28 
29  // Convolute a time series with convolution kernel.
30  template <class T> void Convolute(std::vector<T>& func) const;
31 
32  // Convolute a time series with deconvolution kernel.
33  template <class T> void Deconvolute(std::vector<T>& func) const;
34 
35 
36  // Configuration methods.
37 
38  // Reset this class to default-constructed state.
39  void Reset();
40 
42  void set_normflag(bool flag){fNorm = flag;}
43 
44  // Add a time domain response function.
45  // Updates overall response function and convolution kernel.
46  void AddResponseFunction(const std::vector<double>& resp, bool ResetResponse = false );
47 
48  // Shift response function in time.
49  // Updates overall response function and convolution kernel.
50  void ShiftResponseTime(double ticks);
51  void SetPeakResponseTime(double tick);
52 
53  // Add a filter function.
54  void AddFilterFunction(const std::vector<std::complex<double>>& filt);
55 
56  //Add DeconvKernel Polarity switch to decide how to normalize
57  //deconvoluted signal w.r.t. RawDigits. If +1 then normalize
58  //to Max ADC, if -1 to Min ADC
59  void SetDeconvKernelPolarity(int pol);
60 
61  // Test and lock the current response function.
62  // Does not lock filter configuration.
63  void LockResponse() const;
64 
65  // Calculate deconvolution kernel using current convolution kernel
66  // and filter function.
67  // Fully locks configuration.
68  void CalculateDeconvKernel() const;
69 
70  private:
71 
72  // Attributes.
73  // unused double fMinConvKernelFrac; ///< minimum value of convKernel/peak for deconvolution
74 
75  // Lock flags.
76  mutable bool fResponseLocked;
77  mutable bool fFilterLocked;
78 
79  // Overall response.
80  std::vector<double> fResponse;
81  std::vector<double> fResponse_save;
82 
83  // Convolution kernel (fourier transform of response function).
84  std::vector<std::complex<double>> fConvKernel;
85 
86  // Overall filter function.
87  std::vector<std::complex<double>> fFilter;
88 
89  // Deconvolution kernel (= fFilter / fConvKernel).
90  mutable std::vector<std::complex<double>> fDeconvKernel;
91 
92  // Deconvolution Kernel Polarity Flag
93  // Set to +1 if deconv signal should be deconv to + ADC count
94  // Set to -1 if one wants to normalize to - ADC count
96 
97  // Xin added */
98  bool fNorm;
99 
100  int fFFTSize;
101  const void *fPlan;
102  const void *rPlan;
103  std::unique_ptr<util::LArFFTWPlan> fFFTPlan;
104  std::unique_ptr<util::LArFFTW> fFFT;
105 };
106 
107 }
108 
109 #endif
void CalculateDeconvKernel() const
void AddFilterFunction(const std::vector< std::complex< double >> &filt)
void ShiftResponseTime(double ticks)
std::unique_ptr< util::LArFFTWPlan > fFFTPlan
Definition: SignalShaper.h:103
const std::vector< double > & Response() const
Definition: SignalShaper.h:21
then echo unknown compiler flag
const void * fPlan
Definition: SignalShaper.h:101
std::vector< double > fResponse_save
Definition: SignalShaper.h:81
virtual ~SignalShaper()
const std::vector< std::complex< double > > & ConvKernel() const
Definition: SignalShaper.h:23
void SetPeakResponseTime(double tick)
tick ticks
Alias for common language habits.
Definition: electronics.h:78
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
const void * rPlan
Definition: SignalShaper.h:102
void LockResponse() const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
const std::vector< double > & Response_save() const
Definition: SignalShaper.h:22
std::vector< double > fResponse
Definition: SignalShaper.h:80
std::unique_ptr< util::LArFFTW > fFFT
Definition: SignalShaper.h:104
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
void Deconvolute(std::vector< T > &func) const
std::vector< std::complex< double > > fConvKernel
Definition: SignalShaper.h:84
void set_normflag(bool flag)
Definition: SignalShaper.h:42
SignalShaper(int fftsize, std::string fftopt)
Definition: SignalShaper.cxx:9
const std::vector< std::complex< double > > & Filter() const
Definition: SignalShaper.h:24
then filt
const std::vector< std::complex< double > > & DeconvKernel() const
Definition: SignalShaper.h:25
std::vector< std::complex< double > > fDeconvKernel
Definition: SignalShaper.h:90
void SetDeconvKernelPolarity(int pol)
std::vector< std::complex< double > > fFilter
Definition: SignalShaper.h:87
void Convolute(std::vector< T > &func) const