53#define PEAK_WINDOW 1024
120 Error(
"Background",
"function not yet implemented: h=%s, iter=%d, option=%sn"
121 ,
h->GetName(), number_of_iterations,
option);
130 printf(
"\nNumber of positions = %d\n",
fNPeaks);
168 if (dimension != 3) {
169 Error(
"Search",
"Must be a 3-d histogram");
176 Int_t i, j, k, binx,biny,binz, npeaks;
179 for (i = 0; i < sizex; i++) {
182 for (j = 0; j < sizey; j++) {
185 for (k = 0; k < sizez; k++)
190 npeaks =
SearchHighRes((
const Double_t***)source,
dest, sizex, sizey, sizez,
sigma, 100*threshold,
kTRUE, 3,
kFALSE, 3);
195 for (i = 0; i < npeaks; i++) {
203 for (i = 0; i < sizex; i++) {
204 for (j = 0; j < sizey; j++){
205 delete [] source[i][j];
206 delete []
dest[i][j];
214 if (strstr(
option,
"goff"))
216 if (!npeaks)
return 0;
388 Int_t numberIterationsX,
389 Int_t numberIterationsY,
390 Int_t numberIterationsZ,
394 Int_t i, j,
x,
y, z, sampling, q1, q2, q3;
395 Double_t a,
b,
c,
d, p1, p2, p3, p4, p5, p6, p7, p8,
s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, r1, r2, r3, r4, r5, r6;
396 if (ssizex <= 0 || ssizey <= 0 || ssizez <= 0)
397 return "Wrong parameters";
398 if (numberIterationsX < 1 || numberIterationsY < 1 || numberIterationsZ < 1)
399 return "Width of Clipping Window Must Be Positive";
400 if (ssizex < 2 * numberIterationsX + 1 || ssizey < 2 * numberIterationsY + 1 || ssizey < 2 * numberIterationsZ + 1)
401 return (
"Too Large Clipping Window");
403 for(i=0;i<ssizex;i++){
404 working_space[i] =
new Double_t*[ssizey];
405 for(j=0;j<ssizey;j++)
406 working_space[i][j]=
new Double_t[ssizez];
412 for (i = 1; i <= sampling; i++) {
414 for (z = q3; z < ssizez - q3; z++) {
415 for (
y = q2;
y < ssizey - q2;
y++) {
416 for (
x = q1;
x < ssizex - q1;
x++) {
417 a = spectrum[
x][
y][z];
418 p1 = spectrum[
x + q1][
y + q2][z - q3];
419 p2 = spectrum[
x - q1][
y + q2][z - q3];
420 p3 = spectrum[
x + q1][
y - q2][z - q3];
421 p4 = spectrum[
x - q1][
y - q2][z - q3];
422 p5 = spectrum[
x + q1][
y + q2][z + q3];
423 p6 = spectrum[
x - q1][
y + q2][z + q3];
424 p7 = spectrum[
x + q1][
y - q2][z + q3];
425 p8 = spectrum[
x - q1][
y - q2][z + q3];
426 s1 = spectrum[
x + q1][
y ][z - q3];
427 s2 = spectrum[
x ][
y + q2][z - q3];
428 s3 = spectrum[
x - q1][
y ][z - q3];
429 s4 = spectrum[
x ][
y - q2][z - q3];
430 s5 = spectrum[
x + q1][
y ][z + q3];
431 s6 = spectrum[
x ][
y + q2][z + q3];
432 s7 = spectrum[
x - q1][
y ][z + q3];
433 s8 = spectrum[
x ][
y - q2][z + q3];
434 s9 = spectrum[
x - q1][
y + q2][z ];
435 s10 = spectrum[
x - q1][
y - q2][z ];
436 s11 = spectrum[
x + q1][
y + q2][z ];
437 s12 = spectrum[
x + q1][
y - q2][z ];
438 r1 = spectrum[
x ][
y ][z - q3];
439 r2 = spectrum[
x ][
y ][z + q3];
440 r3 = spectrum[
x - q1][
y ][z ];
441 r4 = spectrum[
x + q1][
y ][z ];
442 r5 = spectrum[
x ][
y + q2][z ];
443 r6 = spectrum[
x ][
y - q2][z ];
480 s1 =
s1 - (p1 + p3) / 2.0;
481 s2 = s2 - (p1 + p2) / 2.0;
482 s3 = s3 - (p2 + p4) / 2.0;
483 s4 = s4 - (p3 + p4) / 2.0;
484 s5 = s5 - (p5 + p7) / 2.0;
485 s6 = s6 - (p5 + p6) / 2.0;
486 s7 = s7 - (p6 + p8) / 2.0;
487 s8 = s8 - (p7 + p8) / 2.0;
488 s9 = s9 - (p2 + p6) / 2.0;
489 s10 = s10 - (p4 + p8) / 2.0;
490 s11 = s11 - (p1 + p5) / 2.0;
491 s12 = s12 - (p3 + p7) / 2.0;
492 b = (
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
495 b = (s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0;
498 b = (s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0;
501 b = (
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0;
504 b = (s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0;
507 b = (s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0;
510 r1 = r1 - ((
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0);
511 r2 = r2 - ((s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0);
512 r3 = r3 - ((s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0);
513 r4 = r4 - ((
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0);
514 r5 = r5 - ((s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0);
515 r6 = r6 - ((s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0);
516 b = (r1 + r2) / 2.0 + (r3 + r4) / 2.0 + (r5 + r6) / 2.0 + (
s1 + s3 + s5 + s7) / 4.0 + (s2 + s4 + s6 + s8) / 4.0 + (s9 + s10 + s11 + s12) / 4.0 + (p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8.0;
519 working_space[
x][
y][z] =
a;
523 for (z = q3; z < ssizez - q3; z++) {
524 for (
y = q2;
y < ssizey - q2;
y++) {
525 for (
x = q1;
x < ssizex - q1;
x++) {
526 spectrum[
x][
y][z] = working_space[
x][
y][z];
534 for (i = 1; i <= sampling; i++) {
536 for (z = q3; z < ssizez - q3; z++) {
537 for (
y = q2;
y < ssizey - q2;
y++) {
538 for (
x = q1;
x < ssizex - q1;
x++) {
539 a = spectrum[
x][
y][z];
540 p1 = spectrum[
x + q1][
y + q2][z - q3];
541 p2 = spectrum[
x - q1][
y + q2][z - q3];
542 p3 = spectrum[
x + q1][
y - q2][z - q3];
543 p4 = spectrum[
x - q1][
y - q2][z - q3];
544 p5 = spectrum[
x + q1][
y + q2][z + q3];
545 p6 = spectrum[
x - q1][
y + q2][z + q3];
546 p7 = spectrum[
x + q1][
y - q2][z + q3];
547 p8 = spectrum[
x - q1][
y - q2][z + q3];
548 s1 = spectrum[
x + q1][
y ][z - q3];
549 s2 = spectrum[
x ][
y + q2][z - q3];
550 s3 = spectrum[
x - q1][
y ][z - q3];
551 s4 = spectrum[
x ][
y - q2][z - q3];
552 s5 = spectrum[
x + q1][
y ][z + q3];
553 s6 = spectrum[
x ][
y + q2][z + q3];
554 s7 = spectrum[
x - q1][
y ][z + q3];
555 s8 = spectrum[
x ][
y - q2][z + q3];
556 s9 = spectrum[
x - q1][
y + q2][z ];
557 s10 = spectrum[
x - q1][
y - q2][z ];
558 s11 = spectrum[
x + q1][
y + q2][z ];
559 s12 = spectrum[
x + q1][
y - q2][z ];
560 r1 = spectrum[
x ][
y ][z - q3];
561 r2 = spectrum[
x ][
y ][z + q3];
562 r3 = spectrum[
x - q1][
y ][z ];
563 r4 = spectrum[
x + q1][
y ][z ];
564 r5 = spectrum[
x ][
y + q2][z ];
565 r6 = spectrum[
x ][
y - q2][z ];
566 b=(p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8 - (
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12) / 4 + (r1 + r2 + r3 + r4 + r5 + r6) / 2;
567 c = -(
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12) / 4 + (r1 + r2 + r3 + r4 + r5 + r6) / 2;
568 d = -(p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8 + (
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12) / 12;
569 if(b < a && b >= 0 &&
c >=0 &&
d >= 0)
571 working_space[
x][
y][z] =
a;
575 for (z = q3; z < ssizez - q3; z++) {
576 for (
y = q2;
y < ssizey - q2;
y++) {
577 for (
x = q1;
x < ssizex - q1;
x++) {
578 spectrum[
x][
y][z] = working_space[
x][
y][z];
588 for (i = sampling; i >= 1; i--) {
590 for (z = q3; z < ssizez - q3; z++) {
591 for (
y = q2;
y < ssizey - q2;
y++) {
592 for (
x = q1;
x < ssizex - q1;
x++) {
593 a = spectrum[
x][
y][z];
594 p1 = spectrum[
x + q1][
y + q2][z - q3];
595 p2 = spectrum[
x - q1][
y + q2][z - q3];
596 p3 = spectrum[
x + q1][
y - q2][z - q3];
597 p4 = spectrum[
x - q1][
y - q2][z - q3];
598 p5 = spectrum[
x + q1][
y + q2][z + q3];
599 p6 = spectrum[
x - q1][
y + q2][z + q3];
600 p7 = spectrum[
x + q1][
y - q2][z + q3];
601 p8 = spectrum[
x - q1][
y - q2][z + q3];
602 s1 = spectrum[
x + q1][
y ][z - q3];
603 s2 = spectrum[
x ][
y + q2][z - q3];
604 s3 = spectrum[
x - q1][
y ][z - q3];
605 s4 = spectrum[
x ][
y - q2][z - q3];
606 s5 = spectrum[
x + q1][
y ][z + q3];
607 s6 = spectrum[
x ][
y + q2][z + q3];
608 s7 = spectrum[
x - q1][
y ][z + q3];
609 s8 = spectrum[
x ][
y - q2][z + q3];
610 s9 = spectrum[
x - q1][
y + q2][z ];
611 s10 = spectrum[
x - q1][
y - q2][z ];
612 s11 = spectrum[
x + q1][
y + q2][z ];
613 s12 = spectrum[
x + q1][
y - q2][z ];
614 r1 = spectrum[
x ][
y ][z - q3];
615 r2 = spectrum[
x ][
y ][z + q3];
616 r3 = spectrum[
x - q1][
y ][z ];
617 r4 = spectrum[
x + q1][
y ][z ];
618 r5 = spectrum[
x ][
y + q2][z ];
619 r6 = spectrum[
x ][
y - q2][z ];
656 s1 =
s1 - (p1 + p3) / 2.0;
657 s2 = s2 - (p1 + p2) / 2.0;
658 s3 = s3 - (p2 + p4) / 2.0;
659 s4 = s4 - (p3 + p4) / 2.0;
660 s5 = s5 - (p5 + p7) / 2.0;
661 s6 = s6 - (p5 + p6) / 2.0;
662 s7 = s7 - (p6 + p8) / 2.0;
663 s8 = s8 - (p7 + p8) / 2.0;
664 s9 = s9 - (p2 + p6) / 2.0;
665 s10 = s10 - (p4 + p8) / 2.0;
666 s11 = s11 - (p1 + p5) / 2.0;
667 s12 = s12 - (p3 + p7) / 2.0;
668 b = (
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
671 b = (s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0;
674 b = (s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0;
677 b = (
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0;
680 b = (s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0;
683 b = (s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0;
686 r1 = r1 - ((
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0);
687 r2 = r2 - ((s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0);
688 r3 = r3 - ((s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0);
689 r4 = r4 - ((
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0);
690 r5 = r5 - ((s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0);
691 r6 = r6 - ((s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0);
692 b = (r1 + r2) / 2.0 + (r3 + r4) / 2.0 + (r5 + r6) / 2.0 + (
s1 + s3 + s5 + s7) / 4.0 + (s2 + s4 + s6 + s8) / 4.0 + (s9 + s10 + s11 + s12) / 4.0 + (p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8.0;
695 working_space[
x][
y][z] =
a;
699 for (z = q3; z < ssizez - q3; z++) {
700 for (
y = q2;
y < ssizey - q2;
y++) {
701 for (
x = q1;
x < ssizex - q1;
x++) {
702 spectrum[
x][
y][z] = working_space[
x][
y][z];
710 for (i = sampling; i >= 1; i--) {
712 for (z = q3; z < ssizez - q3; z++) {
713 for (
y = q2;
y < ssizey - q2;
y++) {
714 for (
x = q1;
x < ssizex - q1;
x++) {
715 a = spectrum[
x][
y][z];
716 p1 = spectrum[
x + q1][
y + q2][z - q3];
717 p2 = spectrum[
x - q1][
y + q2][z - q3];
718 p3 = spectrum[
x + q1][
y - q2][z - q3];
719 p4 = spectrum[
x - q1][
y - q2][z - q3];
720 p5 = spectrum[
x + q1][
y + q2][z + q3];
721 p6 = spectrum[
x - q1][
y + q2][z + q3];
722 p7 = spectrum[
x + q1][
y - q2][z + q3];
723 p8 = spectrum[
x - q1][
y - q2][z + q3];
724 s1 = spectrum[
x + q1][
y ][z - q3];
725 s2 = spectrum[
x ][
y + q2][z - q3];
726 s3 = spectrum[
x - q1][
y ][z - q3];
727 s4 = spectrum[
x ][
y - q2][z - q3];
728 s5 = spectrum[
x + q1][
y ][z + q3];
729 s6 = spectrum[
x ][
y + q2][z + q3];
730 s7 = spectrum[
x - q1][
y ][z + q3];
731 s8 = spectrum[
x ][
y - q2][z + q3];
732 s9 = spectrum[
x - q1][
y + q2][z ];
733 s10 = spectrum[
x - q1][
y - q2][z ];
734 s11 = spectrum[
x + q1][
y + q2][z ];
735 s12 = spectrum[
x + q1][
y - q2][z ];
736 r1 = spectrum[
x ][
y ][z - q3];
737 r2 = spectrum[
x ][
y ][z + q3];
738 r3 = spectrum[
x - q1][
y ][z ];
739 r4 = spectrum[
x + q1][
y ][z ];
740 r5 = spectrum[
x ][
y + q2][z ];
741 r6 = spectrum[
x ][
y - q2][z ];
742 b = (p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8 - (
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12) / 4 + (r1 + r2 + r3 + r4 + r5 + r6) / 2;
743 c = -(
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12) / 4+(r1 + r2 + r3 + r4 + r5 + r6) / 2;
744 d = -(p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8)/8 + (
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12) / 12;
745 if(b < a && b >= 0 &&
c >=0 &&
d >= 0)
747 working_space[
x][
y][z] =
a;
751 for (z = q3; z < ssizez - q3; z++) {
752 for (
y = q2;
y < ssizey - q2;
y++) {
753 for (
x = q1;
x < ssizex - q1;
x++) {
754 spectrum[
x][
y][z] = working_space[
x][
y][z];
761 for(i = 0;i < ssizex; i++){
762 for(j = 0;j < ssizey; j++)
763 delete[] working_space[i][j];
764 delete[] working_space[i];
766 delete[] working_space;
865 Double_t nom,nip,nim,sp,sm,spx,smx,spy,smy,spz,smz,plocha=0;
867 return "Averaging Window must be positive";
869 for(i = 0;i < ssizex; i++){
870 working_space[i] =
new Double_t*[ssizey];
871 for(j = 0;j < ssizey; j++)
872 working_space[i][j] =
new Double_t[ssizez];
880 for(i = 0,maxch = 0;i < ssizex; i++){
881 for(j = 0;j < ssizey; j++){
882 for(k = 0;k < ssizez; k++){
883 working_space[i][j][k] = 0;
884 if(maxch < source[i][j][k])
885 maxch = source[i][j][k];
886 plocha += source[i][j][k];
891 for(i = 0;i < ssizex; i++){
892 for(j = 0;j < ssizey; j++)
893 delete[] working_space[i][j];
894 delete[] working_space[i];
896 delete [] working_space;
901 working_space[
xmin][
ymin][zmin] = 1;
903 nip = source[i][
ymin][zmin] / maxch;
904 nim = source[i + 1][
ymin][zmin] / maxch;
906 for(
l = 1;
l <= averWindow;
l++){
911 a = source[i +
l][
ymin][zmin] / maxch;
927 a = source[i -
l + 1][
ymin][zmin] / maxch;
941 a = working_space[i + 1][
ymin][zmin] =
a * working_space[i][
ymin][zmin];
945 nip = source[
xmin][i][zmin] / maxch;
946 nim = source[
xmin][i + 1][zmin] / maxch;
948 for(
l = 1;
l <= averWindow;
l++){
953 a = source[
xmin][i +
l][zmin] / maxch;
969 a = source[
xmin][i -
l + 1][zmin] / maxch;
983 a = working_space[
xmin][i + 1][zmin] =
a * working_space[
xmin][i][zmin];
986 for(i = zmin;i < zmax; i++){
987 nip = source[
xmin][
ymin][i] / maxch;
988 nim = source[
xmin][
ymin][i + 1] / maxch;
990 for(
l = 1;
l <= averWindow;
l++){
1007 if(i -
l + 1 < zmin)
1029 nip = source[i][j + 1][zmin] / maxch;
1030 nim = source[i + 1][j + 1][zmin] / maxch;
1032 for(
l = 1;
l <= averWindow;
l++){
1034 a = source[
xmax][j][zmin] / maxch;
1037 a = source[i +
l][j][zmin] / maxch;
1049 if(i -
l + 1 <
xmin)
1050 a = source[
xmin][j][zmin] / maxch;
1053 a = source[i -
l + 1][j][zmin] / maxch;
1067 nip = source[i + 1][j][zmin] / maxch;
1068 nim = source[i + 1][j + 1][zmin] / maxch;
1069 for(
l = 1;
l <= averWindow;
l++){
1071 a = source[i][
ymax][zmin] / maxch;
1074 a = source[i][j +
l][zmin] / maxch;
1086 if(j -
l + 1 <
ymin)
1087 a = source[i][
ymin][zmin] / maxch;
1090 a = source[i][j -
l + 1][zmin] / maxch;
1103 a = (spx * working_space[i][j + 1][zmin] + spy * working_space[i + 1][j][zmin]) / (smx + smy);
1104 working_space[i + 1][j + 1][zmin] =
a;
1109 for(j = zmin;j < zmax; j++){
1110 nip = source[i][
ymin][j + 1] / maxch;
1111 nim = source[i + 1][
ymin][j + 1] / maxch;
1113 for(
l = 1;
l <= averWindow;
l++){
1118 a = source[i +
l][
ymin][j] / maxch;
1130 if(i -
l + 1 <
xmin)
1134 a = source[i -
l + 1][
ymin][j] / maxch;
1148 nip = source[i + 1][
ymin][j] / maxch;
1149 nim = source[i + 1][
ymin][j + 1] / maxch;
1150 for(
l = 1;
l <= averWindow;
l++){
1152 a = source[i][
ymin][zmax] / maxch;
1155 a = source[i][
ymin][j +
l] / maxch;
1167 if(j -
l + 1 < zmin)
1168 a = source[i][
ymin][zmin] / maxch;
1171 a = source[i][
ymin][j -
l + 1] / maxch;
1184 a = (spx * working_space[i][
ymin][j + 1] + spz * working_space[i + 1][
ymin][j]) / (smx + smz);
1185 working_space[i + 1][
ymin][j + 1] =
a;
1190 for(j = zmin;j < zmax; j++){
1191 nip = source[
xmin][i][j + 1] / maxch;
1192 nim = source[
xmin][i + 1][j + 1] / maxch;
1194 for(
l = 1;
l <= averWindow;
l++){
1199 a = source[
xmin][i +
l][j] / maxch;
1211 if(i -
l + 1 <
ymin)
1215 a = source[
xmin][i -
l + 1][j] / maxch;
1229 nip = source[
xmin][i + 1][j] / maxch;
1230 nim = source[
xmin][i + 1][j + 1] / maxch;
1231 for(
l = 1;
l <= averWindow;
l++){
1233 a = source[
xmin][i][zmax] / maxch;
1236 a = source[
xmin][i][j +
l] / maxch;
1248 if(j -
l + 1 < zmin)
1249 a = source[
xmin][i][zmin] / maxch;
1252 a = source[
xmin][i][j -
l + 1] / maxch;
1265 a = (spy * working_space[
xmin][i][j + 1] + spz * working_space[
xmin][i + 1][j]) / (smy + smz);
1266 working_space[
xmin][i + 1][j + 1] =
a;
1272 for(k = zmin;k < zmax; k++){
1273 nip = source[i][j + 1][k + 1] / maxch;
1274 nim = source[i + 1][j + 1][k + 1] / maxch;
1276 for(
l = 1;
l <= averWindow;
l++){
1278 a = source[
xmax][j][k] / maxch;
1281 a = source[i +
l][j][k] / maxch;
1293 if(i -
l + 1 <
xmin)
1294 a = source[
xmin][j][k] / maxch;
1297 a = source[i -
l + 1][j][k] / maxch;
1311 nip = source[i + 1][j][k + 1] / maxch;
1312 nim = source[i + 1][j + 1][k + 1] / maxch;
1313 for(
l = 1;
l <= averWindow;
l++){
1315 a = source[i][
ymax][k] / maxch;
1318 a = source[i][j +
l][k] / maxch;
1330 if(j -
l + 1 <
ymin)
1331 a = source[i][
ymin][k] / maxch;
1334 a = source[i][j -
l + 1][k] / maxch;
1348 nip = source[i + 1][j + 1][k] / maxch;
1349 nim = source[i + 1][j + 1][k + 1] / maxch;
1350 for(
l = 1;
l <= averWindow;
l++){
1352 a = source[i][j][zmax] / maxch;
1355 a = source[i][j][k +
l] / maxch;
1367 if(j -
l + 1 <
ymin)
1368 a = source[i][j][zmin] / maxch;
1371 a = source[i][j][k -
l + 1] / maxch;
1384 a = (spx * working_space[i][j + 1][k + 1] + spy * working_space[i + 1][j][k + 1] + spz * working_space[i + 1][j + 1][k]) / (smx + smy + smz);
1385 working_space[i + 1][j + 1][k + 1] =
a;
1392 for(k = zmin;k <= zmax; k++){
1393 working_space[i][j][k] = working_space[i][j][k] / nom;
1397 for(i = 0;i < ssizex; i++){
1398 for(j = 0;j < ssizey; j++){
1399 for(k = 0;k < ssizez; k++){
1400 source[i][j][k] = plocha * working_space[i][j][k];
1404 for(i = 0;i < ssizex; i++){
1405 for(j = 0;j < ssizey; j++)
1406 delete[] working_space[i][j];
1407 delete[] working_space[i];
1409 delete[] working_space;
1601 Int_t numberIterations,
1602 Int_t numberRepetitions,
1605 Int_t i, j, k, lhx, lhy, lhz, i1, i2, i3, j1, j2, j3, k1, k2, k3, lindex, i1min, i1max, i2min, i2max, i3min, i3max, j1min, j1max, j2min, j2max, j3min, j3max, positx = 0, posity = 0, positz = 0, repet;
1606 Double_t lda, ldb, ldc, area, maximum = 0;
1607 if (ssizex <= 0 || ssizey <= 0 || ssizez <= 0)
1608 return "Wrong parameters";
1609 if (numberIterations <= 0)
1610 return "Number of iterations must be positive";
1611 if (numberRepetitions <= 0)
1612 return "Number of repetitions must be positive";
1614 for(i=0;i<ssizex;i++){
1615 working_space[i]=
new Double_t* [ssizey];
1616 for(j=0;j<ssizey;j++)
1617 working_space[i][j]=
new Double_t [5*ssizez];
1620 lhx = -1, lhy = -1, lhz = -1;
1621 for (i = 0; i < ssizex; i++) {
1622 for (j = 0; j < ssizey; j++) {
1623 for (k = 0; k < ssizez; k++) {
1624 lda = resp[i][j][k];
1633 working_space[i][j][k] = lda;
1635 if (lda > maximum) {
1637 positx = i, posity = j, positz = k;
1642 if (lhx == -1 || lhy == -1 || lhz == -1) {
1643 for(i = 0;i < ssizex; i++){
1644 for(j = 0;j < ssizey; j++)
1645 delete[] working_space[i][j];
1646 delete[] working_space[i];
1648 delete [] working_space;
1649 return (
"Zero response data");
1653 for (i3 = 0; i3 < ssizez; i3++) {
1654 for (i2 = 0; i2 < ssizey; i2++) {
1655 for (i1 = 0; i1 < ssizex; i1++) {
1657 for (j3 = 0; j3 <= (lhz - 1); j3++) {
1658 for (j2 = 0; j2 <= (lhy - 1); j2++) {
1659 for (j1 = 0; j1 <= (lhx - 1); j1++) {
1660 k3 = i3 + j3, k2 = i2 + j2, k1 = i1 + j1;
1661 if (k3 >= 0 && k3 < ssizez && k2 >= 0 && k2 < ssizey && k1 >= 0 && k1 < ssizex) {
1662 lda = working_space[j1][j2][j3];
1663 ldb = source[k1][k2][k3];
1664 ldc = ldc + lda * ldb;
1669 working_space[i1][i2][i3 + ssizez] = ldc;
1675 i1min = -(lhx - 1), i1max = lhx - 1;
1676 i2min = -(lhy - 1), i2max = lhy - 1;
1677 i3min = -(lhz - 1), i3max = lhz - 1;
1678 for (i3 = i3min; i3 <= i3max; i3++) {
1679 for (i2 = i2min; i2 <= i2max; i2++) {
1680 for (i1 = i1min; i1 <= i1max; i1++) {
1685 j3max = lhz - 1 - i3;
1686 if (j3max > lhz - 1)
1688 for (j3 = j3min; j3 <= j3max; j3++) {
1692 j2max = lhy - 1 - i2;
1693 if (j2max > lhy - 1)
1695 for (j2 = j2min; j2 <= j2max; j2++) {
1699 j1max = lhx - 1 - i1;
1700 if (j1max > lhx - 1)
1702 for (j1 = j1min; j1 <= j1max; j1++) {
1703 lda = working_space[j1][j2][j3];
1704 if (i1 + j1 < ssizex && i2 + j2 < ssizey)
1705 ldb = working_space[i1 + j1][i2 + j2][i3 + j3];
1708 ldc = ldc + lda * ldb;
1712 working_space[i1 - i1min][i2 - i2min][i3 - i3min + 2 * ssizez ] = ldc;
1718 for (i3 = 0; i3 < ssizez; i3++) {
1719 for (i2 = 0; i2 < ssizey; i2++) {
1720 for (i1 = 0; i1 < ssizex; i1++) {
1721 working_space[i1][i2][i3 + 3 * ssizez] = 1;
1722 working_space[i1][i2][i3 + 4 * ssizez] = 0;
1728 for (repet = 0; repet < numberRepetitions; repet++) {
1730 for (i = 0; i < ssizex; i++) {
1731 for (j = 0; j < ssizey; j++) {
1732 for (k = 0; k < ssizez; k++) {
1733 working_space[i][j][k + 3 * ssizez] =
TMath::Power(working_space[i][j][k + 3 * ssizez],boost);
1738 for (lindex = 0; lindex < numberIterations; lindex++) {
1739 for (i3 = 0; i3 < ssizez; i3++) {
1740 for (i2 = 0; i2 < ssizey; i2++) {
1741 for (i1 = 0; i1 < ssizex; i1++) {
1744 if (j3min > lhz - 1)
1747 j3max = ssizez - i3 - 1;
1748 if (j3max > lhz - 1)
1751 if (j2min > lhy - 1)
1754 j2max = ssizey - i2 - 1;
1755 if (j2max > lhy - 1)
1758 if (j1min > lhx - 1)
1761 j1max = ssizex - i1 - 1;
1762 if (j1max > lhx - 1)
1764 for (j3 = j3min; j3 <= j3max; j3++) {
1765 for (j2 = j2min; j2 <= j2max; j2++) {
1766 for (j1 = j1min; j1 <= j1max; j1++) {
1767 ldc = working_space[j1 - i1min][j2 - i2min][j3 - i3min + 2 * ssizez];
1768 lda = working_space[i1 + j1][i2 + j2][i3 + j3 + 3 * ssizez];
1769 ldb = ldb + lda * ldc;
1773 lda = working_space[i1][i2][i3 + 3 * ssizez];
1774 ldc = working_space[i1][i2][i3 + 1 * ssizez];
1775 if (ldc * lda != 0 && ldb != 0) {
1776 lda = lda * ldc / ldb;
1781 working_space[i1][i2][i3 + 4 * ssizez] = lda;
1785 for (i3 = 0; i3 < ssizez; i3++) {
1786 for (i2 = 0; i2 < ssizey; i2++) {
1787 for (i1 = 0; i1 < ssizex; i1++)
1788 working_space[i1][i2][i3 + 3 * ssizez] = working_space[i1][i2][i3 + 4 * ssizez];
1793 for (i = 0; i < ssizex; i++) {
1794 for (j = 0; j < ssizey; j++){
1795 for (k = 0; k < ssizez; k++)
1796 source[(i + positx) % ssizex][(j + posity) % ssizey][(k + positz) % ssizez] = area * working_space[i][j][k + 3 * ssizez];
1799 for(i = 0;i < ssizex; i++){
1800 for(j = 0;j < ssizey; j++)
1801 delete[] working_space[i][j];
1802 delete[] working_space[i];
1804 delete [] working_space;
1957 Int_t xmin,
xmax,
l,peak_index = 0,sizex_ext=ssizex + 4 * number_of_iterations,sizey_ext = ssizey + 4 * number_of_iterations,sizez_ext = ssizez + 4 * number_of_iterations,shift = 2 * number_of_iterations;
1960 Double_t nom,nip,nim,sp,sm,spx,spy,smx,smy,spz,smz;
1961 Double_t p1,p2,p3,p4,p5,p6,p7,p8,
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,r1,r2,r3,r4,r5,r6;
1964 Int_t lhx,lhy,lhz,i1,i2,i3,j1,j2,j3,k1,k2,k3,i1min,i1max,i2min,i2max,i3min,i3max,j1min,j1max,j2min,j2max,j3min,j3max,positx,posity,positz;
1966 Error(
"SearchHighRes",
"Invalid sigma, must be greater than or equal to 1");
1970 if(threshold<=0||threshold>=100){
1971 Error(
"SearchHighRes",
"Invalid threshold, must be positive and less than 100");
1977 Error(
"SearchHighRes",
"Too large sigma");
1981 if (markov ==
true) {
1982 if (averWindow <= 0) {
1983 Error(
"SearchHighRes",
"Averaging window must be positive");
1988 if(backgroundRemove ==
true){
1989 if(sizex_ext < 2 * number_of_iterations + 1 || sizey_ext < 2 * number_of_iterations + 1 || sizez_ext < 2 * number_of_iterations + 1){
1990 Error(
"SearchHighRes",
"Too large clipping window");
1998 for(j = 0;j < ssizex + i; j++){
1999 working_space[j] =
new Double_t* [ssizey + i];
2000 for(k = 0;k < ssizey + i; k++)
2001 working_space[j][k] =
new Double_t [5 * (ssizez + i)];
2003 for(k = 0;k < sizez_ext; k++){
2004 for(j = 0;j < sizey_ext; j++){
2005 for(i = 0;i < sizex_ext; i++){
2009 working_space[i][j][k + sizez_ext] = source[0][0][0];
2011 else if(k >= ssizez + shift)
2012 working_space[i][j][k + sizez_ext] = source[0][0][ssizez - 1];
2015 working_space[i][j][k + sizez_ext] = source[0][0][k - shift];
2018 else if(j >= ssizey + shift){
2020 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][0];
2022 else if(k >= ssizez + shift)
2023 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][ssizez - 1];
2026 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][k - shift];
2031 working_space[i][j][k + sizez_ext] = source[0][j - shift][0];
2033 else if(k >= ssizez + shift)
2034 working_space[i][j][k + sizez_ext] = source[0][j - shift][ssizez - 1];
2037 working_space[i][j][k + sizez_ext] = source[0][j - shift][k - shift];
2041 else if(i >= ssizex + shift){
2044 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][0];
2046 else if(k >= ssizez + shift)
2047 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][ssizez - 1];
2050 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][k - shift];
2053 else if(j >= ssizey + shift){
2055 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][0];
2057 else if(k >= ssizez + shift)
2058 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][ssizez - 1];
2061 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][k - shift];
2066 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][0];
2068 else if(k >= ssizez + shift)
2069 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][ssizez - 1];
2072 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][k - shift];
2079 working_space[i][j][k + sizez_ext] = source[i - shift][0][0];
2081 else if(k >= ssizez + shift)
2082 working_space[i][j][k + sizez_ext] = source[i - shift][0][ssizez - 1];
2085 working_space[i][j][k + sizez_ext] = source[i - shift][0][k - shift];
2088 else if(j >= ssizey + shift){
2090 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][0];
2092 else if(k >= ssizez + shift)
2093 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][ssizez - 1];
2096 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][k - shift];
2101 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][0];
2103 else if(k >= ssizez + shift)
2104 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][ssizez - 1];
2107 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][k - shift];
2113 if(backgroundRemove ==
true){
2114 for(i = 1;i <= number_of_iterations; i++){
2115 for(z = i;z < sizez_ext - i; z++){
2116 for(
y = i;
y < sizey_ext - i;
y++){
2117 for(
x = i;
x < sizex_ext - i;
x++){
2118 a = working_space[
x][
y][z + sizez_ext];
2119 p1 = working_space[
x + i][
y + i][z - i + sizez_ext];
2120 p2 = working_space[
x - i][
y + i][z - i + sizez_ext];
2121 p3 = working_space[
x + i][
y - i][z - i + sizez_ext];
2122 p4 = working_space[
x - i][
y - i][z - i + sizez_ext];
2123 p5 = working_space[
x + i][
y + i][z + i + sizez_ext];
2124 p6 = working_space[
x - i][
y + i][z + i + sizez_ext];
2125 p7 = working_space[
x + i][
y - i][z + i + sizez_ext];
2126 p8 = working_space[
x - i][
y - i][z + i + sizez_ext];
2127 s1 = working_space[
x + i][
y ][z - i + sizez_ext];
2128 s2 = working_space[
x ][
y + i][z - i + sizez_ext];
2129 s3 = working_space[
x - i][
y ][z - i + sizez_ext];
2130 s4 = working_space[
x ][
y - i][z - i + sizez_ext];
2131 s5 = working_space[
x + i][
y ][z + i + sizez_ext];
2132 s6 = working_space[
x ][
y + i][z + i + sizez_ext];
2133 s7 = working_space[
x - i][
y ][z + i + sizez_ext];
2134 s8 = working_space[
x ][
y - i][z + i + sizez_ext];
2135 s9 = working_space[
x - i][
y + i][z + sizez_ext];
2136 s10 = working_space[
x - i][
y - i][z +sizez_ext];
2137 s11 = working_space[
x + i][
y + i][z +sizez_ext];
2138 s12 = working_space[
x + i][
y - i][z +sizez_ext];
2139 r1 = working_space[
x ][
y ][z - i + sizez_ext];
2140 r2 = working_space[
x ][
y ][z + i + sizez_ext];
2141 r3 = working_space[
x - i][
y ][z + sizez_ext];
2142 r4 = working_space[
x + i][
y ][z + sizez_ext];
2143 r5 = working_space[
x ][
y + i][z + sizez_ext];
2144 r6 = working_space[
x ][
y - i][z + sizez_ext];
2145 b = (p1 + p3) / 2.0;
2149 b = (p1 + p2) / 2.0;
2153 b = (p2 + p4) / 2.0;
2157 b = (p3 + p4) / 2.0;
2161 b = (p5 + p7) / 2.0;
2165 b = (p5 + p6) / 2.0;
2169 b = (p6 + p8) / 2.0;
2173 b = (p7 + p8) / 2.0;
2177 b = (p2 + p6) / 2.0;
2181 b = (p4 + p8) / 2.0;
2185 b = (p1 + p5) / 2.0;
2189 b = (p3 + p7) / 2.0;
2193 s1 =
s1 - (p1 + p3) / 2.0;
2194 s2 = s2 - (p1 + p2) / 2.0;
2195 s3 = s3 - (p2 + p4) / 2.0;
2196 s4 = s4 - (p3 + p4) / 2.0;
2197 s5 = s5 - (p5 + p7) / 2.0;
2198 s6 = s6 - (p5 + p6) / 2.0;
2199 s7 = s7 - (p6 + p8) / 2.0;
2200 s8 = s8 - (p7 + p8) / 2.0;
2201 s9 = s9 - (p2 + p6) / 2.0;
2202 s10 = s10 - (p4 + p8) / 2.0;
2203 s11 = s11 - (p1 + p5) / 2.0;
2204 s12 = s12 - (p3 + p7) / 2.0;
2205 b = (
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
2209 b = (s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0;
2213 b = (s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0;
2217 b = (
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0;
2221 b = (s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0;
2225 b = (s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0;
2229 r1 = r1 - ((
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0);
2230 r2 = r2 - ((s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0);
2231 r3 = r3 - ((s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0);
2232 r4 = r4 - ((
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0);
2233 r5 = r5 - ((s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0);
2234 r6 = r6 - ((s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0);
2235 b = (r1 + r2) / 2.0 + (r3 + r4) / 2.0 + (r5 + r6) / 2.0 + (
s1 + s3 + s5 + s7) / 4.0 + (s2 + s4 + s6 + s8) / 4.0 + (s9 + s10 + s11 + s12) / 4.0 + (p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8.0;
2239 working_space[
x][
y][z] =
a;
2243 for(z = i;z < sizez_ext - i; z++){
2244 for(
y = i;
y < sizey_ext - i;
y++){
2245 for(
x = i;
x < sizex_ext - i;
x++){
2246 working_space[
x][
y][z + sizez_ext] = working_space[
x][
y][z];
2251 for(k = 0;k < sizez_ext; k++){
2252 for(j = 0;j < sizey_ext; j++){
2253 for(i = 0;i < sizex_ext; i++){
2257 working_space[i][j][k + sizez_ext] = source[0][0][0] - working_space[i][j][k + sizez_ext];
2259 else if(k >= ssizez + shift)
2260 working_space[i][j][k + sizez_ext] = source[0][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
2263 working_space[i][j][k + sizez_ext] = source[0][0][k - shift] - working_space[i][j][k + sizez_ext];
2266 else if(j >= ssizey + shift){
2268 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
2270 else if(k >= ssizez + shift)
2271 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
2274 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
2279 working_space[i][j][k + sizez_ext] = source[0][j - shift][0] - working_space[i][j][k + sizez_ext];
2281 else if(k >= ssizez + shift)
2282 working_space[i][j][k + sizez_ext] = source[0][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
2285 working_space[i][j][k + sizez_ext] = source[0][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
2289 else if(i >= ssizex + shift){
2292 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][0] - working_space[i][j][k + sizez_ext];
2294 else if(k >= ssizez + shift)
2295 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
2298 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][k - shift] - working_space[i][j][k + sizez_ext];
2301 else if(j >= ssizey + shift){
2303 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
2305 else if(k >= ssizez + shift)
2306 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
2309 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
2314 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][0] - working_space[i][j][k + sizez_ext];
2316 else if(k >= ssizez + shift)
2317 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
2320 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
2327 working_space[i][j][k + sizez_ext] = source[i - shift][0][0] - working_space[i][j][k + sizez_ext];
2329 else if(k >= ssizez + shift)
2330 working_space[i][j][k + sizez_ext] = source[i - shift][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
2333 working_space[i][j][k + sizez_ext] = source[i - shift][0][k - shift] - working_space[i][j][k + sizez_ext];
2336 else if(j >= ssizey + shift){
2338 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
2340 else if(k >= ssizez + shift)
2341 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
2344 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
2349 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][0] - working_space[i][j][k + sizez_ext];
2351 else if(k >= ssizez + shift)
2352 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
2355 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
2364 for(i = 0;i < sizex_ext; i++){
2365 for(j = 0;j < sizey_ext; j++){
2366 for(k = 0;k < sizez_ext; k++){
2367 working_space[i][j][k + 2 * sizez_ext] = working_space[i][j][sizez_ext + k];
2368 plocha_markov = plocha_markov + working_space[i][j][sizez_ext + k];
2373 xmax = sizex_ext - 1;
2375 ymax = sizey_ext - 1;
2377 zmax = sizez_ext - 1;
2378 for(i = 0,maxch = 0;i < sizex_ext; i++){
2379 for(j = 0;j < sizey_ext;j++){
2380 for(k = 0;k < sizez_ext;k++){
2381 working_space[i][j][k] = 0;
2382 if(maxch < working_space[i][j][k + 2 * sizez_ext])
2383 maxch = working_space[i][j][k + 2 * sizez_ext];
2390 for(i = 0;i < ssizex + k; i++){
2391 for(j = 0;j < ssizey + k; j++)
2392 delete[] working_space[i][j];
2393 delete[] working_space[i];
2395 delete [] working_space;
2399 working_space[
xmin][
ymin][zmin] = 1;
2401 nip = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
2402 nim = working_space[i + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
2404 for(
l = 1;
l <= averWindow;
l++){
2406 a = working_space[
xmax][
ymin][zmin + 2 * sizez_ext] / maxch;
2409 a = working_space[i +
l][
ymin][zmin + 2 * sizez_ext] / maxch;
2421 if(i -
l + 1 <
xmin)
2422 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
2425 a = working_space[i -
l + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
2439 a = working_space[i + 1][
ymin][zmin] =
a * working_space[i][
ymin][zmin];
2443 nip = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
2444 nim = working_space[
xmin][i + 1][zmin + 2 * sizez_ext] / maxch;
2446 for(
l = 1;
l <= averWindow;
l++){
2448 a = working_space[
xmin][
ymax][zmin + 2 * sizez_ext] / maxch;
2451 a = working_space[
xmin][i +
l][zmin + 2 * sizez_ext] / maxch;
2463 if(i -
l + 1 <
ymin)
2464 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
2467 a = working_space[
xmin][i -
l + 1][zmin + 2 * sizez_ext] / maxch;
2481 a = working_space[
xmin][i + 1][zmin] =
a * working_space[
xmin][i][zmin];
2484 for(i = zmin;i < zmax;i++){
2485 nip = working_space[
xmin][
ymin][i + 2 * sizez_ext] / maxch;
2486 nim = working_space[
xmin][
ymin][i + 1 + 2 * sizez_ext] / maxch;
2488 for(
l = 1;
l <= averWindow;
l++){
2490 a = working_space[
xmin][
ymin][zmax + 2 * sizez_ext] / maxch;
2493 a = working_space[
xmin][
ymin][i +
l + 2 * sizez_ext] / maxch;
2505 if(i -
l + 1 < zmin)
2506 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
2509 a = working_space[
xmin][
ymin][i -
l + 1 + 2 * sizez_ext] / maxch;
2528 nip = working_space[i][j + 1][zmin + 2 * sizez_ext] / maxch;
2529 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
2531 for(
l = 1;
l <= averWindow;
l++){
2533 a = working_space[
xmax][j][zmin + 2 * sizez_ext] / maxch;
2536 a = working_space[i +
l][j][zmin + 2 * sizez_ext] / maxch;
2548 if(i -
l + 1 <
xmin)
2549 a = working_space[
xmin][j][zmin + 2 * sizez_ext] / maxch;
2552 a = working_space[i -
l + 1][j][zmin + 2 * sizez_ext] / maxch;
2566 nip = working_space[i + 1][j][zmin + 2 * sizez_ext] / maxch;
2567 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
2568 for(
l = 1;
l <= averWindow;
l++){
2570 a = working_space[i][
ymax][zmin + 2 * sizez_ext] / maxch;
2573 a = working_space[i][j +
l][zmin + 2 * sizez_ext] / maxch;
2585 if(j -
l + 1 <
ymin)
2586 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
2589 a = working_space[i][j -
l + 1][zmin + 2 * sizez_ext] / maxch;
2602 a = (spx * working_space[i][j + 1][zmin] + spy * working_space[i + 1][j][zmin]) / (smx + smy);
2603 working_space[i + 1][j + 1][zmin] =
a;
2608 for(j = zmin;j < zmax;j++){
2609 nip = working_space[i][
ymin][j + 1 + 2 * sizez_ext] / maxch;
2610 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
2612 for(
l = 1;
l <= averWindow;
l++){
2614 a = working_space[
xmax][
ymin][j + 2 * sizez_ext] / maxch;
2617 a = working_space[i +
l][
ymin][j + 2 * sizez_ext] / maxch;
2629 if(i -
l + 1 <
xmin)
2630 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
2633 a = working_space[i -
l + 1][
ymin][j + 2 * sizez_ext] / maxch;
2647 nip = working_space[i + 1][
ymin][j + 2 * sizez_ext] / maxch;
2648 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
2649 for(
l = 1;
l <= averWindow;
l++){
2651 a = working_space[i][
ymin][zmax + 2 * sizez_ext] / maxch;
2654 a = working_space[i][
ymin][j +
l + 2 * sizez_ext] / maxch;
2666 if(j -
l + 1 < zmin)
2667 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
2670 a = working_space[i][
ymin][j -
l + 1 + 2 * sizez_ext] / maxch;
2683 a = (spx * working_space[i][
ymin][j + 1] + spz * working_space[i + 1][
ymin][j]) / (smx + smz);
2684 working_space[i + 1][
ymin][j + 1] =
a;
2689 for(j = zmin;j < zmax;j++){
2690 nip = working_space[
xmin][i][j + 1 + 2 * sizez_ext] / maxch;
2691 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
2693 for(
l = 1;
l <= averWindow;
l++){
2695 a = working_space[
xmin][
ymax][j + 2 * sizez_ext] / maxch;
2698 a = working_space[
xmin][i +
l][j + 2 * sizez_ext] / maxch;
2710 if(i -
l + 1 <
ymin)
2711 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
2714 a = working_space[
xmin][i -
l + 1][j + 2 * sizez_ext] / maxch;
2728 nip = working_space[
xmin][i + 1][j + 2 * sizez_ext] / maxch;
2729 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
2730 for(
l = 1;
l <= averWindow;
l++){
2732 a = working_space[
xmin][i][zmax + 2 * sizez_ext] / maxch;
2735 a = working_space[
xmin][i][j +
l + 2 * sizez_ext] / maxch;
2747 if(j -
l + 1 < zmin)
2748 a = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
2751 a = working_space[
xmin][i][j -
l + 1 + 2 * sizez_ext] / maxch;
2764 a = (spy * working_space[
xmin][i][j + 1] + spz * working_space[
xmin][i + 1][j]) / (smy + smz);
2765 working_space[
xmin][i + 1][j + 1] =
a;
2771 for(k = zmin;k < zmax; k++){
2772 nip = working_space[i][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2773 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2775 for(
l = 1;
l <= averWindow;
l++){
2777 a = working_space[
xmax][j][k + 2 * sizez_ext] / maxch;
2780 a = working_space[i +
l][j][k + 2 * sizez_ext] / maxch;
2792 if(i -
l + 1 <
xmin)
2793 a = working_space[
xmin][j][k + 2 * sizez_ext] / maxch;
2796 a = working_space[i -
l + 1][j][k + 2 * sizez_ext] / maxch;
2810 nip = working_space[i + 1][j][k + 1 + 2 * sizez_ext] / maxch;
2811 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2812 for(
l = 1;
l <= averWindow;
l++){
2814 a = working_space[i][
ymax][k + 2 * sizez_ext] / maxch;
2817 a = working_space[i][j +
l][k + 2 * sizez_ext] / maxch;
2829 if(j -
l + 1 <
ymin)
2830 a = working_space[i][
ymin][k + 2 * sizez_ext] / maxch;
2833 a = working_space[i][j -
l + 1][k + 2 * sizez_ext] / maxch;
2847 nip = working_space[i + 1][j + 1][k + 2 * sizez_ext] / maxch;
2848 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2849 for(
l = 1;
l <= averWindow;
l++ ){
2851 a = working_space[i][j][zmax + 2 * sizez_ext] / maxch;
2854 a = working_space[i][j][k +
l + 2 * sizez_ext] / maxch;
2866 if(j -
l + 1 <
ymin)
2867 a = working_space[i][j][zmin + 2 * sizez_ext] / maxch;
2870 a = working_space[i][j][k -
l + 1 + 2 * sizez_ext] / maxch;
2883 a = (spx * working_space[i][j + 1][k + 1] + spy * working_space[i + 1][j][k + 1] + spz * working_space[i + 1][j + 1][k]) / (smx + smy + smz);
2884 working_space[i + 1][j + 1][k + 1] =
a;
2892 for(k = zmin;k <= zmax; k++){
2893 working_space[i][j][k] = working_space[i][j][k] / nom;
2894 a+=working_space[i][j][k];
2898 for(i = 0;i < sizex_ext; i++){
2899 for(j = 0;j < sizey_ext; j++){
2900 for(k = 0;k < sizez_ext; k++){
2901 working_space[i][j][k + sizez_ext] = working_space[i][j][k] * plocha_markov /
a;
2908 lhx = -1,lhy = -1,lhz = -1;
2909 positx = 0,posity = 0,positz = 0;
2912 for(i = 0;i < sizex_ext; i++){
2913 for(j = 0;j < sizey_ext; j++){
2914 for(k = 0;k < sizez_ext; k++){
2918 lda = (lda * lda + ldb * ldb + ldc * ldc) / (2 *
sigma *
sigma);
2919 l = (
Int_t)(1000 * exp(-lda));
2931 working_space[i][j][k] = lda;
2935 positx = i,posity = j,positz = k;
2941 for(i = 0;i < sizex_ext; i++){
2942 for(j = 0;j < sizey_ext; j++){
2943 for(k = 0;k < sizez_ext; k++){
2944 working_space[i][j][k + 2 * sizez_ext] =
TMath::Abs(working_space[i][j][k + sizez_ext]);
2949 for (i3 = 0; i3 < sizez_ext; i3++) {
2950 for (i2 = 0; i2 < sizey_ext; i2++) {
2951 for (i1 = 0; i1 < sizex_ext; i1++) {
2953 for (j3 = 0; j3 <= (lhz - 1); j3++) {
2954 for (j2 = 0; j2 <= (lhy - 1); j2++) {
2955 for (j1 = 0; j1 <= (lhx - 1); j1++) {
2956 k3 = i3 + j3, k2 = i2 + j2, k1 = i1 + j1;
2957 if (k3 >= 0 && k3 < sizez_ext && k2 >= 0 && k2 < sizey_ext && k1 >= 0 && k1 < sizex_ext) {
2958 lda = working_space[j1][j2][j3];
2959 ldb = working_space[k1][k2][k3+2*sizez_ext];
2960 ldc = ldc + lda * ldb;
2965 working_space[i1][i2][i3 + sizez_ext] = ldc;
2970 i1min = -(lhx - 1), i1max = lhx - 1;
2971 i2min = -(lhy - 1), i2max = lhy - 1;
2972 i3min = -(lhz - 1), i3max = lhz - 1;
2973 for (i3 = i3min; i3 <= i3max; i3++) {
2974 for (i2 = i2min; i2 <= i2max; i2++) {
2975 for (i1 = i1min; i1 <= i1max; i1++) {
2981 j3max = lhz - 1 - i3;
2982 if (j3max > lhz - 1)
2985 for (j3 = j3min; j3 <= j3max; j3++) {
2990 j2max = lhy - 1 - i2;
2991 if (j2max > lhy - 1)
2994 for (j2 = j2min; j2 <= j2max; j2++) {
2999 j1max = lhx - 1 - i1;
3000 if (j1max > lhx - 1)
3003 for (j1 = j1min; j1 <= j1max; j1++) {
3004 lda = working_space[j1][j2][j3];
3005 if (i1 + j1 < sizex_ext && i2 + j2 < sizey_ext)
3006 ldb = working_space[i1 + j1][i2 + j2][i3 + j3];
3011 ldc = ldc + lda * ldb;
3015 working_space[i1 - i1min][i2 - i2min][i3 - i3min + 2 * sizez_ext ] = ldc;
3020 for (i3 = 0; i3 < sizez_ext; i3++) {
3021 for (i2 = 0; i2 < sizey_ext; i2++) {
3022 for (i1 = 0; i1 < sizex_ext; i1++) {
3023 working_space[i1][i2][i3 + 3 * sizez_ext] = 1;
3024 working_space[i1][i2][i3 + 4 * sizez_ext] = 0;
3030 for (lindex=0;lindex<deconIterations;lindex++){
3031 for (i3 = 0; i3 < sizez_ext; i3++) {
3032 for (i2 = 0; i2 < sizey_ext; i2++) {
3033 for (i1 = 0; i1 < sizex_ext; i1++) {
3034 if (
TMath::Abs(working_space[i1][i2][i3 + 3 * sizez_ext])>1
e-6 &&
TMath::Abs(working_space[i1][i2][i3 + 1 * sizez_ext])>1
e-6){
3037 if (j3min > lhz - 1)
3041 j3max = sizez_ext - i3 - 1;
3042 if (j3max > lhz - 1)
3046 if (j2min > lhy - 1)
3050 j2max = sizey_ext - i2 - 1;
3051 if (j2max > lhy - 1)
3055 if (j1min > lhx - 1)
3059 j1max = sizex_ext - i1 - 1;
3060 if (j1max > lhx - 1)
3063 for (j3 = j3min; j3 <= j3max; j3++) {
3064 for (j2 = j2min; j2 <= j2max; j2++) {
3065 for (j1 = j1min; j1 <= j1max; j1++) {
3066 ldc = working_space[j1 - i1min][j2 - i2min][j3 - i3min + 2 * sizez_ext];
3067 lda = working_space[i1 + j1][i2 + j2][i3 + j3 + 3 * sizez_ext];
3068 ldb = ldb + lda * ldc;
3072 lda = working_space[i1][i2][i3 + 3 * sizez_ext];
3073 ldc = working_space[i1][i2][i3 + 1 * sizez_ext];
3074 if (ldc * lda != 0 && ldb != 0) {
3075 lda = lda * ldc / ldb;
3080 working_space[i1][i2][i3 + 4 * sizez_ext] = lda;
3085 for (i3 = 0; i3 < sizez_ext; i3++) {
3086 for (i2 = 0; i2 < sizey_ext; i2++) {
3087 for (i1 = 0; i1 < sizex_ext; i1++)
3088 working_space[i1][i2][i3 + 3 * sizez_ext] = working_space[i1][i2][i3 + 4 * sizez_ext];
3094 for(i = 0;i < sizex_ext; i++){
3095 for(j = 0;j < sizey_ext; j++){
3096 for(k = 0;k < sizez_ext; k++){
3097 working_space[(i + positx) % sizex_ext][(j + posity) % sizey_ext][(k + positz) % sizez_ext] = area * working_space[i][j][k + 3 * sizez_ext];
3098 if(maximum < working_space[(i + positx) % sizex_ext][(j + posity) % sizey_ext][(k + positz) % sizez_ext])
3099 maximum = working_space[(i + positx) % sizex_ext][(j + posity) % sizey_ext][(k + positz) % sizez_ext];
3104 for(i = 1;i < sizex_ext - 1; i++){
3105 for(j = 1;j < sizey_ext - 1; j++){
3106 for(
l = 1;
l < sizez_ext - 1;
l++){
3107 a = working_space[i][j][
l];
3108 if(
a > working_space[i][j][
l - 1] &&
a > working_space[i - 1][j][
l - 1] &&
a > working_space[i - 1][j - 1][
l - 1] &&
a > working_space[i][j - 1][
l - 1] &&
a > working_space[i + 1][j - 1][
l - 1] &&
a > working_space[i + 1][j][
l - 1] &&
a > working_space[i + 1][j + 1][
l - 1] &&
a > working_space[i][j + 1][
l - 1] &&
a > working_space[i - 1][j + 1][
l - 1] &&
a > working_space[i - 1][j][
l] &&
a > working_space[i - 1][j - 1][
l] &&
a > working_space[i][j - 1][
l] &&
a > working_space[i + 1][j - 1][
l] &&
a > working_space[i + 1][j][
l] &&
a > working_space[i + 1][j + 1][
l] &&
a > working_space[i][j + 1][
l] &&
a > working_space[i - 1][j + 1][
l] &&
a > working_space[i][j][
l + 1] &&
a > working_space[i - 1][j][
l + 1] &&
a > working_space[i - 1][j - 1][
l + 1] &&
a > working_space[i][j - 1][
l + 1] &&
a > working_space[i + 1][j - 1][
l + 1] &&
a > working_space[i + 1][j][
l + 1] &&
a > working_space[i + 1][j + 1][
l + 1] &&
a > working_space[i][j + 1][
l + 1] &&
a > working_space[i - 1][j + 1][
l + 1]){
3109 if(i >= shift && i < ssizex + shift && j >= shift && j < ssizey + shift && l >= shift &&
l < ssizez + shift){
3110 if(working_space[i][j][
l] > threshold * maximum / 100.0){
3112 for(k = i - 1,
a = 0,
b = 0;k <= i + 1; k++){
3113 a += (
Double_t)(k - shift) * working_space[k][j][
l];
3114 b += working_space[k][j][
l];
3117 for(k = j - 1,
a = 0,
b = 0;k <= j + 1; k++){
3118 a += (
Double_t)(k - shift) * working_space[i][k][
l];
3119 b += working_space[i][k][
l];
3122 for(k =
l - 1,
a = 0,
b = 0;k <=
l + 1; k++){
3123 a += (
Double_t)(k - shift) * working_space[i][j][k];
3124 b += working_space[i][j][k];
3135 for(i = 0;i < ssizex; i++){
3136 for(j = 0;j < ssizey; j++){
3137 for(k = 0;k < ssizez; k++){
3138 dest[i][j][k] = working_space[i + shift][j + shift][k + shift];
3144 for(i = 0;i < ssizex + k; i++){
3145 for(j = 0;j < ssizey + k; j++)
3146 delete[] working_space[i][j];
3147 delete[] working_space[i];
3149 delete[] working_space;
3179 Int_t i,j,k,
l,li,lj,lk,lmin,lmax,
xmin,
xmax,
ymin,
ymax,zmin,zmax;
3181 Double_t nom,nip,nim,sp,sm,spx,spy,smx,smy,spz,smz;
3182 Double_t norma,val,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14,val15,val16,val17,val18,val19,val20,val21,val22,val23,val24,val25,val26;
3185 Double_t p1,p2,p3,p4,p5,p6,p7,p8,
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,r1,r2,r3,r4,r5,r6;
3188 Int_t sizex_ext=ssizex + 4 * number_of_iterations,sizey_ext = ssizey + 4 * number_of_iterations,sizez_ext = ssizez + 4 * number_of_iterations,shift = 2 * number_of_iterations;
3191 Error(
"SearchFast",
"Invalid sigma, must be greater than or equal to 1");
3195 if(threshold<=0||threshold>=100){
3196 Error(
"SearchFast",
"Invalid threshold, must be positive and less than 100");
3202 Error(
"SearchFast",
"Too large sigma");
3206 if (markov ==
true) {
3207 if (averWindow <= 0) {
3208 Error(
"SearchFast",
"Averaging window must be positive");
3213 if(sizex_ext < 2 * number_of_iterations + 1 || sizey_ext < 2 * number_of_iterations + 1 || sizez_ext < 2 * number_of_iterations + 1){
3214 Error(
"SearchFast",
"Too large clipping window");
3221 for(j = 0;j < ssizex + i; j++){
3222 working_space[j] =
new Double_t* [ssizey + i];
3223 for(k = 0;k < ssizey + i; k++)
3224 working_space[j][k] =
new Double_t [4 * (ssizez + i)];
3227 for(k = 0;k < sizez_ext; k++){
3228 for(j = 0;j < sizey_ext; j++){
3229 for(i = 0;i < sizex_ext; i++){
3233 working_space[i][j][k + sizez_ext] = source[0][0][0];
3235 else if(k >= ssizez + shift)
3236 working_space[i][j][k + sizez_ext] = source[0][0][ssizez - 1];
3239 working_space[i][j][k + sizez_ext] = source[0][0][k - shift];
3242 else if(j >= ssizey + shift){
3244 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][0];
3246 else if(k >= ssizez + shift)
3247 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][ssizez - 1];
3250 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][k - shift];
3255 working_space[i][j][k + sizez_ext] = source[0][j - shift][0];
3257 else if(k >= ssizez + shift)
3258 working_space[i][j][k + sizez_ext] = source[0][j - shift][ssizez - 1];
3261 working_space[i][j][k + sizez_ext] = source[0][j - shift][k - shift];
3265 else if(i >= ssizex + shift){
3268 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][0];
3270 else if(k >= ssizez + shift)
3271 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][ssizez - 1];
3274 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][k - shift];
3277 else if(j >= ssizey + shift){
3279 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][0];
3281 else if(k >= ssizez + shift)
3282 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][ssizez - 1];
3285 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][k - shift];
3290 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][0];
3292 else if(k >= ssizez + shift)
3293 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][ssizez - 1];
3296 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][k - shift];
3303 working_space[i][j][k + sizez_ext] = source[i - shift][0][0];
3305 else if(k >= ssizez + shift)
3306 working_space[i][j][k + sizez_ext] = source[i - shift][0][ssizez - 1];
3309 working_space[i][j][k + sizez_ext] = source[i - shift][0][k - shift];
3312 else if(j >= ssizey + shift){
3314 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][0];
3316 else if(k >= ssizez + shift)
3317 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][ssizez - 1];
3320 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][k - shift];
3325 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][0];
3327 else if(k >= ssizez + shift)
3328 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][ssizez - 1];
3331 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][k - shift];
3337 for(i = 1;i <= number_of_iterations; i++){
3338 for(z = i;z < sizez_ext - i; z++){
3339 for(
y = i;
y < sizey_ext - i;
y++){
3340 for(
x = i;
x < sizex_ext - i;
x++){
3341 a = working_space[
x][
y][z + sizez_ext];
3342 p1 = working_space[
x + i][
y + i][z - i + sizez_ext];
3343 p2 = working_space[
x - i][
y + i][z - i + sizez_ext];
3344 p3 = working_space[
x + i][
y - i][z - i + sizez_ext];
3345 p4 = working_space[
x - i][
y - i][z - i + sizez_ext];
3346 p5 = working_space[
x + i][
y + i][z + i + sizez_ext];
3347 p6 = working_space[
x - i][
y + i][z + i + sizez_ext];
3348 p7 = working_space[
x + i][
y - i][z + i + sizez_ext];
3349 p8 = working_space[
x - i][
y - i][z + i + sizez_ext];
3350 s1 = working_space[
x + i][
y ][z - i + sizez_ext];
3351 s2 = working_space[
x ][
y + i][z - i + sizez_ext];
3352 s3 = working_space[
x - i][
y ][z - i + sizez_ext];
3353 s4 = working_space[
x ][
y - i][z - i + sizez_ext];
3354 s5 = working_space[
x + i][
y ][z + i + sizez_ext];
3355 s6 = working_space[
x ][
y + i][z + i + sizez_ext];
3356 s7 = working_space[
x - i][
y ][z + i + sizez_ext];
3357 s8 = working_space[
x ][
y - i][z + i + sizez_ext];
3358 s9 = working_space[
x - i][
y + i][z + sizez_ext];
3359 s10 = working_space[
x - i][
y - i][z +sizez_ext];
3360 s11 = working_space[
x + i][
y + i][z +sizez_ext];
3361 s12 = working_space[
x + i][
y - i][z +sizez_ext];
3362 r1 = working_space[
x ][
y ][z - i + sizez_ext];
3363 r2 = working_space[
x ][
y ][z + i + sizez_ext];
3364 r3 = working_space[
x - i][
y ][z + sizez_ext];
3365 r4 = working_space[
x + i][
y ][z + sizez_ext];
3366 r5 = working_space[
x ][
y + i][z + sizez_ext];
3367 r6 = working_space[
x ][
y - i][z + sizez_ext];
3368 b = (p1 + p3) / 2.0;
3372 b = (p1 + p2) / 2.0;
3376 b = (p2 + p4) / 2.0;
3380 b = (p3 + p4) / 2.0;
3384 b = (p5 + p7) / 2.0;
3388 b = (p5 + p6) / 2.0;
3392 b = (p6 + p8) / 2.0;
3396 b = (p7 + p8) / 2.0;
3400 b = (p2 + p6) / 2.0;
3404 b = (p4 + p8) / 2.0;
3408 b = (p1 + p5) / 2.0;
3412 b = (p3 + p7) / 2.0;
3416 s1 =
s1 - (p1 + p3) / 2.0;
3417 s2 = s2 - (p1 + p2) / 2.0;
3418 s3 = s3 - (p2 + p4) / 2.0;
3419 s4 = s4 - (p3 + p4) / 2.0;
3420 s5 = s5 - (p5 + p7) / 2.0;
3421 s6 = s6 - (p5 + p6) / 2.0;
3422 s7 = s7 - (p6 + p8) / 2.0;
3423 s8 = s8 - (p7 + p8) / 2.0;
3424 s9 = s9 - (p2 + p6) / 2.0;
3425 s10 = s10 - (p4 + p8) / 2.0;
3426 s11 = s11 - (p1 + p5) / 2.0;
3427 s12 = s12 - (p3 + p7) / 2.0;
3428 b = (
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
3432 b = (s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0;
3436 b = (s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0;
3440 b = (
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0;
3444 b = (s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0;
3448 b = (s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0;
3452 r1 = r1 - ((
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0);
3453 r2 = r2 - ((s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0);
3454 r3 = r3 - ((s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0);
3455 r4 = r4 - ((
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0);
3456 r5 = r5 - ((s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0);
3457 r6 = r6 - ((s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0);
3458 b = (r1 + r2) / 2.0 + (r3 + r4) / 2.0 + (r5 + r6) / 2.0 + (
s1 + s3 + s5 + s7) / 4.0 + (s2 + s4 + s6 + s8) / 4.0 + (s9 + s10 + s11 + s12) / 4.0 + (p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 8.0;
3462 working_space[
x][
y][z] =
a;
3466 for(z = i;z < sizez_ext - i; z++){
3467 for(
y = i;
y < sizey_ext - i;
y++){
3468 for(
x = i;
x < sizex_ext - i;
x++){
3469 working_space[
x][
y][z + sizez_ext] = working_space[
x][
y][z];
3474 for(k = 0;k < sizez_ext; k++){
3475 for(j = 0;j < sizey_ext; j++){
3476 for(i = 0;i < sizex_ext; i++){
3480 working_space[i][j][k + 3 * sizez_ext] = source[0][0][0] - working_space[i][j][k + sizez_ext];
3482 else if(k >= ssizez + shift)
3483 working_space[i][j][k + 3 * sizez_ext] = source[0][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
3486 working_space[i][j][k + 3 * sizez_ext] = source[0][0][k - shift] - working_space[i][j][k + sizez_ext];
3489 else if(j >= ssizey + shift){
3491 working_space[i][j][k + 3 * sizez_ext] = source[0][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
3493 else if(k >= ssizez + shift)
3494 working_space[i][j][k + 3 * sizez_ext] = source[0][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
3497 working_space[i][j][k + 3 * sizez_ext] = source[0][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
3502 working_space[i][j][k + 3 * sizez_ext] = source[0][j - shift][0] - working_space[i][j][k + sizez_ext];
3504 else if(k >= ssizez + shift)
3505 working_space[i][j][k + 3 * sizez_ext] = source[0][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
3508 working_space[i][j][k + 3 * sizez_ext] = source[0][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
3512 else if(i >= ssizex + shift){
3515 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][0][0] - working_space[i][j][k + sizez_ext];
3517 else if(k >= ssizez + shift)
3518 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
3521 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][0][k - shift] - working_space[i][j][k + sizez_ext];
3524 else if(j >= ssizey + shift){
3526 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
3528 else if(k >= ssizez + shift)
3529 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
3532 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
3537 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][j - shift][0] - working_space[i][j][k + sizez_ext];
3539 else if(k >= ssizez + shift)
3540 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
3543 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
3550 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][0][0] - working_space[i][j][k + sizez_ext];
3552 else if(k >= ssizez + shift)
3553 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
3556 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][0][k - shift] - working_space[i][j][k + sizez_ext];
3559 else if(j >= ssizey + shift){
3561 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
3563 else if(k >= ssizez + shift)
3564 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
3567 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
3572 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][j - shift][0] - working_space[i][j][k + sizez_ext];
3574 else if(k >= ssizez + shift)
3575 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
3578 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
3585 for(i = 0;i < sizex_ext; i++){
3586 for(j = 0;j < sizey_ext; j++){
3587 for(k = 0;k < sizez_ext; k++){
3588 if(i >= shift && i < ssizex + shift && j >= shift && j < ssizey + shift && k >= shift && k < ssizez + shift){
3589 working_space[i][j][k + 2 * sizez_ext] = source[i - shift][j - shift][k - shift];
3590 plocha_markov = plocha_markov + source[i - shift][j - shift][k - shift];
3593 working_space[i][j][k + 2 * sizez_ext] = 0;
3600 xmax = sizex_ext - 1;
3602 ymax = sizey_ext - 1;
3604 zmax = sizez_ext - 1;
3605 for(i = 0,maxch = 0;i < sizex_ext; i++){
3606 for(j = 0;j < sizey_ext;j++){
3607 for(k = 0;k < sizez_ext;k++){
3608 working_space[i][j][k] = 0;
3609 if(maxch < working_space[i][j][k + 2 * sizez_ext])
3610 maxch = working_space[i][j][k + 2 * sizez_ext];
3617 for(i = 0;i < ssizex + k; i++){
3618 for(j = 0;j < ssizey + k; j++)
3619 delete[] working_space[i][j];
3620 delete[] working_space[i];
3622 delete [] working_space;
3627 working_space[
xmin][
ymin][zmin] = 1;
3629 nip = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
3630 nim = working_space[i + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
3632 for(
l = 1;
l <= averWindow;
l++){
3634 a = working_space[
xmax][
ymin][zmin + 2 * sizez_ext] / maxch;
3637 a = working_space[i +
l][
ymin][zmin + 2 * sizez_ext] / maxch;
3649 if(i -
l + 1 <
xmin)
3650 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
3653 a = working_space[i -
l + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
3667 a = working_space[i + 1][
ymin][zmin] =
a * working_space[i][
ymin][zmin];
3671 nip = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
3672 nim = working_space[
xmin][i + 1][zmin + 2 * sizez_ext] / maxch;
3674 for(
l = 1;
l <= averWindow;
l++){
3676 a = working_space[
xmin][
ymax][zmin + 2 * sizez_ext] / maxch;
3679 a = working_space[
xmin][i +
l][zmin + 2 * sizez_ext] / maxch;
3691 if(i -
l + 1 <
ymin)
3692 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
3695 a = working_space[
xmin][i -
l + 1][zmin + 2 * sizez_ext] / maxch;
3709 a = working_space[
xmin][i + 1][zmin] =
a * working_space[
xmin][i][zmin];
3712 for(i = zmin;i < zmax;i++){
3713 nip = working_space[
xmin][
ymin][i + 2 * sizez_ext] / maxch;
3714 nim = working_space[
xmin][
ymin][i + 1 + 2 * sizez_ext] / maxch;
3716 for(
l = 1;
l <= averWindow;
l++){
3718 a = working_space[
xmin][
ymin][zmax + 2 * sizez_ext] / maxch;
3721 a = working_space[
xmin][
ymin][i +
l + 2 * sizez_ext] / maxch;
3733 if(i -
l + 1 < zmin)
3734 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
3737 a = working_space[
xmin][
ymin][i -
l + 1 + 2 * sizez_ext] / maxch;
3756 nip = working_space[i][j + 1][zmin + 2 * sizez_ext] / maxch;
3757 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
3759 for(
l = 1;
l <= averWindow;
l++){
3761 a = working_space[
xmax][j][zmin + 2 * sizez_ext] / maxch;
3764 a = working_space[i +
l][j][zmin + 2 * sizez_ext] / maxch;
3776 if(i -
l + 1 <
xmin)
3777 a = working_space[
xmin][j][zmin + 2 * sizez_ext] / maxch;
3780 a = working_space[i -
l + 1][j][zmin + 2 * sizez_ext] / maxch;
3794 nip = working_space[i + 1][j][zmin + 2 * sizez_ext] / maxch;
3795 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
3796 for(
l = 1;
l <= averWindow;
l++){
3798 a = working_space[i][
ymax][zmin + 2 * sizez_ext] / maxch;
3801 a = working_space[i][j +
l][zmin + 2 * sizez_ext] / maxch;
3813 if(j -
l + 1 <
ymin)
3814 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
3817 a = working_space[i][j -
l + 1][zmin + 2 * sizez_ext] / maxch;
3830 a = (spx * working_space[i][j + 1][zmin] + spy * working_space[i + 1][j][zmin]) / (smx + smy);
3831 working_space[i + 1][j + 1][zmin] =
a;
3836 for(j = zmin;j < zmax;j++){
3837 nip = working_space[i][
ymin][j + 1 + 2 * sizez_ext] / maxch;
3838 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
3840 for(
l = 1;
l <= averWindow;
l++){
3842 a = working_space[
xmax][
ymin][j + 2 * sizez_ext] / maxch;
3845 a = working_space[i +
l][
ymin][j + 2 * sizez_ext] / maxch;
3857 if(i -
l + 1 <
xmin)
3858 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
3861 a = working_space[i -
l + 1][
ymin][j + 2 * sizez_ext] / maxch;
3875 nip = working_space[i + 1][
ymin][j + 2 * sizez_ext] / maxch;
3876 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
3877 for(
l = 1;
l <= averWindow;
l++){
3879 a = working_space[i][
ymin][zmax + 2 * sizez_ext] / maxch;
3882 a = working_space[i][
ymin][j +
l + 2 * sizez_ext] / maxch;
3894 if(j -
l + 1 < zmin)
3895 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
3898 a = working_space[i][
ymin][j -
l + 1 + 2 * sizez_ext] / maxch;
3911 a = (spx * working_space[i][
ymin][j + 1] + spz * working_space[i + 1][
ymin][j]) / (smx + smz);
3912 working_space[i + 1][
ymin][j + 1] =
a;
3917 for(j = zmin;j < zmax;j++){
3918 nip = working_space[
xmin][i][j + 1 + 2 * sizez_ext] / maxch;
3919 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
3921 for(
l = 1;
l <= averWindow;
l++){
3923 a = working_space[
xmin][
ymax][j + 2 * sizez_ext] / maxch;
3926 a = working_space[
xmin][i +
l][j + 2 * sizez_ext] / maxch;
3938 if(i -
l + 1 <
ymin)
3939 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
3942 a = working_space[
xmin][i -
l + 1][j + 2 * sizez_ext] / maxch;
3956 nip = working_space[
xmin][i + 1][j + 2 * sizez_ext] / maxch;
3957 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
3958 for(
l = 1;
l <= averWindow;
l++){
3960 a = working_space[
xmin][i][zmax + 2 * sizez_ext] / maxch;
3963 a = working_space[
xmin][i][j +
l + 2 * sizez_ext] / maxch;
3975 if(j -
l + 1 < zmin)
3976 a = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
3979 a = working_space[
xmin][i][j -
l + 1 + 2 * sizez_ext] / maxch;
3992 a = (spy * working_space[
xmin][i][j + 1] + spz * working_space[
xmin][i + 1][j]) / (smy + smz);
3993 working_space[
xmin][i + 1][j + 1] =
a;
3999 for(k = zmin;k < zmax; k++){
4000 nip = working_space[i][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4001 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4003 for(
l = 1;
l <= averWindow;
l++){
4005 a = working_space[
xmax][j][k + 2 * sizez_ext] / maxch;
4008 a = working_space[i +
l][j][k + 2 * sizez_ext] / maxch;
4020 if(i -
l + 1 <
xmin)
4021 a = working_space[
xmin][j][k + 2 * sizez_ext] / maxch;
4024 a = working_space[i -
l + 1][j][k + 2 * sizez_ext] / maxch;
4038 nip = working_space[i + 1][j][k + 1 + 2 * sizez_ext] / maxch;
4039 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4040 for(
l = 1;
l <= averWindow;
l++){
4042 a = working_space[i][
ymax][k + 2 * sizez_ext] / maxch;
4045 a = working_space[i][j +
l][k + 2 * sizez_ext] / maxch;
4057 if(j -
l + 1 <
ymin)
4058 a = working_space[i][
ymin][k + 2 * sizez_ext] / maxch;
4061 a = working_space[i][j -
l + 1][k + 2 * sizez_ext] / maxch;
4075 nip = working_space[i + 1][j + 1][k + 2 * sizez_ext] / maxch;
4076 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4077 for(
l = 1;
l <= averWindow;
l++ ){
4079 a = working_space[i][j][zmax + 2 * sizez_ext] / maxch;
4082 a = working_space[i][j][k +
l + 2 * sizez_ext] / maxch;
4094 if(j -
l + 1 <
ymin)
4095 a = working_space[i][j][zmin + 2 * sizez_ext] / maxch;
4098 a = working_space[i][j][k -
l + 1 + 2 * sizez_ext] / maxch;
4111 a = (spx * working_space[i][j + 1][k + 1] + spy * working_space[i + 1][j][k + 1] + spz * working_space[i + 1][j + 1][k]) / (smx + smy + smz);
4112 working_space[i + 1][j + 1][k + 1] =
a;
4120 for(k = zmin;k <= zmax; k++){
4121 working_space[i][j][k] = working_space[i][j][k] / nom;
4122 a+=working_space[i][j][k];
4126 for(i = 0;i < sizex_ext; i++){
4127 for(j = 0;j < sizey_ext; j++){
4128 for(k = 0;k < sizez_ext; k++){
4129 working_space[i][j][k + 2 * sizez_ext] = working_space[i][j][k] * plocha_markov /
a;
4136 for(k = 0;k < ssizez; k++){
4137 for(j = 0;j < ssizey; j++){
4138 for(i = 0;i < ssizex; i++){
4139 working_space[i][j][k] = 0;
4140 working_space[i][j][sizez_ext + k] = 0;
4141 if(working_space[i][j][k + 3 * sizez_ext] > maximum)
4142 maximum=working_space[i][j][k+3*sizez_ext];
4150 for(i = -j;i <= j; i++){
4168 c[i] =
c[i] / norma;
4170 a = pocet_sigma *
sigma + 0.5;
4173 zmax = sizez_ext - i - 1;
4175 ymax = sizey_ext - i - 1;
4177 xmax = sizex_ext - i - 1;
4182 for(k = zmin;k <= zmax; k++){
4184 for(li = lmin;li <= lmax; li++){
4185 for(lj = lmin;lj <= lmax; lj++){
4186 for(lk = lmin;lk <= lmax; lk++){
4188 b =
c[li] *
c[lj] *
c[lk];
4194 working_space[i][j][k] = s;
4201 for(z = zmin + 1;z < zmax; z++){
4202 val = working_space[
x][
y][z];
4203 val1 = working_space[
x - 1][
y - 1][z - 1];
4204 val2 = working_space[
x ][
y - 1][z - 1];
4205 val3 = working_space[
x + 1][
y - 1][z - 1];
4206 val4 = working_space[
x - 1][
y ][z - 1];
4207 val5 = working_space[
x ][
y ][z - 1];
4208 val6 = working_space[
x + 1][
y ][z - 1];
4209 val7 = working_space[
x - 1][
y + 1][z - 1];
4210 val8 = working_space[
x ][
y + 1][z - 1];
4211 val9 = working_space[
x + 1][
y + 1][z - 1];
4212 val10 = working_space[
x - 1][
y - 1][z ];
4213 val11 = working_space[
x ][
y - 1][z ];
4214 val12 = working_space[
x + 1][
y - 1][z ];
4215 val13 = working_space[
x - 1][
y ][z ];
4216 val14 = working_space[
x + 1][
y ][z ];
4217 val15 = working_space[
x - 1][
y + 1][z ];
4218 val16 = working_space[
x ][
y + 1][z ];
4219 val17 = working_space[
x + 1][
y + 1][z ];
4220 val18 = working_space[
x - 1][
y - 1][z + 1];
4221 val19 = working_space[
x ][
y - 1][z + 1];
4222 val20 = working_space[
x + 1][
y - 1][z + 1];
4223 val21 = working_space[
x - 1][
y ][z + 1];
4224 val22 = working_space[
x ][
y ][z + 1];
4225 val23 = working_space[
x + 1][
y ][z + 1];
4226 val24 = working_space[
x - 1][
y + 1][z + 1];
4227 val25 = working_space[
x ][
y + 1][z + 1];
4228 val26 = working_space[
x + 1][
y + 1][z + 1];
4229 f = -s_f_ratio_peaks * working_space[
x][
y][z + sizez_ext];
4230 if(val <
f && val < val1 && val < val2 && val < val3 && val < val4 && val < val5 && val < val6 && val < val7 && val < val8 && val < val9 && val < val10 && val < val11 && val < val12 && val < val13 && val < val14 && val < val15 && val < val16 && val < val17 && val < val18 && val < val19 && val < val20 && val < val21 && val < val22 && val < val23 && val < val24 && val < val25 && val < val26){
4232 for(li = lmin;li <= lmax; li++){
4233 a = working_space[
x + li -
PEAK_WINDOW / 2][
y][z + 2 * sizez_ext];
4235 f +=
a *
c[li] *
c[li];
4237 f = -s_f_ratio_peaks * sqrt(
f);
4240 for(li = lmin;li <= lmax; li++){
4241 a = working_space[
x][
y + li -
PEAK_WINDOW / 2][z + 2 * sizez_ext];
4243 f +=
a *
c[li] *
c[li];
4245 f = -s_f_ratio_peaks * sqrt(
f);
4248 for(li = lmin;li <= lmax; li++){
4249 a = working_space[
x][
y][z + li -
PEAK_WINDOW / 2 + 2 * sizez_ext];
4251 f +=
a *
c[li] *
c[li];
4253 f = -s_f_ratio_peaks * sqrt(
f);
4256 for(li = lmin;li <= lmax; li++){
4257 for(lj = lmin;lj <= lmax; lj++){
4259 s +=
a *
c[li] *
c[lj];
4260 f +=
a *
c[li] *
c[li] *
c[lj] *
c[lj];
4263 f = s_f_ratio_peaks * sqrt(
f);
4266 for(li = lmin;li <= lmax; li++){
4267 for(lj = lmin;lj <= lmax; lj++){
4269 s +=
a *
c[li] *
c[lj];
4270 f +=
a *
c[li] *
c[li] *
c[lj] *
c[lj];
4273 f = s_f_ratio_peaks * sqrt(
f);
4276 for(li = lmin;li <= lmax; li++){
4277 for(lj=lmin;lj<=lmax;lj++){
4279 s +=
a *
c[li] *
c[lj];
4280 f +=
a *
c[li] *
c[li] *
c[lj] *
c[lj];
4283 f = s_f_ratio_peaks * sqrt(
f);
4285 if(
x >= shift && x < ssizex + shift && y >= shift && y < ssizey + shift && z >= shift && z < ssizez + shift){
4286 if(working_space[
x][
y][z + 3 * sizez_ext] > threshold * maximum / 100.0){
4288 for(k =
x - 1,
a = 0,
b = 0;k <=
x + 1; k++){
4289 a += (
Double_t)(k - shift) * working_space[k][
y][z];
4290 b += working_space[k][
y][z];
4293 for(k =
y - 1,
a = 0,
b = 0;k <=
y + 1; k++){
4294 a += (
Double_t)(k - shift) * working_space[
x][k][z];
4295 b += working_space[
x][k][z];
4298 for(k = z - 1,
a = 0,
b = 0;k <= z + 1; k++){
4299 a += (
Double_t)(k - shift) * working_space[
x][
y][k];
4300 b += working_space[
x][
y][k];
4317 for(i = 0;i < ssizex; i++){
4318 for(j = 0;j < ssizey; j++){
4319 for(k = 0;k < ssizez; k++){
4320 val = -working_space[i + shift][j + shift][k + shift];
4323 dest[i][j][k] = val;
4329 for(i = 0;i < ssizex + k; i++){
4330 for(j = 0;j < ssizey + k; j++)
4331 delete[] working_space[i][j];
4332 delete[] working_space[i];
4334 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 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
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
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.
Advanced 3-dimensional spectra processing functions.
Double_t fResolution
NOT USED resolution of the neighboring peaks
Int_t fMaxPeaks
Maximum number of peaks to be found.
Int_t SearchFast(const Double_t ***source, Double_t ***dest, Int_t ssizex, Int_t ssizey, Int_t ssizez, Double_t sigma, Double_t threshold, Bool_t markov, Int_t averWindow)
THREE-DIMENSIONAL CLASSICAL PEAK SEARCH FUNCTION This function searches for peaks in source spectrum ...
virtual const char * Background(const TH1 *hist, Int_t niter, Option_t *option="goff")
This function calculates background spectrum from source in h.
TH1 * fHistogram
resulting histogram
const char * Deconvolution(Double_t ***source, const Double_t ***resp, Int_t ssizex, Int_t ssizey, Int_t ssizez, Int_t numberIterations, Int_t numberRepetitions, Double_t boost)
This function calculates deconvolution from source spectrum according to response spectrum The result...
Double_t * fPositionY
[fNPeaks] Y positions of peaks
Double_t * fPosition
[fNPeaks] array of current peak positions
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="goff", Double_t threshold=0.05)
This function searches for peaks in source spectrum in hin The number of found peaks and their positi...
Int_t SearchHighRes(const Double_t ***source, Double_t ***dest, Int_t ssizex, Int_t ssizey, Int_t ssizez, 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.
const char * SmoothMarkov(Double_t ***source, Int_t ssizex, Int_t ssizey, Int_t ssizez, Int_t averWindow)
This function calculates smoothed spectrum from source spectrum based on Markov chain method.
@ kBackSuccessiveFiltering
Double_t * fPositionZ
[fNPeaks] Z positions of peaks
Double_t * fPositionX
[fNPeaks] X positions of peaks
Int_t fNPeaks
number of peaks found
void Print(Option_t *option="") const override
Print the array of positions.
void SetResolution(Double_t resolution=1)
NOT USED resolution: determines resolution of the neighbouring peaks default value is 1 correspond to...
~TSpectrum3() override
Destructor.
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.