Only visualizing tracks with certain particles

Hey all,

I have a simulation where I am investigating electron bremsstrahlung. Of course, only a handful of the actual events produce any photons (generally about 1 in every 1000). I want to produce a figure where I only see tracks for which a photon was produced, is there an easy way to do this that won’t require me to manually sort through every event?

Take a look at the “trajectory filtering” visualization commands in the Developer’s Guide: Trajectory Filtering — Book For Application Developers 11.0 documentation

Thank you for the reply, I have tried the trajectory filtering but the problem is I can’t seem to filter an entire event based on one of the particles within the event. When a photon is produced I want to see the electron trajectory as well.

Oh, that’s different from what you described (“I want to produce a figure where I only see tracks for which a photon was produced”). I believe there’s a way, for instance in your stepping action, to “flag” an event for display. If you put a check in your stepping action to see if a secondary is a photon, then you should be able to do this. The same chapter in the Developer’s guide should talk about this.

Yes. If you can identify the event(s) you want to see in, say, your stepping action, you can “keep” them:

if ( some criterion ) {
  G4EventManager::GetEventManager()->KeepTheCurrentEvent();
}

and they will be available for viewing at the end of run with /vis/reviewKeptEvents - see guidance - help /vis/reviewKeptEvents).

You may also /vis/drawOnlyToBeKeptEvents and see only the kept events during a run.

This is documented in Controlling Visualization from Commands — Book For Application Developers 11.0 documentation, Additional Note 2.

1 Like