25 return StatusCode::SUCCESS;
29 {
return StatusCode::SUCCESS;}
34 std::vector<float> solution;
36 float shape_max,delay_max;
37 float sample_max,adc_max;
39 double chi2,chi2_best,yi2,yigi,gi2,lambda=0;
45 const std::vector<double>::const_iterator wave_max=max_element(wave.begin(),wave.end());
46 if (wave_max==wave.end())
50 shape_max = *wave_max;
52 delay_max =
distance(wave.begin(),wave_max);
57 delay_max,wave[
d], delay_max+1,wave[
d+1]);
61 const std::vector<float>::const_iterator it_max=max_element(samples.begin(),samples.end());
62 if (it_max==samples.end())
67 sample_max =
distance(samples.begin(),it_max);
73 std::vector<float>::const_iterator it_sample = samples.begin();
74 std::vector<float>::const_iterator it_sample_end = samples.end();
77 int sample_2ndmax =
static_cast<int> (sample_max);
78 for (;it_sample!=it_sample_end;++it_sample) {
79 if((*it_sample>adc_2ndmax) && (*it_sample<=adc_max)) {
80 adc_2ndmax = *it_sample;
81 sample_2ndmax =
distance(samples.begin(),it_sample);
86 if(std::abs(sample_max-sample_2ndmax)>1) std::cout <<
"maxima are far away ? index(max) = " << sample_max <<
", index(2nd max) = " << sample_2ndmax <<
", samples = " << samples[0] <<
", " << samples[1] <<
", " << samples[2] <<
", " << samples[3] <<
", " << samples[4] <<
", " << samples[5] <<
", " << std::endl;
88 if(sample_max-sample_2ndmax > 0) {
89 s1 = sample_2ndmax - 1;
90 s2 =
static_cast<int> (sample_max + 1);
92 s1 =
static_cast<int> (sample_max - 1);
93 s2 = sample_2ndmax + 1;
113 yi2=0; gi2=0; yigi=0;
117 yi2+=samples[
s]*samples[
s];
118 gi2+=wave[
i]*wave[
i];
119 yigi+=wave[
i]*samples[
s];
122 if(gi2<=0)
chi2=chi2_best;
123 else chi2=yi2-yigi*yigi/gi2;
133 if(delay_best<=-999) {
return solution; }
135 float adc_reco = lambda*shape_max;
137 float time_reco = delay_best;
138 if(delay_best<adc_max) time_reco = delay_best;
140 solution.push_back(adc_reco);
141 solution.push_back(time_reco);
148 float x2,
float y2,
float x3,
float y3)
const
151 float x12, x13, xx12, xx13, y12, y13;
159 xx13 =
x1*
x1 - x3*x3;
161 n = y13 - x13/x12*y12;
162 d = xx13 - x13/x12*xx12;
164 b = (y12 -
a*xx12)/x12;
173 float delay_max,
int nbin,
int nsample)
const
177 s1 = (
int) (sample_max - (delay_max - 5.)/25.) +1;
179 s2 = (
int) (sample_max + (nbin - delay_max - 5.)/25.);
180 if(
s2>=nsample)
s2=nsample-1;
183 if(
s2-sample_max>sample_max-
s1)
s2--;