McStasMcXtrace / McCode

The home of the McStas (neutrons) and McXtrace (x-rays) Monte-Carlo ray-tracing instrument simulation codes.
https://github.com/McStasMcXtrace/McCode/wiki
GNU General Public License v3.0
77 stars 54 forks source link

McStas -> Mantid: single event in detector bug #577

Open huegle opened 6 years ago

huegle commented 6 years ago

A little bug that I ran into every now and then when running McStas to Mantid simulations: If a detector (Monitor_nD) manages to catch one single event, it writes the corresponding events page in the .h5 file in a way that is a) interpreted by mantid as a one-dimensional workspace, which messes up the loadMcStas routine and creates an empty, undeletable zombie workspace. b) interpreted by hdfView as one column with five lines, rather than one line with five columns.

Based on some crashes that I see right now, it might also cause problems when an MPI run is trying to combine data from the slave nodes. I can't prove this 100% (it just freezes up and does not deliver output), but it does seem to happen only on simulations where I expect very low countrate detectors (e.g. It works when I run the instrument with a guide and crashes when I run it without).

willend commented 6 years ago

Dear @huegle,

Thanks for the bug report! @ebknudsen and myself are already looking at various other Mantid-related issues for the next McStas release, so we hope to fix this one also.

It could be a great help if you posted a zip file here including an example instrument?

Best, Peter

huegle commented 6 years ago

mccode.zip

Here is an example output mccode.h5 file. The Mantid error message is "Event data in McStas nexus file not loaded. Expected event data block to be two dimensional". Detector 62 is the culprit, I think. Unfortunately, I do not remember how many histories I ran this one with (1E6? 1E7?), which is of course crucial for this bug. The instrument itself is rather stupid: It was supposed to be a circular arrangement of 8-packs, but by messing up a rotation, the detectors are mostly oriented radially away from the sample, instead of facing it along the tangential lines (really easy to get a single event in a detector that way). It is a perfect example of what can go wrong if you generate a instrument files by scripts, and a good example of where I usually encounter the bug: during the "quick test run" phase, trying to debug my .instr files.