cosz corrected (was always positive).
[u/mrichter/AliRoot.git] / TFluka / source.cxx
index 7b29e4b0cf22a329a218ed3ea5fb881c427849f7..118a4e1b12a3f22583a1974e2ce185e4050189b0 100644 (file)
@@ -206,7 +206,8 @@ extern "C" {
     //STACK.tz [STACK.lstack] = BEAM.tinz;
     Double_t cosx = particle->Px()/particle->P();
     Double_t cosy = particle->Py()/particle->P();
-    Double_t cosz = sqrt(oneone - cosx*cosx - cosy*cosy);
+    Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+    if (particle->Pz() < 0.) cosz = -cosz;
     STACK.tx [STACK.lstack] = cosx;
     STACK.ty [STACK.lstack] = cosy;
     STACK.tz [STACK.lstack] = cosz;