Setup the given G4Track as the current primary particle which we'll process.
122{
123
124
125
126
128 if ( trackInfo ) {
131 << "Started simulation of primary particle which already has a TrackInformation/TrackBarcodeInfo object attached (trackID: "
132 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
133 << ", parentID " << aTrack.GetParentID() << ")";
134 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"TrackInformationAlreadyExists", FatalException,
description);
135 return;
136 }
137
138 auto* primaryPartInfo = dynamic_cast <PrimaryParticleInformation*> (aTrack.GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
139 if (!primaryPartInfo) {
141 description << G4String(
"PreUserTrackingAction: ") +
"NULL PrimaryParticleInformation pointer for current G4Step (trackID "
142 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
143 << ", parentID " << aTrack.GetParentID() << ")";
144 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoPPInfo", FatalException,
description);
145 return;
146 }
147
148
149 auto* baseISP = primaryPartInfo->GetISFParticle();
150 if (!baseISP) {
152 description << G4String(
"PreUserTrackingAction: ") +
"No ISFParticle associated with primary particle (trackID: "
153 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
154 << ", parentID " << aTrack.GetParentID() << ")";
155 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFParticle", FatalException,
description);
156 return;
157 }
158
159 ISF::TruthBinding* truthBinding = baseISP->getTruthBinding();
160 if (!truthBinding) {
162 description << G4String(
"PreUserTrackingAction: ") +
"No ISF::TruthBinding associated with primary particle (trackID: "
163 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
164 << ", parentID " << aTrack.GetParentID() << ")";
165 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFTruthBinding", FatalException,
description);
166 return;
167 }
168
169 int regenerationNr = primaryPartInfo->GetRegenerationNr();
170
171
172
176
177 auto classification =
classify(primaryGenParticle,
178 generationZeroGenParticle,
179 currentGenParticle,
180 regenerationNr);
181
183 *baseISP,
184 classification,
185 generationZeroGenParticle );
186 newTrackInfo->SetRegenerationNr(regenerationNr);
187
189
190 return;
191}
VTrackInformation::TrackClassification classify(HepMC::ConstGenParticlePtr primaryGenParticle, HepMC::ConstGenParticlePtr generationZeroGenParticle, HepMC::ConstGenParticlePtr currentGenParticle, int regenerationNumber) const
Classify the particle represented by the given set of truth links.
void updateCurrentBaseISFParticle(ISF::ISFParticle *baseISFParticle)
Set the base ISFParticle for the currently traced particle.
HepMC::GenParticlePtr getCurrentGenParticle()
pointer to the particle in the simulation truth
HepMC::GenParticlePtr getGenerationZeroGenParticle()
pointer to the simulation truth particle before any regeneration happened (eg.
static VTrackInformation * getISFTrackInfo(const G4Track &aTrack)
return a valid UserInformation object of the G4Track for use within the ISF
static TrackInformation * attachTrackInfoToNewG4Track(G4Track &aTrack, ISF::ISFParticle &baseIsp, VTrackInformation::TrackClassification classification, HepMC::GenParticlePtr generationZeroGenParticle=nullptr)
attach a new TrackInformation object to the given new (!) G4Track (the G4Track must not have a UserIn...
HepMC3::GenParticlePtr GenParticlePtr