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;
1959 Double_t a,
b,maxch,plocha = 0,plocha_markov = 0;
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];
2385 plocha += working_space[i][j][k + 2 * sizez_ext];
2392 for(i = 0;i < ssizex + k; i++){
2393 for(j = 0;j < ssizey + k; j++)
2394 delete[] working_space[i][j];
2395 delete[] working_space[i];
2397 delete [] working_space;
2401 working_space[
xmin][
ymin][zmin] = 1;
2403 nip = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
2404 nim = working_space[i + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
2406 for(
l = 1;
l <= averWindow;
l++){
2408 a = working_space[
xmax][
ymin][zmin + 2 * sizez_ext] / maxch;
2411 a = working_space[i +
l][
ymin][zmin + 2 * sizez_ext] / maxch;
2423 if(i -
l + 1 <
xmin)
2424 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
2427 a = working_space[i -
l + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
2441 a = working_space[i + 1][
ymin][zmin] =
a * working_space[i][
ymin][zmin];
2445 nip = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
2446 nim = working_space[
xmin][i + 1][zmin + 2 * sizez_ext] / maxch;
2448 for(
l = 1;
l <= averWindow;
l++){
2450 a = working_space[
xmin][
ymax][zmin + 2 * sizez_ext] / maxch;
2453 a = working_space[
xmin][i +
l][zmin + 2 * sizez_ext] / maxch;
2465 if(i -
l + 1 <
ymin)
2466 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
2469 a = working_space[
xmin][i -
l + 1][zmin + 2 * sizez_ext] / maxch;
2483 a = working_space[
xmin][i + 1][zmin] =
a * working_space[
xmin][i][zmin];
2486 for(i = zmin;i < zmax;i++){
2487 nip = working_space[
xmin][
ymin][i + 2 * sizez_ext] / maxch;
2488 nim = working_space[
xmin][
ymin][i + 1 + 2 * sizez_ext] / maxch;
2490 for(
l = 1;
l <= averWindow;
l++){
2492 a = working_space[
xmin][
ymin][zmax + 2 * sizez_ext] / maxch;
2495 a = working_space[
xmin][
ymin][i +
l + 2 * sizez_ext] / maxch;
2507 if(i -
l + 1 < zmin)
2508 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
2511 a = working_space[
xmin][
ymin][i -
l + 1 + 2 * sizez_ext] / maxch;
2530 nip = working_space[i][j + 1][zmin + 2 * sizez_ext] / maxch;
2531 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
2533 for(
l = 1;
l <= averWindow;
l++){
2535 a = working_space[
xmax][j][zmin + 2 * sizez_ext] / maxch;
2538 a = working_space[i +
l][j][zmin + 2 * sizez_ext] / maxch;
2550 if(i -
l + 1 <
xmin)
2551 a = working_space[
xmin][j][zmin + 2 * sizez_ext] / maxch;
2554 a = working_space[i -
l + 1][j][zmin + 2 * sizez_ext] / maxch;
2568 nip = working_space[i + 1][j][zmin + 2 * sizez_ext] / maxch;
2569 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
2570 for(
l = 1;
l <= averWindow;
l++){
2572 a = working_space[i][
ymax][zmin + 2 * sizez_ext] / maxch;
2575 a = working_space[i][j +
l][zmin + 2 * sizez_ext] / maxch;
2587 if(j -
l + 1 <
ymin)
2588 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
2591 a = working_space[i][j -
l + 1][zmin + 2 * sizez_ext] / maxch;
2604 a = (spx * working_space[i][j + 1][zmin] + spy * working_space[i + 1][j][zmin]) / (smx + smy);
2605 working_space[i + 1][j + 1][zmin] =
a;
2610 for(j = zmin;j < zmax;j++){
2611 nip = working_space[i][
ymin][j + 1 + 2 * sizez_ext] / maxch;
2612 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
2614 for(
l = 1;
l <= averWindow;
l++){
2616 a = working_space[
xmax][
ymin][j + 2 * sizez_ext] / maxch;
2619 a = working_space[i +
l][
ymin][j + 2 * sizez_ext] / maxch;
2631 if(i -
l + 1 <
xmin)
2632 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
2635 a = working_space[i -
l + 1][
ymin][j + 2 * sizez_ext] / maxch;
2649 nip = working_space[i + 1][
ymin][j + 2 * sizez_ext] / maxch;
2650 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
2651 for(
l = 1;
l <= averWindow;
l++){
2653 a = working_space[i][
ymin][zmax + 2 * sizez_ext] / maxch;
2656 a = working_space[i][
ymin][j +
l + 2 * sizez_ext] / maxch;
2668 if(j -
l + 1 < zmin)
2669 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
2672 a = working_space[i][
ymin][j -
l + 1 + 2 * sizez_ext] / maxch;
2685 a = (spx * working_space[i][
ymin][j + 1] + spz * working_space[i + 1][
ymin][j]) / (smx + smz);
2686 working_space[i + 1][
ymin][j + 1] =
a;
2691 for(j = zmin;j < zmax;j++){
2692 nip = working_space[
xmin][i][j + 1 + 2 * sizez_ext] / maxch;
2693 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
2695 for(
l = 1;
l <= averWindow;
l++){
2697 a = working_space[
xmin][
ymax][j + 2 * sizez_ext] / maxch;
2700 a = working_space[
xmin][i +
l][j + 2 * sizez_ext] / maxch;
2712 if(i -
l + 1 <
ymin)
2713 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
2716 a = working_space[
xmin][i -
l + 1][j + 2 * sizez_ext] / maxch;
2730 nip = working_space[
xmin][i + 1][j + 2 * sizez_ext] / maxch;
2731 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
2732 for(
l = 1;
l <= averWindow;
l++){
2734 a = working_space[
xmin][i][zmax + 2 * sizez_ext] / maxch;
2737 a = working_space[
xmin][i][j +
l + 2 * sizez_ext] / maxch;
2749 if(j -
l + 1 < zmin)
2750 a = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
2753 a = working_space[
xmin][i][j -
l + 1 + 2 * sizez_ext] / maxch;
2766 a = (spy * working_space[
xmin][i][j + 1] + spz * working_space[
xmin][i + 1][j]) / (smy + smz);
2767 working_space[
xmin][i + 1][j + 1] =
a;
2773 for(k = zmin;k < zmax; k++){
2774 nip = working_space[i][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2775 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2777 for(
l = 1;
l <= averWindow;
l++){
2779 a = working_space[
xmax][j][k + 2 * sizez_ext] / maxch;
2782 a = working_space[i +
l][j][k + 2 * sizez_ext] / maxch;
2794 if(i -
l + 1 <
xmin)
2795 a = working_space[
xmin][j][k + 2 * sizez_ext] / maxch;
2798 a = working_space[i -
l + 1][j][k + 2 * sizez_ext] / maxch;
2812 nip = working_space[i + 1][j][k + 1 + 2 * sizez_ext] / maxch;
2813 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2814 for(
l = 1;
l <= averWindow;
l++){
2816 a = working_space[i][
ymax][k + 2 * sizez_ext] / maxch;
2819 a = working_space[i][j +
l][k + 2 * sizez_ext] / maxch;
2831 if(j -
l + 1 <
ymin)
2832 a = working_space[i][
ymin][k + 2 * sizez_ext] / maxch;
2835 a = working_space[i][j -
l + 1][k + 2 * sizez_ext] / maxch;
2849 nip = working_space[i + 1][j + 1][k + 2 * sizez_ext] / maxch;
2850 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
2851 for(
l = 1;
l <= averWindow;
l++ ){
2853 a = working_space[i][j][zmax + 2 * sizez_ext] / maxch;
2856 a = working_space[i][j][k +
l + 2 * sizez_ext] / maxch;
2868 if(j -
l + 1 <
ymin)
2869 a = working_space[i][j][zmin + 2 * sizez_ext] / maxch;
2872 a = working_space[i][j][k -
l + 1 + 2 * sizez_ext] / maxch;
2885 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);
2886 working_space[i + 1][j + 1][k + 1] =
a;
2894 for(k = zmin;k <= zmax; k++){
2895 working_space[i][j][k] = working_space[i][j][k] / nom;
2896 a+=working_space[i][j][k];
2900 for(i = 0;i < sizex_ext; i++){
2901 for(j = 0;j < sizey_ext; j++){
2902 for(k = 0;k < sizez_ext; k++){
2903 working_space[i][j][k + sizez_ext] = working_space[i][j][k] * plocha_markov /
a;
2910 lhx = -1,lhy = -1,lhz = -1;
2911 positx = 0,posity = 0,positz = 0;
2914 for(i = 0;i < sizex_ext; i++){
2915 for(j = 0;j < sizey_ext; j++){
2916 for(k = 0;k < sizez_ext; k++){
2920 lda = (lda * lda + ldb * ldb + ldc * ldc) / (2 *
sigma *
sigma);
2921 l = (
Int_t)(1000 * exp(-lda));
2933 working_space[i][j][k] = lda;
2937 positx = i,posity = j,positz = k;
2943 for(i = 0;i < sizex_ext; i++){
2944 for(j = 0;j < sizey_ext; j++){
2945 for(k = 0;k < sizez_ext; k++){
2946 working_space[i][j][k + 2 * sizez_ext] =
TMath::Abs(working_space[i][j][k + sizez_ext]);
2951 for (i3 = 0; i3 < sizez_ext; i3++) {
2952 for (i2 = 0; i2 < sizey_ext; i2++) {
2953 for (i1 = 0; i1 < sizex_ext; i1++) {
2955 for (j3 = 0; j3 <= (lhz - 1); j3++) {
2956 for (j2 = 0; j2 <= (lhy - 1); j2++) {
2957 for (j1 = 0; j1 <= (lhx - 1); j1++) {
2958 k3 = i3 + j3, k2 = i2 + j2, k1 = i1 + j1;
2959 if (k3 >= 0 && k3 < sizez_ext && k2 >= 0 && k2 < sizey_ext && k1 >= 0 && k1 < sizex_ext) {
2960 lda = working_space[j1][j2][j3];
2961 ldb = working_space[k1][k2][k3+2*sizez_ext];
2962 ldc = ldc + lda * ldb;
2967 working_space[i1][i2][i3 + sizez_ext] = ldc;
2972 i1min = -(lhx - 1), i1max = lhx - 1;
2973 i2min = -(lhy - 1), i2max = lhy - 1;
2974 i3min = -(lhz - 1), i3max = lhz - 1;
2975 for (i3 = i3min; i3 <= i3max; i3++) {
2976 for (i2 = i2min; i2 <= i2max; i2++) {
2977 for (i1 = i1min; i1 <= i1max; i1++) {
2983 j3max = lhz - 1 - i3;
2984 if (j3max > lhz - 1)
2987 for (j3 = j3min; j3 <= j3max; j3++) {
2992 j2max = lhy - 1 - i2;
2993 if (j2max > lhy - 1)
2996 for (j2 = j2min; j2 <= j2max; j2++) {
3001 j1max = lhx - 1 - i1;
3002 if (j1max > lhx - 1)
3005 for (j1 = j1min; j1 <= j1max; j1++) {
3006 lda = working_space[j1][j2][j3];
3007 if (i1 + j1 < sizex_ext && i2 + j2 < sizey_ext)
3008 ldb = working_space[i1 + j1][i2 + j2][i3 + j3];
3013 ldc = ldc + lda * ldb;
3017 working_space[i1 - i1min][i2 - i2min][i3 - i3min + 2 * sizez_ext ] = ldc;
3022 for (i3 = 0; i3 < sizez_ext; i3++) {
3023 for (i2 = 0; i2 < sizey_ext; i2++) {
3024 for (i1 = 0; i1 < sizex_ext; i1++) {
3025 working_space[i1][i2][i3 + 3 * sizez_ext] = 1;
3026 working_space[i1][i2][i3 + 4 * sizez_ext] = 0;
3032 for (lindex=0;lindex<deconIterations;lindex++){
3033 for (i3 = 0; i3 < sizez_ext; i3++) {
3034 for (i2 = 0; i2 < sizey_ext; i2++) {
3035 for (i1 = 0; i1 < sizex_ext; i1++) {
3036 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){
3039 if (j3min > lhz - 1)
3043 j3max = sizez_ext - i3 - 1;
3044 if (j3max > lhz - 1)
3048 if (j2min > lhy - 1)
3052 j2max = sizey_ext - i2 - 1;
3053 if (j2max > lhy - 1)
3057 if (j1min > lhx - 1)
3061 j1max = sizex_ext - i1 - 1;
3062 if (j1max > lhx - 1)
3065 for (j3 = j3min; j3 <= j3max; j3++) {
3066 for (j2 = j2min; j2 <= j2max; j2++) {
3067 for (j1 = j1min; j1 <= j1max; j1++) {
3068 ldc = working_space[j1 - i1min][j2 - i2min][j3 - i3min + 2 * sizez_ext];
3069 lda = working_space[i1 + j1][i2 + j2][i3 + j3 + 3 * sizez_ext];
3070 ldb = ldb + lda * ldc;
3074 lda = working_space[i1][i2][i3 + 3 * sizez_ext];
3075 ldc = working_space[i1][i2][i3 + 1 * sizez_ext];
3076 if (ldc * lda != 0 && ldb != 0) {
3077 lda = lda * ldc / ldb;
3082 working_space[i1][i2][i3 + 4 * sizez_ext] = lda;
3087 for (i3 = 0; i3 < sizez_ext; i3++) {
3088 for (i2 = 0; i2 < sizey_ext; i2++) {
3089 for (i1 = 0; i1 < sizex_ext; i1++)
3090 working_space[i1][i2][i3 + 3 * sizez_ext] = working_space[i1][i2][i3 + 4 * sizez_ext];
3096 for(i = 0;i < sizex_ext; i++){
3097 for(j = 0;j < sizey_ext; j++){
3098 for(k = 0;k < sizez_ext; k++){
3099 working_space[(i + positx) % sizex_ext][(j + posity) % sizey_ext][(k + positz) % sizez_ext] = area * working_space[i][j][k + 3 * sizez_ext];
3100 if(maximum < working_space[(i + positx) % sizex_ext][(j + posity) % sizey_ext][(k + positz) % sizez_ext])
3101 maximum = working_space[(i + positx) % sizex_ext][(j + posity) % sizey_ext][(k + positz) % sizez_ext];
3106 for(i = 1;i < sizex_ext - 1; i++){
3107 for(j = 1;j < sizey_ext - 1; j++){
3108 for(
l = 1;
l < sizez_ext - 1;
l++){
3109 a = working_space[i][j][
l];
3110 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]){
3111 if(i >= shift && i < ssizex + shift && j >= shift && j < ssizey + shift && l >= shift &&
l < ssizez + shift){
3112 if(working_space[i][j][
l] > threshold * maximum / 100.0){
3114 for(k = i - 1,
a = 0,
b = 0;k <= i + 1; k++){
3115 a += (
Double_t)(k - shift) * working_space[k][j][
l];
3116 b += working_space[k][j][
l];
3119 for(k = j - 1,
a = 0,
b = 0;k <= j + 1; k++){
3120 a += (
Double_t)(k - shift) * working_space[i][k][
l];
3121 b += working_space[i][k][
l];
3124 for(k =
l - 1,
a = 0,
b = 0;k <=
l + 1; k++){
3125 a += (
Double_t)(k - shift) * working_space[i][j][k];
3126 b += working_space[i][j][k];
3137 for(i = 0;i < ssizex; i++){
3138 for(j = 0;j < ssizey; j++){
3139 for(k = 0;k < ssizez; k++){
3140 dest[i][j][k] = working_space[i + shift][j + shift][k + shift];
3146 for(i = 0;i < ssizex + k; i++){
3147 for(j = 0;j < ssizey + k; j++)
3148 delete[] working_space[i][j];
3149 delete[] working_space[i];
3151 delete[] working_space;
3181 Int_t i,j,k,
l,li,lj,lk,lmin,lmax,
xmin,
xmax,
ymin,
ymax,zmin,zmax;
3182 Double_t maxch,plocha = 0,plocha_markov = 0;
3183 Double_t nom,nip,nim,sp,sm,spx,spy,smx,smy,spz,smz;
3184 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;
3187 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;
3190 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;
3193 Error(
"SearchFast",
"Invalid sigma, must be greater than or equal to 1");
3197 if(threshold<=0||threshold>=100){
3198 Error(
"SearchFast",
"Invalid threshold, must be positive and less than 100");
3204 Error(
"SearchFast",
"Too large sigma");
3208 if (markov ==
true) {
3209 if (averWindow <= 0) {
3210 Error(
"SearchFast",
"Averaging window must be positive");
3215 if(sizex_ext < 2 * number_of_iterations + 1 || sizey_ext < 2 * number_of_iterations + 1 || sizez_ext < 2 * number_of_iterations + 1){
3216 Error(
"SearchFast",
"Too large clipping window");
3223 for(j = 0;j < ssizex + i; j++){
3224 working_space[j] =
new Double_t* [ssizey + i];
3225 for(k = 0;k < ssizey + i; k++)
3226 working_space[j][k] =
new Double_t [4 * (ssizez + i)];
3229 for(k = 0;k < sizez_ext; k++){
3230 for(j = 0;j < sizey_ext; j++){
3231 for(i = 0;i < sizex_ext; i++){
3235 working_space[i][j][k + sizez_ext] = source[0][0][0];
3237 else if(k >= ssizez + shift)
3238 working_space[i][j][k + sizez_ext] = source[0][0][ssizez - 1];
3241 working_space[i][j][k + sizez_ext] = source[0][0][k - shift];
3244 else if(j >= ssizey + shift){
3246 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][0];
3248 else if(k >= ssizez + shift)
3249 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][ssizez - 1];
3252 working_space[i][j][k + sizez_ext] = source[0][ssizey - 1][k - shift];
3257 working_space[i][j][k + sizez_ext] = source[0][j - shift][0];
3259 else if(k >= ssizez + shift)
3260 working_space[i][j][k + sizez_ext] = source[0][j - shift][ssizez - 1];
3263 working_space[i][j][k + sizez_ext] = source[0][j - shift][k - shift];
3267 else if(i >= ssizex + shift){
3270 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][0];
3272 else if(k >= ssizez + shift)
3273 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][ssizez - 1];
3276 working_space[i][j][k + sizez_ext] = source[ssizex - 1][0][k - shift];
3279 else if(j >= ssizey + shift){
3281 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][0];
3283 else if(k >= ssizez + shift)
3284 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][ssizez - 1];
3287 working_space[i][j][k + sizez_ext] = source[ssizex - 1][ssizey - 1][k - shift];
3292 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][0];
3294 else if(k >= ssizez + shift)
3295 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][ssizez - 1];
3298 working_space[i][j][k + sizez_ext] = source[ssizex - 1][j - shift][k - shift];
3305 working_space[i][j][k + sizez_ext] = source[i - shift][0][0];
3307 else if(k >= ssizez + shift)
3308 working_space[i][j][k + sizez_ext] = source[i - shift][0][ssizez - 1];
3311 working_space[i][j][k + sizez_ext] = source[i - shift][0][k - shift];
3314 else if(j >= ssizey + shift){
3316 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][0];
3318 else if(k >= ssizez + shift)
3319 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][ssizez - 1];
3322 working_space[i][j][k + sizez_ext] = source[i - shift][ssizey - 1][k - shift];
3327 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][0];
3329 else if(k >= ssizez + shift)
3330 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][ssizez - 1];
3333 working_space[i][j][k + sizez_ext] = source[i - shift][j - shift][k - shift];
3339 for(i = 1;i <= number_of_iterations; i++){
3340 for(z = i;z < sizez_ext - i; z++){
3341 for(
y = i;
y < sizey_ext - i;
y++){
3342 for(
x = i;
x < sizex_ext - i;
x++){
3343 a = working_space[
x][
y][z + sizez_ext];
3344 p1 = working_space[
x + i][
y + i][z - i + sizez_ext];
3345 p2 = working_space[
x - i][
y + i][z - i + sizez_ext];
3346 p3 = working_space[
x + i][
y - i][z - i + sizez_ext];
3347 p4 = working_space[
x - i][
y - i][z - i + sizez_ext];
3348 p5 = working_space[
x + i][
y + i][z + i + sizez_ext];
3349 p6 = working_space[
x - i][
y + i][z + i + sizez_ext];
3350 p7 = working_space[
x + i][
y - i][z + i + sizez_ext];
3351 p8 = working_space[
x - i][
y - i][z + i + sizez_ext];
3352 s1 = working_space[
x + i][
y ][z - i + sizez_ext];
3353 s2 = working_space[
x ][
y + i][z - i + sizez_ext];
3354 s3 = working_space[
x - i][
y ][z - i + sizez_ext];
3355 s4 = working_space[
x ][
y - i][z - i + sizez_ext];
3356 s5 = working_space[
x + i][
y ][z + i + sizez_ext];
3357 s6 = working_space[
x ][
y + i][z + i + sizez_ext];
3358 s7 = working_space[
x - i][
y ][z + i + sizez_ext];
3359 s8 = working_space[
x ][
y - i][z + i + sizez_ext];
3360 s9 = working_space[
x - i][
y + i][z + sizez_ext];
3361 s10 = working_space[
x - i][
y - i][z +sizez_ext];
3362 s11 = working_space[
x + i][
y + i][z +sizez_ext];
3363 s12 = working_space[
x + i][
y - i][z +sizez_ext];
3364 r1 = working_space[
x ][
y ][z - i + sizez_ext];
3365 r2 = working_space[
x ][
y ][z + i + sizez_ext];
3366 r3 = working_space[
x - i][
y ][z + sizez_ext];
3367 r4 = working_space[
x + i][
y ][z + sizez_ext];
3368 r5 = working_space[
x ][
y + i][z + sizez_ext];
3369 r6 = working_space[
x ][
y - i][z + sizez_ext];
3370 b = (p1 + p3) / 2.0;
3374 b = (p1 + p2) / 2.0;
3378 b = (p2 + p4) / 2.0;
3382 b = (p3 + p4) / 2.0;
3386 b = (p5 + p7) / 2.0;
3390 b = (p5 + p6) / 2.0;
3394 b = (p6 + p8) / 2.0;
3398 b = (p7 + p8) / 2.0;
3402 b = (p2 + p6) / 2.0;
3406 b = (p4 + p8) / 2.0;
3410 b = (p1 + p5) / 2.0;
3414 b = (p3 + p7) / 2.0;
3418 s1 =
s1 - (p1 + p3) / 2.0;
3419 s2 = s2 - (p1 + p2) / 2.0;
3420 s3 = s3 - (p2 + p4) / 2.0;
3421 s4 = s4 - (p3 + p4) / 2.0;
3422 s5 = s5 - (p5 + p7) / 2.0;
3423 s6 = s6 - (p5 + p6) / 2.0;
3424 s7 = s7 - (p6 + p8) / 2.0;
3425 s8 = s8 - (p7 + p8) / 2.0;
3426 s9 = s9 - (p2 + p6) / 2.0;
3427 s10 = s10 - (p4 + p8) / 2.0;
3428 s11 = s11 - (p1 + p5) / 2.0;
3429 s12 = s12 - (p3 + p7) / 2.0;
3430 b = (
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0;
3434 b = (s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0;
3438 b = (s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0;
3442 b = (
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0;
3446 b = (s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0;
3450 b = (s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0;
3454 r1 = r1 - ((
s1 + s3) / 2.0 + (s2 + s4) / 2.0 + (p1 + p2 + p3 + p4) / 4.0);
3455 r2 = r2 - ((s5 + s7) / 2.0 + (s6 + s8) / 2.0 + (p5 + p6 + p7 + p8) / 4.0);
3456 r3 = r3 - ((s3 + s7) / 2.0 + (s9 + s10) / 2.0 + (p2 + p4 + p6 + p8) / 4.0);
3457 r4 = r4 - ((
s1 + s5) / 2.0 + (s11 + s12) / 2.0 + (p1 + p3 + p5 + p7) / 4.0);
3458 r5 = r5 - ((s9 + s11) / 2.0 + (s2 + s6) / 2.0 + (p1 + p2 + p5 + p6) / 4.0);
3459 r6 = r6 - ((s4 + s8) / 2.0 + (s10 + s12) / 2.0 + (p3 + p4 + p7 + p8) / 4.0);
3460 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;
3464 working_space[
x][
y][z] =
a;
3468 for(z = i;z < sizez_ext - i; z++){
3469 for(
y = i;
y < sizey_ext - i;
y++){
3470 for(
x = i;
x < sizex_ext - i;
x++){
3471 working_space[
x][
y][z + sizez_ext] = working_space[
x][
y][z];
3476 for(k = 0;k < sizez_ext; k++){
3477 for(j = 0;j < sizey_ext; j++){
3478 for(i = 0;i < sizex_ext; i++){
3482 working_space[i][j][k + 3 * sizez_ext] = source[0][0][0] - working_space[i][j][k + sizez_ext];
3484 else if(k >= ssizez + shift)
3485 working_space[i][j][k + 3 * sizez_ext] = source[0][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
3488 working_space[i][j][k + 3 * sizez_ext] = source[0][0][k - shift] - working_space[i][j][k + sizez_ext];
3491 else if(j >= ssizey + shift){
3493 working_space[i][j][k + 3 * sizez_ext] = source[0][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
3495 else if(k >= ssizez + shift)
3496 working_space[i][j][k + 3 * sizez_ext] = source[0][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
3499 working_space[i][j][k + 3 * sizez_ext] = source[0][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
3504 working_space[i][j][k + 3 * sizez_ext] = source[0][j - shift][0] - working_space[i][j][k + sizez_ext];
3506 else if(k >= ssizez + shift)
3507 working_space[i][j][k + 3 * sizez_ext] = source[0][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
3510 working_space[i][j][k + 3 * sizez_ext] = source[0][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
3514 else if(i >= ssizex + shift){
3517 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][0][0] - working_space[i][j][k + sizez_ext];
3519 else if(k >= ssizez + shift)
3520 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
3523 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][0][k - shift] - working_space[i][j][k + sizez_ext];
3526 else if(j >= ssizey + shift){
3528 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
3530 else if(k >= ssizez + shift)
3531 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
3534 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
3539 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][j - shift][0] - working_space[i][j][k + sizez_ext];
3541 else if(k >= ssizez + shift)
3542 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
3545 working_space[i][j][k + 3 * sizez_ext] = source[ssizex - 1][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
3552 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][0][0] - working_space[i][j][k + sizez_ext];
3554 else if(k >= ssizez + shift)
3555 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][0][ssizez - 1] - working_space[i][j][k + sizez_ext];
3558 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][0][k - shift] - working_space[i][j][k + sizez_ext];
3561 else if(j >= ssizey + shift){
3563 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][ssizey - 1][0] - working_space[i][j][k + sizez_ext];
3565 else if(k >= ssizez + shift)
3566 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][ssizey - 1][ssizez - 1] - working_space[i][j][k + sizez_ext];
3569 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][ssizey - 1][k - shift] - working_space[i][j][k + sizez_ext];
3574 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][j - shift][0] - working_space[i][j][k + sizez_ext];
3576 else if(k >= ssizez + shift)
3577 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][j - shift][ssizez - 1] - working_space[i][j][k + sizez_ext];
3580 working_space[i][j][k + 3 * sizez_ext] = source[i - shift][j - shift][k - shift] - working_space[i][j][k + sizez_ext];
3587 for(i = 0;i < sizex_ext; i++){
3588 for(j = 0;j < sizey_ext; j++){
3589 for(k = 0;k < sizez_ext; k++){
3590 if(i >= shift && i < ssizex + shift && j >= shift && j < ssizey + shift && k >= shift && k < ssizez + shift){
3591 working_space[i][j][k + 2 * sizez_ext] = source[i - shift][j - shift][k - shift];
3592 plocha_markov = plocha_markov + source[i - shift][j - shift][k - shift];
3595 working_space[i][j][k + 2 * sizez_ext] = 0;
3602 xmax = sizex_ext - 1;
3604 ymax = sizey_ext - 1;
3606 zmax = sizez_ext - 1;
3607 for(i = 0,maxch = 0;i < sizex_ext; i++){
3608 for(j = 0;j < sizey_ext;j++){
3609 for(k = 0;k < sizez_ext;k++){
3610 working_space[i][j][k] = 0;
3611 if(maxch < working_space[i][j][k + 2 * sizez_ext])
3612 maxch = working_space[i][j][k + 2 * sizez_ext];
3614 plocha += working_space[i][j][k + 2 * sizez_ext];
3621 for(i = 0;i < ssizex + k; i++){
3622 for(j = 0;j < ssizey + k; j++)
3623 delete[] working_space[i][j];
3624 delete[] working_space[i];
3626 delete [] working_space;
3631 working_space[
xmin][
ymin][zmin] = 1;
3633 nip = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
3634 nim = working_space[i + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
3636 for(
l = 1;
l <= averWindow;
l++){
3638 a = working_space[
xmax][
ymin][zmin + 2 * sizez_ext] / maxch;
3641 a = working_space[i +
l][
ymin][zmin + 2 * sizez_ext] / maxch;
3653 if(i -
l + 1 <
xmin)
3654 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
3657 a = working_space[i -
l + 1][
ymin][zmin + 2 * sizez_ext] / maxch;
3671 a = working_space[i + 1][
ymin][zmin] =
a * working_space[i][
ymin][zmin];
3675 nip = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
3676 nim = working_space[
xmin][i + 1][zmin + 2 * sizez_ext] / maxch;
3678 for(
l = 1;
l <= averWindow;
l++){
3680 a = working_space[
xmin][
ymax][zmin + 2 * sizez_ext] / maxch;
3683 a = working_space[
xmin][i +
l][zmin + 2 * sizez_ext] / maxch;
3695 if(i -
l + 1 <
ymin)
3696 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
3699 a = working_space[
xmin][i -
l + 1][zmin + 2 * sizez_ext] / maxch;
3713 a = working_space[
xmin][i + 1][zmin] =
a * working_space[
xmin][i][zmin];
3716 for(i = zmin;i < zmax;i++){
3717 nip = working_space[
xmin][
ymin][i + 2 * sizez_ext] / maxch;
3718 nim = working_space[
xmin][
ymin][i + 1 + 2 * sizez_ext] / maxch;
3720 for(
l = 1;
l <= averWindow;
l++){
3722 a = working_space[
xmin][
ymin][zmax + 2 * sizez_ext] / maxch;
3725 a = working_space[
xmin][
ymin][i +
l + 2 * sizez_ext] / maxch;
3737 if(i -
l + 1 < zmin)
3738 a = working_space[
xmin][
ymin][zmin + 2 * sizez_ext] / maxch;
3741 a = working_space[
xmin][
ymin][i -
l + 1 + 2 * sizez_ext] / maxch;
3760 nip = working_space[i][j + 1][zmin + 2 * sizez_ext] / maxch;
3761 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
3763 for(
l = 1;
l <= averWindow;
l++){
3765 a = working_space[
xmax][j][zmin + 2 * sizez_ext] / maxch;
3768 a = working_space[i +
l][j][zmin + 2 * sizez_ext] / maxch;
3780 if(i -
l + 1 <
xmin)
3781 a = working_space[
xmin][j][zmin + 2 * sizez_ext] / maxch;
3784 a = working_space[i -
l + 1][j][zmin + 2 * sizez_ext] / maxch;
3798 nip = working_space[i + 1][j][zmin + 2 * sizez_ext] / maxch;
3799 nim = working_space[i + 1][j + 1][zmin + 2 * sizez_ext] / maxch;
3800 for(
l = 1;
l <= averWindow;
l++){
3802 a = working_space[i][
ymax][zmin + 2 * sizez_ext] / maxch;
3805 a = working_space[i][j +
l][zmin + 2 * sizez_ext] / maxch;
3817 if(j -
l + 1 <
ymin)
3818 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
3821 a = working_space[i][j -
l + 1][zmin + 2 * sizez_ext] / maxch;
3834 a = (spx * working_space[i][j + 1][zmin] + spy * working_space[i + 1][j][zmin]) / (smx + smy);
3835 working_space[i + 1][j + 1][zmin] =
a;
3840 for(j = zmin;j < zmax;j++){
3841 nip = working_space[i][
ymin][j + 1 + 2 * sizez_ext] / maxch;
3842 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
3844 for(
l = 1;
l <= averWindow;
l++){
3846 a = working_space[
xmax][
ymin][j + 2 * sizez_ext] / maxch;
3849 a = working_space[i +
l][
ymin][j + 2 * sizez_ext] / maxch;
3861 if(i -
l + 1 <
xmin)
3862 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
3865 a = working_space[i -
l + 1][
ymin][j + 2 * sizez_ext] / maxch;
3879 nip = working_space[i + 1][
ymin][j + 2 * sizez_ext] / maxch;
3880 nim = working_space[i + 1][
ymin][j + 1 + 2 * sizez_ext] / maxch;
3881 for(
l = 1;
l <= averWindow;
l++){
3883 a = working_space[i][
ymin][zmax + 2 * sizez_ext] / maxch;
3886 a = working_space[i][
ymin][j +
l + 2 * sizez_ext] / maxch;
3898 if(j -
l + 1 < zmin)
3899 a = working_space[i][
ymin][zmin + 2 * sizez_ext] / maxch;
3902 a = working_space[i][
ymin][j -
l + 1 + 2 * sizez_ext] / maxch;
3915 a = (spx * working_space[i][
ymin][j + 1] + spz * working_space[i + 1][
ymin][j]) / (smx + smz);
3916 working_space[i + 1][
ymin][j + 1] =
a;
3921 for(j = zmin;j < zmax;j++){
3922 nip = working_space[
xmin][i][j + 1 + 2 * sizez_ext] / maxch;
3923 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
3925 for(
l = 1;
l <= averWindow;
l++){
3927 a = working_space[
xmin][
ymax][j + 2 * sizez_ext] / maxch;
3930 a = working_space[
xmin][i +
l][j + 2 * sizez_ext] / maxch;
3942 if(i -
l + 1 <
ymin)
3943 a = working_space[
xmin][
ymin][j + 2 * sizez_ext] / maxch;
3946 a = working_space[
xmin][i -
l + 1][j + 2 * sizez_ext] / maxch;
3960 nip = working_space[
xmin][i + 1][j + 2 * sizez_ext] / maxch;
3961 nim = working_space[
xmin][i + 1][j + 1 + 2 * sizez_ext] / maxch;
3962 for(
l = 1;
l <= averWindow;
l++){
3964 a = working_space[
xmin][i][zmax + 2 * sizez_ext] / maxch;
3967 a = working_space[
xmin][i][j +
l + 2 * sizez_ext] / maxch;
3979 if(j -
l + 1 < zmin)
3980 a = working_space[
xmin][i][zmin + 2 * sizez_ext] / maxch;
3983 a = working_space[
xmin][i][j -
l + 1 + 2 * sizez_ext] / maxch;
3996 a = (spy * working_space[
xmin][i][j + 1] + spz * working_space[
xmin][i + 1][j]) / (smy + smz);
3997 working_space[
xmin][i + 1][j + 1] =
a;
4003 for(k = zmin;k < zmax; k++){
4004 nip = working_space[i][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4005 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4007 for(
l = 1;
l <= averWindow;
l++){
4009 a = working_space[
xmax][j][k + 2 * sizez_ext] / maxch;
4012 a = working_space[i +
l][j][k + 2 * sizez_ext] / maxch;
4024 if(i -
l + 1 <
xmin)
4025 a = working_space[
xmin][j][k + 2 * sizez_ext] / maxch;
4028 a = working_space[i -
l + 1][j][k + 2 * sizez_ext] / maxch;
4042 nip = working_space[i + 1][j][k + 1 + 2 * sizez_ext] / maxch;
4043 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4044 for(
l = 1;
l <= averWindow;
l++){
4046 a = working_space[i][
ymax][k + 2 * sizez_ext] / maxch;
4049 a = working_space[i][j +
l][k + 2 * sizez_ext] / maxch;
4061 if(j -
l + 1 <
ymin)
4062 a = working_space[i][
ymin][k + 2 * sizez_ext] / maxch;
4065 a = working_space[i][j -
l + 1][k + 2 * sizez_ext] / maxch;
4079 nip = working_space[i + 1][j + 1][k + 2 * sizez_ext] / maxch;
4080 nim = working_space[i + 1][j + 1][k + 1 + 2 * sizez_ext] / maxch;
4081 for(
l = 1;
l <= averWindow;
l++ ){
4083 a = working_space[i][j][zmax + 2 * sizez_ext] / maxch;
4086 a = working_space[i][j][k +
l + 2 * sizez_ext] / maxch;
4098 if(j -
l + 1 <
ymin)
4099 a = working_space[i][j][zmin + 2 * sizez_ext] / maxch;
4102 a = working_space[i][j][k -
l + 1 + 2 * sizez_ext] / maxch;
4115 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);
4116 working_space[i + 1][j + 1][k + 1] =
a;
4124 for(k = zmin;k <= zmax; k++){
4125 working_space[i][j][k] = working_space[i][j][k] / nom;
4126 a+=working_space[i][j][k];
4130 for(i = 0;i < sizex_ext; i++){
4131 for(j = 0;j < sizey_ext; j++){
4132 for(k = 0;k < sizez_ext; k++){
4133 working_space[i][j][k + 2 * sizez_ext] = working_space[i][j][k] * plocha_markov /
a;
4140 for(k = 0;k < ssizez; k++){
4141 for(j = 0;j < ssizey; j++){
4142 for(i = 0;i < ssizex; i++){
4143 working_space[i][j][k] = 0;
4144 working_space[i][j][sizez_ext + k] = 0;
4145 if(working_space[i][j][k + 3 * sizez_ext] > maximum)
4146 maximum=working_space[i][j][k+3*sizez_ext];
4154 for(i = -j;i <= j; i++){
4172 c[i] =
c[i] / norma;
4174 a = pocet_sigma *
sigma + 0.5;
4177 zmax = sizez_ext - i - 1;
4179 ymax = sizey_ext - i - 1;
4181 xmax = sizex_ext - i - 1;
4186 for(k = zmin;k <= zmax; k++){
4188 for(li = lmin;li <= lmax; li++){
4189 for(lj = lmin;lj <= lmax; lj++){
4190 for(lk = lmin;lk <= lmax; lk++){
4192 b =
c[li] *
c[lj] *
c[lk];
4198 working_space[i][j][k] = s;
4205 for(z = zmin + 1;z < zmax; z++){
4206 val = working_space[
x][
y][z];
4207 val1 = working_space[
x - 1][
y - 1][z - 1];
4208 val2 = working_space[
x ][
y - 1][z - 1];
4209 val3 = working_space[
x + 1][
y - 1][z - 1];
4210 val4 = working_space[
x - 1][
y ][z - 1];
4211 val5 = working_space[
x ][
y ][z - 1];
4212 val6 = working_space[
x + 1][
y ][z - 1];
4213 val7 = working_space[
x - 1][
y + 1][z - 1];
4214 val8 = working_space[
x ][
y + 1][z - 1];
4215 val9 = working_space[
x + 1][
y + 1][z - 1];
4216 val10 = working_space[
x - 1][
y - 1][z ];
4217 val11 = working_space[
x ][
y - 1][z ];
4218 val12 = working_space[
x + 1][
y - 1][z ];
4219 val13 = working_space[
x - 1][
y ][z ];
4220 val14 = working_space[
x + 1][
y ][z ];
4221 val15 = working_space[
x - 1][
y + 1][z ];
4222 val16 = working_space[
x ][
y + 1][z ];
4223 val17 = working_space[
x + 1][
y + 1][z ];
4224 val18 = working_space[
x - 1][
y - 1][z + 1];
4225 val19 = working_space[
x ][
y - 1][z + 1];
4226 val20 = working_space[
x + 1][
y - 1][z + 1];
4227 val21 = working_space[
x - 1][
y ][z + 1];
4228 val22 = working_space[
x ][
y ][z + 1];
4229 val23 = working_space[
x + 1][
y ][z + 1];
4230 val24 = working_space[
x - 1][
y + 1][z + 1];
4231 val25 = working_space[
x ][
y + 1][z + 1];
4232 val26 = working_space[
x + 1][
y + 1][z + 1];
4233 f = -s_f_ratio_peaks * working_space[
x][
y][z + sizez_ext];
4234 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){
4236 for(li = lmin;li <= lmax; li++){
4237 a = working_space[
x + li -
PEAK_WINDOW / 2][
y][z + 2 * sizez_ext];
4239 f +=
a *
c[li] *
c[li];
4241 f = -s_f_ratio_peaks * sqrt(
f);
4244 for(li = lmin;li <= lmax; li++){
4245 a = working_space[
x][
y + li -
PEAK_WINDOW / 2][z + 2 * sizez_ext];
4247 f +=
a *
c[li] *
c[li];
4249 f = -s_f_ratio_peaks * sqrt(
f);
4252 for(li = lmin;li <= lmax; li++){
4253 a = working_space[
x][
y][z + li -
PEAK_WINDOW / 2 + 2 * sizez_ext];
4255 f +=
a *
c[li] *
c[li];
4257 f = -s_f_ratio_peaks * sqrt(
f);
4260 for(li = lmin;li <= lmax; li++){
4261 for(lj = lmin;lj <= lmax; lj++){
4263 s +=
a *
c[li] *
c[lj];
4264 f +=
a *
c[li] *
c[li] *
c[lj] *
c[lj];
4267 f = s_f_ratio_peaks * sqrt(
f);
4270 for(li = lmin;li <= lmax; li++){
4271 for(lj = lmin;lj <= lmax; lj++){
4273 s +=
a *
c[li] *
c[lj];
4274 f +=
a *
c[li] *
c[li] *
c[lj] *
c[lj];
4277 f = s_f_ratio_peaks * sqrt(
f);
4280 for(li = lmin;li <= lmax; li++){
4281 for(lj=lmin;lj<=lmax;lj++){
4283 s +=
a *
c[li] *
c[lj];
4284 f +=
a *
c[li] *
c[li] *
c[lj] *
c[lj];
4287 f = s_f_ratio_peaks * sqrt(
f);
4289 if(
x >= shift && x < ssizex + shift && y >= shift && y < ssizey + shift && z >= shift && z < ssizez + shift){
4290 if(working_space[
x][
y][z + 3 * sizez_ext] > threshold * maximum / 100.0){
4292 for(k =
x - 1,
a = 0,
b = 0;k <=
x + 1; k++){
4293 a += (
Double_t)(k - shift) * working_space[k][
y][z];
4294 b += working_space[k][
y][z];
4297 for(k =
y - 1,
a = 0,
b = 0;k <=
y + 1; k++){
4298 a += (
Double_t)(k - shift) * working_space[
x][k][z];
4299 b += working_space[
x][k][z];
4302 for(k = z - 1,
a = 0,
b = 0;k <= z + 1; k++){
4303 a += (
Double_t)(k - shift) * working_space[
x][
y][k];
4304 b += working_space[
x][
y][k];
4321 for(i = 0;i < ssizex; i++){
4322 for(j = 0;j < ssizey; j++){
4323 for(k = 0;k < ssizez; k++){
4324 val = -working_space[i + shift][j + shift][k + shift];
4327 dest[i][j][k] = val;
4333 for(i = 0;i < ssizex + k; i++){
4334 for(j = 0;j < ssizey + k; j++)
4335 delete[] working_space[i][j];
4336 delete[] working_space[i];
4338 delete[] working_space;
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
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
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.
virtual ~TSpectrum3()
Destructor.
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
virtual void Print(Option_t *option="") const
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...
Short_t Max(Short_t a, Short_t b)
Double_t Sqrt(Double_t x)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Short_t Min(Short_t a, Short_t b)
#define dest(otri, vertexptr)