16 #include <Geant4/G4DynamicParticle.hh>
17 #include <Geant4/G4ParticleDefinition.hh>
18 #include <Geant4/G4PrimaryParticle.hh>
19 #include <Geant4/G4SystemOfUnits.hh>
20 #include <Geant4/G4ThreeVector.hh>
21 #include <Geant4/G4Track.hh>
22 #include <Geant4/G4TrackVector.hh>
23 #include <Geant4/G4TrackingManager.hh>
24 #include <Geant4/G4VUserTrackInformation.hh>
35 : m_EventAction(eventAction)
36 , m_TruthInfoList(nullptr)
49 int track_id_g4 = track->GetTrackID() * (track->GetParentID() ? -1 : +1);
59 if (track->GetParentID())
70 if (!track->GetParentID())
82 if (!track->GetParentID())
94 if (G4VUserTrackInformation*
p = track->GetUserInformation())
100 pp->GetShower()->add_g4particle_id(trackid);
101 pp->GetShower()->add_g4vertex_id(vtxindex);
108 if (!track->GetParentID())
123 if (fpTrackingManager)
125 int trackid = track->GetTrackID();
130 trackid =
p->GetUserTrackId();
131 primaryid =
p->GetUserPrimaryId();
132 shower =
p->GetShower();
135 G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries();
138 for (
size_t i = 0;
i < secondaries->size(); ++
i)
140 G4Track* secondary = (*secondaries)[
i];
152 int trackid =
p->GetUserTrackId();
187 bool keep_curr_track = p && p->
GetKeep() ?
true :
false;
190 while (keep_curr_track && stack_iter !=
m_G4ParticleStack.rend() && stack_iter->g4track_id < 0)
192 stack_iter->g4track_id *= -1;
200 m_TruthInfoList = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
205 std::cout <<
"PHG4TruthEventAction::SetInterfacePointers - unable to find G4TruthInfo" << std::endl;
228 if (track.GetParentID())
240 G4ParticleDefinition* def = track.GetDefinition();
241 int pdgid = def->GetPDGEncoding();
242 double mass = def->GetPDGMass();
243 double ke = track.GetVertexKineticEnergy();
244 double ptot = sqrt(ke * ke + 2.0 * mass * ke);
245 G4ThreeVector pdir = track.GetVertexMomentumDirection();
249 if (def->IsGeneralIon())
252 ti->
set_A(def->GetAtomicMass());
253 ti->
set_Z(def->GetAtomicNumber());
268 ti->
set_name(def->GetParticleName());
269 ti->
set_e(track.GetTotalEnergy() /
GeV);
280 G4ThreeVector
v = track.GetVertexPosition();
283 auto [iter, inserted] =
m_VertexMap.insert(std::make_pair(v, vtxindex));
288 return truth.
GetVtxMap().find(iter->second)->second;
293 return truth.
AddVertex(vtxindex, vtxpt)->second;