Pass Info from PrimaryGeneratorAction to

Ladies and gents,

I am using a forward-biased PrimaryGeneratorAction and would like to pass the corresponding weight (1 if forward-directed, N if backward-directed) to my Run::RecordEvent() function where I curently store my hit data for later output. When I tried to modify the function to take both G4Event* and G4PrimaryGeneratorAction* objects as arguments, it seems as though the RecordEvent() function no longer gets called.

Is there an easy way to pass a user-defined, event-specific quantity from PrimaryGeneratorAction to either a SensitiveDetector or Run class?

Thanks so much!

User information classes can be used to associate additional data with G4 classes, in particular for the event have a look at the G4VUserEventInformation.

Thank you, @anna - I am having the issue of passing user information to the G4VUserEventInformation class from the PrimaryGeneratorAction since the event is not yet created(?). I get a warning that says “G4VUserEventInformation cannot be set because of ansense of G4Event,” so I am unable to subsequently pass paramters regarding primary info to my user class.

For the primaries, there are both particle-by-particle hooks (G4VUserPrimaryParticleInformation) and vertex hooks (G4VUserPrimaryVertexInformation).

If you want to be able to access everything in one place downstream, you could implement something in G4UserEventAction::BeginOfEventAction() to capture those objects and copy them into a G4VUserEventInformation object.

Thank you, both! I believe I have it working with your collective advice.