Getting the event number

I’m working on B4 inspired model of a single particle gun (CaloGAN/generation/src/SteppingAction.cc at two_layer · hep-lbdl/CaloGAN · GitHub). In SteppingAction.cc I’m trying to write to a text file, which I can do successfully but I need to differentiate one event from the next one. I tried to use:
G4int evtNo = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();

but it always returns 0 for all events. How can I retrieve the correct event number?

you can get the eventID in the EventAction.

void EventAction::BeginOfEventAction(const G4Event* evt)
{
  nEvent = evt->GetEventID();
}

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