Message: Re: How to get Primary Particle Energy ? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: How to get Primary Particle Energy ? 

Forum: Space Applications
Re: None How to get Primary Particle Energy ? (Mehmet)
Re: None Re: How to get Primary Particle Energy ? (John Allison)
Date: 03 Jul, 2012
From: Mehmet <Mehmet>

Thank you John and Neil for the responses. I could not make Neil's suggestion


work due to my lack of Geant4 knowledge. Instead, I have added a couple of more lines to Johns's suggestion since G4double ke = primaryParticle->GetKineticEnergy(); gave error. Pasted below is part of the code that works:

G4PrimaryVertex* primaryVertex = evt->GetPrimaryVertex();

G4PrimaryParticle* primaryParticle = primaryVertex->GetPrimary();

G4double px = primaryParticle->GetPx();

G4double py = primaryParticle->GetPy();

G4double pz = primaryParticle->GetPz();

G4double mass = primaryParticle->GetMass();

G4double mom2=px*px+py*py+pz*pz;

G4double E=sqrt(mom2+mass*mass);

This may not be the shortest and best way to get what I want, but it seems to work.

Thank you again for the help, Mehmet

On Mon, 02 Jul 2012 13:25:48 GMT, John Allison wrote:

> In your event action:
>   G4PrimaryVertex* primaryVertex = event->GetPrimaryVertex();
>   G4PrimaryParticle* primaryParticle = primaryVertex->GetPrimary();
>   G4double ke = primaryParticle->GetKineticEnergy();

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

1 Feedback: Re: How to get Primary Particle Energy ?   (Michael H. Kelsey - 03 Jul, 2012)
 Add Message Add Message
to: "Re: How to get Primary Particle Energy ?"

 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 ]