1852 Int_t i, i1, i2, j, k, shift =
1855 Double_t a,
b,
c,
d = 0, alpha, chi_opt, yw, ywm,
f, chi2, chi_min, chi =
1856 0, pi, pmin = 0, chi_cel = 0, chi_er;
1858 for (i = 0, j = 0; i <
fNPeaks; i++) {
1859 working_space[7 * i] =
fAmpInit[i];
1861 working_space[shift + j] =
fAmpInit[i];
1906 working_space[7 * i + 2] =
fRoInit;
1908 working_space[shift + j] =
fRoInit;
1911 working_space[7 * i + 3] =
fA0Init;
1913 working_space[shift + j] =
fA0Init;
1916 working_space[7 * i + 4] =
fAxInit;
1918 working_space[shift + j] =
fAxInit;
1921 working_space[7 * i + 5] =
fAyInit;
1923 working_space[shift + j] =
fAyInit;
1926 working_space[7 * i + 6] =
fTxyInit;
1928 working_space[shift + j] =
fTxyInit;
1931 working_space[7 * i + 7] =
fSxyInit;
1933 working_space[shift + j] =
fSxyInit;
1936 working_space[7 * i + 8] =
fTxInit;
1938 working_space[shift + j] =
fTxInit;
1941 working_space[7 * i + 9] =
fTyInit;
1943 working_space[shift + j] =
fTyInit;
1946 working_space[7 * i + 10] =
fSxyInit;
1948 working_space[shift + j] =
fSxInit;
1951 working_space[7 * i + 11] =
fSyInit;
1953 working_space[shift + j] =
fSyInit;
1956 working_space[7 * i + 12] =
fBxInit;
1958 working_space[shift + j] =
fBxInit;
1961 working_space[7 * i + 13] =
fByInit;
1963 working_space[shift + j] =
fByInit;
1968 for (j = 0; j <
size; j++) {
1969 working_space[2 * shift + j] = 0, working_space[3 * shift + j] = 0;
1974 chi_opt = 0, pw =
fPower - 2;
1977 yw = source[i1][i2];
1980 working_space, working_space[peak_vel],
1981 working_space[peak_vel + 1],
1982 working_space[peak_vel + 2],
1983 working_space[peak_vel + 3],
1984 working_space[peak_vel + 4],
1985 working_space[peak_vel + 5],
1986 working_space[peak_vel + 6],
1987 working_space[peak_vel + 7],
1988 working_space[peak_vel + 8],
1989 working_space[peak_vel + 9],
1990 working_space[peak_vel + 10],
1991 working_space[peak_vel + 11],
1992 working_space[peak_vel + 12],
1993 working_space[peak_vel + 13]);
2001 chi_opt += (yw -
f) * (yw -
f) / ywm;
2021 for (j = 0, k = 0; j <
fNPeaks; j++) {
2024 working_space[7 * j + 1],
2025 working_space[7 * j + 2],
2026 working_space[peak_vel],
2027 working_space[peak_vel + 1],
2028 working_space[peak_vel + 2],
2029 working_space[peak_vel + 6],
2030 working_space[peak_vel + 7],
2031 working_space[peak_vel + 12],
2032 working_space[peak_vel + 13]);
2036 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2037 working_space[2 * shift + k] +=
b *
c;
2038 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2039 working_space[3 * shift + k] +=
b *
c;
2043 b =
a * (yw -
f) / ywm;
2044 working_space[2 * shift + k] +=
b *
c;
2046 working_space[3 * shift + k] +=
b *
c;
2053 working_space[7 * j],
2054 working_space[7 * j + 1],
2055 working_space[7 * j + 2],
2056 working_space[peak_vel],
2057 working_space[peak_vel + 1],
2058 working_space[peak_vel + 2],
2059 working_space[peak_vel + 6],
2060 working_space[peak_vel + 7],
2061 working_space[peak_vel + 12],
2062 working_space[peak_vel + 13]);
2065 working_space[7 * j],
2066 working_space[7 * j + 1],
2067 working_space[7 * j + 2],
2068 working_space[peak_vel],
2069 working_space[peak_vel + 1],
2070 working_space[peak_vel + 2]);
2076 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0
2085 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2086 working_space[2 * shift + k] +=
b *
c;
2087 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2088 working_space[3 * shift + k] +=
b *
c;
2092 b =
a * (yw -
f) / ywm;
2093 working_space[2 * shift + k] +=
b *
c;
2095 working_space[3 * shift + k] +=
b *
c;
2102 working_space[7 * j],
2103 working_space[7 * j + 1],
2104 working_space[7 * j + 2],
2105 working_space[peak_vel],
2106 working_space[peak_vel + 1],
2107 working_space[peak_vel + 2],
2108 working_space[peak_vel + 6],
2109 working_space[peak_vel + 7],
2110 working_space[peak_vel + 12],
2111 working_space[peak_vel + 13]);
2114 working_space[7 * j],
2115 working_space[7 * j + 1],
2116 working_space[7 * j + 2],
2117 working_space[peak_vel],
2118 working_space[peak_vel + 1],
2119 working_space[peak_vel + 2]);
2125 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0
2134 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2135 working_space[2 * shift + k] +=
b *
c;
2136 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2137 working_space[3 * shift + k] +=
b *
c;
2141 b =
a * (yw -
f) / ywm;
2142 working_space[2 * shift + k] +=
b *
c;
2144 working_space[3 * shift + k] +=
b *
c;
2150 a =
Derampx(i1, working_space[7 * j + 5],
2151 working_space[peak_vel],
2152 working_space[peak_vel + 8],
2153 working_space[peak_vel + 10],
2154 working_space[peak_vel + 12]);
2158 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2159 working_space[2 * shift + k] +=
b *
c;
2160 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2161 working_space[3 * shift + k] +=
b *
c;
2165 b =
a * (yw -
f) / ywm;
2166 working_space[2 * shift + k] +=
b *
c;
2168 working_space[3 * shift + k] +=
b *
c;
2174 a =
Derampx(i2, working_space[7 * j + 6],
2175 working_space[peak_vel + 1],
2176 working_space[peak_vel + 9],
2177 working_space[peak_vel + 11],
2178 working_space[peak_vel + 13]);
2182 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2183 working_space[2 * shift + k] +=
b *
c;
2184 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2185 working_space[3 * shift + k] +=
b *
c;
2189 b =
a * (yw -
f) / ywm;
2190 working_space[2 * shift + k] +=
b *
c;
2192 working_space[3 * shift + k] +=
b *
c;
2198 a =
Deri01(i1, working_space[7 * j + 3],
2199 working_space[7 * j + 5],
2200 working_space[peak_vel],
2201 working_space[peak_vel + 8],
2202 working_space[peak_vel + 10],
2203 working_space[peak_vel + 12]);
2206 working_space[7 * j + 5],
2207 working_space[peak_vel]);
2213 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0
2222 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2223 working_space[2 * shift + k] +=
b *
c;
2224 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2225 working_space[3 * shift + k] +=
b *
c;
2229 b =
a * (yw -
f) / ywm;
2230 working_space[2 * shift + k] +=
b *
c;
2232 working_space[3 * shift + k] +=
b *
c;
2238 a =
Deri01(i2, working_space[7 * j + 4],
2239 working_space[7 * j + 6],
2240 working_space[peak_vel + 1],
2241 working_space[peak_vel + 9],
2242 working_space[peak_vel + 11],
2243 working_space[peak_vel + 13]);
2246 working_space[7 * j + 6],
2247 working_space[peak_vel + 1]);
2253 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0
2262 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2263 working_space[2 * shift + k] +=
b *
c;
2264 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2265 working_space[3 * shift + k] +=
b *
c;
2269 b =
a * (yw -
f) / ywm;
2270 working_space[2 * shift + k] +=
b *
c;
2272 working_space[3 * shift + k] +=
b *
c;
2280 working_space, working_space[peak_vel],
2281 working_space[peak_vel + 1],
2282 working_space[peak_vel + 2],
2283 working_space[peak_vel + 6],
2284 working_space[peak_vel + 7],
2285 working_space[peak_vel + 8],
2286 working_space[peak_vel + 10],
2287 working_space[peak_vel + 12],
2288 working_space[peak_vel + 13]);
2292 working_space[peak_vel],
2293 working_space[peak_vel + 1],
2294 working_space[peak_vel + 2]);
2300 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0 &&
a <= 0))
2308 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2309 working_space[2 * shift + k] +=
b *
c;
2310 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2311 working_space[3 * shift + k] +=
b *
c;
2315 b =
a * (yw -
f) / ywm;
2316 working_space[2 * shift + k] +=
b *
c;
2318 working_space[3 * shift + k] +=
b *
c;
2325 working_space, working_space[peak_vel],
2326 working_space[peak_vel + 1],
2327 working_space[peak_vel + 2],
2328 working_space[peak_vel + 6],
2329 working_space[peak_vel + 7],
2330 working_space[peak_vel + 9],
2331 working_space[peak_vel + 11],
2332 working_space[peak_vel + 12],
2333 working_space[peak_vel + 13]);
2337 working_space[peak_vel],
2338 working_space[peak_vel + 1],
2339 working_space[peak_vel + 2]);
2345 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0 &&
a <= 0))
2353 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2354 working_space[2 * shift + k] +=
b *
c;
2355 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2356 working_space[3 * shift + k] +=
b *
c;
2360 b =
a * (yw -
f) / ywm;
2361 working_space[2 * shift + k] +=
b *
c;
2363 working_space[3 * shift + k] +=
b *
c;
2370 working_space, working_space[peak_vel],
2371 working_space[peak_vel + 1],
2372 working_space[peak_vel + 2]);
2378 if (((
a +
d) <= 0 &&
a >= 0) || ((
a +
d) >= 0 &&
a <= 0))
2386 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2387 working_space[2 * shift + k] +=
b *
c;
2388 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2389 working_space[3 * shift + k] +=
b *
c;
2393 b =
a * (yw -
f) / ywm;
2394 working_space[2 * shift + k] +=
b *
c;
2396 working_space[3 * shift + k] +=
b *
c;
2406 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2407 working_space[2 * shift + k] +=
b *
c;
2408 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2409 working_space[3 * shift + k] +=
b *
c;
2413 b =
a * (yw -
f) / ywm;
2414 working_space[2 * shift + k] +=
b *
c;
2416 working_space[3 * shift + k] +=
b *
c;
2426 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2427 working_space[2 * shift + k] +=
b *
c;
2428 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2429 working_space[3 * shift + k] +=
b *
c;
2433 b =
a * (yw -
f) / ywm;
2434 working_space[2 * shift + k] +=
b *
c;
2436 working_space[3 * shift + k] +=
b *
c;
2446 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2447 working_space[2 * shift + k] +=
b *
c;
2448 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2449 working_space[3 * shift + k] +=
b *
c;
2453 b =
a * (yw -
f) / ywm;
2454 working_space[2 * shift + k] +=
b *
c;
2456 working_space[3 * shift + k] +=
b *
c;
2463 working_space, working_space[peak_vel],
2464 working_space[peak_vel + 1],
2465 working_space[peak_vel + 12],
2466 working_space[peak_vel + 13]);
2470 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2471 working_space[2 * shift + k] +=
b *
c;
2472 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2473 working_space[3 * shift + k] +=
b *
c;
2477 b =
a * (yw -
f) / ywm;
2478 working_space[2 * shift + k] +=
b *
c;
2480 working_space[3 * shift + k] +=
b *
c;
2487 working_space, working_space[peak_vel],
2488 working_space[peak_vel + 1]);
2492 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2493 working_space[2 * shift + k] +=
b *
c;
2494 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2495 working_space[3 * shift + k] +=
b *
c;
2499 b =
a * (yw -
f) / ywm;
2500 working_space[2 * shift + k] +=
b *
c;
2502 working_space[3 * shift + k] +=
b *
c;
2509 working_space[peak_vel],
2510 working_space[peak_vel + 12]);
2514 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2515 working_space[2 * shift + k] +=
b *
c;
2516 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2517 working_space[3 * shift + k] +=
b *
c;
2521 b =
a * (yw -
f) / ywm;
2522 working_space[2 * shift + k] +=
b *
c;
2524 working_space[3 * shift + k] +=
b *
c;
2531 working_space[peak_vel + 1],
2532 working_space[peak_vel + 13]);
2536 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2537 working_space[2 * shift + k] +=
b *
c;
2538 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2539 working_space[3 * shift + k] +=
b *
c;
2543 b =
a * (yw -
f) / ywm;
2544 working_space[2 * shift + k] +=
b *
c;
2546 working_space[3 * shift + k] +=
b *
c;
2553 working_space[peak_vel]);
2557 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2558 working_space[2 * shift + k] +=
b *
c;
2559 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2560 working_space[3 * shift + k] +=
b *
c;
2564 b =
a * (yw -
f) / ywm;
2565 working_space[2 * shift + k] +=
b *
c;
2567 working_space[3 * shift + k] +=
b *
c;
2574 working_space[peak_vel + 1]);
2578 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2579 working_space[2 * shift + k] +=
b *
c;
2580 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2581 working_space[3 * shift + k] +=
b *
c;
2585 b =
a * (yw -
f) / ywm;
2586 working_space[2 * shift + k] +=
b *
c;
2588 working_space[3 * shift + k] +=
b *
c;
2595 working_space, working_space[peak_vel],
2596 working_space[peak_vel + 1],
2597 working_space[peak_vel + 6],
2598 working_space[peak_vel + 8],
2599 working_space[peak_vel + 12],
2600 working_space[peak_vel + 13]);
2604 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2605 working_space[2 * shift + k] +=
b *
c;
2606 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2607 working_space[3 * shift + k] +=
b *
c;
2611 b =
a * (yw -
f) / ywm;
2612 working_space[2 * shift + k] +=
b *
c;
2614 working_space[3 * shift + k] +=
b *
c;
2621 working_space, working_space[peak_vel],
2622 working_space[peak_vel + 1],
2623 working_space[peak_vel + 6],
2624 working_space[peak_vel + 8],
2625 working_space[peak_vel + 12],
2626 working_space[peak_vel + 13]);
2630 b =
a * (yw * yw -
f *
f) / (ywm * ywm);
2631 working_space[2 * shift + k] +=
b *
c;
2632 b =
a *
a * (4 * yw - 2 *
f) / (ywm * ywm);
2633 working_space[3 * shift + k] +=
b *
c;
2637 b =
a * (yw -
f) / ywm;
2638 working_space[2 * shift + k] +=
b *
c;
2640 working_space[3 * shift + k] +=
b *
c;
2647 for (j = 0; j <
size; j++) {
2648 if (
TMath::Abs(working_space[3 * shift + j]) > 0.000001)
2649 working_space[2 * shift + j] = working_space[2 * shift + j] /
TMath::Abs(working_space[3 * shift + j]);
2651 working_space[2 * shift + j] = 0;
2660 for (j = 0; j <
size; j++) {
2661 working_space[4 * shift + j] = working_space[shift + j];
2667 chi_min = 10000 * chi2;
2670 chi_min = 0.1 * chi2;
2672 for (pi = 0.1; flag == 0 && pi <= 100; pi += 0.1) {
2673 for (j = 0; j <
size; j++) {
2674 working_space[shift + j] = working_space[4 * shift + j] + pi * alpha * working_space[2 * shift + j];
2676 for (i = 0, j = 0; i <
fNPeaks; i++) {
2678 if (working_space[shift + j] < 0)
2679 working_space[shift + j] = 0;
2680 working_space[7 * i] = working_space[shift + j];
2684 if (working_space[shift + j] <
fXmin)
2685 working_space[shift + j] =
fXmin;
2686 if (working_space[shift + j] >
fXmax)
2687 working_space[shift + j] =
fXmax;
2688 working_space[7 * i + 1] = working_space[shift + j];
2692 if (working_space[shift + j] <
fYmin)
2693 working_space[shift + j] =
fYmin;
2694 if (working_space[shift + j] >
fYmax)
2695 working_space[shift + j] =
fYmax;
2696 working_space[7 * i + 2] = working_space[shift + j];
2700 if (working_space[shift + j] < 0)
2701 working_space[shift + j] = 0;
2702 working_space[7 * i + 3] = working_space[shift + j];
2706 if (working_space[shift + j] < 0)
2707 working_space[shift + j] = 0;
2708 working_space[7 * i + 4] = working_space[shift + j];
2712 if (working_space[shift + j] <
fXmin)
2713 working_space[shift + j] =
fXmin;
2714 if (working_space[shift + j] >
fXmax)
2715 working_space[shift + j] =
fXmax;
2716 working_space[7 * i + 5] = working_space[shift + j];
2720 if (working_space[shift + j] <
fYmin)
2721 working_space[shift + j] =
fYmin;
2722 if (working_space[shift + j] >
fYmax)
2723 working_space[shift + j] =
fYmax;
2724 working_space[7 * i + 6] = working_space[shift + j];
2729 if (working_space[shift + j] < 0.001) {
2730 working_space[shift + j] = 0.001;
2732 working_space[peak_vel] = working_space[shift + j];
2736 if (working_space[shift + j] < 0.001) {
2737 working_space[shift + j] = 0.001;
2739 working_space[peak_vel + 1] = working_space[shift + j];
2743 if (working_space[shift + j] < -1) {
2744 working_space[shift + j] = -1;
2746 if (working_space[shift + j] > 1) {
2747 working_space[shift + j] = 1;
2749 working_space[peak_vel + 2] = working_space[shift + j];
2753 working_space[peak_vel + 3] = working_space[shift + j];
2757 working_space[peak_vel + 4] = working_space[shift + j];
2761 working_space[peak_vel + 5] = working_space[shift + j];
2765 working_space[peak_vel + 6] = working_space[shift + j];
2769 working_space[peak_vel + 7] = working_space[shift + j];
2773 working_space[peak_vel + 8] = working_space[shift + j];
2777 working_space[peak_vel + 9] = working_space[shift + j];
2781 working_space[peak_vel + 10] = working_space[shift + j];
2785 working_space[peak_vel + 11] = working_space[shift + j];
2789 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
2790 if (working_space[shift + j] < 0)
2791 working_space[shift + j] = -0.001;
2793 working_space[shift + j] = 0.001;
2795 working_space[peak_vel + 12] = working_space[shift + j];
2799 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
2800 if (working_space[shift + j] < 0)
2801 working_space[shift + j] = -0.001;
2803 working_space[shift + j] = 0.001;
2805 working_space[peak_vel + 13] = working_space[shift + j];
2811 yw = source[i1][i2];
2815 working_space[peak_vel],
2816 working_space[peak_vel + 1],
2817 working_space[peak_vel + 2],
2818 working_space[peak_vel + 3],
2819 working_space[peak_vel + 4],
2820 working_space[peak_vel + 5],
2821 working_space[peak_vel + 6],
2822 working_space[peak_vel + 7],
2823 working_space[peak_vel + 8],
2824 working_space[peak_vel + 9],
2825 working_space[peak_vel + 10],
2826 working_space[peak_vel + 11],
2827 working_space[peak_vel + 12],
2828 working_space[peak_vel + 13]);
2841 chi2 += (yw -
f) * (yw -
f) / ywm;
2849 pmin = pi, chi_min = chi2;
2859 for (j = 0; j <
size; j++) {
2860 working_space[shift + j] = working_space[4 * shift + j] + pmin * alpha * working_space[2 * shift + j];
2862 for (i = 0, j = 0; i <
fNPeaks; i++) {
2864 if (working_space[shift + j] < 0)
2865 working_space[shift + j] = 0;
2866 working_space[7 * i] = working_space[shift + j];
2870 if (working_space[shift + j] <
fXmin)
2871 working_space[shift + j] =
fXmin;
2872 if (working_space[shift + j] >
fXmax)
2873 working_space[shift + j] =
fXmax;
2874 working_space[7 * i + 1] = working_space[shift + j];
2878 if (working_space[shift + j] <
fYmin)
2879 working_space[shift + j] =
fYmin;
2880 if (working_space[shift + j] >
fYmax)
2881 working_space[shift + j] =
fYmax;
2882 working_space[7 * i + 2] = working_space[shift + j];
2886 if (working_space[shift + j] < 0)
2887 working_space[shift + j] = 0;
2888 working_space[7 * i + 3] = working_space[shift + j];
2892 if (working_space[shift + j] < 0)
2893 working_space[shift + j] = 0;
2894 working_space[7 * i + 4] = working_space[shift + j];
2898 if (working_space[shift + j] <
fXmin)
2899 working_space[shift + j] =
fXmin;
2900 if (working_space[shift + j] >
fXmax)
2901 working_space[shift + j] =
fXmax;
2902 working_space[7 * i + 5] = working_space[shift + j];
2906 if (working_space[shift + j] <
fYmin)
2907 working_space[shift + j] =
fYmin;
2908 if (working_space[shift + j] >
fYmax)
2909 working_space[shift + j] =
fYmax;
2910 working_space[7 * i + 6] = working_space[shift + j];
2915 if (working_space[shift + j] < 0.001) {
2916 working_space[shift + j] = 0.001;
2918 working_space[peak_vel] = working_space[shift + j];
2922 if (working_space[shift + j] < 0.001) {
2923 working_space[shift + j] = 0.001;
2925 working_space[peak_vel + 1] = working_space[shift + j];
2929 if (working_space[shift + j] < -1) {
2930 working_space[shift + j] = -1;
2932 if (working_space[shift + j] > 1) {
2933 working_space[shift + j] = 1;
2935 working_space[peak_vel + 2] = working_space[shift + j];
2939 working_space[peak_vel + 3] = working_space[shift + j];
2943 working_space[peak_vel + 4] = working_space[shift + j];
2947 working_space[peak_vel + 5] = working_space[shift + j];
2951 working_space[peak_vel + 6] = working_space[shift + j];
2955 working_space[peak_vel + 7] = working_space[shift + j];
2959 working_space[peak_vel + 8] = working_space[shift + j];
2963 working_space[peak_vel + 9] = working_space[shift + j];
2967 working_space[peak_vel + 10] = working_space[shift + j];
2971 working_space[peak_vel + 11] = working_space[shift + j];
2975 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
2976 if (working_space[shift + j] < 0)
2977 working_space[shift + j] = -0.001;
2979 working_space[shift + j] = 0.001;
2981 working_space[peak_vel + 12] = working_space[shift + j];
2985 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
2986 if (working_space[shift + j] < 0)
2987 working_space[shift + j] = -0.001;
2989 working_space[shift + j] = 0.001;
2991 working_space[peak_vel + 13] = working_space[shift + j];
2999 for (j = 0; j <
size; j++) {
3000 working_space[shift + j] = working_space[4 * shift + j] + alpha * working_space[2 * shift + j];
3002 for (i = 0, j = 0; i <
fNPeaks; i++) {
3004 if (working_space[shift + j] < 0)
3005 working_space[shift + j] = 0;
3006 working_space[7 * i] = working_space[shift + j];
3010 if (working_space[shift + j] <
fXmin)
3011 working_space[shift + j] =
fXmin;
3012 if (working_space[shift + j] >
fXmax)
3013 working_space[shift + j] =
fXmax;
3014 working_space[7 * i + 1] = working_space[shift + j];
3018 if (working_space[shift + j] <
fYmin)
3019 working_space[shift + j] =
fYmin;
3020 if (working_space[shift + j] >
fYmax)
3021 working_space[shift + j] =
fYmax;
3022 working_space[7 * i + 2] = working_space[shift + j];
3026 if (working_space[shift + j] < 0)
3027 working_space[shift + j] = 0;
3028 working_space[7 * i + 3] = working_space[shift + j];
3032 if (working_space[shift + j] < 0)
3033 working_space[shift + j] = 0;
3034 working_space[7 * i + 4] = working_space[shift + j];
3038 if (working_space[shift + j] <
fXmin)
3039 working_space[shift + j] =
fXmin;
3040 if (working_space[shift + j] >
fXmax)
3041 working_space[shift + j] =
fXmax;
3042 working_space[7 * i + 5] = working_space[shift + j];
3046 if (working_space[shift + j] <
fYmin)
3047 working_space[shift + j] =
fYmin;
3048 if (working_space[shift + j] >
fYmax)
3049 working_space[shift + j] =
fYmax;
3050 working_space[7 * i + 6] = working_space[shift + j];
3055 if (working_space[shift + j] < 0.001) {
3056 working_space[shift + j] = 0.001;
3058 working_space[peak_vel] = working_space[shift + j];
3062 if (working_space[shift + j] < 0.001) {
3063 working_space[shift + j] = 0.001;
3065 working_space[peak_vel + 1] = working_space[shift + j];
3069 if (working_space[shift + j] < -1) {
3070 working_space[shift + j] = -1;
3072 if (working_space[shift + j] > 1) {
3073 working_space[shift + j] = 1;
3075 working_space[peak_vel + 2] = working_space[shift + j];
3079 working_space[peak_vel + 3] = working_space[shift + j];
3083 working_space[peak_vel + 4] = working_space[shift + j];
3087 working_space[peak_vel + 5] = working_space[shift + j];
3091 working_space[peak_vel + 6] = working_space[shift + j];
3095 working_space[peak_vel + 7] = working_space[shift + j];
3099 working_space[peak_vel + 8] = working_space[shift + j];
3103 working_space[peak_vel + 9] = working_space[shift + j];
3107 working_space[peak_vel + 10] = working_space[shift + j];
3111 working_space[peak_vel + 11] = working_space[shift + j];
3115 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
3116 if (working_space[shift + j] < 0)
3117 working_space[shift + j] = -0.001;
3119 working_space[shift + j] = 0.001;
3121 working_space[peak_vel + 12] = working_space[shift + j];
3125 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
3126 if (working_space[shift + j] < 0)
3127 working_space[shift + j] = -0.001;
3129 working_space[shift + j] = 0.001;
3131 working_space[peak_vel + 13] = working_space[shift + j];
3137 yw = source[i1][i2];
3140 working_space, working_space[peak_vel],
3141 working_space[peak_vel + 1],
3142 working_space[peak_vel + 2],
3143 working_space[peak_vel + 3],
3144 working_space[peak_vel + 4],
3145 working_space[peak_vel + 5],
3146 working_space[peak_vel + 6],
3147 working_space[peak_vel + 7],
3148 working_space[peak_vel + 8],
3149 working_space[peak_vel + 9],
3150 working_space[peak_vel + 10],
3151 working_space[peak_vel + 11],
3152 working_space[peak_vel + 12],
3153 working_space[peak_vel + 13]);
3166 chi += (yw -
f) * (yw -
f) / ywm;
3174 alpha = alpha * chi_opt / (2 * chi);
3177 alpha = alpha / 10.0;
3180 }
while (((chi > chi_opt
3185 for (j = 0; j <
size; j++) {
3186 working_space[4 * shift + j] = 0;
3187 working_space[2 * shift + j] = 0;
3189 for (i1 =
fXmin, chi_cel = 0; i1 <=
fXmax; i1++) {
3191 yw = source[i1][i2];
3195 working_space, working_space[peak_vel],
3196 working_space[peak_vel + 1],
3197 working_space[peak_vel + 2],
3198 working_space[peak_vel + 3],
3199 working_space[peak_vel + 4],
3200 working_space[peak_vel + 5],
3201 working_space[peak_vel + 6],
3202 working_space[peak_vel + 7],
3203 working_space[peak_vel + 8],
3204 working_space[peak_vel + 9],
3205 working_space[peak_vel + 10],
3206 working_space[peak_vel + 11],
3207 working_space[peak_vel + 12],
3208 working_space[peak_vel + 13]);
3209 chi_opt = (yw -
f) * (yw -
f) / yw;
3210 chi_cel += (yw -
f) * (yw -
f) / yw;
3213 for (j = 0, k = 0; j <
fNPeaks; j++) {
3216 working_space[7 * j + 1],
3217 working_space[7 * j + 2],
3218 working_space[peak_vel],
3219 working_space[peak_vel + 1],
3220 working_space[peak_vel + 2],
3221 working_space[peak_vel + 6],
3222 working_space[peak_vel + 7],
3223 working_space[peak_vel + 12],
3224 working_space[peak_vel + 13]);
3227 working_space[2 * shift + k] += chi_opt *
c;
3229 working_space[4 * shift + k] +=
b *
c;
3235 working_space[7 * j],
3236 working_space[7 * j + 1],
3237 working_space[7 * j + 2],
3238 working_space[peak_vel],
3239 working_space[peak_vel + 1],
3240 working_space[peak_vel + 2],
3241 working_space[peak_vel + 6],
3242 working_space[peak_vel + 7],
3243 working_space[peak_vel + 12],
3244 working_space[peak_vel + 13]);
3247 working_space[2 * shift + k] += chi_opt *
c;
3249 working_space[4 * shift + k] +=
b *
c;
3255 working_space[7 * j],
3256 working_space[7 * j + 1],
3257 working_space[7 * j + 2],
3258 working_space[peak_vel],
3259 working_space[peak_vel + 1],
3260 working_space[peak_vel + 2],
3261 working_space[peak_vel + 6],
3262 working_space[peak_vel + 7],
3263 working_space[peak_vel + 12],
3264 working_space[peak_vel + 13]);
3267 working_space[2 * shift + k] += chi_opt *
c;
3269 working_space[4 * shift + k] +=
b *
c;
3274 a =
Derampx(i1, working_space[7 * j + 5],
3275 working_space[peak_vel],
3276 working_space[peak_vel + 8],
3277 working_space[peak_vel + 10],
3278 working_space[peak_vel + 12]);
3281 working_space[2 * shift + k] += chi_opt *
c;
3283 working_space[4 * shift + k] +=
b *
c;
3288 a =
Derampx(i2, working_space[7 * j + 6],
3289 working_space[peak_vel + 1],
3290 working_space[peak_vel + 9],
3291 working_space[peak_vel + 11],
3292 working_space[peak_vel + 13]);
3295 working_space[2 * shift + k] += chi_opt *
c;
3297 working_space[4 * shift + k] +=
b *
c;
3302 a =
Deri01(i1, working_space[7 * j + 3],
3303 working_space[7 * j + 5],
3304 working_space[peak_vel],
3305 working_space[peak_vel + 8],
3306 working_space[peak_vel + 10],
3307 working_space[peak_vel + 12]);
3310 working_space[2 * shift + k] += chi_opt *
c;
3312 working_space[4 * shift + k] +=
b *
c;
3317 a =
Deri01(i2, working_space[7 * j + 4],
3318 working_space[7 * j + 6],
3319 working_space[peak_vel + 1],
3320 working_space[peak_vel + 9],
3321 working_space[peak_vel + 11],
3322 working_space[peak_vel + 13]);
3325 working_space[2 * shift + k] += chi_opt *
c;
3327 working_space[4 * shift + k] +=
b *
c;
3334 working_space, working_space[peak_vel],
3335 working_space[peak_vel + 1],
3336 working_space[peak_vel + 2],
3337 working_space[peak_vel + 6],
3338 working_space[peak_vel + 7],
3339 working_space[peak_vel + 8],
3340 working_space[peak_vel + 10],
3341 working_space[peak_vel + 12],
3342 working_space[peak_vel + 13]);
3345 working_space[2 * shift + k] += chi_opt *
c;
3347 working_space[4 * shift + k] +=
b *
c;
3353 working_space, working_space[peak_vel],
3354 working_space[peak_vel + 1],
3355 working_space[peak_vel + 2],
3356 working_space[peak_vel + 6],
3357 working_space[peak_vel + 7],
3358 working_space[peak_vel + 9],
3359 working_space[peak_vel + 11],
3360 working_space[peak_vel + 12],
3361 working_space[peak_vel + 13]);
3364 working_space[2 * shift + k] += chi_opt *
c;
3366 working_space[4 * shift + k] +=
b *
c;
3372 working_space, working_space[peak_vel],
3373 working_space[peak_vel + 1],
3374 working_space[peak_vel + 2]);
3377 working_space[2 * shift + k] += chi_opt *
c;
3379 working_space[4 * shift + k] +=
b *
c;
3387 working_space[2 * shift + k] += chi_opt *
c;
3389 working_space[4 * shift + k] +=
b *
c;
3397 working_space[2 * shift + k] += chi_opt *
c;
3399 working_space[4 * shift + k] +=
b *
c;
3407 working_space[2 * shift + k] += chi_opt *
c;
3409 working_space[4 * shift + k] +=
b *
c;
3415 working_space, working_space[peak_vel],
3416 working_space[peak_vel + 1],
3417 working_space[peak_vel + 12],
3418 working_space[peak_vel + 13]);
3421 working_space[2 * shift + k] += chi_opt *
c;
3423 working_space[4 * shift + k] +=
b *
c;
3429 working_space, working_space[peak_vel],
3430 working_space[peak_vel + 1]);
3433 working_space[2 * shift + k] += chi_opt *
c;
3435 working_space[4 * shift + k] +=
b *
c;
3441 working_space[peak_vel],
3442 working_space[peak_vel + 12]);
3445 working_space[2 * shift + k] += chi_opt *
c;
3447 working_space[4 * shift + k] +=
b *
c;
3453 working_space[peak_vel + 1],
3454 working_space[peak_vel + 13]);
3457 working_space[2 * shift + k] += chi_opt *
c;
3459 working_space[4 * shift + k] +=
b *
c;
3465 working_space[peak_vel]);
3468 working_space[2 * shift + k] += chi_opt *
c;
3470 working_space[4 * shift + k] +=
b *
c;
3476 working_space[peak_vel + 1]);
3479 working_space[2 * shift + k] += chi_opt *
c;
3481 working_space[4 * shift + k] +=
b *
c;
3487 working_space, working_space[peak_vel],
3488 working_space[peak_vel + 1],
3489 working_space[peak_vel + 6],
3490 working_space[peak_vel + 8],
3491 working_space[peak_vel + 12],
3492 working_space[peak_vel + 13]);
3495 working_space[2 * shift + k] += chi_opt *
c;
3497 working_space[4 * shift + k] +=
b *
c;
3503 working_space, working_space[peak_vel],
3504 working_space[peak_vel + 1],
3505 working_space[peak_vel + 6],
3506 working_space[peak_vel + 8],
3507 working_space[peak_vel + 12],
3508 working_space[peak_vel + 13]);
3511 working_space[2 * shift + k] += chi_opt *
c;
3513 working_space[4 * shift + k] +=
b *
c;
3521 chi_er = chi_cel /
b;
3522 for (i = 0, j = 0; i <
fNPeaks; i++) {
3524 Volume(working_space[7 * i], working_space[peak_vel],
3525 working_space[peak_vel + 1], working_space[peak_vel + 2]);
3529 a =
Derpa2(working_space[peak_vel],
3530 working_space[peak_vel + 1],
3531 working_space[peak_vel + 2]);
3532 b = working_space[4 * shift + j];
3542 working_space[peak_vel + 1],
3543 working_space[peak_vel + 2]);
3544 b = working_space[4 * shift + peak_vel];
3554 working_space[peak_vel],
3555 working_space[peak_vel + 2]);
3556 b = working_space[4 * shift + peak_vel + 1];
3565 a =
Derpro(working_space[shift + j], working_space[peak_vel],
3566 working_space[peak_vel + 1],
3567 working_space[peak_vel + 2]);
3568 b = working_space[4 * shift + peak_vel + 2];
3583 fAmpCalc[i] = working_space[shift + j];
3584 if (working_space[3 * shift + j] != 0)
3595 if (working_space[3 * shift + j] != 0)
3606 if (working_space[3 * shift + j] != 0)
3617 if (working_space[3 * shift + j] != 0)
3628 if (working_space[3 * shift + j] != 0)
3639 if (working_space[3 * shift + j] != 0)
3650 if (working_space[3 * shift + j] != 0)
3662 if (working_space[3 * shift + j] != 0)
3673 if (working_space[3 * shift + j] != 0)
3683 fRoCalc = working_space[shift + j];
3684 if (working_space[3 * shift + j] != 0)
3694 fA0Calc = working_space[shift + j];
3695 if (working_space[3 * shift + j] != 0)
3705 fAxCalc = working_space[shift + j];
3706 if (working_space[3 * shift + j] != 0)
3716 fAyCalc = working_space[shift + j];
3717 if (working_space[3 * shift + j] != 0)
3727 fTxyCalc = working_space[shift + j];
3728 if (working_space[3 * shift + j] != 0)
3738 fSxyCalc = working_space[shift + j];
3739 if (working_space[3 * shift + j] != 0)
3749 fTxCalc = working_space[shift + j];
3750 if (working_space[3 * shift + j] != 0)
3760 fTyCalc = working_space[shift + j];
3761 if (working_space[3 * shift + j] != 0)
3771 fSxCalc = working_space[shift + j];
3772 if (working_space[3 * shift + j] != 0)
3782 fSyCalc = working_space[shift + j];
3783 if (working_space[3 * shift + j] != 0)
3793 fBxCalc = working_space[shift + j];
3794 if (working_space[3 * shift + j] != 0)
3804 fByCalc = working_space[shift + j];
3805 if (working_space[3 * shift + j] != 0)
3819 working_space, working_space[peak_vel],
3820 working_space[peak_vel + 1],
3821 working_space[peak_vel + 2],
3822 working_space[peak_vel + 3],
3823 working_space[peak_vel + 4],
3824 working_space[peak_vel + 5],
3825 working_space[peak_vel + 6],
3826 working_space[peak_vel + 7],
3827 working_space[peak_vel + 8],
3828 working_space[peak_vel + 9],
3829 working_space[peak_vel + 10],
3830 working_space[peak_vel + 11],
3831 working_space[peak_vel + 12],
3832 working_space[peak_vel + 13]);
3836 delete [] working_space;
3946 Int_t i, i1, i2, j, k, shift =
3947 7 *
fNPeaks + 14, peak_vel,
size, iter, regul_cycle,
3949 Double_t a,
b,
c, alpha, chi_opt, yw, ywm,
f, chi2, chi_min, chi = 0
3950 , pi, pmin = 0, chi_cel = 0, chi_er;
3952 for (i = 0, j = 0; i <
fNPeaks; i++) {
3953 working_space[7 * i] =
fAmpInit[i];
3955 working_space[shift + j] =
fAmpInit[i];
4000 working_space[7 * i + 2] =
fRoInit;
4002 working_space[shift + j] =
fRoInit;
4005 working_space[7 * i + 3] =
fA0Init;
4007 working_space[shift + j] =
fA0Init;
4010 working_space[7 * i + 4] =
fAxInit;
4012 working_space[shift + j] =
fAxInit;
4015 working_space[7 * i + 5] =
fAyInit;
4017 working_space[shift + j] =
fAyInit;
4020 working_space[7 * i + 6] =
fTxyInit;
4022 working_space[shift + j] =
fTxyInit;
4025 working_space[7 * i + 7] =
fSxyInit;
4027 working_space[shift + j] =
fSxyInit;
4030 working_space[7 * i + 8] =
fTxInit;
4032 working_space[shift + j] =
fTxInit;
4035 working_space[7 * i + 9] =
fTyInit;
4037 working_space[shift + j] =
fTyInit;
4040 working_space[7 * i + 10] =
fSxyInit;
4042 working_space[shift + j] =
fSxInit;
4045 working_space[7 * i + 11] =
fSyInit;
4047 working_space[shift + j] =
fSyInit;
4050 working_space[7 * i + 12] =
fBxInit;
4052 working_space[shift + j] =
fBxInit;
4055 working_space[7 * i + 13] =
fByInit;
4057 working_space[shift + j] =
fByInit;
4062 for (i = 0; i <
size; i++)
4065 for (j = 0; j <
size; j++) {
4066 working_space[3 * shift + j] = 0;
4067 for (k = 0; k < (
size + 4); k++) {
4068 working_matrix[j][k] = 0;
4078 for (j = 0, k = 0; j <
fNPeaks; j++) {
4080 working_space[2 * shift + k] =
4082 working_space[7 * j + 1],
4083 working_space[7 * j + 2],
4084 working_space[peak_vel],
4085 working_space[peak_vel + 1],
4086 working_space[peak_vel + 2],
4087 working_space[peak_vel + 6],
4088 working_space[peak_vel + 7],
4089 working_space[peak_vel + 12],
4090 working_space[peak_vel + 13]);
4094 working_space[2 * shift + k] =
4096 working_space[7 * j],
4097 working_space[7 * j + 1],
4098 working_space[7 * j + 2],
4099 working_space[peak_vel],
4100 working_space[peak_vel + 1],
4101 working_space[peak_vel + 2],
4102 working_space[peak_vel + 6],
4103 working_space[peak_vel + 7],
4104 working_space[peak_vel + 12],
4105 working_space[peak_vel + 13]);
4109 working_space[2 * shift + k] =
4111 working_space[7 * j],
4112 working_space[7 * j + 1],
4113 working_space[7 * j + 2],
4114 working_space[peak_vel],
4115 working_space[peak_vel + 1],
4116 working_space[peak_vel + 2],
4117 working_space[peak_vel + 6],
4118 working_space[peak_vel + 7],
4119 working_space[peak_vel + 12],
4120 working_space[peak_vel + 13]);
4124 working_space[2 * shift + k] =
4125 Derampx(i1, working_space[7 * j + 5],
4126 working_space[peak_vel],
4127 working_space[peak_vel + 8],
4128 working_space[peak_vel + 10],
4129 working_space[peak_vel + 12]);
4133 working_space[2 * shift + k] =
4134 Derampx(i2, working_space[7 * j + 6],
4135 working_space[peak_vel + 1],
4136 working_space[peak_vel + 9],
4137 working_space[peak_vel + 11],
4138 working_space[peak_vel + 13]);
4142 working_space[2 * shift + k] =
4143 Deri01(i1, working_space[7 * j + 3],
4144 working_space[7 * j + 5],
4145 working_space[peak_vel],
4146 working_space[peak_vel + 8],
4147 working_space[peak_vel + 10],
4148 working_space[peak_vel + 12]);
4152 working_space[2 * shift + k] =
4153 Deri01(i2, working_space[7 * j + 4],
4154 working_space[7 * j + 6],
4155 working_space[peak_vel + 1],
4156 working_space[peak_vel + 9],
4157 working_space[peak_vel + 11],
4158 working_space[peak_vel + 13]);
4162 working_space[2 * shift + k] =
4164 working_space, working_space[peak_vel],
4165 working_space[peak_vel + 1],
4166 working_space[peak_vel + 2],
4167 working_space[peak_vel + 6],
4168 working_space[peak_vel + 7],
4169 working_space[peak_vel + 8],
4170 working_space[peak_vel + 10],
4171 working_space[peak_vel + 12],
4172 working_space[peak_vel + 13]);
4176 working_space[2 * shift + k] =
4178 working_space, working_space[peak_vel],
4179 working_space[peak_vel + 1],
4180 working_space[peak_vel + 2],
4181 working_space[peak_vel + 6],
4182 working_space[peak_vel + 7],
4183 working_space[peak_vel + 9],
4184 working_space[peak_vel + 11],
4185 working_space[peak_vel + 12],
4186 working_space[peak_vel + 13]);
4190 working_space[2 * shift + k] =
4192 working_space, working_space[peak_vel],
4193 working_space[peak_vel + 1],
4194 working_space[peak_vel + 2]);
4198 working_space[2 * shift + k] = 1.;
4202 working_space[2 * shift + k] = i1;
4206 working_space[2 * shift + k] = i2;
4210 working_space[2 * shift + k] =
4212 working_space, working_space[peak_vel],
4213 working_space[peak_vel + 1],
4214 working_space[peak_vel + 12],
4215 working_space[peak_vel + 13]);
4219 working_space[2 * shift + k] =
4221 working_space, working_space[peak_vel],
4222 working_space[peak_vel + 1]);
4226 working_space[2 * shift + k] =
4228 working_space[peak_vel],
4229 working_space[peak_vel + 12]);
4233 working_space[2 * shift + k] =
4235 working_space[peak_vel + 1],
4236 working_space[peak_vel + 13]);
4240 working_space[2 * shift + k] =
4242 working_space[peak_vel]);
4246 working_space[2 * shift + k] =
4248 working_space[peak_vel + 1]);
4252 working_space[2 * shift + k] =
4254 working_space, working_space[peak_vel],
4255 working_space[peak_vel + 1],
4256 working_space[peak_vel + 6],
4257 working_space[peak_vel + 8],
4258 working_space[peak_vel + 12],
4259 working_space[peak_vel + 13]);
4263 working_space[2 * shift + k] =
4265 working_space, working_space[peak_vel],
4266 working_space[peak_vel + 1],
4267 working_space[peak_vel + 6],
4268 working_space[peak_vel + 8],
4269 working_space[peak_vel + 12],
4270 working_space[peak_vel + 13]);
4273 yw = source[i1][i2];
4276 working_space, working_space[peak_vel],
4277 working_space[peak_vel + 1],
4278 working_space[peak_vel + 2],
4279 working_space[peak_vel + 3],
4280 working_space[peak_vel + 4],
4281 working_space[peak_vel + 5],
4282 working_space[peak_vel + 6],
4283 working_space[peak_vel + 7],
4284 working_space[peak_vel + 8],
4285 working_space[peak_vel + 9],
4286 working_space[peak_vel + 10],
4287 working_space[peak_vel + 11],
4288 working_space[peak_vel + 12],
4289 working_space[peak_vel + 13]);
4297 chi_opt += (yw -
f) * (yw -
f) / ywm;
4315 for (j = 0; j <
size; j++) {
4316 for (k = 0; k <
size; k++) {
4317 b = working_space[2 * shift +
4318 j] * working_space[2 * shift +
4321 b =
b * (4 * yw - 2 *
f) / ywm;
4322 working_matrix[j][k] +=
b;
4324 working_space[3 * shift + j] +=
b;
4328 b = (
f *
f - yw * yw) / (ywm * ywm);
4332 for (j = 0; j <
size; j++) {
4333 working_matrix[j][
size] -=
4334 b * working_space[2 * shift + j];
4338 for (i = 0; i <
size; i++) {
4339 working_matrix[i][
size + 1] = 0;
4342 for (i = 0; i <
size; i++) {
4343 working_space[2 * shift + i] = working_matrix[i][
size + 1];
4352 for (j = 0; j <
size; j++) {
4353 working_space[4 * shift + j] = working_space[shift + j];
4359 chi_min = 10000 * chi2;
4362 chi_min = 0.1 * chi2;
4364 for (pi = 0.1; flag == 0 && pi <= 100; pi += 0.1) {
4365 for (j = 0; j <
size; j++) {
4366 working_space[shift + j] = working_space[4 * shift + j] + pi * alpha * working_space[2 * shift + j];
4368 for (i = 0, j = 0; i <
fNPeaks; i++) {
4370 if (working_space[shift + j] < 0)
4371 working_space[shift + j] = 0;
4372 working_space[7 * i] = working_space[shift + j];
4376 if (working_space[shift + j] <
fXmin)
4377 working_space[shift + j] =
fXmin;
4378 if (working_space[shift + j] >
fXmax)
4379 working_space[shift + j] =
fXmax;
4380 working_space[7 * i + 1] = working_space[shift + j];
4384 if (working_space[shift + j] <
fYmin)
4385 working_space[shift + j] =
fYmin;
4386 if (working_space[shift + j] >
fYmax)
4387 working_space[shift + j] =
fYmax;
4388 working_space[7 * i + 2] = working_space[shift + j];
4392 if (working_space[shift + j] < 0)
4393 working_space[shift + j] = 0;
4394 working_space[7 * i + 3] = working_space[shift + j];
4398 if (working_space[shift + j] < 0)
4399 working_space[shift + j] = 0;
4400 working_space[7 * i + 4] = working_space[shift + j];
4404 if (working_space[shift + j] <
fXmin)
4405 working_space[shift + j] =
fXmin;
4406 if (working_space[shift + j] >
fXmax)
4407 working_space[shift + j] =
fXmax;
4408 working_space[7 * i + 5] = working_space[shift + j];
4412 if (working_space[shift + j] <
fYmin)
4413 working_space[shift + j] =
fYmin;
4414 if (working_space[shift + j] >
fYmax)
4415 working_space[shift + j] =
fYmax;
4416 working_space[7 * i + 6] = working_space[shift + j];
4421 if (working_space[shift + j] < 0.001) {
4422 working_space[shift + j] = 0.001;
4424 working_space[peak_vel] = working_space[shift + j];
4428 if (working_space[shift + j] < 0.001) {
4429 working_space[shift + j] = 0.001;
4431 working_space[peak_vel + 1] = working_space[shift + j];
4435 if (working_space[shift + j] < -1) {
4436 working_space[shift + j] = -1;
4438 if (working_space[shift + j] > 1) {
4439 working_space[shift + j] = 1;
4441 working_space[peak_vel + 2] = working_space[shift + j];
4445 working_space[peak_vel + 3] = working_space[shift + j];
4449 working_space[peak_vel + 4] = working_space[shift + j];
4453 working_space[peak_vel + 5] = working_space[shift + j];
4457 working_space[peak_vel + 6] = working_space[shift + j];
4461 working_space[peak_vel + 7] = working_space[shift + j];
4465 working_space[peak_vel + 8] = working_space[shift + j];
4469 working_space[peak_vel + 9] = working_space[shift + j];
4473 working_space[peak_vel + 10] = working_space[shift + j];
4477 working_space[peak_vel + 11] = working_space[shift + j];
4481 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
4482 if (working_space[shift + j] < 0)
4483 working_space[shift + j] = -0.001;
4485 working_space[shift + j] = 0.001;
4487 working_space[peak_vel + 12] = working_space[shift + j];
4491 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
4492 if (working_space[shift + j] < 0)
4493 working_space[shift + j] = -0.001;
4495 working_space[shift + j] = 0.001;
4497 working_space[peak_vel + 13] = working_space[shift + j];
4503 yw = source[i1][i2];
4507 working_space[peak_vel],
4508 working_space[peak_vel + 1],
4509 working_space[peak_vel + 2],
4510 working_space[peak_vel + 3],
4511 working_space[peak_vel + 4],
4512 working_space[peak_vel + 5],
4513 working_space[peak_vel + 6],
4514 working_space[peak_vel + 7],
4515 working_space[peak_vel + 8],
4516 working_space[peak_vel + 9],
4517 working_space[peak_vel + 10],
4518 working_space[peak_vel + 11],
4519 working_space[peak_vel + 12],
4520 working_space[peak_vel + 13]);
4533 chi2 += (yw -
f) * (yw -
f) / ywm;
4541 pmin = pi, chi_min = chi2;
4551 for (j = 0; j <
size; j++) {
4552 working_space[shift + j] = working_space[4 * shift + j] + pmin * alpha * working_space[2 * shift + j];
4554 for (i = 0, j = 0; i <
fNPeaks; i++) {
4556 if (working_space[shift + j] < 0)
4557 working_space[shift + j] = 0;
4558 working_space[7 * i] = working_space[shift + j];
4562 if (working_space[shift + j] <
fXmin)
4563 working_space[shift + j] =
fXmin;
4564 if (working_space[shift + j] >
fXmax)
4565 working_space[shift + j] =
fXmax;
4566 working_space[7 * i + 1] = working_space[shift + j];
4570 if (working_space[shift + j] <
fYmin)
4571 working_space[shift + j] =
fYmin;
4572 if (working_space[shift + j] >
fYmax)
4573 working_space[shift + j] =
fYmax;
4574 working_space[7 * i + 2] = working_space[shift + j];
4578 if (working_space[shift + j] < 0)
4579 working_space[shift + j] = 0;
4580 working_space[7 * i + 3] = working_space[shift + j];
4584 if (working_space[shift + j] < 0)
4585 working_space[shift + j] = 0;
4586 working_space[7 * i + 4] = working_space[shift + j];
4590 if (working_space[shift + j] <
fXmin)
4591 working_space[shift + j] =
fXmin;
4592 if (working_space[shift + j] >
fXmax)
4593 working_space[shift + j] =
fXmax;
4594 working_space[7 * i + 5] = working_space[shift + j];
4598 if (working_space[shift + j] <
fYmin)
4599 working_space[shift + j] =
fYmin;
4600 if (working_space[shift + j] >
fYmax)
4601 working_space[shift + j] =
fYmax;
4602 working_space[7 * i + 6] = working_space[shift + j];
4607 if (working_space[shift + j] < 0.001) {
4608 working_space[shift + j] = 0.001;
4610 working_space[peak_vel] = working_space[shift + j];
4614 if (working_space[shift + j] < 0.001) {
4615 working_space[shift + j] = 0.001;
4617 working_space[peak_vel + 1] = working_space[shift + j];
4621 if (working_space[shift + j] < -1) {
4622 working_space[shift + j] = -1;
4624 if (working_space[shift + j] > 1) {
4625 working_space[shift + j] = 1;
4627 working_space[peak_vel + 2] = working_space[shift + j];
4631 working_space[peak_vel + 3] = working_space[shift + j];
4635 working_space[peak_vel + 4] = working_space[shift + j];
4639 working_space[peak_vel + 5] = working_space[shift + j];
4643 working_space[peak_vel + 6] = working_space[shift + j];
4647 working_space[peak_vel + 7] = working_space[shift + j];
4651 working_space[peak_vel + 8] = working_space[shift + j];
4655 working_space[peak_vel + 9] = working_space[shift + j];
4659 working_space[peak_vel + 10] = working_space[shift + j];
4663 working_space[peak_vel + 11] = working_space[shift + j];
4667 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
4668 if (working_space[shift + j] < 0)
4669 working_space[shift + j] = -0.001;
4671 working_space[shift + j] = 0.001;
4673 working_space[peak_vel + 12] = working_space[shift + j];
4677 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
4678 if (working_space[shift + j] < 0)
4679 working_space[shift + j] = -0.001;
4681 working_space[shift + j] = 0.001;
4683 working_space[peak_vel + 13] = working_space[shift + j];
4691 for (j = 0; j <
size; j++) {
4692 working_space[shift + j] = working_space[4 * shift + j] + alpha * working_space[2 * shift + j];
4694 for (i = 0, j = 0; i <
fNPeaks; i++) {
4696 if (working_space[shift + j] < 0)
4697 working_space[shift + j] = 0;
4698 working_space[7 * i] = working_space[shift + j];
4702 if (working_space[shift + j] <
fXmin)
4703 working_space[shift + j] =
fXmin;
4704 if (working_space[shift + j] >
fXmax)
4705 working_space[shift + j] =
fXmax;
4706 working_space[7 * i + 1] = working_space[shift + j];
4710 if (working_space[shift + j] <
fYmin)
4711 working_space[shift + j] =
fYmin;
4712 if (working_space[shift + j] >
fYmax)
4713 working_space[shift + j] =
fYmax;
4714 working_space[7 * i + 2] = working_space[shift + j];
4718 if (working_space[shift + j] < 0)
4719 working_space[shift + j] = 0;
4720 working_space[7 * i + 3] = working_space[shift + j];
4724 if (working_space[shift + j] < 0)
4725 working_space[shift + j] = 0;
4726 working_space[7 * i + 4] = working_space[shift + j];
4730 if (working_space[shift + j] <
fXmin)
4731 working_space[shift + j] =
fXmin;
4732 if (working_space[shift + j] >
fXmax)
4733 working_space[shift + j] =
fXmax;
4734 working_space[7 * i + 5] = working_space[shift + j];
4738 if (working_space[shift + j] <
fYmin)
4739 working_space[shift + j] =
fYmin;
4740 if (working_space[shift + j] >
fYmax)
4741 working_space[shift + j] =
fYmax;
4742 working_space[7 * i + 6] = working_space[shift + j];
4747 if (working_space[shift + j] < 0.001) {
4748 working_space[shift + j] = 0.001;
4750 working_space[peak_vel] = working_space[shift + j];
4754 if (working_space[shift + j] < 0.001) {
4755 working_space[shift + j] = 0.001;
4757 working_space[peak_vel + 1] = working_space[shift + j];
4761 if (working_space[shift + j] < -1) {
4762 working_space[shift + j] = -1;
4764 if (working_space[shift + j] > 1) {
4765 working_space[shift + j] = 1;
4767 working_space[peak_vel + 2] = working_space[shift + j];
4771 working_space[peak_vel + 3] = working_space[shift + j];
4775 working_space[peak_vel + 4] = working_space[shift + j];
4779 working_space[peak_vel + 5] = working_space[shift + j];
4783 working_space[peak_vel + 6] = working_space[shift + j];
4787 working_space[peak_vel + 7] = working_space[shift + j];
4791 working_space[peak_vel + 8] = working_space[shift + j];
4795 working_space[peak_vel + 9] = working_space[shift + j];
4799 working_space[peak_vel + 10] = working_space[shift + j];
4803 working_space[peak_vel + 11] = working_space[shift + j];
4807 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
4808 if (working_space[shift + j] < 0)
4809 working_space[shift + j] = -0.001;
4811 working_space[shift + j] = 0.001;
4813 working_space[peak_vel + 12] = working_space[shift + j];
4817 if (
TMath::Abs(working_space[shift + j]) < 0.001) {
4818 if (working_space[shift + j] < 0)
4819 working_space[shift + j] = -0.001;
4821 working_space[shift + j] = 0.001;
4823 working_space[peak_vel + 13] = working_space[shift + j];
4829 yw = source[i1][i2];
4832 working_space, working_space[peak_vel],
4833 working_space[peak_vel + 1],
4834 working_space[peak_vel + 2],
4835 working_space[peak_vel + 3],
4836 working_space[peak_vel + 4],
4837 working_space[peak_vel + 5],
4838 working_space[peak_vel + 6],
4839 working_space[peak_vel + 7],
4840 working_space[peak_vel + 8],
4841 working_space[peak_vel + 9],
4842 working_space[peak_vel + 10],
4843 working_space[peak_vel + 11],
4844 working_space[peak_vel + 12],
4845 working_space[peak_vel + 13]);
4858 chi += (yw -
f) * (yw -
f) / ywm;
4866 alpha = alpha * chi_opt / (2 * chi);
4869 alpha = alpha / 10.0;
4872 }
while (((chi > chi_opt
4877 for (j = 0; j <
size; j++) {
4878 working_space[4 * shift + j] = 0;
4879 working_space[2 * shift + j] = 0;
4881 for (i1 =
fXmin, chi_cel = 0; i1 <=
fXmax; i1++) {
4883 yw = source[i1][i2];
4887 working_space, working_space[peak_vel],
4888 working_space[peak_vel + 1],
4889 working_space[peak_vel + 2],
4890 working_space[peak_vel + 3],
4891 working_space[peak_vel + 4],
4892 working_space[peak_vel + 5],
4893 working_space[peak_vel + 6],
4894 working_space[peak_vel + 7],
4895 working_space[peak_vel + 8],
4896 working_space[peak_vel + 9],
4897 working_space[peak_vel + 10],
4898 working_space[peak_vel + 11],
4899 working_space[peak_vel + 12],
4900 working_space[peak_vel + 13]);
4901 chi_opt = (yw -
f) * (yw -
f) / yw;
4902 chi_cel += (yw -
f) * (yw -
f) / yw;
4905 for (j = 0, k = 0; j <
fNPeaks; j++) {
4908 working_space[7 * j + 1],
4909 working_space[7 * j + 2],
4910 working_space[peak_vel],
4911 working_space[peak_vel + 1],
4912 working_space[peak_vel + 2],
4913 working_space[peak_vel + 6],
4914 working_space[peak_vel + 7],
4915 working_space[peak_vel + 12],
4916 working_space[peak_vel + 13]);
4918 working_space[2 * shift + k] += chi_opt;
4920 working_space[4 * shift + k] +=
b;
4926 working_space[7 * j],
4927 working_space[7 * j + 1],
4928 working_space[7 * j + 2],
4929 working_space[peak_vel],
4930 working_space[peak_vel + 1],
4931 working_space[peak_vel + 2],
4932 working_space[peak_vel + 6],
4933 working_space[peak_vel + 7],
4934 working_space[peak_vel + 12],
4935 working_space[peak_vel + 13]);
4937 working_space[2 * shift + k] += chi_opt;
4939 working_space[4 * shift + k] +=
b;
4945 working_space[7 * j],
4946 working_space[7 * j + 1],
4947 working_space[7 * j + 2],
4948 working_space[peak_vel],
4949 working_space[peak_vel + 1],
4950 working_space[peak_vel + 2],
4951 working_space[peak_vel + 6],
4952 working_space[peak_vel + 7],
4953 working_space[peak_vel + 12],
4954 working_space[peak_vel + 13]);
4956 working_space[2 * shift + k] += chi_opt;
4958 working_space[4 * shift + k] +=
b;
4963 a =
Derampx(i1, working_space[7 * j + 5],
4964 working_space[peak_vel],
4965 working_space[peak_vel + 8],
4966 working_space[peak_vel + 10],
4967 working_space[peak_vel + 12]);
4969 working_space[2 * shift + k] += chi_opt;
4971 working_space[4 * shift + k] +=
b;
4976 a =
Derampx(i2, working_space[7 * j + 6],
4977 working_space[peak_vel + 1],
4978 working_space[peak_vel + 9],
4979 working_space[peak_vel + 11],
4980 working_space[peak_vel + 13]);
4982 working_space[2 * shift + k] += chi_opt;
4984 working_space[4 * shift + k] +=
b;
4989 a =
Deri01(i1, working_space[7 * j + 3],
4990 working_space[7 * j + 5],
4991 working_space[peak_vel],
4992 working_space[peak_vel + 8],
4993 working_space[peak_vel + 10],
4994 working_space[peak_vel + 12]);
4996 working_space[2 * shift + k] += chi_opt;
4998 working_space[4 * shift + k] +=
b;
5003 a =
Deri01(i2, working_space[7 * j + 4],
5004 working_space[7 * j + 6],
5005 working_space[peak_vel + 1],
5006 working_space[peak_vel + 9],
5007 working_space[peak_vel + 11],
5008 working_space[peak_vel + 13]);
5010 working_space[2 * shift + k] += chi_opt;
5012 working_space[4 * shift + k] +=
b;
5019 working_space, working_space[peak_vel],
5020 working_space[peak_vel + 1],
5021 working_space[peak_vel + 2],
5022 working_space[peak_vel + 6],
5023 working_space[peak_vel + 7],
5024 working_space[peak_vel + 8],
5025 working_space[peak_vel + 10],
5026 working_space[peak_vel + 12],
5027 working_space[peak_vel + 13]);
5029 working_space[2 * shift + k] += chi_opt;
5031 working_space[4 * shift + k] +=
b;
5037 working_space, working_space[peak_vel],
5038 working_space[peak_vel + 1],
5039 working_space[peak_vel + 2],
5040 working_space[peak_vel + 6],
5041 working_space[peak_vel + 7],
5042 working_space[peak_vel + 9],
5043 working_space[peak_vel + 11],
5044 working_space[peak_vel + 12],
5045 working_space[peak_vel + 13]);
5047 working_space[2 * shift + k] += chi_opt;
5049 working_space[4 * shift + k] +=
b;
5055 working_space, working_space[peak_vel],
5056 working_space[peak_vel + 1],
5057 working_space[peak_vel + 2]);
5059 working_space[2 * shift + k] += chi_opt;
5061 working_space[4 * shift + k] +=
b;
5068 working_space[2 * shift + k] += chi_opt;
5070 working_space[4 * shift + k] +=
b;
5077 working_space[2 * shift + k] += chi_opt;
5079 working_space[4 * shift + k] +=
b;
5086 working_space[2 * shift + k] += chi_opt;
5088 working_space[4 * shift + k] +=
b;
5094 working_space, working_space[peak_vel],
5095 working_space[peak_vel + 1],
5096 working_space[peak_vel + 12],
5097 working_space[peak_vel + 13]);
5099 working_space[2 * shift + k] += chi_opt;
5101 working_space[4 * shift + k] +=
b;
5107 working_space, working_space[peak_vel],
5108 working_space[peak_vel + 1]);
5110 working_space[2 * shift + k] += chi_opt;
5112 working_space[4 * shift + k] +=
b;
5118 working_space[peak_vel],
5119 working_space[peak_vel + 12]);
5121 working_space[2 * shift + k] += chi_opt;
5123 working_space[4 * shift + k] +=
b;
5129 working_space[peak_vel + 1],
5130 working_space[peak_vel + 13]);
5132 working_space[2 * shift + k] += chi_opt;
5134 working_space[4 * shift + k] +=
b;
5140 working_space[peak_vel]);
5142 working_space[2 * shift + k] += chi_opt;
5144 working_space[4 * shift + k] +=
b;
5150 working_space[peak_vel + 1]);
5152 working_space[2 * shift + k] += chi_opt;
5154 working_space[4 * shift + k] +=
b;
5160 working_space, working_space[peak_vel],
5161 working_space[peak_vel + 1],
5162 working_space[peak_vel + 6],
5163 working_space[peak_vel + 8],
5164 working_space[peak_vel + 12],
5165 working_space[peak_vel + 13]);
5167 working_space[2 * shift + k] += chi_opt;
5169 working_space[4 * shift + k] +=
b;
5175 working_space, working_space[peak_vel],
5176 working_space[peak_vel + 1],
5177 working_space[peak_vel + 6],
5178 working_space[peak_vel + 8],
5179 working_space[peak_vel + 12],
5180 working_space[peak_vel + 13]);
5182 working_space[2 * shift + k] += chi_opt;
5184 working_space[4 * shift + k] +=
b;
5192 chi_er = chi_cel /
b;
5193 for (i = 0, j = 0; i <
fNPeaks; i++) {
5195 Volume(working_space[7 * i], working_space[peak_vel],
5196 working_space[peak_vel + 1], working_space[peak_vel + 2]);
5200 a =
Derpa2(working_space[peak_vel],
5201 working_space[peak_vel + 1],
5202 working_space[peak_vel + 2]);
5203 b = working_space[4 * shift + j];
5213 working_space[peak_vel + 1],
5214 working_space[peak_vel + 2]);
5215 b = working_space[4 * shift + peak_vel];
5225 working_space[peak_vel],
5226 working_space[peak_vel + 2]);
5227 b = working_space[4 * shift + peak_vel + 1];
5236 a =
Derpro(working_space[shift + j], working_space[peak_vel],
5237 working_space[peak_vel + 1],
5238 working_space[peak_vel + 2]);
5239 b = working_space[4 * shift + peak_vel + 2];
5254 fAmpCalc[i] = working_space[shift + j];
5255 if (working_space[3 * shift + j] != 0)
5266 if (working_space[3 * shift + j] != 0)
5277 if (working_space[3 * shift + j] != 0)
5288 if (working_space[3 * shift + j] != 0)
5299 if (working_space[3 * shift + j] != 0)
5310 if (working_space[3 * shift + j] != 0)
5321 if (working_space[3 * shift + j] != 0)
5333 if (working_space[3 * shift + j] != 0)
5344 if (working_space[3 * shift + j] != 0)
5354 fRoCalc = working_space[shift + j];
5355 if (working_space[3 * shift + j] != 0)
5365 fA0Calc = working_space[shift + j];
5366 if (working_space[3 * shift + j] != 0)
5376 fAxCalc = working_space[shift + j];
5377 if (working_space[3 * shift + j] != 0)
5387 fAyCalc = working_space[shift + j];
5388 if (working_space[3 * shift + j] != 0)
5398 fTxyCalc = working_space[shift + j];
5399 if (working_space[3 * shift + j] != 0)
5409 fSxyCalc = working_space[shift + j];
5410 if (working_space[3 * shift + j] != 0)
5420 fTxCalc = working_space[shift + j];
5421 if (working_space[3 * shift + j] != 0)
5431 fTyCalc = working_space[shift + j];
5432 if (working_space[3 * shift + j] != 0)
5442 fSxCalc = working_space[shift + j];
5443 if (working_space[3 * shift + j] != 0)
5453 fSyCalc = working_space[shift + j];
5454 if (working_space[3 * shift + j] != 0)
5464 fBxCalc = working_space[shift + j];
5465 if (working_space[3 * shift + j] != 0)
5475 fByCalc = working_space[shift + j];
5476 if (working_space[3 * shift + j] != 0)
5490 working_space, working_space[peak_vel],
5491 working_space[peak_vel + 1],
5492 working_space[peak_vel + 2],
5493 working_space[peak_vel + 3],
5494 working_space[peak_vel + 4],
5495 working_space[peak_vel + 5],
5496 working_space[peak_vel + 6],
5497 working_space[peak_vel + 7],
5498 working_space[peak_vel + 8],
5499 working_space[peak_vel + 9],
5500 working_space[peak_vel + 10],
5501 working_space[peak_vel + 11],
5502 working_space[peak_vel + 12],
5503 working_space[peak_vel + 13]);
5508 for (i = 0; i <
size; i++)
delete [] working_matrix[i];
5509 delete [] working_matrix;
5510 delete [] working_space;