<html aria-label="message body">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
(Sorry for potential double-posting, debugging McStas mailman setup)</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Dear all,</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
I received the below question on using USERVARS in place of PreMonitor_nD from Andreas Ostermann - along with a report that the mailinglist seems to be down.</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hence this email is both a test of the mailinglist and includes my response to Andreas.</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
</div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div><br>
</div>
<div><br>
</div>
<div>For the USERVARS concept, I admit that the manual(s) are missing some updates on this point. Here is an initial recipe to get this to work:</div>
<div><br>
</div>
<div>1. Add a USERVARS block to your instrument - below DECLARE but before INITIALIZE</div>
<div><br>
</div>
<div>USERVARS %{</div>
<div> // Variables added to the neutron, for measuring starting-coords at the source:</div>
<div> double Xsrc;</div>
<div> double Ysrc;</div>
<div>%}</div>
<div><br>
</div>
<div>2. Add an EXTEND block to the component where you want to measure the “pre” state:</div>
<div><br>
</div>
<div>COMPONENT ColdSource = Some_source(...)</div>
<div>AT (0,0,0) RELATIVE origin</div>
<div>EXTEND %{</div>
<div> // After initialisation in the source comp, neutron has starting coords. We measure here:</div>
<div> Xsrc=x;</div>
<div> Ysrc=y;</div>
<div>%}</div>
<div><br>
</div>
<div>3. Let a later Monitor_nD use Xsrc and Ysrc as “uservars”:</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>COMPONENT CS_area_mon = Monitor_nD(xmin=-0.01, xmax=0.01,</div>
<div> ymin=-0.01, ymax=0.01, user1="Xsrc", user2="Ysrc", username1="y at source / [m]", username2=“y at source / [m], </div>
<div> filename="CS_area_pre.psd",</div>
<div> options= “user1,user2, all bins=50, all limits=[-0.12 0.12], use premonitor")</div>
<div> AT (0,0,0.0008) RELATIVE Arm_SAM_pos</div>
<div> ROTATED (0,0,0) RELATIVE Arm_SAM_pos</div>
</div>
<div><br>
</div>
<div>
<div>Hope this helps?</div>
<div><br>
</div>
<div>Best,</div>
<div>Peter</div>
<div><br>
</div>
<div><br>
<blockquote type="cite">
<div>On 8 Jun 2026, at 10.27, Andreas Ostermann <Andreas.Ostermann@frm2.tum.de> wrote:</div>
<div>
<div>
<pre class="moz-quote-pre" wrap="">Dear colleagues,
In the past, I have often used the "PreMonitor_nD / Monitor_nD" pair
to investigate the origin of neutrons which reach the sample in a
upstream positon. For example:
*******
COMPONENT PreMon_CS_area_mon = PreMonitor_nD(monitor_comp =
CS_area_mon)
AT (0,0,0.0001) RELATIVE ColdSource
ROTATED (0,0,0) RELATIVE ColdSource
COMPONENT CS_area_mon = Monitor_nD(xmin=-0.01, xmax=0.01,
ymin=-0.01, ymax=0.01,
filename="CS_area_pre.psd",
options= "x,y, all bins=50, all
limits=[-0.12 0.12], use premonitor")
AT (0,0,0.0008) RELATIVE Arm_SAM_pos
ROTATED (0,0,0) RELATIVE Arm_SAM_pos
*******
In the current versions of McStas, I am supposed to use the
"uservars" concept to investigate or plot the status of neutrons
earlier in the instrument. Unfortunately, after reading the manuals,
it is not entirely clear to me how I can use the "uservars" concept
to reconstruct the "PreMonitor_nD / Monitor_nD" bundle.
I would be grateful for any help.
Best wishes from the MLZ,
Andreas Ostermann
</pre>
<div class="moz-signature">-- <br>
<b>Dr. Andreas Ostermann</b><br>
Instrument BIODIFF<br>
Technical University of Munich<br>
Forschungs-Neutronenquelle <br>
Heinz Maier-Leibnitz (FRM II) <br>
Lichtenbergstr. 1 <br>
85748 Garching <br>
Germany<br>
Tel.: +49 (0)89 289-14702<br>
<br>
<br>
<a href="mailto:andreas.ostermann@frm2.tum.de" class="moz-txt-link-freetext">andreas.ostermann@frm2.tum.de</a><br>
<a href="https://mlz-garching.de/" originalsrc="https://mlz-garching.de/">www.mlz-garching.de
</a><br>
<a href="https://www.frm2.tum.de/frm2/startseite/" originalsrc="https://www.frm2.tum.de/frm2/startseite/">www.frm2.tum.de</a><br>
Follow us on social media: <a href="https://www.instagram.com/frm_ii/" originalsrc="https://www.instagram.com/frm_ii/">
<img src="https://mlz-garching.de/media/social_media-kanaele-instagram.jpg" alt="error" width="25" height="20"></a><a href="https://www.facebook.com/FRMII" originalsrc="https://www.facebook.com/FRMII"><img src="https://mlz-garching.de/media/social_media-kanaele-facebook.jpg" alt="error" width="25" height="20"></a><a href="https://www.youtube.com/channel/UCupBuiPnpYkDpuJyQrMsvdA" originalsrc="https://www.youtube.com/channel/UCupBuiPnpYkDpuJyQrMsvdA"><img src="https://mlz-garching.de/media/social_media-kanaele-youtube.jpg" alt="error" width="25" height="20"></a><a href="https://www.linkedin.com/company/frm-ii/" originalsrc="https://www.linkedin.com/company/frm-ii/"><img src="https://mlz-garching.de/media/social_media-kanaele-linkedin.jpg" alt="error" width="25" height="20"></a></div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>