Show all trajectories / particles

I finally set up my first working example:

I figured out I can create particles and their trajectories when I simply hit the “beam on” button in the GUI. Now, I would like to overlay all shown particles when I do so. At the moment, there is always a new particle / trajectory shown in the GUI but I would like to see all that were created within one session.

I tried to follow the commands given in the GUI but it seems it doesn’t work. Here are the UI codes I’m using:

G4UImanager *UImanager = G4UImanager::GetUIpointer();

UImanager->ApplyCommand(“/vis/open OGL”);
UImanager->ApplyCommand(“/vis/Viewer/set/ViewpointVector 1 1 1”);
UImanager->ApplyCommand(“/vis/drawVolume”);
UImanager->ApplyCommand(“/vis/viewer/set/autoRefresh true”);
UImanager->ApplyCommand(“/vis/scene/add/trajectories smooth”);
UImanager->ApplyCommand(“/vis/enable”);
UImanager->ApplyCommand(“/vis/viewer/flush”);
UImanager->ApplyCommand(“/vis/viewer/rebuild”);
UImanager->ApplyCommand(“/vis/reviewKeptEvents”);

Could you please advice? Thank you!

Hi Benjamin

I would say the usual way of interacting with Geant4 is through commands issued in the input window (the one-line window at the bottom of the Qt GUI, labeled “Session”). Is there any particular reason you are programming the commands with the ApplyCommand method? There is an issue of where those ApplyCommand statements should go - you do not say where you have put them?

Have a look at examples/basic/B1. By default it executes a “macro” called vis.mac. vis.mac will give you an idea of what commands you could use. If you want to write your own main program and do things a different way, you may, of course. Let us say you have a main program that opens the Qt GUI, and halts, waiting for input in the Session window. You could simply type some commands:

/vis/open OGL
/vis/scene/add/trajectories
/vis/scene/endOfEventAction accumulate

then run some events, say:

/run/beamOn 100

or you could put those commands in a macro file, say my-macro.mac and

/control/execute my-macro.mac

(which would allow you to edit my-macro.mac with an editor and re-run your app without having to recompile it).

Use ls or help to see what commands are available, or look at Built-in Commands — Book For Application Developers 11.0 documentation.

John

1 Like

Hi allison,

thanks for your reply. Basically, as I’m rather fresh to Geant4, I’m using these commands because I’m following someone in a tutorial doing so. But meanwhile I figured it is the command "

UImanager->ApplyCommand(“/vis/scene/endOfEventAction accumulate”);

" that is needed. Thanks for the help and further input nevertheless!

Is the file type “*.mac” short for macro?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.