I have my implementation of G4UserRunAction and I want to change the run ID, calling G4Run::SetRunID in my implementation of the virtual method G4UserRunAction::BeginOfRunAction. However, since the method is declared as virtual void BeginOfRunAction(const G4Run* aRun) I get a compiler error for the statement aRun->SetRunID(id) I guess the reason is that somehow the compiler understands that I want to modify G4Run and that is not allowed since the pointer to G4Run is declared as a const. Is that a problem or just poor understanding on my side?
It is intentionally set to "const" to avoid any mis-use. But, given run number is not used in Geant4 kernel, you can set the number by casting const pointer to non-const pointer.