49#define PEAK_WINDOW 1024
160 Error(
"Background",
"function not yet implemented: h=%s, iter=%d, option=%sn"
161 ,
h->GetName(), number_of_iterations,
option);
170 printf(
"\nNumber of positions = %d\n",
fNPeaks);
214 if (dimension != 2) {
215 Error(
"Search",
"Must be a 2-d histogram");
234 Int_t i, j, binx,biny, npeaks;
237 for (i = 0; i < sizex; i++) {
240 for (j = 0; j < sizey; j++) {
251 for (i = 0; i < npeaks; i++) {
257 for (i = 0; i < sizex; i++) {
266 if (!npeaks)
return 0;
371 Int_t numberIterationsX,
372 Int_t numberIterationsY,
376 Int_t i,
x,
y, sampling, r1, r2;
378 if (ssizex <= 0 || ssizey <= 0)
379 return "Wrong parameters";
380 if (numberIterationsX < 1 || numberIterationsY < 1)
381 return "Width of Clipping Window Must Be Positive";
382 if (ssizex < 2 * numberIterationsX + 1
383 || ssizey < 2 * numberIterationsY + 1)
384 return (
"Too Large Clipping Window");
386 for (i = 0; i < ssizex; i++)
387 working_space[i] =
new Double_t[ssizey];
392 for (i = 1; i <= sampling; i++) {
395 for (
y = r2;
y < ssizey - r2;
y++) {
396 for (
x = r1;
x < ssizex - r1;
x++) {
398 p1 = spectrum[
x - r1][
y - r2];
399 p2 = spectrum[
x - r1][
y + r2];
400 p3 = spectrum[
x + r1][
y - r2];
401 p4 = spectrum[
x + r1][
y + r2];
402 s1 = spectrum[
x][
y - r2];
403 s2 = spectrum[
x - r1][
y];
404 s3 = spectrum[
x + r1][
y];
405 s4 = spectrum[
x][
y + r2];
418 s1 =
s1 - (p1 + p3) / 2.0;
419 s2 = s2 - (p1 + p2) / 2.0;
420 s3 = s3 - (p3 + p4) / 2.0;
421 s4 = s4 - (p2 + p4) / 2.0;
422 b = (
s1 + s4) / 2.0 + (s2 + s3) / 2.0 + (p1 + p2 +
427 working_space[
x][
y] =
a;
430 for (
y = r2;
y < ssizey - r2;
y++) {
431 for (
x = r1;
x < ssizex - r1;
x++) {
432 spectrum[
x][
y] = working_space[
x][
y];
439 for (i = 1; i <= sampling; i++) {
442 for (
y = r2;
y < ssizey - r2;
y++) {
443 for (
x = r1;
x < ssizex - r1;
x++) {
445 b = -(spectrum[
x - r1][
y - r2] +
446 spectrum[
x - r1][
y + r2] + spectrum[
x + r1][
y -
448 + spectrum[
x + r1][
y + r2]) / 4 +
449 (spectrum[
x][
y - r2] + spectrum[
x - r1][
y] +
450 spectrum[
x + r1][
y] + spectrum[
x][
y + r2]) / 2;
453 working_space[
x][
y] =
a;
456 for (
y = i;
y < ssizey - i;
y++) {
457 for (
x = i;
x < ssizex - i;
x++) {
458 spectrum[
x][
y] = working_space[
x][
y];
467 for (i = sampling; i >= 1; i--) {
470 for (
y = r2;
y < ssizey - r2;
y++) {
471 for (
x = r1;
x < ssizex - r1;
x++) {
473 p1 = spectrum[
x - r1][
y - r2];
474 p2 = spectrum[
x - r1][
y + r2];
475 p3 = spectrum[
x + r1][
y - r2];
476 p4 = spectrum[
x + r1][
y + r2];
477 s1 = spectrum[
x][
y - r2];
478 s2 = spectrum[
x - r1][
y];
479 s3 = spectrum[
x + r1][
y];
480 s4 = spectrum[
x][
y + r2];
493 s1 =
s1 - (p1 + p3) / 2.0;
494 s2 = s2 - (p1 + p2) / 2.0;
495 s3 = s3 - (p3 + p4) / 2.0;
496 s4 = s4 - (p2 + p4) / 2.0;
497 b = (
s1 + s4) / 2.0 + (s2 + s3) / 2.0 + (p1 + p2 +
502 working_space[
x][
y] =
a;
505 for (
y = r2;
y < ssizey - r2;
y++) {
506 for (
x = r1;
x < ssizex - r1;
x++) {
507 spectrum[
x][
y] = working_space[
x][
y];
514 for (i = sampling; i >= 1; i--) {
517 for (
y = r2;
y < ssizey - r2;
y++) {
518 for (
x = r1;
x < ssizex - r1;
x++) {
520 b = -(spectrum[
x - r1][
y - r2] +
521 spectrum[
x - r1][
y + r2] + spectrum[
x + r1][
y -
523 + spectrum[
x + r1][
y + r2]) / 4 +
524 (spectrum[
x][
y - r2] + spectrum[
x - r1][
y] +
525 spectrum[
x + r1][
y] + spectrum[
x][
y + r2]) / 2;
528 working_space[
x][
y] =
a;
531 for (
y = i;
y < ssizey - i;
y++) {
532 for (
x = i;
x < ssizex - i;
x++) {
533 spectrum[
x][
y] = working_space[
x][
y];
539 for (i = 0; i < ssizex; i++)
540 delete[]working_space[i];
541 delete[]working_space;
587 Double_t nom, nip, nim, sp, sm, spx, spy, smx, smy, plocha = 0;
589 return "Averaging Window must be positive";
591 for(i = 0; i < ssizex; i++)
592 working_space[i] =
new Double_t[ssizey];
597 for(i = 0, maxch = 0; i < ssizex; i++){
598 for(j = 0; j < ssizey; j++){
599 working_space[i][j] = 0;
600 if(maxch < source[i][j])
601 maxch = source[i][j];
603 plocha += source[i][j];
607 for (i = 0; i < ssizex; i++)
608 delete[]working_space[i];
609 delete [] working_space;
616 nip = source[i][
ymin] / maxch;
617 nim = source[i + 1][
ymin] / maxch;
619 for(
l = 1;
l <= averWindow;
l++){
624 a = source[i +
l][
ymin] / maxch;
638 a = source[i -
l + 1][
ymin] / maxch;
650 a = working_space[i + 1][
ymin] =
a * working_space[i][
ymin];
654 nip = source[
xmin][i] / maxch;
655 nim = source[
xmin][i + 1] / maxch;
657 for(
l = 1;
l <= averWindow;
l++){
662 a = source[
xmin][i +
l] / maxch;
676 a = source[
xmin][i -
l + 1] / maxch;
688 a = working_space[
xmin][i + 1] =
a * working_space[
xmin][i];
693 nip = source[i][j + 1] / maxch;
694 nim = source[i + 1][j + 1] / maxch;
696 for(
l = 1;
l <= averWindow;
l++){
698 a = source[
xmax][j] / maxch;
701 a = source[i +
l][j] / maxch;
712 a = source[
xmin][j] / maxch;
715 a = source[i -
l + 1][j] / maxch;
727 nip = source[i + 1][j] / maxch;
728 nim = source[i + 1][j + 1] / maxch;
729 for (
l = 1;
l <= averWindow;
l++) {
731 else a = source[i][j +
l] / maxch;
733 if (
a + nip <= 0)
a = 1;
738 if (j -
l + 1 <
ymin)
a = source[i][
ymin] / maxch;
739 else a = source[i][j -
l + 1] / maxch;
741 if (
a + nim <= 0)
a = 1;
747 a = (spx * working_space[i][j + 1] + spy * working_space[i + 1][j]) / (smx +smy);
748 working_space[i + 1][j + 1] =
a;
754 working_space[i][j] = working_space[i][j] / nom;
757 for(i = 0;i < ssizex; i++){
758 for(j = 0; j < ssizey; j++){
759 source[i][j] = plocha * working_space[i][j];
762 for (i = 0; i < ssizex; i++)
763 delete[]working_space[i];
764 delete[]working_space;
837 Int_t numberIterations,
838 Int_t numberRepetitions,
841 Int_t i, j, lhx, lhy, i1, i2, j1, j2, k1, k2, lindex, i1min, i1max,
842 i2min, i2max, j1min, j1max, j2min, j2max, positx = 0, posity = 0, repet;
843 Double_t lda, ldb, ldc, area, maximum = 0;
844 if (ssizex <= 0 || ssizey <= 0)
845 return "Wrong parameters";
846 if (numberIterations <= 0)
847 return "Number of iterations must be positive";
848 if (numberRepetitions <= 0)
849 return "Number of repetitions must be positive";
851 for (i = 0; i < ssizex; i++)
852 working_space[i] =
new Double_t[5 * ssizey];
855 for (i = 0; i < ssizex; i++) {
856 for (j = 0; j < ssizey; j++) {
864 working_space[i][j] = lda;
868 positx = i, posity = j;
872 if (lhx == -1 || lhy == -1) {
873 for (i = 0; i < ssizex; i++)
874 delete[]working_space[i];
875 delete [] working_space;
876 return (
"Zero response data");
880 for (i2 = 0; i2 < ssizey; i2++) {
881 for (i1 = 0; i1 < ssizex; i1++) {
883 for (j2 = 0; j2 <= (lhy - 1); j2++) {
884 for (j1 = 0; j1 <= (lhx - 1); j1++) {
885 k2 = i2 + j2, k1 = i1 + j1;
886 if (k2 >= 0 && k2 < ssizey && k1 >= 0 && k1 < ssizex) {
887 lda = working_space[j1][j2];
888 ldb = source[k1][k2];
889 ldc = ldc + lda * ldb;
893 working_space[i1][i2 + ssizey] = ldc;
898 i1min = -(lhx - 1), i1max = lhx - 1;
899 i2min = -(lhy - 1), i2max = lhy - 1;
900 for (i2 = i2min; i2 <= i2max; i2++) {
901 for (i1 = i1min; i1 <= i1max; i1++) {
906 j2max = lhy - 1 - i2;
909 for (j2 = j2min; j2 <= j2max; j2++) {
913 j1max = lhx - 1 - i1;
916 for (j1 = j1min; j1 <= j1max; j1++) {
917 lda = working_space[j1][j2];
918 if (i1 + j1 < ssizex && i2 + j2 < ssizey)
919 ldb = working_space[i1 + j1][i2 + j2];
922 ldc = ldc + lda * ldb;
925 working_space[i1 - i1min][i2 - i2min + 2 * ssizey ] = ldc;
930 for (i2 = 0; i2 < ssizey; i2++) {
931 for (i1 = 0; i1 < ssizex; i1++) {
932 working_space[i1][i2 + 3 * ssizey] = 1;
933 working_space[i1][i2 + 4 * ssizey] = 0;
938 for (repet = 0; repet < numberRepetitions; repet++) {
940 for (i = 0; i < ssizex; i++) {
941 for (j = 0; j < ssizey; j++) {
942 working_space[i][j + 3 * ssizey] =
947 for (lindex = 0; lindex < numberIterations; lindex++) {
948 for (i2 = 0; i2 < ssizey; i2++) {
949 for (i1 = 0; i1 < ssizex; i1++) {
955 j2max = ssizey - i2 - 1;
962 j1max = ssizex - i1 - 1;
965 for (j2 = j2min; j2 <= j2max; j2++) {
966 for (j1 = j1min; j1 <= j1max; j1++) {
967 ldc = working_space[j1 - i1min][j2 - i2min + 2 * ssizey];
968 lda = working_space[i1 + j1][i2 + j2 + 3 * ssizey];
969 ldb = ldb + lda * ldc;
972 lda = working_space[i1][i2 + 3 * ssizey];
973 ldc = working_space[i1][i2 + 1 * ssizey];
974 if (ldc * lda != 0 && ldb != 0) {
975 lda = lda * ldc / ldb;
980 working_space[i1][i2 + 4 * ssizey] = lda;
983 for (i2 = 0; i2 < ssizey; i2++) {
984 for (i1 = 0; i1 < ssizex; i1++)
985 working_space[i1][i2 + 3 * ssizey] =
986 working_space[i1][i2 + 4 * ssizey];
990 for (i = 0; i < ssizex; i++) {
991 for (j = 0; j < ssizey; j++)
992 source[(i + positx) % ssizex][(j + posity) % ssizey] =
993 area * working_space[i][j + 3 * ssizey];
995 for (i = 0; i < ssizex; i++)
996 delete[]working_space[i];
997 delete[]working_space;
1097 Int_t k, lindex, priz;
1098 Double_t lda, ldb, ldc, area, maximum;
1099 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;
1102 Double_t nom, nip, nim, sp, sm, spx, spy, smx, smy;
1105 Int_t lhx, lhy, i1, i2, j1, j2, k1, k2, i1min, i1max, i2min, i2max, j1min, j1max, j2min, j2max, positx, posity;
1107 Error(
"SearchHighRes",
"Invalid sigma, must be greater than or equal to 1");
1111 if(threshold<=0||threshold>=100){
1112 Error(
"SearchHighRes",
"Invalid threshold, must be positive and less than 100");
1118 Error(
"SearchHighRes",
"Too large sigma");
1122 if (markov ==
true) {
1123 if (averWindow <= 0) {
1124 Error(
"SearchHighRes",
"Averaging window must be positive");
1128 if(backgroundRemove ==
true){
1129 if(ssizex_ext < 2 * number_of_iterations + 1 || ssizey_ext < 2 * number_of_iterations + 1){
1130 Error(
"SearchHighRes",
"Too large clipping window");
1137 for (j = 0; j < ssizex + i; j++) {
1139 for (k=0;k<16 * (ssizey + i);k++) wsk[k] = 0;
1141 for(j = 0; j < ssizey_ext; j++){
1142 for(i = 0; i < ssizex_ext; i++){
1145 working_space[i][j + ssizey_ext] = source[0][0];
1147 else if(j >= ssizey + shift)
1148 working_space[i][j + ssizey_ext] = source[0][ssizey - 1];
1151 working_space[i][j + ssizey_ext] = source[0][j - shift];
1154 else if(i >= ssizex + shift){
1156 working_space[i][j + ssizey_ext] = source[ssizex - 1][0];
1158 else if(j >= ssizey + shift)
1159 working_space[i][j + ssizey_ext] = source[ssizex - 1][ssizey - 1];
1162 working_space[i][j + ssizey_ext] = source[ssizex - 1][j - shift];
1167 working_space[i][j + ssizey_ext] = source[i - shift][0];
1169 else if(j >= ssizey + shift)
1170 working_space[i][j + ssizey_ext] = source[i - shift][ssizey - 1];
1173 working_space[i][j + ssizey_ext] = source[i - shift][j - shift];
1177 if(backgroundRemove ==
true){
1178 for(i = 1; i <= number_of_iterations; i++){
1179 for(
y = i;
y < ssizey_ext - i;
y++){
1180 for(
x = i;
x < ssizex_ext - i;
x++){
1181 a = working_space[
x][
y + ssizey_ext];
1182 p1 = working_space[
x - i][
y + ssizey_ext - i];
1183 p2 = working_space[
x - i][
y + ssizey_ext + i];
1184 p3 = working_space[
x + i][
y + ssizey_ext - i];
1185 p4 = working_space[
x + i][
y + ssizey_ext + i];
1186 s1 = working_space[
x][
y + ssizey_ext - i];
1187 s2 = working_space[
x - i][
y + ssizey_ext];
1188 s3 = working_space[
x + i][
y + ssizey_ext];
1189 s4 = working_space[
x][
y + ssizey_ext + i];
1190 b = (p1 + p2) / 2.0;
1193 b = (p1 + p3) / 2.0;
1196 b = (p2 + p4) / 2.0;
1199 b = (p3 + p4) / 2.0;
1202 s1 =
s1 - (p1 + p3) / 2.0;
1203 s2 = s2 - (p1 + p2) / 2.0;
1204 s3 = s3 - (p3 + p4) / 2.0;
1205 s4 = s4 - (p2 + p4) / 2.0;
1206 b = (
s1 + s4) / 2.0 + (s2 + s3) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
1209 working_space[
x][
y] =
a;
1212 for(
y = i;
y < ssizey_ext - i;
y++){
1213 for(
x = i;
x < ssizex_ext - i;
x++){
1214 working_space[
x][
y + ssizey_ext] = working_space[
x][
y];
1218 for(j = 0;j < ssizey_ext; j++){
1219 for(i = 0; i < ssizex_ext; i++){
1222 working_space[i][j + ssizey_ext] = source[0][0] - working_space[i][j + ssizey_ext];
1224 else if(j >= ssizey + shift)
1225 working_space[i][j + ssizey_ext] = source[0][ssizey - 1] - working_space[i][j + ssizey_ext];
1228 working_space[i][j + ssizey_ext] = source[0][j - shift] - working_space[i][j + ssizey_ext];
1231 else if(i >= ssizex + shift){
1233 working_space[i][j + ssizey_ext] = source[ssizex - 1][0] - working_space[i][j + ssizey_ext];
1235 else if(j >= ssizey + shift)
1236 working_space[i][j + ssizey_ext] = source[ssizex - 1][ssizey - 1] - working_space[i][j + ssizey_ext];
1239 working_space[i][j + ssizey_ext] = source[ssizex - 1][j - shift] - working_space[i][j + ssizey_ext];
1244 working_space[i][j + ssizey_ext] = source[i - shift][0] - working_space[i][j + ssizey_ext];
1246 else if(j >= ssizey + shift)
1247 working_space[i][j + ssizey_ext] = source[i - shift][ssizey - 1] - working_space[i][j + ssizey_ext];
1250 working_space[i][j + ssizey_ext] = source[i - shift][j - shift] - working_space[i][j + ssizey_ext];
1255 for(j = 0; j < ssizey_ext; j++){
1256 for(i = 0; i < ssizex_ext; i++){
1257 working_space[i][j + 15*ssizey_ext] = working_space[i][j + ssizey_ext];
1261 for(i = 0;i < ssizex_ext; i++){
1262 for(j = 0; j < ssizey_ext; j++)
1263 working_space[i][j + 2 * ssizex_ext] = working_space[i][ssizey_ext + j];
1266 xmax = ssizex_ext - 1;
1268 ymax = ssizey_ext - 1;
1269 for(i = 0, maxch = 0; i < ssizex_ext; i++){
1270 for(j = 0; j < ssizey_ext; j++){
1271 working_space[i][j] = 0;
1272 if(maxch < working_space[i][j + 2 * ssizey_ext])
1273 maxch = working_space[i][j + 2 * ssizey_ext];
1274 plocha += working_space[i][j + 2 * ssizey_ext];
1280 for (j = 0; j < ssizex + i; j++)
1281 delete[]working_space[j];
1282 delete [] working_space;
1289 nip = working_space[i][
ymin + 2 * ssizey_ext] / maxch;
1290 nim = working_space[i + 1][
ymin + 2 * ssizey_ext] / maxch;
1292 for(
l = 1;
l <= averWindow;
l++){
1294 a = working_space[
xmax][
ymin + 2 * ssizey_ext] / maxch;
1297 a = working_space[i +
l][
ymin + 2 * ssizey_ext] / maxch;
1308 if(i -
l + 1 <
xmin)
1309 a = working_space[
xmin][
ymin + 2 * ssizey_ext] / maxch;
1312 a = working_space[i -
l + 1][
ymin + 2 * ssizey_ext] / maxch;
1324 a = working_space[i + 1][
ymin] =
a * working_space[i][
ymin];
1328 nip = working_space[
xmin][i + 2 * ssizey_ext] / maxch;
1329 nim = working_space[
xmin][i + 1 + 2 * ssizey_ext] / maxch;
1331 for(
l = 1;
l <= averWindow;
l++){
1333 a = working_space[
xmin][
ymax + 2 * ssizey_ext] / maxch;
1336 a = working_space[
xmin][i +
l + 2 * ssizey_ext] / maxch;
1346 if(i -
l + 1 <
ymin)
1347 a = working_space[
xmin][
ymin + 2 * ssizey_ext] / maxch;
1350 a = working_space[
xmin][i -
l + 1 + 2 * ssizey_ext] / maxch;
1362 a = working_space[
xmin][i + 1] =
a * working_space[
xmin][i];
1367 nip = working_space[i][j + 1 + 2 * ssizey_ext] / maxch;
1368 nim = working_space[i + 1][j + 1 + 2 * ssizey_ext] / maxch;
1370 for(
l = 1;
l <= averWindow;
l++){
1372 a = working_space[
xmax][j + 2 * ssizey_ext] / maxch;
1375 a = working_space[i +
l][j + 2 * ssizey_ext] / maxch;
1385 if(i -
l + 1 <
xmin)
1386 a = working_space[
xmin][j + 2 * ssizey_ext] / maxch;
1389 a = working_space[i -
l + 1][j + 2 * ssizey_ext] / maxch;
1401 nip = working_space[i + 1][j + 2 * ssizey_ext] / maxch;
1402 nim = working_space[i + 1][j + 1 + 2 * ssizey_ext] / maxch;
1403 for(
l = 1;
l <= averWindow;
l++){
1405 a = working_space[i][
ymax + 2 * ssizey_ext] / maxch;
1408 a = working_space[i][j +
l + 2 * ssizey_ext] / maxch;
1418 if(j -
l + 1 <
ymin)
1419 a = working_space[i][
ymin + 2 * ssizey_ext] / maxch;
1422 a = working_space[i][j -
l + 1 + 2 * ssizey_ext] / maxch;
1432 a = (spx * working_space[i][j + 1] + spy * working_space[i + 1][j]) / (smx + smy);
1433 working_space[i + 1][j + 1] =
a;
1439 working_space[i][j] = working_space[i][j] / nom;
1442 for(i = 0; i < ssizex_ext; i++){
1443 for(j = 0; j < ssizey_ext; j++){
1444 working_space[i][j + ssizey_ext] = working_space[i][j] * plocha;
1445 working_space[i][2 * ssizey_ext + j] = working_space[i][ssizey_ext + j];
1452 positx = 0,posity = 0;
1455 for(i = 0; i < ssizex_ext; i++){
1456 for(j = 0; j < ssizey_ext; j++){
1459 lda = (lda * lda + ldb * ldb) / (2 *
sigma *
sigma);
1469 working_space[i][j] = lda;
1473 positx = i,posity = j;
1478 for(i = 0;i < ssizex_ext; i++){
1479 for(j = 0;j < ssizey_ext; j++){
1480 working_space[i][j + 14 * ssizey_ext] =
TMath::Abs(working_space[i][j + ssizey_ext]);
1492 i1min = -i,i1max = i;
1493 i2min = -j,i2max = j;
1494 for(i2 = i2min; i2 <= i2max; i2++){
1495 for(i1 = i1min; i1 <= i1max; i1++){
1501 j2max = lhy - 1 - i2;
1505 for(j2 = j2min; j2 <= j2max; j2++){
1510 j1max = lhx - 1 - i1;
1514 for(j1 = j1min; j1 <= j1max; j1++){
1515 lda = working_space[j1][j2];
1516 ldb = working_space[i1 + j1][i2 + j2];
1517 ldc = ldc + lda * ldb;
1520 k = (i1 + ssizex_ext) / ssizex_ext;
1521 working_space[(i1 + ssizex_ext) % ssizex_ext][i2 + ssizey_ext + 10 * ssizey_ext + k * 2 * ssizey_ext] = ldc;
1533 i2min = -j,i2max = ssizey_ext + j - 1;
1534 i1min = -i,i1max = ssizex_ext + i - 1;
1535 for(i2 = i2min; i2 <= i2max; i2++){
1536 for(i1=i1min;i1<=i1max;i1++){
1538 for(j2 = 0; j2 <= (lhy - 1); j2++){
1539 for(j1 = 0; j1 <= (lhx - 1); j1++){
1540 k2 = i2 + j2,k1 = i1 + j1;
1541 if(k2 >= 0 && k2 < ssizey_ext && k1 >= 0 && k1 < ssizex_ext){
1542 lda = working_space[j1][j2];
1543 ldb = working_space[k1][k2 + 14 * ssizey_ext];
1544 ldc = ldc + lda * ldb;
1548 k = (i1 + ssizex_ext) / ssizex_ext;
1549 working_space[(i1 + ssizex_ext) % ssizex_ext][i2 + ssizey_ext + ssizey_ext + k * 3 * ssizey_ext] = ldc;
1553 for(i2 = 0; i2 < ssizey_ext; i2++){
1554 for(i1 = 0; i1 < ssizex_ext; i1++){
1555 k = (i1 + ssizex_ext) / ssizex_ext;
1556 ldb = working_space[(i1 + ssizex_ext) % ssizex_ext][i2 + ssizey_ext + ssizey_ext + k * 3 * ssizey_ext];
1557 working_space[i1][i2 + 14 * ssizey_ext] = ldb;
1561 for(i2 = 0; i2 < ssizey_ext; i2++){
1562 for(i1 = 0; i1 < ssizex_ext; i1++){
1563 working_space[i1][i2 + ssizey_ext] = 1;
1564 working_space[i1][i2 + 2 * ssizey_ext] = 0;
1568 for(lindex = 0; lindex < deconIterations; lindex++){
1569 for(i2 = 0; i2 < ssizey_ext; i2++){
1570 for(i1 = 0; i1 < ssizex_ext; i1++){
1571 lda = working_space[i1][i2 + ssizey_ext];
1572 ldc = working_space[i1][i2 + 14 * ssizey_ext];
1573 if(lda > 0.000001 && ldc > 0.000001){
1580 j2max = ssizey_ext - i2 - 1;
1589 j1max = ssizex_ext - i1 - 1;
1593 for(j2 = j2min; j2 <= j2max; j2++){
1594 for(j1 = j1min; j1 <= j1max; j1++){
1595 k = (j1 + ssizex_ext) / ssizex_ext;
1596 ldc = working_space[(j1 + ssizex_ext) % ssizex_ext][j2 + ssizey_ext + 10 * ssizey_ext + k * 2 * ssizey_ext];
1597 lda = working_space[i1 + j1][i2 + j2 + ssizey_ext];
1598 ldb = ldb + lda * ldc;
1601 lda = working_space[i1][i2 + ssizey_ext];
1602 ldc = working_space[i1][i2 + 14 * ssizey_ext];
1603 if(ldc * lda != 0 && ldb != 0){
1604 lda =lda * ldc / ldb;
1609 working_space[i1][i2 + 2 * ssizey_ext] = lda;
1613 for(i2 = 0; i2 < ssizey_ext; i2++){
1614 for(i1 = 0; i1 < ssizex_ext; i1++)
1615 working_space[i1][i2 + ssizey_ext] = working_space[i1][i2 + 2 * ssizey_ext];
1620 for(i = 0; i < ssizex_ext; i++){
1621 for(j = 0; j < ssizey_ext; j++){
1622 working_space[(i + positx) % ssizex_ext][(j + posity) % ssizey_ext] = area * working_space[i][j + ssizey_ext];
1623 if(maximum < working_space[(i + positx) % ssizex_ext][(j + posity) % ssizey_ext])
1624 maximum = working_space[(i + positx) % ssizex_ext][(j + posity) % ssizey_ext];
1629 for(i = 1; i < ssizex_ext - 1; i++){
1630 for(j = 1; j < ssizey_ext - 1; j++){
1631 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]){
1632 if(i >= shift && i < ssizex + shift && j >= shift && j < ssizey + shift){
1633 if(working_space[i][j] > threshold * maximum / 100.0){
1635 for(k = i - 1,
a = 0,
b = 0; k <= i + 1; k++){
1636 a += (
Double_t)(k - shift) * working_space[k][j];
1637 b += working_space[k][j];
1646 for(k = j - 1,
a = 0,
b = 0; k <= j + 1; k++){
1647 a += (
Double_t)(k - shift) * working_space[i][k];
1648 b += working_space[i][k];
1657 if(peak_index == 0){
1664 for(k = 0, priz = 0; k < peak_index && priz == 0; k++){
1676 for(
l = peak_index;
l >= k;
l--){
1695 for(i = 0; i < ssizex; i++){
1696 for(j = 0; j < ssizey; j++){
1697 dest[i][j] = working_space[i + shift][j + shift];
1702 for (j = 0; j < ssizex + i; j++)
1703 delete[]working_space[j];
1704 delete[]working_space;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetDimension() const
TList * GetListOfFunctions() const
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
The TNamed class is the base class for all named ROOT classes.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
A PolyMarker is defined by an array on N points in a 2-D space.
Advanced 2-dimensional spectra processing.
Double_t fResolution
NOT USED resolution of the neighboring peaks
TH1 * fHistogram
resulting histogram
static Int_t fgIterations
Maximum number of decon iterations (default=3)
static void SetDeconIterations(Int_t n=3)
static function: Set max number of decon iterations in deconvolution operation see TSpectrum2::Search...
static TH1 * StaticBackground(const TH1 *hist, Int_t niter=20, Option_t *option="")
static function (called by TH1), interface to TSpectrum2::Background
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.
void SetResolution(Double_t resolution=1)
NOT USED resolution: determines resolution of the neighboring peaks default value is 1 correspond to ...
static Int_t fgAverageWindow
Average window of searched peaks.
Int_t fMaxPeaks
Maximum number of peaks to be found.
@ kBackSuccessiveFiltering
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.
void Print(Option_t *option="") const override
Print the array of positions.
Int_t fNPeaks
number of peaks found
virtual TH1 * Background(const TH1 *hist, Int_t niter=20, Option_t *option="")
This function calculates the background spectrum in the input histogram h.
static void SetAverageWindow(Int_t w=3)
static function: Set average window of searched peaks see TSpectrum2::SearchHighRes
~TSpectrum2() override
Destructor.
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...
Double_t * fPositionY
[fNPeaks] Y position of peaks
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
Double_t * fPosition
[fNPeaks] array of current peak positions
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...
Double_t * fPositionX
[fNPeaks] X position of peaks
void ToLower()
Change string to lower-case.
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.