Setup the given G4Track as the current primary particle which we'll process.
122{
123
124
125
126
128 if ( trackInfo && aTrack.GetCurrentStepNumber() > 0 ) {
129
130
131
132
134 return;
135 }
136 if ( trackInfo ) {
139 << "Started simulation of primary particle which already has a TrackInformation/TrackBarcodeInfo object attached (trackID: "
140 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
141 << ", parentID " << aTrack.GetParentID() << ")";
142 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"TrackInformationAlreadyExists", FatalException,
description);
143 return;
144 }
145
146 auto* primaryPartInfo = dynamic_cast <PrimaryParticleInformation*> (aTrack.GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
147 if (!primaryPartInfo) {
149 description << G4String(
"PreUserTrackingAction: ") +
"NULL PrimaryParticleInformation pointer for current G4Step (trackID "
150 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
151 << ", parentID " << aTrack.GetParentID() << ")";
152 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoPPInfo", FatalException,
description);
153 return;
154 }
155
156
157 auto* baseISP = primaryPartInfo->GetISFParticle();
158 if (!baseISP) {
160 description << G4String(
"PreUserTrackingAction: ") +
"No ISFParticle associated with primary particle (trackID: "
161 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
162 << ", parentID " << aTrack.GetParentID() << ")";
163 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFParticle", FatalException,
description);
164 return;
165 }
166
167 ISF::TruthBinding* truthBinding = baseISP->getTruthBinding();
168 if (!truthBinding) {
170 description << G4String(
"PreUserTrackingAction: ") +
"No ISF::TruthBinding associated with primary particle (trackID: "
171 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
172 << ", parentID " << aTrack.GetParentID() << ")";
173 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFTruthBinding", FatalException,
description);
174 return;
175 }
176
177 int regenerationNr = primaryPartInfo->GetRegenerationNr();
178
179
180
184
185 auto classification =
classify(primaryGenParticle,
186 generationZeroGenParticle,
187 currentGenParticle,
188 regenerationNr);
189
191 *baseISP,
192 classification,
193 generationZeroGenParticle );
194 newTrackInfo->SetRegenerationNr(regenerationNr);
195
197
198 return;
199}
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