48{
49
50
51 const int numSecondaries = aStep->GetSecondaryInCurrentStep()->size();
52
53
54 if (numSecondaries) {
55
56 G4Track*
track=aStep->GetTrack();
57#ifdef _ISFTRAJECTORY_DEBUG_
58 std::cout << "A new track "
59 <<
" (trackID " <<
track->GetTrackID()
60 <<
"), track pos: "<<
track->GetPosition()
61 <<
", mom: "<<
track->GetMomentum()
62 <<
", parentID " <<
track->GetParentID()
63 << ", numSec="<<numSecondaries<<" is in AppendStep." << std::endl;
64#endif
65
66
67
68 TrackHelper tHelper(track);
69 if (tHelper.IsSecondary()) {
70#ifdef _ISFTRAJECTORY_DEBUG_
71 std::cout<<"is secondary, returning"<<std::endl;
72#endif
73 return;
74 }
75
76
78 if (!trackInfo) {
80 description << G4String(
"AppendStep: ") +
"No VTrackInformation associated with G4Track (trackID: "
81 <<
track->GetTrackID() <<
", track pos: "<<
track->GetPosition() <<
", mom: "<<
track->GetMomentum()
82 <<
", parentID " <<
track->GetParentID() <<
")";
83 G4Exception(
"iGeant4::ISFTrajectory",
"NoVTrackInformation", FatalException,
description);
84 return;
85 }
86
87 ISF::ISFParticle* baseIsp = trackInfo->GetBaseISFParticle();
88 if (!baseIsp) {
90 description << G4String(
"AppendStep: ") +
"NULL ISFParticle pointer for current G4Step (trackID "
91 <<
track->GetTrackID() <<
", track pos: "<<
track->GetPosition() <<
", mom: "<<
track->GetMomentum()
92 <<
", parentID " <<
track->GetParentID() <<
", numSec="<<numSecondaries <<
")";
93 G4Exception(
"iGeant4::ISFTrajectory",
"NoISFParticle", FatalException,
description);
94 return;
95 }
96
98
100 if (currentGenParticle && currentGenParticle->end_vertex()) {
102 description << G4String(
"AppendStep: ") +
"Currently Traced Particle has an end vertex!\n";
103 description <<
"G4Track Properties: trackID = " <<
track->GetTrackID()<<
", Step Number = "<<
track->GetCurrentStepNumber() <<
", parentID = " <<
track->GetParentID() <<
", TrackStatus = " <<
track->GetTrackStatus() <<
"\n";
104 description <<
"G4Step Properties: number of secondaries in the current step: " << aStep->GetSecondaryInCurrentStep()->size() <<
"\n";
105 description <<
"currentGenParticle : " << currentGenParticle <<
", barcode: " <<
HepMC::barcode(currentGenParticle) <<
"\n";
106 description <<
"currentGenParticle->end_vertex(): " << currentGenParticle->end_vertex() <<
", barcode: " <<
HepMC::barcode(currentGenParticle->end_vertex()) <<
"\n";
107 description <<
"ISFParticle (from TrackInformation): " << *baseIsp;
109 if (currentTrackInfoGenParticle) {
110 description <<
"currentTrackInfoGenParticle : " << currentTrackInfoGenParticle <<
", barcode: " <<
HepMC::barcode(currentTrackInfoGenParticle) <<
"\n";
111 if (currentTrackInfoGenParticle->end_vertex()) {
112 description <<
"currentTrackInfoGenParticle->end_vertex(): " << currentTrackInfoGenParticle->end_vertex() <<
", barcode: " <<
HepMC::barcode(currentTrackInfoGenParticle->end_vertex()) <<
"\n";
113 }
114 else {
115 description <<
"currentTrackInfoGenParticle has no end_vertex!\n";
116 }
117 }
118 else {
119 description <<
" trackInfo->GetHepMCParticle() == nullptr \n";
120 }
121 G4Exception(
"iGeant4::ISFTrajectory",
"EndVertexExists", FatalException,
description);
122 }
123 iGeant4::Geant4TruthIncident truth(aStep, geoID);
124
127
128
129
130 if ( trackInfo->GetReturnedToISF()==true ) {
131
132
133
134 auto currentGenPart = trackInfo->GetCurrentGenParticle();
135 baseIsp->getTruthBinding()->setCurrentGenParticle( currentGenPart );
137 baseIsp->setBarcode( newBarcode );
138 baseIsp->setStatus( currentGenPart->status() );
140 baseIsp->setId( id );
141 }
142 }
143 else {
145 description << G4String(
"AppendStep: ") +
"m_truthRecordSvcQuick is NULL!";
146 G4Exception(
"iGeant4::ISFTrajectory",
"NoTruthRecordSvc", FatalException,
description);
147 }
148 }
149
150 G4Trajectory::AppendStep(aStep);
151}
AtlasDetDescr::AtlasRegion nextGeoID() const
next geoID the particle will be simulated in
static VTrackInformation * getISFTrackInfo(const G4Track &aTrack)
return a valid UserInformation object of the G4Track for use within the ISF
std::string description
glabal timer - how long have I taken so far?
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
HepMC3::GenParticlePtr GenParticlePtr