ATLAS Offline Software
Loading...
Searching...
No Matches
iGeant4::ISFTrajectory Class Reference

#include <ISFTrajectory.h>

Inheritance diagram for iGeant4::ISFTrajectory:
Collaboration diagram for iGeant4::ISFTrajectory:

Public Member Functions

 ISFTrajectory ()
 ISFTrajectory (const G4Track *aTrack, ISF::ITruthSvc *truthSvc)
 ~ISFTrajectory ()
void AppendStep (const G4Step *aStep)

Private Attributes

ISF::ITruthSvcm_truthRecordSvcQuick

Detailed Description

Definition at line 17 of file ISFTrajectory.h.

Constructor & Destructor Documentation

◆ ISFTrajectory() [1/2]

iGeant4::ISFTrajectory::ISFTrajectory ( )

Definition at line 29 of file ISFTrajectory.cxx.

30 : G4Trajectory()
31 , m_truthRecordSvcQuick(nullptr)
32{
33}
ISF::ITruthSvc * m_truthRecordSvcQuick

◆ ISFTrajectory() [2/2]

iGeant4::ISFTrajectory::ISFTrajectory ( const G4Track * aTrack,
ISF::ITruthSvc * truthSvc )

Definition at line 35 of file ISFTrajectory.cxx.

37 : G4Trajectory(aTrack)
38 , m_truthRecordSvcQuick(truthSvc)
39{
40}

◆ ~ISFTrajectory()

iGeant4::ISFTrajectory::~ISFTrajectory ( )

Definition at line 42 of file ISFTrajectory.cxx.

43{
44
45}

Member Function Documentation

◆ AppendStep()

void iGeant4::ISFTrajectory::AppendStep ( const G4Step * aStep)

Definition at line 47 of file ISFTrajectory.cxx.

48{
49
50 // only use truth service if there are new any secondaries
51 const int numSecondaries = aStep->GetSecondaryInCurrentStep()->size();
52 //const int numSecondaries = aStep->GetNumberOfSecondariesInCurrentStep(); //Once we switch to G4 10.2 or later
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 // OK, there was an interaction. look at the track, if it
66 // is not a secondary (i.e. we have a connected tree) we
67 // apply the MC truth machinery...
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 // get base ISFParticle
77 auto* trackInfo = ISFG4Helper::getISFTrackInfo(*track);
78 if (!trackInfo) {
79 G4ExceptionDescription description;
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; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
85 }
86
87 ISF::ISFParticle* baseIsp = trackInfo->GetBaseISFParticle();
88 if (!baseIsp) {
89 G4ExceptionDescription description;
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; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
95 }
96
97 AtlasDetDescr::AtlasRegion geoID = baseIsp->nextGeoID();
98
99 HepMC::GenParticlePtr currentGenParticle = trackInfo->GetCurrentGenParticle();
100 if (currentGenParticle && currentGenParticle->end_vertex()) {
101 G4ExceptionDescription description;
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;
108 HepMC::GenParticlePtr currentTrackInfoGenParticle = trackInfo->GetCurrentGenParticle();
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
126 m_truthRecordSvcQuick->registerTruthIncident(truth);
127
128 // read the TrackInformation to determine whether the G4Track was
129 // returned to the ISF in this step
130 if ( trackInfo->GetReturnedToISF()==true ) {
131 // make sure that the TruthBinding of the ISFParticle points to the newest
132 // HepMC::GenParticle instance in case it got updated by the
133 // ITruthSvc::registerTruthIncident call above
134 auto currentGenPart = trackInfo->GetCurrentGenParticle();
135 baseIsp->getTruthBinding()->setCurrentGenParticle( currentGenPart );
136 int newBarcode = HepMC::barcode(currentGenPart); // FIXME barcode-based
137 baseIsp->setBarcode( newBarcode ); // FIXME barcode-based
138 baseIsp->setStatus( currentGenPart->status() );
139 int id = HepMC::uniqueID(currentGenPart);
140 baseIsp->setId( id );
141 }
142 }
143 else {
144 G4ExceptionDescription description;
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?
Definition hcg.cxx:93
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
Definition AtlasRegion.h:21
int barcode(const T *p)
Definition Barcode.h:15
int uniqueID(const T &p)
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19

Member Data Documentation

◆ m_truthRecordSvcQuick

ISF::ITruthSvc* iGeant4::ISFTrajectory::m_truthRecordSvcQuick
private

Definition at line 26 of file ISFTrajectory.h.


The documentation for this class was generated from the following files: