Skip to content
Snippets Groups Projects
Unverified Commit db45e52b authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn Committed by GitHub
Browse files

Merge pull request #110 from mirguest/master

WIP: store the primary particle's position and momentum at endpoint
parents 9c5a2fd6 b3aeeaaf
No related branches found
No related tags found
No related merge requests found
......@@ -283,7 +283,38 @@ Edm4hepWriterAnaElemTool::PreUserTrackingAction(const G4Track* track) {
}
void
Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track*) {
Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
int curtrkid = track->GetTrackID(); // starts from 1
int curparid = track->GetParentID();
if (curparid == 0) {
// select the primary tracks (parentID == 0)
auto mcCol = m_mcParCol.get();
if (curtrkid-1>=mcCol->size()) {
error() << "out of range: curtrkid is " << curtrkid
<< " while the MCParticle size is " << mcCol->size() << endmsg;
return;
}
auto primary_particle = mcCol->at(curtrkid-1);
const G4ThreeVector& stop_pos = track->GetPosition();
edm4hep::Vector3d endpoint(stop_pos.x()/CLHEP::mm,
stop_pos.y()/CLHEP::mm,
stop_pos.z()/CLHEP::mm);
primary_particle.setEndpoint(endpoint);
const G4ThreeVector& stop_mom = track->GetMomentum();
edm4hep::Vector3f mom_endpoint(stop_mom.x()/CLHEP::GeV,
stop_mom.y()/CLHEP::GeV,
stop_mom.z()/CLHEP::GeV);
primary_particle.setMomentumAtEndpoint(mom_endpoint);
} else {
// TODO: select other interested tracks
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment