8#include <ecl/digitization/algorithms.h>
13void Belle2::ECL::shapeFitter(
short int*
id,
int* f,
int* f1,
int* fg41,
int* fg43,
int* fg31,
int* fg32,
int* fg33,
int* y,
14 int* ttrig2,
int* n16,
int* lar,
int* ltr,
int* lq,
int* hi2)
16 static const long long int k_np[16] = {
36 int A0 = (int) * (
id + 0) - 128;
37 int Askip = (int) * (
id + 1) - 128;
40 int Ahard = (int) * (
id + 2);
41 int k_a = (int) * ((
unsigned char*)
id + 26);
42 int k_b = (int) * ((
unsigned char*)
id + 27);
43 int k_c = (int) * ((
unsigned char*)
id + 28);
44 int k_16 = (int) * ((
unsigned char*)
id + 29);
45 int k1_chi = (int) * ((
unsigned char*)
id + 24);
46 int k2_chi = (int) * ((
unsigned char*)
id + 25);
48 int chi_thres = (int) * (
id + 15);
61 long long A1, B1, A2, C1, ch1, ch2, B2, B3, B5 ;
62 int low_ampl, i, T, iter;
68 if (k_16 + *n16 != 16) {
69 cout <<
"disagreement in number of the points " << k_16 <<
"and " << *n16 << endl;
73 int validity_code = 0;
74 for (i = ys, z00 = 0; i < 16; i++) {
82 it0 = 48 + ((143 - *ttrig2) << 2) / 6;
85 if (ttrig > 23) {cout <<
"*Ttrig Warning" << ttrig << endl; ttrig = 23;}
86 if (ttrig < 0) {cout <<
"*Ttrig Warning" << ttrig << endl; ttrig = 0;}
93 if (it0 < it_l)it0 = it_l;
94 if (it0 > it_h)it0 = it_h;
101 s1 = (*(fg41 + ttrig * 16));
108 for (i = 1; i < 16; i++) {
109 s1 = (*(fg41 + ttrig * 16 + i));
118 A2 += (1 << (k_a - 1));
136 for (iter = 0, it = it0; iter < 3;) {
138 s1 = (*(fg31 + it * 16));
139 s2 = (*(fg32 + it * 16));
145 for (i = 1; i < 16; i++) {
146 s1 = (*(fg31 + i + it * 16));
147 s2 = (*(fg32 + i + it * 16));
159 A1 += (1 << (k_a - 1));
176 B2 = B1 >> (k_b - 9);
185 it += ((B3 + 1) >> 1) - 256;
186 it = it > it_h ? it_h : it;
187 it = it < it_l ? it_l : it;
189 B2 = B1 >> (k_b - 11);
190 B5 = B1 >> (k_b - 9);
195 T = ((it) << 3) + ((it) << 2) + ((B3 + 1) >> 1) + B3 - 3072;
197 T = ((215 - *ttrig2) << 3) - 4 - T;
202 it += ((B3 + 1) >> 1) - 256;
203 it = it > it_h ? it_h : it;
204 it = it < it_l ? it_l : it;
206 T = T > 2046 ? 2047 : T;
208 T = T < -2046 ? -2047 : T;
210 C1 = (*(fg33 + it * 16) * z00);
212 for (i = 1; i < 16; i++)
213 C1 += *(fg33 + i + it * 16) * y[15 + i];
214 C1 += (1 << (k_c - 1));
230 C1 = (*(fg43 + ttrig * 16) * z00);
231 for (i = 1; i < 16; i++) {
233 C1 += *(fg43 + i + ttrig * 16) * B5;
235 C1 += (1 << (k_c - 1));
240 ch2 = z00 - *n16 * C1;
241 ch1 = ((ch2) * (ch2));
242 ch1 = ch1 * k_np[*n16 - 1];
244 for (i = 1; i < 16; i++) {
245 ch2 = A1 * (*(f + i + it * 16)) + B1 * (*(f1 + i + it * 16));
247 ch2 = (y[i + 15] - ch2 - C1);
249 ch1 = ch1 + ch2 * ch2;
252 B2 = (A1 >> 1) * (A1 >> 1);
255 if (ch1 > B2)validity_code = 3;
263 if (A1 < Askip)validity_code = validity_code + 8;
265 int ss = (y[20] + y[21]);
267 if (ss <= Ahard)validity_code = validity_code + 4;