12 using namespace Diana;
16 fMaxJitter(maxJitter),
40 for(
size_t i = 1 ; i <
fSize;i++) {
63 if(p.Size() !=
fSize) {
130 err.SetDescription(
"Chisquare not at minimum, interpolation not possible");
136 double detA = xa*xa*(xb-xc)-xb*xb*(xa-xc)+xc*xc*(xa-xb);
137 double detA1 = ya*(xb-xc)-yb*(xa-xc)+yc*(xa-xb);
138 double detA2 = xa*xa*(yb-yc)-xb*xb*(ya-yc)+xc*xc*(ya-yb);
141 double p0 = detA1/detA;
142 double p1 = detA2/detA;
145 intJitter = -p1/2./p0;
146 int low = floor(intJitter);
147 int high = ceil (intJitter);
148 double x = intJitter-low;
149 if(low < 0) low +=
fSize;
150 if(high < 0) high +=
fSize;
155 inta1 = (a1High-a1Low)*x+a1Low;
156 inta2 = (a2High-a2Low)*x+a2Low;
164 QVector baseline(ret.Size());
165 baseline.Initialize(ret[0]);
173 const size_t size = ap1.Size();
180 Diana::QMatrix M(2,2);
181 M(0,0) = (ap1f.GetModulusSquare().Div(
fAverageNoise)).Sum(size-1,1);
182 M(0,1) = ((ap1f.Conj().Mult(ap2f)).
Re().Div(
fAverageNoise)).Sum(size-1,1);
184 M(1,1) = (ap2f.GetModulusSquare().Div(
fAverageNoise)).Sum(size-1,1);
191 fFilter1 = (M(0,0)*ap1f.Conj()+M(0,1)*ap2f.Conj()).Div(anc);
192 fFilter2 = (M(1,0)*ap1f.Conj()+M(1,1)*ap2f.Conj()).Div(anc);
206 int minJitter = -maxJitter;
208 QVector ap1Shifted = ap1;
210 QVector ap2Shifted =
ap2;
212 QVectorC ap1ShiftedF,ap2ShiftedF;
235 if(index < 0) index +=
fSize;
245 vector<double> chiSquare;
246 for(
size_t j = 0; j <
fJitters.size(); j++) {
249 if(jitter < 0) jitter +=
fSize;
250 a1 = ap1Filtered[jitter];
251 a2 = ap2Filtered[jitter];
254 double chi2 = (p-a1*ap1f-a2*ap2f).GetModulusSquare().Div(
fAverageNoise).Sum(
fSize-1,1);
256 chiSquare.push_back(chi2);
265 output.ShiftReal(jitter);
double Re(const Diana::QComplex &z)
Function to get the real part.
Diana::QVector cos(const Diana::QVector &v)
QError ComputeAmplitude(const Diana::QVectorC &transformed)
std::vector< double > ChiSquare(const Diana::QVectorC &p, const Diana::QVector &ap1Filtered, const Diana::QVector &ap2Filtered) const
Diana::QVector NormalizeVector(const Diana::QVector &vec) const
double fAvgPulseIntegral1
QError Filter(const Diana::QVector &p)
filter p. In case of failure an error is returned.
Diana::QVector fFiltered1
double fAvgPulseIntegral2
Diana::QVector GetFitFunction(const double jitter, const double a1, const double a2) const
Diana::QVector fAveragePulse2
std::vector< double > fChiSquareWithJitter
double GetChiSquareAtMinimium() const
get chi square value at its minimum, if Filter()!=QERR_SUCCESS throw the error
void BuildFilter(const Diana::QVector &ap1, const Diana::QVector &ap2)
virtual ~QBiComponentOptimumFilter()
Diana::QVector fFiltered2
QBiComponentOptimumFilter(const Diana::QVector &ap1, const Diana::QVector &ap2, const Diana::QVector &an, size_t maxJitter, bool diff=false)
constructor
Diana::QVector fAveragePulse1
int GetJitterAtMinimum() const
get jitter at the minimum of the chi square. if Filter()!=QERR_SUCCESS throw the error
const std::vector< double > & GetChiSquareWithJitter() const
get chi square as a function of jitter, same indexing of GetJitters(). if Filter()==QERR_SIZE_NOT_MAT...
std::vector< int > fJitters
QError GetInterpolated(double &jitter, double &a1, double &a2, double &integral) const
get values at interpolated chi^2 minimum. Three points around the minimum are used for a parabolic in...
void GetFiltered(Diana::QVector &f1, Diana::QVector &f2) const
get filtered waveforms. if Filter()==QERR_SIZE_NOT_MATCH throws the error
Diana::QRealComplexFFT * fTransformer
std::vector< Diana::QVectorC > fAveragePulse1Shifted
std::vector< Diana::QVectorC > fAveragePulse2Shifted
Diana::QVector fAverageNoise
void GetAmplitude(double &a1, double &a2, double &integral) const
get amplitudes at chi^2 minimum. if Filter()!=QERR_SUCCESS throws the error
error class with error type and description
Wrapper for a specific QRealComplexFFT algorithm class.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...