12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

User Actions6.3.1. G4VUserEventIn<strong>for</strong>mationG4VUserEventIn<strong>for</strong>mation is an abstract class from which the user can derive his/her own concrete class <strong>for</strong> storinguser in<strong>for</strong>mation associated with a G4Event class object. It is the user's responsibility to construct a concrete classobject and set the pointer to a proper G4Event object.Within a concrete implementation of G4UserEventAction, the SetUserEventIn<strong>for</strong>mation() method ofG4EventManager may be used to set a pointer of a concrete class object to G4Event, given that the G4Event objectis available only by "pointer to const". Alternatively, the user may modify the GenerateEvent() method of his/herown RunManager to instantiate a G4VUserEventIn<strong>for</strong>mation object and set it to G4Event.The concrete class object is deleted by the <strong>Geant4</strong> kernel when the associated G4Event object is deleted.6.3.2. G4VUserTrackIn<strong>for</strong>mationThis is an abstract class from which the user can derive his/her own concrete class <strong>for</strong> storing user in<strong>for</strong>mationassociated with a G4Track class object. It is the user's responsibility to construct a concrete class object and setthe pointer to the proper G4Track object.Within a concrete implementation of G4UserTrackingAction, the SetUserTrackIn<strong>for</strong>mation() method ofG4TrackingManager may be used to set a pointer of a concrete class object to G4Track, given that the G4Trackobject is available only by "pointer to const".The ideal place to copy a G4VUserTrackIn<strong>for</strong>mation object from a mother track to its daughter tracks isG4UserTrackingAction::PostUserTrackingAction().Example 6.9. Copying G4VUserTrackIn<strong>for</strong>mation from mother to daughter tracksvoid RE01TrackingAction::PostUserTrackingAction(const G4Track* aTrack){G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries();if(secondaries){RE01TrackIn<strong>for</strong>mation* info = (RE01TrackIn<strong>for</strong>mation*)(aTrack->GetUserIn<strong>for</strong>mation());size_t nSeco = secondaries->size();if(nSeco>0){<strong>for</strong>(size_t i=0; i < nSeco; i++){RE01TrackIn<strong>for</strong>mation* infoNew = new RE01TrackIn<strong>for</strong>mation(info);(*secondaries)[i]->SetUserIn<strong>for</strong>mation(infoNew);}}}}The concrete class object is deleted by the <strong>Geant4</strong> kernel when the associated G4Track object is deleted. In casethe user wants to keep the in<strong>for</strong>mation, it should be copied to a trajectory corresponding to the track.6.3.3. G4VUserPrimaryVertexIn<strong>for</strong>mation andG4VUserPrimaryTrackIn<strong>for</strong>mationThese abstract classes allow the user to attach in<strong>for</strong>mation regarding the generated primary vertex and primaryparticle. Concrete class objects derived from these classes should be attached to G4PrimaryVertex andG4PrimaryParticle class objects, respectively.The concrete class objects are deleted by the <strong>Geant4</strong> Kernel when the associated G4PrimaryVertex orG4PrimaryParticle class objects are deleted along with the deletion of G4Event.203

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!