Huge output simulation file : events selection possible?

Hello,

I’m still novice using rest but I think I didn’t find a way to do what I want.

We are running atmospheric muons simulations in a big detector and we obtain huge output files when we want to generate 1e6 events (~400 Go). Which is not possible to use in the end.

In these events only ~1e4 events are interesting to us (events with neutrons produced mostly).
So I was wondering if there would be a way to save in the output file only events where a neutron has been produced or if a specific detector volume has been reached ? Directly at the simulation level.

If not, a second chance could be to run such selection on the huge output file to produce a smaller one at a second stage. But I couldn’t find an easy way to do that has well.

Thanks in advance if you have suggestions.

Mathieu

Hello @bongrand,

Unless the “saveAllEvents” flag is set to true (defaults to false), only events depositing energy in a sensitive volume are stored. The easiest way to achieve what you want is to set an appropiate volume as sensitive in order to reduce the number of generated events.

Currently it’s not possible to apply a filter / analysis on the fly to discard simulation events.

If playing with the sensitive volume does not work, you could try to generate smaller files, remove the unwanted events (via a root macro for example) and loop until you have the desired number of events, this could be done as a bash or python script.

A drawback of this approach is that you will end up with multiple small files which may make the analysis complicated. There are some tools in the framework to help with this such as TRestDataSet.

Perhaps @jgalan has additional comments.

Thanks for your prompt reply.

Unfortunately, I need several sensitive volumes, I was more interested to the type of events produced.
So I will go for the second solution, split my jobs into smaller files and filter them afterwards.

I though earlier about doing that but in fact I don’t know how to do.
Would it work only with root tools on the TFile ?
Or should I use a writer of TRestRun to handle input and output file ?

Sorry for the naive question
Thanks