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