[mcstas-users] logarithmic binning detector

Peter Kjær Willendrup pkwi at dtu.dk
Thu Jan 22 16:36:23 CET 2026


HI Rob, Markus


The manual is unfortunately somewhat out-of-date wrt. Monitor_nD and uservars. Since McStas 3 you can no longer directly pass a value (i.e. log(something) to the user1 input.
Today uservars become part of the particle and identified / handled by a string symbol.


Building on Markus’ input, the easiest achievable option would be to

1) Use an instrument USERVAR to calculate your own value of log10(Q) based on time-of-flight of the individual neutron (let’s call it logQ)

2) Measure that uservar with Monitor_nD(user1=“logQ”, username1=“Log10(Q)”, options=“user1 limits=[-3 0] bins=90”)


The output routines of Monitor_nD are effectively the same as used in every other monitor, DETECTOR_OUT_0D … DETECTOR_OUT_2D  (list-mode is also a 2d block “with trimmings”)


Feel free to add an issue on GitHub about a wish for log-binning, then it could potentially come some time in the future...


Best
Peter



On 22 Jan 2026, at 13.04, Robert Dalgliesh - STFC UKRI via mcstas-users <mcstas-users at mcstas.org> wrote:

Hi Markus,
I can’t use the built in q monitors because they don’t take account of time-of-flight.
I’m writing monitors that essentially perform a TOF data reduction in mcstas to remove the step where you have to push the data through e.g. Mantid.

This route is much more efficient as it doesn’t result in large event mode files but relies on you not using the fact that mcstas inherently knows the direction of travel and wavelength of the neutron.
The downside is that you run into this sort of problem and you have to do a bunch of geometry calculations to work out where pixels are in real space.

That being said I can possibly use the output routines from monitor_nd….
I’ll take a look

Thanks for the reply

Rob


From: Markus APPEL <appel at ill.fr>
Sent: 22 January 2026 08:27
To: Dalgliesh, Robert (STFC,RAL,ISIS) <robert.dalgliesh at stfc.ac.uk>; mcstas-users at mcstas.org
Subject: Re: [mcstas-users] logarithmic binning detector

Hi Rob,
not sure if it's what you want to achieve, but would it not be easier to monitor log10(Q) with limits from -3 to 0 and 90 linear bins?
That should be simple with Monitor_nD and user variables (see section 9.8.7 of the Component Manual):
COMPONENT QMonitor = Monitor nD ( user1=log10(Q) , username1=”Log (Q)” , ....)

Unless that's what you wanted to avoid for some reason.

Best,
Markus

On 21/01/2026 13:09, Robert Dalgliesh - STFC UKRI via mcstas-users wrote:
Hi,
If I want to create a new detector with logarithmic binning is there an easy way to export the x array?
The way DETECTOR_OUT_1D works requires the binning scheme to be linear.

I would like to define e.g. q bins
1e-3 to 1.0 with 8% binning so the bins are

[a,ab,ab^2,….] where a=1e-3 and b=1.08.

Working out which bin to put data into is straightforward in the same way as linear bins but data output isn’t, due to the constraints of the function above.
In addition, the read function for mcstas plotting would need modification so I guess it will mean an additional function is required unless I’ve missed something.

Obviously, I can write something that outputs the data and post process the x array but that’s not ideal.

Rob



====================================================================
If you receive this email outside working hours then please do not feel obliged to reply
====================================================================
Dr. Robert Dalgliesh
Small Angle Scattering Group Leader
ISIS Neutron and Muon Source
Science and Technology Facilities Council
Building R3 1.29,
Rutherford Appleton Laboratory​​,
​Harwell Campus,
Didcot
​Oxfordshire,
OX11 0QX.
UK
Tel: +44(0)1235-445687
Email: Robert.dalgliesh at stfc.ac.uk<mailto:Robert.dalgliesh at stfc.ac.uk>




_______________________________________________

mcstas-users mailing list

mcstas-users at mcstas.org<mailto:mcstas-users at mcstas.org>

https://mailman2.mcstas.org/mailman/listinfo/mcstas-users


_______________________________________________
mcstas-users mailing list
mcstas-users at mcstas.org
https://mailman2.mcstas.org/mailman/listinfo/mcstas-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20260122/d31b414f/attachment-0001.htm>


More information about the mcstas-users mailing list