| File: | ecl/digitization/src/ShapeFitter.cc |
| Warning: | line 168, column 9 Value stored to 'low_ampl' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /************************************************************************** |
| 2 | * basf2 (Belle II Analysis Software Framework) * |
| 3 | * Author: The Belle II Collaboration * |
| 4 | * * |
| 5 | * See git log for contributors and copyright holders. * |
| 6 | * This file is licensed under LGPL-3.0, see LICENSE.md. * |
| 7 | **************************************************************************/ |
| 8 | #include <ecl/digitization/algorithms.h> |
| 9 | #include <iostream> |
| 10 | |
| 11 | using namespace std; |
| 12 | |
| 13 | void 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) |
| 15 | { |
| 16 | static const long long int k_np[16] = { |
| 17 | 65536, |
| 18 | 32768, |
| 19 | 21845, |
| 20 | 16384, |
| 21 | 13107, |
| 22 | 10923, |
| 23 | 9362, |
| 24 | 8192, |
| 25 | 7282, |
| 26 | 6554, |
| 27 | 5958, |
| 28 | 5461, |
| 29 | 5041, |
| 30 | 4681, |
| 31 | 4369, |
| 32 | 4096 |
| 33 | }; |
| 34 | |
| 35 | |
| 36 | int A0 = (int) * (id + 0) - 128; |
| 37 | int Askip = (int) * (id + 1) - 128; |
| 38 | |
| 39 | int ttrig; |
| 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); |
| 47 | |
| 48 | int chi_thres = (int) * (id + 15); |
| 49 | |
| 50 | |
| 51 | |
| 52 | int s1, s2; |
| 53 | |
| 54 | long long int z00; |
| 55 | |
| 56 | int ys; |
| 57 | ys = 0; |
| 58 | int it, it0; |
| 59 | // long long d_it; |
| 60 | int it_h, it_l; |
| 61 | long long A1, B1, A2, C1, ch1, ch2, B2, B3, B5 ; |
| 62 | int low_ampl, i, T, iter; |
| 63 | ch1 = -1; |
| 64 | |
| 65 | ttrig = *ttrig2 / 6; |
| 66 | |
| 67 | |
| 68 | if (k_16 + *n16 != 16) { |
| 69 | cout << "disagreement in number of the points " << k_16 << "and " << *n16 << endl; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | int validity_code = 0; |
| 74 | for (i = ys, z00 = 0; i < 16; i++) { |
| 75 | z00 += y[i]; |
| 76 | |
| 77 | } |
| 78 | //initial time index |
| 79 | |
| 80 | |
| 81 | |
| 82 | it0 = 48 + ((143 - *ttrig2) << 2) / 6; |
| 83 | |
| 84 | |
| 85 | if (ttrig > 23) {cout << "*Ttrig Warning" << ttrig << endl; ttrig = 23;} |
| 86 | if (ttrig < 0) {cout << "*Ttrig Warning" << ttrig << endl; ttrig = 0;} |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | it_h = 191; |
| 92 | it_l = 0; |
| 93 | if (it0 < it_l)it0 = it_l; |
| 94 | if (it0 > it_h)it0 = it_h; |
| 95 | it = it0; |
| 96 | |
| 97 | //first approximation without time correction |
| 98 | |
| 99 | // int it00=23-it0; |
| 100 | |
| 101 | s1 = (*(fg41 + ttrig * 16)); |
| 102 | |
| 103 | |
| 104 | A2 = (s1 * z00); |
| 105 | |
| 106 | |
| 107 | |
| 108 | for (i = 1; i < 16; i++) { |
| 109 | s1 = (*(fg41 + ttrig * 16 + i)); |
| 110 | B3 = y[15 + i]; |
| 111 | B3 = s1 * B3; |
| 112 | A2 += B3; |
| 113 | |
| 114 | |
| 115 | } |
| 116 | |
| 117 | |
| 118 | A2 += (1 << (k_a - 1)); |
| 119 | A2 >>= k_a; |
| 120 | T = -2048; |
| 121 | //too large amplitude |
| 122 | if (A2 > 262143) { |
| 123 | A1 = A2 >> 3; |
| 124 | validity_code = 1; |
| 125 | |
| 126 | goto ou; |
| 127 | } |
| 128 | |
| 129 | |
| 130 | low_ampl = 0; |
| 131 | |
| 132 | |
| 133 | |
| 134 | if (A2 >= A0) { |
| 135 | |
| 136 | for (iter = 0, it = it0; iter < 3;) { |
| 137 | iter++; |
| 138 | s1 = (*(fg31 + it * 16)); |
| 139 | s2 = (*(fg32 + it * 16)); |
| 140 | A1 = (s1 * z00); |
| 141 | B1 = (s2 * z00); |
| 142 | |
| 143 | |
| 144 | |
| 145 | for (i = 1; i < 16; i++) { |
| 146 | s1 = (*(fg31 + i + it * 16)); |
| 147 | s2 = (*(fg32 + i + it * 16)); |
| 148 | |
| 149 | B5 = y[15 + i]; |
| 150 | |
| 151 | B5 = s1 * B5; |
| 152 | A1 += B5; |
| 153 | |
| 154 | |
| 155 | B3 = y[15 + i]; |
| 156 | B3 = s2 * B3; |
| 157 | B1 += B3; |
| 158 | } |
| 159 | A1 += (1 << (k_a - 1)); |
| 160 | A1 = A1 >> k_a; |
| 161 | |
| 162 | |
| 163 | |
| 164 | if (A1 > 262143) |
| 165 | goto ou; |
| 166 | if (A1 < A0) { |
| 167 | |
| 168 | low_ampl = 1; |
Value stored to 'low_ampl' is never read | |
| 169 | it = it0; |
| 170 | |
| 171 | goto lam; |
| 172 | } |
| 173 | |
| 174 | if (iter != 3) { |
| 175 | |
| 176 | B2 = B1 >> (k_b - 9); |
| 177 | B1 = B2 >> 9; |
| 178 | |
| 179 | B2 += (A1 << 9); |
| 180 | |
| 181 | |
| 182 | B3 = (B2 / A1); |
| 183 | |
| 184 | |
| 185 | it += ((B3 + 1) >> 1) - 256; |
| 186 | it = it > it_h ? it_h : it; |
| 187 | it = it < it_l ? it_l : it; |
| 188 | } else { |
| 189 | B2 = B1 >> (k_b - 11); |
| 190 | B5 = B1 >> (k_b - 9); |
| 191 | |
| 192 | B2 += (A1 << 11); |
| 193 | B3 = (B2 / A1); |
| 194 | |
| 195 | T = ((it) << 3) + ((it) << 2) + ((B3 + 1) >> 1) + B3 - 3072; |
| 196 | |
| 197 | T = ((215 - *ttrig2) << 3) - 4 - T; |
| 198 | |
| 199 | B1 = B5 >> 9; |
| 200 | B5 += (A1 << 9); |
| 201 | B3 = (B5 / A1); |
| 202 | it += ((B3 + 1) >> 1) - 256; |
| 203 | it = it > it_h ? it_h : it; |
| 204 | it = it < it_l ? it_l : it; |
| 205 | |
| 206 | T = T > 2046 ? 2047 : T; |
| 207 | |
| 208 | T = T < -2046 ? -2047 : T; |
| 209 | |
| 210 | C1 = (*(fg33 + it * 16) * z00); |
| 211 | |
| 212 | for (i = 1; i < 16; i++) |
| 213 | C1 += *(fg33 + i + it * 16) * y[15 + i]; |
| 214 | C1 += (1 << (k_c - 1)); |
| 215 | C1 >>= k_c; |
| 216 | |
| 217 | |
| 218 | } |
| 219 | |
| 220 | } |
| 221 | } else |
| 222 | low_ampl = 1; |
| 223 | |
| 224 | if (low_ampl == 1) { |
| 225 | |
| 226 | lam: |
| 227 | A1 = A2; |
| 228 | validity_code = 0; |
| 229 | B1 = 0; |
| 230 | C1 = (*(fg43 + ttrig * 16) * z00); |
| 231 | for (i = 1; i < 16; i++) { |
| 232 | B5 = y[15 + i]; |
| 233 | C1 += *(fg43 + i + ttrig * 16) * B5; |
| 234 | } |
| 235 | C1 += (1 << (k_c - 1)); |
| 236 | C1 >>= k_c; |
| 237 | } |
| 238 | |
| 239 | |
| 240 | ch2 = z00 - *n16 * C1; |
| 241 | ch1 = ((ch2) * (ch2)); |
| 242 | ch1 = ch1 * k_np[*n16 - 1]; |
| 243 | ch1 = ch1 >> 16; |
| 244 | for (i = 1; i < 16; i++) { |
| 245 | ch2 = A1 * (*(f + i + it * 16)) + B1 * (*(f1 + i + it * 16)); |
| 246 | ch2 >>= k1_chi; |
| 247 | ch2 = (y[i + 15] - ch2 - C1); |
| 248 | |
| 249 | ch1 = ch1 + ch2 * ch2; |
| 250 | |
| 251 | } |
| 252 | B2 = (A1 >> 1) * (A1 >> 1); |
| 253 | B2 >>= (k2_chi - 2); |
| 254 | B2 += chi_thres; |
| 255 | if (ch1 > B2)validity_code = 3; |
| 256 | ou: |
| 257 | |
| 258 | *lar = A1; |
| 259 | *ltr = T; |
| 260 | *hi2 = ch1; |
| 261 | |
| 262 | |
| 263 | if (A1 < Askip)validity_code = validity_code + 8; |
| 264 | |
| 265 | int ss = (y[20] + y[21]); |
| 266 | |
| 267 | if (ss <= Ahard)validity_code = validity_code + 4; |
| 268 | |
| 269 | |
| 270 | *lq = validity_code; |
| 271 | |
| 272 | |
| 273 | return ; |
| 274 | } |