[mcstas-users] Monitor_nD question (V3.5.23)
Peter Kjær Willendrup
pkwi at dtu.dk
Tue Mar 25 07:20:09 CET 2025
Hi Uli,
Since McStas 3, Monitor_nD measures user variables via the so-called particle USERVARS, that become “part of the particle”.
(This consequently needs better documentation it seems, sorry about that!)
In your instrument file, add a USERVARS block below DECLARE and before INITIALIZE, something like this:
INSTRUMENT my_instrument()
DECLARE %{
%}
USERVARS %{
int xtalindex; // A double is of course also OK
%}
INITIALIZE %{
%}
Best and hope this helps?
Peter
On 24 Mar 2025, at 21.24, Wildgruber, Christoph U. via mcstas-users <mcstas-users at mcstas.org> wrote:
Hi,
I am trying to follow the recipe in the Monitor_nD component description.
The purpose is to track the value of ‘xtalindex’ together with the particle index ‘n’ on an event basis
to evaluate our multi-crystal analyzer setup:
How to monitor any instrument/component variable into a Monitor_nD
Suppose you want to monitor a variable 'age' which you assign somwhere in
the instrument:
COMPONENT MyMonitor = Monitor_nD(
xwidth = 0.1, yheight = 0.1,
user1="age", username1="Age of the Captain [years]",
options="user1, auto")
AT ...
to keep track of a variable I am setting with “EXTEND”.
…
COMPONENT Analyzer_14 = Monochromator_flat_CUW(zwidth = Alength, yheight = Awidth_14,
mosaich = mos, mosaicv = mos,
r0 = 0.99, DM = 3.355)
AT (0, 0, 0) RELATIVE Mono_Arm_14
ROTATED (0, analyzer_rot_14, 0) RELATIVE Mono_Arm_14
EXTEND
%{
xtalindex = 14.0;
%}
…
…and use ‘xtalindex’ the following way:
COMPONENT Collimator_out = Monitor_nD(user1 = ”xtalindex”, username1 = “Crystal index”,
options = "user1,n,x,y,z,vx,vy,vz,t,list all neutrons verbose",
xmin = 0.0, xmax = 1.0, ymin = -0.2, ymax = 0.2,
filename="collimator_out.evt", restore_neutron=1)
AT (0, 0, 0.2) RELATIVE Monitor_Arm
I do get an extra column in the output file but the value is always 0, regardless how I
define and initialize xtalindex. I must be doing something fundamentally wrong.
Any suggestions are greatly appreciated!
Thanks,
Uli
_______________________________________________
mcstas-users mailing list
mcstas-users at mcstas.org<mailto:mcstas-users at mcstas.org>
https://mailman2.mcstas.org/mailman/listinfo/mcstas-users
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/20250325/6c1582fb/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/20250325/6c1582fb/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/20250325/6c1582fb/attachment-0003.gif>
More information about the mcstas-users
mailing list