Message: Re: How to get track length of a primary particle at the end of event in the digitization Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: How to get track length of a primary particle at the end of event in the digitization 

Forum: Hits, Digitization and Pileup
Re: Question How to get track length of a primary particle at the end of event in the digitization (Soman)
Date: 20 Jul, 2017
From: Michael H. Kelsey <Michael H. Kelsey>

On Thu, 20 Jul 2017 21:21:32 GMT, Soman wrote:
> Is there any way to get the track length of a primary particle at the
> end of event through the G4VTrajectory? Indeed, I need to know the total
> traveled path length of each particle at the end of event.

I don't see an obvious way, either through the base class or the concrete G4Trajectory. You may need to write yourself a utility function which iterates through the trajectory points; something like

G4double GetTrackLength(G4VTrajectory* traj) {
    G4double trklen = 0.;
    for (G4int i=1; i < traj->GetPointEntries(); i++) {
      G4VTrajectoryPoint *pf = traj->GetPoint(i);
      G4VTrajectoryPoint *pi = traj->GetPoint(i-1);
      trklen += (pf->GetPosition() - pi->GetPosition()).mag();
    }

    G4cout << " Length of traj is " << trklen/mm << " mm" << G4endl;
    return trklen;
}

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Question: Re: How to get track length of a primary particle at the end of event in the digitization   (Soman - 21 Jul, 2017)
(_ None: Re: How to get track length of a primary particle at the end of event in the digitization   (Mike Kelsey - 21 Jul, 2017)
(_ Question: Re: How to get track length of a primary particle at the end of event in the digitization   (Soman - 21 Jul, 2017)
(_ None: Re: How to get track length of a primary particle at the end of event in the digitization   (Mike Kelsey - 21 Jul, 2017)
 Add Message Add Message
to: "Re: How to get track length of a primary particle at the end of event in the digitization"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]