[mcstas-users] Absolute interaction position calculation
Peter Kjær Willendrup
pkwi at dtu.dk
Tue Mar 31 13:07:24 CEST 2026
Hi again Rob,
This one was also overlooked, sorry... :-(
On Tue Aug 12 10:40:26 CEST 2025 Robert Dalgliesh - STFC UKRI robert.dalgliesh at stfc.ac.uk wrote:
Is there a straightforward way to calculate the absolute interaction position of a neutron within a component after you have used PROP_Z0?
I am thinking you mean after SCATTER? (PROP_Z0 just puts everything at the z=0 plane of the component? Anyway, the procedure is about the same
I would like to know the interaction point in both local (component) coordinates and in the world system so I can then work out the interaction position relative to other components.
Having dug around in the documentation I couldn’t see anything obvious.
Yes, there is indeed:
1) Add USERVARS for measuring local and global coordinates to your instrument file:
USERVARS %{
double xloc;
double yloc;
double zloc;
double xglob;
double yglob;
double zglob;
%}
2) Add an EXTEND block on your sample comp:
COMPONENT Sample = Something(…)
AT (0,0,0) RELATIVE SamplePos
EXTEND %{
// Measure neutron coordinates in sample frame
// (can be made to depend on e.g. if (SCATTERED) )
xloc=x;
yloc=y;
zloc=z;
%}
3) Add an Arm located at the Sample position, but ROTATED into the global frame:
COMPONENT SemiGlobal = Arm()
AT (0,0,0) RELATIVE SamplePos
ROTATED (0,0,0) ABSOLUTE
EXTEND %{
// Take comp absolute comps...
coords_get(POS_A_COMP_INDEX(INDEX_CURRENT_COMP), &xglob, &yglob, &zglob);
// … and add the relative coordinates of the neutron in the semi-global frame
xglob+=x;
yglob+=y;
zglob+=z;
%}
(There are surely other ways to do that calculation also, but this is the simplest one in my mind.)
4) Measure on the vars using Monitor_nD(user1=“xglob”…) or Flex_monitor_1/2/3D(user1=“xglob”…)
All the best and happy easter,
Peter
Peter Kjær Willendrup
Forskningsingeniør, Specialkonsulent
DTU Physics
[image001.gif]
Technical University of Denmark
[image002.gif]
Department of Physics
Fysikvej
Building 307
DK-2800 Kongens Lyngby
Main office at
ESS DMSC
Building 305
DK-2800 Kongens Lyngby
Direct +45 2125 4612
Mobil +45 2125 4612
Fax +45 4593 2399
pkwi at fysik.dtu.dk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20260331/39717c1d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 58 bytes
Desc: image001.gif
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20260331/39717c1d/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.gif
Type: image/gif
Size: 1055 bytes
Desc: image002.gif
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20260331/39717c1d/attachment-0003.gif>
More information about the mcstas-users
mailing list