Setup the given G4Track as the current primary particle which we'll process.
126{
127
128
129
130
132 if ( trackInfo ) {
135 << "Started simulation of primary particle which already has a TrackInformation/TrackBarcodeInfo object attached (trackID: "
136 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
137 << ", parentID " << aTrack.GetParentID() << ")";
138 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"TrackInformationAlreadyExists", FatalException,
description);
139 return;
140 }
141
142 auto* primaryPartInfo = dynamic_cast <PrimaryParticleInformation*> (aTrack.GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
143 if (!primaryPartInfo) {
145 description << G4String(
"PreUserTrackingAction: ") +
"NULL PrimaryParticleInformation pointer for current G4Step (trackID "
146 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
147 << ", parentID " << aTrack.GetParentID() << ")";
148 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoPPInfo", FatalException,
description);
149 return;
150 }
151
152
153 auto* baseISP = primaryPartInfo->GetISFParticle();
154 if (!baseISP) {
156 description << G4String(
"PreUserTrackingAction: ") +
"No ISFParticle associated with primary particle (trackID: "
157 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
158 << ", parentID " << aTrack.GetParentID() << ")";
159 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFParticle", FatalException,
description);
160 return;
161 }
162
163 ISF::TruthBinding* truthBinding = baseISP->getTruthBinding();
164 if (!truthBinding) {
166 description << G4String(
"PreUserTrackingAction: ") +
"No ISF::TruthBinding associated with primary particle (trackID: "
167 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
168 << ", parentID " << aTrack.GetParentID() << ")";
169 G4Exception(
"iGeant4::TrackProcessorUserActionBase",
"NoISFTruthBinding", FatalException,
description);
170 return;
171 }
172
173 int regenerationNr = primaryPartInfo->GetRegenerationNr();
174
178
179 auto classification =
classify(primaryGenParticle,
180 generationZeroGenParticle,
181 currentGenParticle,
182 regenerationNr);
183
185 *baseISP,
186 classification,
187 generationZeroGenParticle );
188 newTrackInfo->SetRegenerationNr(regenerationNr);
189
191 primaryGenParticle,
192 currentGenParticle);
193
194 return;
195}
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.
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...
std::string description
glabal timer - how long have I taken so far?
HepMC3::GenParticlePtr GenParticlePtr