Setting a limit on number of trajectories

Is it possible to set a limit on the maximum number of trajectories that will be saved to a visualization?

I would like to save the first 100 to 1000 events so I can confirm that the x-rays are firing in the correct direction and over the right area. But I don’t want all the events when I do a longer run.

It seems like there should be a UI command for this, but I can’t find it.

Thanks!

We don’t have a specific command for this use case.

Typically I run 100 to 1000 events to see if all’s OK, then /vis/disable, then start a second long run.

If you must do it all in one run, you can keep the first 100 (say) events in your event action:

  if (event->GetEventID() < 100) {
    G4EventManager::GetEventManager()->KeepTheCurrentEvent();
  }

and /vis/drawOnlyKeptEvents.

Thanks. That’s helpful.
I thought I would be able to accomplish this through UI commands alone using:

 /vis/scene/endOfEventAction accumulate 100
 /vis/drawOnlyToBeKeptEvents

where 100 is the maximum number of events to keep. But it does not seem to work the way I expected. For others reading this later: Note that the command on the second line is drawOnlyToBeKeptEvents

I think that will still draw them, even though it does not keep them.

“Keeping” refers to what’s kept at end of run. At end of run you may
/vis/reviewKeptEvents
They are also used when re-drawing, for example, with another graphics system.