We can set #of events we want to generate with /run/beamOn.
Is it possible to get this number in source code of ActionInitialization, RunAction or EventAction etc…??
for instance
int events = xxxx - > GetNumberOfEventsToBeProcessed()
or
int events = xxx - > GetNumberOfEventsToBeStored()
something like above.
Is it possible to update this number in RunAction?
below does not work…
void RunAction::BeginOfRunAction(const G4Run* aRun)
{
// originally, it's 10, for instance.
G4int eventsInRun = aRun->GetNumberOfEventToBeProcessed();
// update it to 20
G4RunManager::GetRunManager() ->SetNumberOfEventsToBeProcessed( 20 )
// this can not update #of events to be processed. its still 10 in the follwowing.
G4cout << "update #of Evts : " << aRun->GetNumberOfEventToBeProcessed() << G4endl;
}
If I use G4RunManager::GetRunManager()-> Initialize()
it seems everything is initialized?
In fact, any place is ok. In other words, is it possible to give #of simulation events in source code without using /run/beamOn ?
As per line 170 in G4RunManager.hh /run/beamOn is analysed before the event loop. The BeginOfRunAction method is executed at the start of the event loop I believe, therefore, this is the reason why you cannot change the value here.
Yes, you can set the beam on and the number of events in the main program. An easy way is to call the beamOn method from the run manager. This can be done using the following:
RunManager* runMan= new RunManager();
runMan->BeamOn(20);
Alternatively you can run UI commands in the main using: