Dear Richard,
sorry for the late reply. I took some time to consider your question and engaged in useful discussions with colleagues. Below, you will find my proposal and some accompanying considerations.
FLUKA offers a card, THRESHOLd, with which it is possible to set thresholds for elastic and inelastic hadron reactions. By specifying a sufficiently high threshold, you could hence suppress the secondaries. This approach is surely powerful and immediate, but also crude.
Moreover, the approach may not align with your objectives, because the carbon beam would not be depleted in a natural way, with all the consequences that you can image. Nevertheless, it’s valuable to mention this option for the benefit of users.
FLUKA also includes the mdstk.f
user routine (manual). This routine is called without the need of any specific card and is definitely suitable for suppressing the secondaries; in fact, it is designed for the management of the stack of secondaries. An older post discusses this topic and could provide you with some useful insights. Also there, the approach involved looping through the stacks and applying particle filtering.
mdstck.f
is called after a nuclear interaction in which at least one secondary particle has been produced, before any biasing is applied, to decide which secondary will be loaded in the main stack for further transport (quoting the manual). This is why, generally speaking, this solution is definitely interesting. It is worth noting that acting on secondaries has an impact on energy conservation.
Regarding your implementation, despite the use of usrmed.f
might be non-standard, I would say that much of the logic is there. A robust implementation of if/else conditions can filter out the particles that you want to exclude. You are also looking for negative numbers in generalised particles as in this post.
I would suggest to give mdstck.f
a try.
If you want to explore the usrmed.f
implementation further, my only idea would be to look also for heavy residuals (I was inspired by this example of the Fluka course, slide 22, last lines of code). My guess is that a contribution might come from this, but further testing would be needed.
I hope that this can be a good starting point for your simulation.
Best regards,
Tommaso