14 <<
", useParabolaFit=" << useParabolaFit <<
", useFivePoleFit=" <<
useFivePoleFit;
33 for (
size_t i = 0;
i < 4; ++
i) {
35 sumt += adc[
i] * float(tmax - 1 +
i);
37 return sumt / sum * 50.;
54 if ((y1 + y3) < 2.
f * y2)
55 tcorr = 0.5f * (y1 - y3) / (y1 - 2. * y2 + y3);
58 LogTrace(
"CSCFindPeakTime") <<
"[CSCFindPeakTime] tmax=" << tmax <<
", parabolic peak time is tmax+" << tcorr
59 <<
" bins, or " << tpeak * 50.f <<
" ns";
79 constexpr
float t0peak = 133.f;
80 constexpr
float p0 = 4.f / t0peak;
85 if (tmax < 2 || tmax > 6)
91 for (
int time = 0; time < 4; ++time) {
92 tb[time] = (tmax + time - 1) * 50.
f;
101 float chi_min = 1.e10f;
102 float chi_last = 1.e10f;
112 while (del_t > 1.
f) {
116 for (
int j = 0;
j < n_fit; ++
j) {
117 float tdif = tb[
j] - tt0;
118 x[
j] = (tdif * tdif) * (tdif * tdif) *
std::exp(-p0 * tdif);
120 sxy += x[
j] * adc[
j];
126 for (
int j = 0;
j < n_fit; ++
j)
127 chi2 += (adc[
j] - fN * x[
j]) * (adc[
j] - fN * x[
j]);
130 if (chi_last > chi2) {
131 if (chi2 < chi_min) {
137 tt0 = tt0 - 2.f * del_t;
148 int tmax,
const float*
adc,
const float& t_zero,
const float& t_peak, std::vector<float>& adcsFit) {
151 float p0 = 4.f / t_peak;
158 for (
int t = 0;
t < 4; ++
t) {
159 tb[
t] = float(tmax +
t - 1) * 50.f;
167 for (
int j = 0;
j < n_fit; ++
j) {
169 x[
j] = ((t - tt0) * (t - tt0)) * ((t - tt0) * (t - tt0)) *
std::exp(-p0 * (t - tt0));
170 sx2 = sx2 + x[
j] * x[
j];
171 sxy = sxy + x[
j] * y[
j];
176 for (
int i = 0;
i < 3; ++
i) {
177 float t = t_peak + float(
i - 1) * 50.f;
178 float q_fitted = float(N) * ((t - tt0) * (t - tt0)) * ((t - tt0) * (t - tt0)) *
std::exp(-p0 * (t - tt0));
179 adcsFit.push_back(q_fitted);
float parabolaFitTime(int tmax, const float *adc)
Parabolic fit to three time bins centered on maximum.
float fivePoleFitTime(int tmax, const float *adc, float t_peak)
Exp< T >::type exp(const T &t)
void fivePoleFitCharge(int tmax, const float *adc, const float &t_zero, const float &t_peak, std::vector< float > &adcsFit)
static const double tmax[3]
T getParameter(std::string const &) const
CSCFindPeakTime(const edm::ParameterSet &ps)
float averageTime(int tmax, const float *adc)
Weighted average of time bins.
float peakTime(int tmax, const float *adc, float t_peak)
Basic result of this class.
uint16_t *__restrict__ uint16_t const *__restrict__ adc