Visualizing Specific Events

Is there any possible way to view specific events in the Geant4 visualizer? For context, I am running a simulation of 100,000 particles and filtering out specific events through a script on a ROOT file. In the Geant4 viewer, the only method I have found to view individual events is through /vis/reviewKeptEvents, and typing “cont” to index through every event becomes quite difficult with this many events.

I have tried using this set of macro commands,

/vis/filtering/trajectories/create/attributeFilter fEvent
/vis/filtering/trajectories/fEvent/setAttribute EventID
/vis/filtering/trajectories/fEvent/addInterval 1 100

but adding intervals or values just hides every event instead of showing the values in the attribute filter, sometimes crashing Geant4 as well.

_Geant4 Version: v11.2.2
_Operating System: MacOS Sonoma 14.5

Hi Shivom

You can be as specific as you like by calling, in, say, your EndOfEvent:

  auto evMan = G4EventManager::GetEventManager();
  if (<your chosen criterion>) {
    evMan->KeepTheCurrentEvent();
  }

Perhaps first, disable the vis manager event keeping:

/vis/scene/endOfEventAction accumulate 0

Is this what you were looking for?

John

Thank you John,

I will definitely use this method, although it was not exactly what I was looking for. I was asking for a faster way to go through specific events at random directly through the visualizer itself. Seeing as it is possible to index through each event in order (/vis/reviewKeptEvents), I was curious if there was a way to ‘skip’ to certain events (like something that has a parameter for which event(s) to view).

Regardless, the method you showed is helpful, so thank you.

HI Shivom

Just a couple of comments…

  1. There is no selection method with /vis/reviewKeptEvents. I can’t think of a simple way to add it. Of course, you do have control of selection in your EndOfEventAction.

  2. After /vis/reviewKeptEvents, as you have figured, you type continue, or just cont, to get the next event. After the first time you can use the up-arrow key.

John