12 #ifndef __KVDigitalFilter_H
13 #define __KVDigitalFilter_H
18 KVDigitalFilter(
const double& tau,
int N,
const double* Xcoeffs,
const double* Ycoeffs);
35 void Quantize(
int nbits,
int use_pow2 = 0,
double* xgain = NULL,
int* x_out = NULL,
int* y_out = NULL,
int* x_scale = NULL,
int* y_scale = NULL);
43 const double& percent_ripple,
int npoles,
53 return (
int)(val * 32768 * 256 + 0.5);
57 return val / (32768.*256.);
81 for (
int i = 0; i <
Ncoeff; i++)
a[i] *=
v;
87 static const double zero = 0;
88 if (i >= 0 && i <
Ncoeff)
return a[i];
93 static const double zero = 0;
94 if (i >= 0 && i <
Ncoeff)
return b[i];
102 printf(
"ERROR in %s: index %d out of bounds (0..%d).\n",
103 __PRETTY_FUNCTION__, i,
Ncoeff - 1);
110 printf(
"ERROR in %s: index %d out of bounds (0..%d).\n",
111 __PRETTY_FUNCTION__, i,
Ncoeff - 1);
132 void ApplyTo(
double* data,
const int N,
int reverse = 0)
const;
133 void ApplyTo(
float* data,
const int N,
int reverse = 0)
const;
134 void ApplyTo(
int* data,
const int N,
int reverse = 0)
const;
135 void FIRApplyTo(
double* datax,
const int NSamples,
int reverse)
const;
136 void FIRApplyTo(
float* datax,
const int NSamples,
int reverse)
const;
140 printf(
"ERROR in %s: different tau_clk! %e != %e\n",
141 __PRETTY_FUNCTION__,
s->GetChannelWidth(),
tau_clk);
144 ApplyTo(
s->GetArray()->GetArray(),
s->GetNSamples(), reverse);
149 printf(
"ERROR in %s: different tau_clk! %e != %e\n",
150 __PRETTY_FUNCTION__,
s->GetChannelWidth(),
tau_clk);
153 FIRApplyTo(
s->GetArray()->GetArray(),
s->GetNSamples(), reverse);
162 const double& pr,
const double& np,
164 double* a0,
double* a1,
double* a2,
165 double* b1,
double* b2);
168 int is_highpass,
const double& percent_ripple,
int npoles,
169 double*
a,
double*
b);
#define ClassDef(name, id)
Base class for KaliVeda framework.
static KVDigitalFilter CombineStages(const KVDigitalFilter &f1, const KVDigitalFilter &f2, int parallel=0)
static KVDigitalFilter BuildRCHighPassWithPZ(const double &tau_usec, const double &preamp_decay_usec, const double &tau_clk)
void Compress()
shorten filter. No deallocation of memory.
virtual void Draw(Option_t *option="")
void ApplyTo(KVSignal *s, int reverse=0) const
const double & GetYcoeff(int i) const
static void ComputeChebyshevCoeffs_serv(const double &fc, const double &lh, const double &pr, const double &np, int p, double *a0, double *a1, double *a2, double *b1, double *b2)
static int Double2DSP(const double &val)
– conversion to/from DSP 1.15? notation
void SetXcoeff(int i, const double &val)
static KVDigitalFilter BuildRCLowPassDeconv(const double &tau_usec, const double &tau_clk)
virtual ~ KVDigitalFilter()
void Quantize(int nbits, int use_pow2=0, double *xgain=NULL, int *x_out=NULL, int *y_out=NULL, int *x_scale=NULL, int *y_scale=NULL)
static KVDigitalFilter BuildRCLowPass(const double &tau_usec, const double &tau_clk)
static double DSP2Double(const int val)
void PrintCoeffsDSP() const
static void ComputeChebyshevCoeffs(const double &freq_cutoff, int is_highpass, const double &percent_ripple, int npoles, double *a, double *b)
static KVDigitalFilter BuildChebyshev(const double &freq_cutoff_mhz, int is_highpass, const double &percent_ripple, int npoles, const double &tau_clk)
void ApplyTo(double *data, const int N, int reverse=0) const
KVDigitalFilter operator=(const KVDigitalFilter &)
int ReadMatlabFIR(char *filecoeff)
FILE *fin = fopen("notch_coeffs.txt","r");.
static KVDigitalFilter BuildUnity(const double &tau_clk)
const double & GetXcoeff(int i) const
static KVDigitalFilter BuildRCHighPass(const double &tau_usec, const double &tau_clk)
void FIRApplyTo(KVSignal *s, int reverse=0) const
void SetYcoeff(int i, const double &val)
const double & GetTauClk()
static KVDigitalFilter BuildIntegrator(const double &tau_clk)
KVDigitalFilter(const double &tau=10)
int WriteMatlabFIR(char *filecoeff)
void PrintCoeffs_AsC() const
void Alloc(const int Ncoeff)
printf("a=%p, N=%d, Ncoeff=%d\n", a, N, Ncoeff);
void FIRApplyTo(double *datax, const int NSamples, int reverse) const
static KVDigitalFilter BuildInverse(KVDigitalFilter *filter)
**************************************/
static KVDigitalFilter CombineStagesMany(const KVDigitalFilter *f1, const KVDigitalFilter *f2, const KVDigitalFilter *f3=NULL, const KVDigitalFilter *f4=NULL, const KVDigitalFilter *f5=NULL, const KVDigitalFilter *f6=NULL, const KVDigitalFilter *f7=NULL, const KVDigitalFilter *f8=NULL, const KVDigitalFilter *f9=NULL, const KVDigitalFilter *f10=NULL)
se ne devi combinare + di 1 IN CASCATA!
VecExpr< UnaryOp< Fabs< T >, SVector< T, D >, T >, T, D > fabs(const SVector< T, D > &rhs)