43 #define PEAK_WINDOW 1024
154 Error(
"Background",
"function not yet implemented: h=%s, iter=%d, option=%sn"
155 , h->
GetName(), number_of_iterations, option);
208 if (dimension != 2) {
209 Error(
"Search",
"Must be a 2-d histogram");
228 Int_t i, j, binx,biny, npeaks;
231 for (i = 0; i < sizex; i++) {
234 for (j = 0; j < sizey; j++) {
245 for (i = 0; i < npeaks; i++) {
251 for (i = 0; i < sizex; i++) {
260 if (!npeaks)
return 0;
271 ((
TH1*)hin)->Draw(option);
480 Int_t numberIterationsX,
481 Int_t numberIterationsY,
487 if (ssizex <= 0 || ssizey <= 0)
488 return "Wrong parameters";
489 if (numberIterationsX < 1 || numberIterationsY < 1)
490 return "Width of Clipping Window Must Be Positive";
491 if (ssizex < 2 * numberIterationsX + 1
492 || ssizey < 2 * numberIterationsY + 1)
493 return (
"Too Large Clipping Window");
495 for (i = 0; i < ssizex; i++)
496 working_space[i] =
new Double_t[ssizey];
501 for (i = 1; i <= sampling; i++) {
504 for (y = r2; y < ssizey -
r2; y++) {
505 for (x = r1; x < ssizex -
r1; x++) {
507 p1 = spectrum[x -
r1][y -
r2];
508 p2 = spectrum[x -
r1][y +
r2];
509 p3 = spectrum[x +
r1][y -
r2];
510 p4 = spectrum[x +
r1][y +
r2];
511 s1 = spectrum[
x][y -
r2];
512 s2 = spectrum[x -
r1][
y];
513 s3 = spectrum[x +
r1][
y];
514 s4 = spectrum[
x][y +
r2];
527 s1 = s1 - (p1 +
p3) / 2.0;
528 s2 = s2 - (p1 +
p2) / 2.0;
529 s3 = s3 - (p3 + p4) / 2.0;
530 s4 = s4 - (p2 + p4) / 2.0;
531 b = (s1 + s4) / 2.0 + (s2 + s3) / 2.0 + (p1 + p2 +
536 working_space[
x][
y] =
a;
539 for (y = r2; y < ssizey -
r2; y++) {
540 for (x = r1; x < ssizex -
r1; x++) {
541 spectrum[
x][
y] = working_space[
x][
y];
548 for (i = 1; i <= sampling; i++) {
551 for (y = r2; y < ssizey -
r2; y++) {
552 for (x = r1; x < ssizex -
r1; x++) {
554 b = -(spectrum[x -
r1][y -
r2] +
555 spectrum[x -
r1][y +
r2] + spectrum[x +
r1][y -
557 + spectrum[x +
r1][y +
r2]) / 4 +
558 (spectrum[x][y - r2] + spectrum[x - r1][y] +
559 spectrum[x + r1][y] + spectrum[x][y + r2]) / 2;
562 working_space[
x][
y] =
a;
565 for (y = i; y < ssizey - i; y++) {
566 for (x = i; x < ssizex - i; x++) {
567 spectrum[
x][
y] = working_space[
x][
y];
576 for (i = sampling; i >= 1; i--) {
579 for (y = r2; y < ssizey -
r2; y++) {
580 for (x = r1; x < ssizex -
r1; x++) {
582 p1 = spectrum[x -
r1][y -
r2];
583 p2 = spectrum[x -
r1][y +
r2];
584 p3 = spectrum[x +
r1][y -
r2];
585 p4 = spectrum[x +
r1][y +
r2];
586 s1 = spectrum[
x][y -
r2];
587 s2 = spectrum[x -
r1][
y];
588 s3 = spectrum[x +
r1][
y];
589 s4 = spectrum[
x][y +
r2];
602 s1 = s1 - (p1 +
p3) / 2.0;
603 s2 = s2 - (p1 +
p2) / 2.0;
604 s3 = s3 - (p3 + p4) / 2.0;
605 s4 = s4 - (p2 + p4) / 2.0;
606 b = (s1 + s4) / 2.0 + (s2 + s3) / 2.0 + (p1 + p2 +
611 working_space[
x][
y] =
a;
614 for (y = r2; y < ssizey -
r2; y++) {
615 for (x = r1; x < ssizex -
r1; x++) {
616 spectrum[
x][
y] = working_space[
x][
y];
623 for (i = sampling; i >= 1; i--) {
626 for (y = r2; y < ssizey -
r2; y++) {
627 for (x = r1; x < ssizex -
r1; x++) {
629 b = -(spectrum[x -
r1][y -
r2] +
630 spectrum[x -
r1][y +
r2] + spectrum[x +
r1][y -
632 + spectrum[x +
r1][y +
r2]) / 4 +
633 (spectrum[x][y - r2] + spectrum[x - r1][y] +
634 spectrum[x + r1][y] + spectrum[x][y + r2]) / 2;
637 working_space[
x][
y] =
a;
640 for (y = i; y < ssizey - i; y++) {
641 for (x = i; x < ssizex - i; x++) {
642 spectrum[
x][
y] = working_space[
x][
y];
648 for (i = 0; i < ssizex; i++)
649 delete[]working_space[i];
650 delete[]working_space;
736 Double_t nom, nip, nim, sp, sm, spx,
spy, smx, smy, plocha = 0;
738 return "Averaging Window must be positive";
740 for(i = 0; i < ssizex; i++)
741 working_space[i] =
new Double_t[ssizey];
746 for(i = 0, maxch = 0; i < ssizex; i++){
747 for(j = 0; j < ssizey; j++){
748 working_space[i][j] = 0;
749 if(maxch < source[i][j])
750 maxch = source[i][j];
752 plocha += source[i][j];
756 delete [] working_space;
762 for(i = xmin; i <
xmax; i++){
763 nip = source[i][
ymin] / maxch;
764 nim = source[i + 1][
ymin] / maxch;
766 for(l = 1; l <= averWindow; l++){
771 a = source[i +
l][
ymin] / maxch;
785 a = source[i - l + 1][
ymin] / maxch;
797 a = working_space[i + 1][
ymin] = a * working_space[i][
ymin];
800 for(i = ymin; i <
ymax; i++){
801 nip = source[
xmin][i] / maxch;
802 nim = source[
xmin][i + 1] / maxch;
804 for(l = 1; l <= averWindow; l++){
809 a = source[
xmin][i +
l] / maxch;
823 a = source[
xmin][i - l + 1] / maxch;
835 a = working_space[
xmin][i + 1] = a * working_space[
xmin][i];
838 for(i = xmin; i <
xmax; i++){
839 for(j = ymin; j <
ymax; j++){
840 nip = source[i][j + 1] / maxch;
841 nim = source[i + 1][j + 1] / maxch;
843 for(l = 1; l <= averWindow; l++){
845 a = source[
xmax][j] / maxch;
848 a = source[i +
l][j] / maxch;
859 a = source[
xmin][j] / maxch;
862 a = source[i - l + 1][j] / maxch;
874 nip = source[i + 1][j] / maxch;
875 nim = source[i + 1][j + 1] / maxch;
876 for (l = 1; l <= averWindow; l++) {
877 if (j + l > ymax) a = source[i][
ymax]/maxch;
878 else a = source[i][j +
l] / maxch;
880 if (a + nip <= 0) a = 1;
885 if (j - l + 1 < ymin) a = source[i][
ymin] / maxch;
886 else a = source[i][j - l + 1] / maxch;
888 if (a + nim <= 0) a = 1;
894 a = (spx * working_space[i][j + 1] + spy * working_space[i + 1][j]) / (smx +smy);
895 working_space[i + 1][j + 1] =
a;
899 for(i = xmin; i <=
xmax; i++){
900 for(j = ymin; j <=
ymax; j++){
901 working_space[i][j] = working_space[i][j] / nom;
904 for(i = 0;i < ssizex; i++){
905 for(j = 0; j < ssizey; j++){
906 source[i][j] = plocha * working_space[i][j];
909 for (i = 0; i < ssizex; i++)
910 delete[]working_space[i];
911 delete[]working_space;
1131 Int_t numberIterations,
1132 Int_t numberRepetitions,
1135 Int_t i, j, lhx, lhy, i1, i2, j1, j2, k1, k2, lindex, i1min, i1max,
1136 i2min, i2max, j1min, j1max, j2min, j2max, positx = 0, posity = 0, repet;
1137 Double_t lda, ldb, ldc, area, maximum = 0;
1138 if (ssizex <= 0 || ssizey <= 0)
1139 return "Wrong parameters";
1140 if (numberIterations <= 0)
1141 return "Number of iterations must be positive";
1142 if (numberRepetitions <= 0)
1143 return "Number of repetitions must be positive";
1145 for (i = 0; i < ssizex; i++)
1146 working_space[i] =
new Double_t[5 * ssizey];
1149 for (i = 0; i < ssizex; i++) {
1150 for (j = 0; j < ssizey; j++) {
1158 working_space[i][j] = lda;
1160 if (lda > maximum) {
1162 positx = i, posity = j;
1166 if (lhx == -1 || lhy == -1) {
1167 delete [] working_space;
1168 return (
"Zero response data");
1172 for (i2 = 0; i2 < ssizey; i2++) {
1173 for (i1 = 0; i1 < ssizex; i1++) {
1175 for (j2 = 0; j2 <= (lhy - 1); j2++) {
1176 for (j1 = 0; j1 <= (lhx - 1); j1++) {
1177 k2 = i2 + j2, k1 = i1 + j1;
1178 if (k2 >= 0 && k2 < ssizey && k1 >= 0 && k1 < ssizex) {
1179 lda = working_space[j1][j2];
1180 ldb = source[k1][k2];
1181 ldc = ldc + lda * ldb;
1185 working_space[i1][i2 + ssizey] = ldc;
1190 i1min = -(lhx - 1), i1max = lhx - 1;
1191 i2min = -(lhy - 1), i2max = lhy - 1;
1192 for (i2 = i2min; i2 <= i2max; i2++) {
1193 for (i1 = i1min; i1 <= i1max; i1++) {
1198 j2max = lhy - 1 - i2;
1199 if (j2max > lhy - 1)
1201 for (j2 = j2min; j2 <= j2max; j2++) {
1205 j1max = lhx - 1 - i1;
1206 if (j1max > lhx - 1)
1208 for (j1 = j1min; j1 <= j1max; j1++) {
1209 lda = working_space[j1][j2];
1210 if (i1 + j1 < ssizex && i2 + j2 < ssizey)
1211 ldb = working_space[i1 + j1][i2 + j2];
1214 ldc = ldc + lda * ldb;
1217 working_space[i1 - i1min][i2 - i2min + 2 * ssizey ] = ldc;
1222 for (i2 = 0; i2 < ssizey; i2++) {
1223 for (i1 = 0; i1 < ssizex; i1++) {
1224 working_space[i1][i2 + 3 * ssizey] = 1;
1225 working_space[i1][i2 + 4 * ssizey] = 0;
1230 for (repet = 0; repet < numberRepetitions; repet++) {
1232 for (i = 0; i < ssizex; i++) {
1233 for (j = 0; j < ssizey; j++) {
1234 working_space[i][j + 3 * ssizey] =
1239 for (lindex = 0; lindex < numberIterations; lindex++) {
1240 for (i2 = 0; i2 < ssizey; i2++) {
1241 for (i1 = 0; i1 < ssizex; i1++) {
1244 if (j2min > lhy - 1)
1247 j2max = ssizey - i2 - 1;
1248 if (j2max > lhy - 1)
1251 if (j1min > lhx - 1)
1254 j1max = ssizex - i1 - 1;
1255 if (j1max > lhx - 1)
1257 for (j2 = j2min; j2 <= j2max; j2++) {
1258 for (j1 = j1min; j1 <= j1max; j1++) {
1259 ldc = working_space[j1 - i1min][j2 - i2min + 2 * ssizey];
1260 lda = working_space[i1 + j1][i2 + j2 + 3 * ssizey];
1261 ldb = ldb + lda * ldc;
1264 lda = working_space[i1][i2 + 3 * ssizey];
1265 ldc = working_space[i1][i2 + 1 * ssizey];
1266 if (ldc * lda != 0 && ldb != 0) {
1267 lda = lda * ldc / ldb;
1272 working_space[i1][i2 + 4 * ssizey] = lda;
1275 for (i2 = 0; i2 < ssizey; i2++) {
1276 for (i1 = 0; i1 < ssizex; i1++)
1277 working_space[i1][i2 + 3 * ssizey] =
1278 working_space[i1][i2 + 4 * ssizey];
1282 for (i = 0; i < ssizex; i++) {
1283 for (j = 0; j < ssizey; j++)
1284 source[(i + positx) % ssizex][(j + posity) % ssizey] =
1285 area * working_space[i][j + 3 * ssizey];
1287 for (i = 0; i < ssizex; i++)
1288 delete[]working_space[i];
1289 delete[]working_space;
1590 Int_t number_of_iterations = (
Int_t)(4 * sigma + 0.5);
1591 Int_t k, lindex, priz;
1592 Double_t lda, ldb, ldc, area, maximum;
1593 Int_t xmin,
xmax,
l, peak_index = 0, ssizex_ext = ssizex + 4 * number_of_iterations, ssizey_ext = ssizey + 4 * number_of_iterations, shift = 2 * number_of_iterations;
1595 Double_t a, b, ax, ay, maxch, plocha = 0;
1596 Double_t nom, nip, nim, sp, sm, spx,
spy, smx, smy;
1599 Int_t lhx, lhy, i1, i2, j1, j2, k1, k2, i1min, i1max, i2min, i2max, j1min, j1max, j2min, j2max, positx, posity;
1601 Error(
"SearchHighRes",
"Invalid sigma, must be greater than or equal to 1");
1605 if(threshold<=0||threshold>=100){
1606 Error(
"SearchHighRes",
"Invalid threshold, must be positive and less than 100");
1610 j = (
Int_t) (5.0 * sigma + 0.5);
1612 Error(
"SearchHighRes",
"Too large sigma");
1616 if (markov ==
true) {
1617 if (averWindow <= 0) {
1618 Error(
"SearchHighRes",
"Averaging window must be positive");
1622 if(backgroundRemove ==
true){
1623 if(ssizex_ext < 2 * number_of_iterations + 1 || ssizey_ext < 2 * number_of_iterations + 1){
1624 Error(
"SearchHighRes",
"Too large clipping window");
1628 i = (
Int_t)(4 * sigma + 0.5);
1631 for (j = 0; j < ssizex + i; j++) {
1633 for (k=0;k<16 * (ssizey + i);k++) wsk[k] = 0;
1635 for(j = 0; j < ssizey_ext; j++){
1636 for(i = 0; i < ssizex_ext; i++){
1639 working_space[i][j + ssizey_ext] = source[0][0];
1641 else if(j >= ssizey + shift)
1642 working_space[i][j + ssizey_ext] = source[0][ssizey - 1];
1645 working_space[i][j + ssizey_ext] = source[0][j - shift];
1648 else if(i >= ssizex + shift){
1650 working_space[i][j + ssizey_ext] = source[ssizex - 1][0];
1652 else if(j >= ssizey + shift)
1653 working_space[i][j + ssizey_ext] = source[ssizex - 1][ssizey - 1];
1656 working_space[i][j + ssizey_ext] = source[ssizex - 1][j - shift];
1661 working_space[i][j + ssizey_ext] = source[i - shift][0];
1663 else if(j >= ssizey + shift)
1664 working_space[i][j + ssizey_ext] = source[i - shift][ssizey - 1];
1667 working_space[i][j + ssizey_ext] = source[i - shift][j - shift];
1671 if(backgroundRemove ==
true){
1672 for(i = 1; i <= number_of_iterations; i++){
1673 for(y = i; y < ssizey_ext - i; y++){
1674 for(x = i; x < ssizex_ext - i; x++){
1675 a = working_space[
x][y + ssizey_ext];
1676 p1 = working_space[x - i][y + ssizey_ext - i];
1677 p2 = working_space[x - i][y + ssizey_ext + i];
1678 p3 = working_space[x + i][y + ssizey_ext - i];
1679 p4 = working_space[x + i][y + ssizey_ext + i];
1680 s1 = working_space[
x][y + ssizey_ext - i];
1681 s2 = working_space[x - i][y + ssizey_ext];
1682 s3 = working_space[x + i][y + ssizey_ext];
1683 s4 = working_space[
x][y + ssizey_ext + i];
1684 b = (p1 +
p2) / 2.0;
1687 b = (p1 +
p3) / 2.0;
1690 b = (p2 + p4) / 2.0;
1693 b = (p3 + p4) / 2.0;
1696 s1 = s1 - (p1 +
p3) / 2.0;
1697 s2 = s2 - (p1 +
p2) / 2.0;
1698 s3 = s3 - (p3 + p4) / 2.0;
1699 s4 = s4 - (p2 + p4) / 2.0;
1700 b = (s1 + s4) / 2.0 + (s2 + s3) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
1703 working_space[
x][
y] =
a;
1706 for(y = i;y < ssizey_ext - i; y++){
1707 for(x = i; x < ssizex_ext - i; x++){
1708 working_space[
x][y + ssizey_ext] = working_space[
x][
y];
1712 for(j = 0;j < ssizey_ext; j++){
1713 for(i = 0; i < ssizex_ext; i++){
1716 working_space[i][j + ssizey_ext] = source[0][0] - working_space[i][j + ssizey_ext];
1718 else if(j >= ssizey + shift)
1719 working_space[i][j + ssizey_ext] = source[0][ssizey - 1] - working_space[i][j + ssizey_ext];
1722 working_space[i][j + ssizey_ext] = source[0][j - shift] - working_space[i][j + ssizey_ext];
1725 else if(i >= ssizex + shift){
1727 working_space[i][j + ssizey_ext] = source[ssizex - 1][0] - working_space[i][j + ssizey_ext];
1729 else if(j >= ssizey + shift)
1730 working_space[i][j + ssizey_ext] = source[ssizex - 1][ssizey - 1] - working_space[i][j + ssizey_ext];
1733 working_space[i][j + ssizey_ext] = source[ssizex - 1][j - shift] - working_space[i][j + ssizey_ext];
1738 working_space[i][j + ssizey_ext] = source[i - shift][0] - working_space[i][j + ssizey_ext];
1740 else if(j >= ssizey + shift)
1741 working_space[i][j + ssizey_ext] = source[i - shift][ssizey - 1] - working_space[i][j + ssizey_ext];
1744 working_space[i][j + ssizey_ext] = source[i - shift][j - shift] - working_space[i][j + ssizey_ext];
1749 for(j = 0; j < ssizey_ext; j++){
1750 for(i = 0; i < ssizex_ext; i++){
1751 working_space[i][j + 15*ssizey_ext] = working_space[i][j + ssizey_ext];
1755 for(i = 0;i < ssizex_ext; i++){
1756 for(j = 0; j < ssizey_ext; j++)
1757 working_space[i][j + 2 * ssizex_ext] = working_space[i][ssizey_ext + j];
1760 xmax = ssizex_ext - 1;
1762 ymax = ssizey_ext - 1;
1763 for(i = 0, maxch = 0; i < ssizex_ext; i++){
1764 for(j = 0; j < ssizey_ext; j++){
1765 working_space[i][j] = 0;
1766 if(maxch < working_space[i][j + 2 * ssizey_ext])
1767 maxch = working_space[i][j + 2 * ssizey_ext];
1768 plocha += working_space[i][j + 2 * ssizey_ext];
1772 delete [] working_space;
1778 for(i = xmin; i <
xmax; i++){
1779 nip = working_space[i][ymin + 2 * ssizey_ext] / maxch;
1780 nim = working_space[i + 1][ymin + 2 * ssizey_ext] / maxch;
1782 for(l = 1;l <= averWindow; l++){
1784 a = working_space[xmax][ymin + 2 * ssizey_ext] / maxch;
1787 a = working_space[i +
l][ymin + 2 * ssizey_ext] / maxch;
1798 if(i - l + 1 < xmin)
1799 a = working_space[
xmin][ymin + 2 * ssizey_ext] / maxch;
1802 a = working_space[i - l + 1][ymin + 2 * ssizey_ext] / maxch;
1814 a = working_space[i + 1][
ymin] = a * working_space[i][
ymin];
1817 for(i = ymin; i <
ymax; i++){
1818 nip = working_space[
xmin][i + 2 * ssizey_ext] / maxch;
1819 nim = working_space[
xmin][i + 1 + 2 * ssizey_ext] / maxch;
1821 for(l = 1; l <= averWindow; l++){
1823 a = working_space[
xmin][ymax + 2 * ssizey_ext] / maxch;
1826 a = working_space[
xmin][i + l + 2 * ssizey_ext] / maxch;
1836 if(i - l + 1 < ymin)
1837 a = working_space[
xmin][ymin + 2 * ssizey_ext] / maxch;
1840 a = working_space[
xmin][i - l + 1 + 2 * ssizey_ext] / maxch;
1852 a = working_space[
xmin][i + 1] = a * working_space[
xmin][i];
1855 for(i = xmin; i <
xmax; i++){
1856 for(j = ymin; j <
ymax; j++){
1857 nip = working_space[i][j + 1 + 2 * ssizey_ext] / maxch;
1858 nim = working_space[i + 1][j + 1 + 2 * ssizey_ext] / maxch;
1860 for(l = 1; l <= averWindow; l++){
1862 a = working_space[
xmax][j + 2 * ssizey_ext] / maxch;
1865 a = working_space[i +
l][j + 2 * ssizey_ext] / maxch;
1875 if(i - l + 1 < xmin)
1876 a = working_space[
xmin][j + 2 * ssizey_ext] / maxch;
1879 a = working_space[i - l + 1][j + 2 * ssizey_ext] / maxch;
1891 nip = working_space[i + 1][j + 2 * ssizey_ext] / maxch;
1892 nim = working_space[i + 1][j + 1 + 2 * ssizey_ext] / maxch;
1893 for(l = 1; l <= averWindow; l++){
1895 a = working_space[i][ymax + 2 * ssizey_ext] / maxch;
1898 a = working_space[i][j + l + 2 * ssizey_ext] / maxch;
1908 if(j - l + 1 < ymin)
1909 a = working_space[i][ymin + 2 * ssizey_ext] / maxch;
1912 a = working_space[i][j - l + 1 + 2 * ssizey_ext] / maxch;
1922 a = (spx * working_space[i][j + 1] + spy * working_space[i + 1][j]) / (smx + smy);
1923 working_space[i + 1][j + 1] =
a;
1927 for(i = xmin; i <=
xmax; i++){
1928 for(j = ymin; j <=
ymax; j++){
1929 working_space[i][j] = working_space[i][j] / nom;
1932 for(i = 0; i < ssizex_ext; i++){
1933 for(j = 0; j < ssizey_ext; j++){
1934 working_space[i][j + ssizey_ext] = working_space[i][j] * plocha;
1935 working_space[i][2 * ssizey_ext + j] = working_space[i][ssizey_ext + j];
1942 positx = 0,posity = 0;
1945 for(i = 0; i < ssizex_ext; i++){
1946 for(j = 0; j < ssizey_ext; j++){
1949 lda = (lda * lda + ldb * ldb) / (2 * sigma * sigma);
1959 working_space[i][j] = lda;
1963 positx = i,posity = j;
1968 for(i = 0;i < ssizex_ext; i++){
1969 for(j = 0;j < ssizey_ext; j++){
1970 working_space[i][j + 14 * ssizey_ext] =
TMath::Abs(working_space[i][j + ssizey_ext]);
1982 i1min = -i,i1max = i;
1983 i2min = -j,i2max = j;
1984 for(i2 = i2min; i2 <= i2max; i2++){
1985 for(i1 = i1min; i1 <= i1max; i1++){
1991 j2max = lhy - 1 - i2;
1995 for(j2 = j2min; j2 <= j2max; j2++){
2000 j1max = lhx - 1 - i1;
2004 for(j1 = j1min; j1 <= j1max; j1++){
2005 lda = working_space[j1][j2];
2006 ldb = working_space[i1 + j1][i2 + j2];
2007 ldc = ldc + lda * ldb;
2010 k = (i1 + ssizex_ext) / ssizex_ext;
2011 working_space[(i1 + ssizex_ext) % ssizex_ext][i2 + ssizey_ext + 10 * ssizey_ext + k * 2 * ssizey_ext] = ldc;
2023 i2min = -j,i2max = ssizey_ext + j - 1;
2024 i1min = -i,i1max = ssizex_ext + i - 1;
2025 for(i2 = i2min; i2 <= i2max; i2++){
2026 for(i1=i1min;i1<=i1max;i1++){
2028 for(j2 = 0; j2 <= (lhy - 1); j2++){
2029 for(j1 = 0; j1 <= (lhx - 1); j1++){
2030 k2 = i2 + j2,k1 = i1 + j1;
2031 if(k2 >= 0 && k2 < ssizey_ext && k1 >= 0 && k1 < ssizex_ext){
2032 lda = working_space[j1][j2];
2033 ldb = working_space[k1][k2 + 14 * ssizey_ext];
2034 ldc = ldc + lda * ldb;
2038 k = (i1 + ssizex_ext) / ssizex_ext;
2039 working_space[(i1 + ssizex_ext) % ssizex_ext][i2 + ssizey_ext + ssizey_ext + k * 3 * ssizey_ext] = ldc;
2043 for(i2 = 0; i2 < ssizey_ext; i2++){
2044 for(i1 = 0; i1 < ssizex_ext; i1++){
2045 k = (i1 + ssizex_ext) / ssizex_ext;
2046 ldb = working_space[(i1 + ssizex_ext) % ssizex_ext][i2 + ssizey_ext + ssizey_ext + k * 3 * ssizey_ext];
2047 working_space[i1][i2 + 14 * ssizey_ext] = ldb;
2051 for(i2 = 0; i2 < ssizey_ext; i2++){
2052 for(i1 = 0; i1 < ssizex_ext; i1++){
2053 working_space[i1][i2 + ssizey_ext] = 1;
2054 working_space[i1][i2 + 2 * ssizey_ext] = 0;
2058 for(lindex = 0; lindex < deconIterations; lindex++){
2059 for(i2 = 0; i2 < ssizey_ext; i2++){
2060 for(i1 = 0; i1 < ssizex_ext; i1++){
2061 lda = working_space[i1][i2 + ssizey_ext];
2062 ldc = working_space[i1][i2 + 14 * ssizey_ext];
2063 if(lda > 0.000001 && ldc > 0.000001){
2070 j2max = ssizey_ext - i2 - 1;
2079 j1max = ssizex_ext - i1 - 1;
2083 for(j2 = j2min; j2 <= j2max; j2++){
2084 for(j1 = j1min; j1 <= j1max; j1++){
2085 k = (j1 + ssizex_ext) / ssizex_ext;
2086 ldc = working_space[(j1 + ssizex_ext) % ssizex_ext][j2 + ssizey_ext + 10 * ssizey_ext + k * 2 * ssizey_ext];
2087 lda = working_space[i1 + j1][i2 + j2 + ssizey_ext];
2088 ldb = ldb + lda * ldc;
2091 lda = working_space[i1][i2 + ssizey_ext];
2092 ldc = working_space[i1][i2 + 14 * ssizey_ext];
2093 if(ldc * lda != 0 && ldb != 0){
2094 lda =lda * ldc / ldb;
2099 working_space[i1][i2 + 2 * ssizey_ext] = lda;
2103 for(i2 = 0; i2 < ssizey_ext; i2++){
2104 for(i1 = 0; i1 < ssizex_ext; i1++)
2105 working_space[i1][i2 + ssizey_ext] = working_space[i1][i2 + 2 * ssizey_ext];
2110 for(i = 0; i < ssizex_ext; i++){
2111 for(j = 0; j < ssizey_ext; j++){
2112 working_space[(i + positx) % ssizex_ext][(j + posity) % ssizey_ext] = area * working_space[i][j + ssizey_ext];
2113 if(maximum < working_space[(i + positx) % ssizex_ext][(j + posity) % ssizey_ext])
2114 maximum = working_space[(i + positx) % ssizex_ext][(j + posity) % ssizey_ext];
2119 for(i = 1; i < ssizex_ext - 1; i++){
2120 for(j = 1; j < ssizey_ext - 1; j++){
2121 if(working_space[i][j] > working_space[i - 1][j] && working_space[i][j] > working_space[i - 1][j - 1] && working_space[i][j] > working_space[i][j - 1] && working_space[i][j] > working_space[i + 1][j - 1] && working_space[i][j] > working_space[i + 1][j] && working_space[i][j] > working_space[i + 1][j + 1] && working_space[i][j] > working_space[i][j + 1] && working_space[i][j] > working_space[i - 1][j + 1]){
2122 if(i >= shift && i < ssizex + shift && j >= shift && j < ssizey + shift){
2123 if(working_space[i][j] > threshold * maximum / 100.0){
2125 for(k = i - 1,a = 0,b = 0; k <= i + 1; k++){
2126 a += (
Double_t)(k - shift) * working_space[k][j];
2127 b += working_space[k][j];
2136 for(k = j - 1,a = 0,b = 0; k <= j + 1; k++){
2137 a += (
Double_t)(k - shift) * working_space[i][k];
2138 b += working_space[i][k];
2147 if(peak_index == 0){
2154 for(k = 0, priz = 0; k < peak_index && priz == 0; k++){
2166 for(l = peak_index; l >= k; l--){
2185 for(i = 0; i < ssizex; i++){
2186 for(j = 0; j < ssizey; j++){
2187 dest[i][j] = working_space[i + shift][j + shift];
2190 i = (
Int_t)(4 * sigma + 0.5);
2192 for (j = 0; j < ssizex + i; j++)
2193 delete[]working_space[j];
2194 delete[]working_space;
2205 return s.
Search(hist,sigma,option,threshold);
const char * Deconvolution(Double_t **source, Double_t **resp, Int_t ssizex, Int_t ssizey, Int_t numberIterations, Int_t numberRepetitions, Double_t boost)
This function calculates deconvolution from source spectrum according to response spectrum The result...
TList * GetListOfFunctions() const
ClassImp(TSpectrum2) TSpectrum2
Constructor.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
static double p3(double t, double a, double b, double c, double d)
Double_t * fPositionY
[fNPeaks] Y position of peaks
Advanced 2-dimensional spectra processing.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual Int_t GetDimension() const
static Int_t fgAverageWindow
Average window of searched peaks.
TH1 * fHistogram
resulting histogram
static void SetDeconIterations(Int_t n=3)
static function: Set max number of decon iterations in deconvolution operation see TSpectrum2::Search...
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Double_t fResolution
resolution of the neighboring peaks
void SetResolution(Double_t resolution=1)
resolution: determines resolution of the neighboring peaks default value is 1 correspond to 3 sigma d...
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Int_t fNPeaks
number of peaks found
The TNamed class is the base class for all named ROOT classes.
static double p2(double t, double a, double b, double c)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Int_t fMaxPeaks
Maximum number of peaks to be found.
Double_t * fPositionX
[fNPeaks] X position of peaks
virtual TObject * Remove(TObject *obj)
Remove object from the list.
unsigned int r1[N_CITIES]
static void SetAverageWindow(Int_t w=3)
static function: Set average window of searched peaks see TSpectrum2::SearchHighRes ...
LVector boost(const LVector &v, const BoostVector &b)
Boost a generic Lorentz Vector class using a generic 3D Vector class describing the boost The only re...
virtual const char * GetName() const
Returns name of object.
virtual void SetMarkerStyle(Style_t mstyle=1)
static double p1(double t, double a, double b)
virtual void SetMarkerSize(Size_t msize=1)
virtual void Print(Option_t *option="") const
Print the array of positions.
static Int_t StaticSearch(const TH1 *hist, Double_t sigma=2, Option_t *option="goff", Double_t threshold=0.05)
static function (called by TH1), interface to TSpectrum2::Search
A PolyMarker is defined by an array on N points in a 2-D space.
Double_t * fPosition
[fNPeaks] array of current peak positions
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual ~TSpectrum2()
Destructor.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual void Add(TObject *obj)
const char * SmoothMarkov(Double_t **source, Int_t ssizex, Int_t ssizey, Int_t averWindow)
This function calculates smoothed spectrum from source spectrum based on Markov chain method...
#define dest(otri, vertexptr)
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
static TH1 * StaticBackground(const TH1 *hist, Int_t niter=20, Option_t *option="")
static function (called by TH1), interface to TSpectrum2::Background
virtual TH1 * Background(const TH1 *hist, Int_t niter=20, Option_t *option="")
This function calculates the background spectrum in the input histogram h.
Double_t Sqrt(Double_t x)
Int_t SearchHighRes(Double_t **source, Double_t **dest, Int_t ssizex, Int_t ssizey, Double_t sigma, Double_t threshold, Bool_t backgroundRemove, Int_t deconIterations, Bool_t markov, Int_t averWindow)
This function searches for peaks in source spectrum It is based on deconvolution method.
unsigned int r2[N_CITIES]
static Int_t fgIterations
Maximum number of decon iterations (default=3)
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
This function searches for peaks in source spectrum in hin The number of found peaks and their positi...