Message: Re: Angle distribution from direction cosines | Not Logged In (login) |
Dear Valentina, perhaps this can be usefull for you. Let's suppose you derive the three direcions of the momentum of your particle: G4double px = particleMomentum.x(); G4double py = particleMomentum.y(); G4double pz = particleMomentum.z(); At this point you are able to calculate the projections of the momentum onto the planes as well as the total momentum and the angle theta (in degrees)that is always positive:
G4double rho = sqrt(pow(px,2) + pow(py,2) + pow(pz,2)); G4double S = sqrt(pow(pz,2) + pow(py,2)); G4double R = sqrt(pow(px,2) + pow(pz,2)); theta = acos(px/rho)*(180/3.14159); // in degrees Now you must derive the phi angle but its sign depends on the particle directon. For example you could write:
if(py >= 0) {
if(pz >= 0) { phi = 180 - (asin(py/S)*(180/3.14159)); //in gradi } else { phi = (asin(py/S)*(180/3.14159)); //in gradi } //G4cout << "Phi= " << phi << " Pz= " << pz << " Py= " << py <<G4endl; }
else { if(pz >= 0) { phi = -(180- (-(asin(py/S))*(180/3.1459))); //in gradi //G4cout << "Phi= " << phi << " Pz= " << pz << " Py= " << py <<G4endl; } else { phi = (asin(py/S))*(180/3.1459); //in gradi //G4cout << "Phi= " << phi << " Pz= " << pz << " Py= " << py <<G4endl; }
} Another idea could be to give a look to our wiki pages: http://geant4lns.wikispaces.com in the "Discussion-Frag/MOBIDIC experiment" section click on progress on Monte Carlo simulation. in that slides you can find useful picture for the carthesia-spherical conversion. All the Best, Pablo Cirrone (for the Catania Geant4 Group) |
Inline Depth: | Outline Depth: | Add message: |
to: |