Skip to content

Commit

Permalink
Remove apparent typo (x->y) in calculation of y-bin index, protect ag…
Browse files Browse the repository at this point in the history
…ainst under/overrun of indices
  • Loading branch information
willend committed Dec 11, 2023
1 parent 22a171d commit 879505a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions mcstas-comps/monitors/TOF2Q_cylPSD_monitor.comp
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ TRACE

E = VS2E*(L_flight/(t-T_zero))*(L_flight/(t-T_zero));

j = floor((x - ymin)*ny/(ymax - ymin));
// printf("--------------- E = %g meV --------------- \n",E);
// printf("--------------- sqrt4 = %g meV --------------- \n",sqrt(4));
// printf("--------------- lambda = %g Å --------------- \n",2*PI/sqrt(E/2.072));
j = floor((y - ymin)*ny/(ymax - ymin));

Q=2*sqrt(E/2.072)*sin(theta);
// printf("--------------- Q = %g Å --------------- \n",Q);
i = floor((Q-Qmin)*nQ/(Qmax-Qmin));

double p2 = p*p;
#pragma acc atomic
TOF_N[i][j] = TOF_N[i][j]+1;
#pragma acc atomic
TOF_p[i][j] = TOF_p[i][j]+p;
#pragma acc atomic
TOF_p2[i][j] = TOF_p2[i][j]+p2;
i = floor((Q-Qmin)*nQ/(Qmax-Qmin));

if (i>=0 && i<nQ && j>=0 && j<ny) {
double p2 = p*p;
#pragma acc atomic
TOF_N[i][j] = TOF_N[i][j]+1;
#pragma acc atomic
TOF_p[i][j] = TOF_p[i][j]+p;
#pragma acc atomic
TOF_p2[i][j] = TOF_p2[i][j]+p2;
}
if (restore_neutron) {
RESTORE_NEUTRON(INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p);
}
Expand Down

0 comments on commit 879505a

Please sign in to comment.