Setup the given G4Track as the current primary particle which we'll process.
112{
113
114
115
116
118 if ( trackInfo ) {
121 << "Started simulation of primary particle which already has a TrackInformation/TrackBarcodeInfo object attached (trackID: "
122 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
123 << ", parentID " << aTrack.GetParentID() << ")";
124 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"TrackInformationAlreadyExists", FatalException,
description);
125 return;
126 }
127
128 auto* primaryPartInfo = dynamic_cast <PrimaryParticleInformation*> (aTrack.GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
129 if (!primaryPartInfo) {
131 description << G4String(
"PreUserTrackingAction: ") +
"NULL PrimaryParticleInformation pointer for current G4Step (trackID "
132 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
133 << ", parentID " << aTrack.GetParentID() << ")";
134 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoPPInfo", FatalException,
description);
135 return;
136 }
137
138
139 auto* baseISP = primaryPartInfo->GetISFParticle();
140 if (!baseISP) {
142 description << G4String(
"PreUserTrackingAction: ") +
"No ISFParticle associated with primary particle (trackID: "
143 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
144 << ", parentID " << aTrack.GetParentID() << ")";
145 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFParticle", FatalException,
description);
146 return;
147 }
148
149 ISF::TruthBinding* truthBinding = baseISP->getTruthBinding();
150 if (!truthBinding) {
152 description << G4String(
"PreUserTrackingAction: ") +
"No ISF::TruthBinding associated with primary particle (trackID: "
153 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
154 << ", parentID " << aTrack.GetParentID() << ")";
155 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFTruthBinding", FatalException,
description);
156 return;
157 }
158
159 int regenerationNr = primaryPartInfo->GetRegenerationNr();
160
164
165 auto classification =
classify(primaryGenParticle,
166 generationZeroGenParticle,
167 currentGenParticle,
168 regenerationNr);
169
171 *baseISP,
172 classification,
173 generationZeroGenParticle );
174 newTrackInfo->SetRegenerationNr(regenerationNr);
175
177 primaryGenParticle,
178 currentGenParticle);
179
180 return;
181}
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 updateCachedParticleInfo(ISF::ISFParticle *baseISFParticle, HepMC::ConstGenParticlePtr primaryGenParticle, HepMC::GenParticlePtr currentGenParticle)
Set the following information as 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.