Geant4 Getmomentum()

Hey everyone, is there anyway someone can deubg this for me. I am new to geant4 so I am not really understanding this bug. I think it is the fact that it cant be 3d vector but I don’t know to to deubg it. Thanks

Hi @zhuohengy !
As you mention, you are trying to assign G4double to a G4ThreeVector.
You can fix it using comparing fMom1 to GetMomentumDirection().x() or GetMomentumDirection().y()
or GetMomentumDirection().z()
Best Regards

I agree, how do I find all direction then. Do I just specify the rest of the coordinates too? Thanks you once again

It depends on how you want to treat your data & which data you want to keep
I think you could do something like that :
fMom1=track->GetMomentumDirection().x();
fMom2=track->GetMomentumDirection().y();
fMom3=track->GetMomentumDirection().z();
( You have to add fMom2 and fMom3 fo the .hh )
Then you can extract this data in a .txt or an histogram ; as you want !

1 Like

Understood. Thank you so much :slight_smile:

1 Like