Dear Geant4 users, I am trying to draw only the first fifty particles that are generated in an application. My aim is to run use /run/beamOn and generate 100000 particles but obviously the graphics interface is not capable of withstanding so many.
I am modifying the example B1 and tried to insert this bit of code to do that.
if (i < 50) {
G4EventManager::GetEventManager()->KeepTheCurrentEvent();
std::cout << i << “\n”;
i++;
}
if (i == nofEvents){
i=0;
}
The seccond if statement is to reset the counter variable i when the run is over but I cannot seem to define the number of events correctly. I have tried inserting the code in the B1EventAction.cc and in the B1RunAction.cc but it is not working. Does anyone have some idea as to why??
What I am basically looking for is a way of telling when the run is over so that I can reset the counter. I am not being able to find it.
Or is there a command that allows me to set the maximum number of trajectories that I want it to show without stopping the simulation, meaning that it would carry on but just not display them?
Any help is much apretiated.
but you would still get lots of events drawn, which might be a problem for the vis system. (Perhaps not if
/vis/scene/endOfEventAction refresh
)
I wonder if you could use trajectory filtering. I’ve never tried this, but you could filter on event ID. If this appeals to you I’ll look into it further.
Thanks for the reply John. Yes, you are right, it is enough to run a test with 50 first and then run the 100000 with the interface disabled. At least for the level at which I currently am with geant4.
Hi @allison, I have another question related to this. Is there a way of generating the 100000 photons but only keeping those that hit the scoring volume?
Not sure what you mean by “keeping”. But if you mean keeping for visualisation, then if you can figure out how to flag such an event in, say, your stepping action, you can /vis/disable and
if (flag) {
G4EventManager::GetEventManager()->KeepTheCurrentEvent();
}
and then /vis/enable and view them at end of run. But you already know about that.