Coding conventions (Ionut)
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / UKUtility.cxx
CommitLineData
03896fc4 1//
2//
3// Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
4// amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
5// November. 2, 2005
6//
7//
b1c2e580 8
9#include "TLorentzVector.h"
10#include "TVector3.h"
11#include "TRandom.h"
12
b1c2e580 13#include "UKUtility.h"
b1c2e580 14
03896fc4 15//_____________________________________________________________________
b1c2e580 16void IsotropicR3(Double_t r, Double_t *x, Double_t *y, Double_t *z) {
03896fc4 17 //
18 // return a random isotropic orientation
19 //
b1c2e580 20 Double_t pZ = 1. - 2.*(gRandom->Rndm());
bfd20868 21 Double_t st = TMath::Sqrt((1.-pZ)*(1.+pZ)) * r;
b1c2e580 22 Double_t phi = 2. * TMath::Pi() * (gRandom->Rndm());
23
24 *x = st * cos(phi);
25 *y = st * sin(phi);
26 *z = pZ * r;
27}
28
03896fc4 29//_____________________________________________________________________
b1c2e580 30void IsotropicR3(Double_t r, TVector3 &pos) {
03896fc4 31 //
32 // return a random isotropic orientation
33 //
b1c2e580 34 Double_t pZ = 1. - 2.* (gRandom->Rndm());
bfd20868 35 Double_t st = TMath::Sqrt((1.-pZ)*(1.+pZ)) * r;
b1c2e580 36 Double_t phi = 2. * TMath::Pi() * (gRandom->Rndm());
37
38 pos.SetX(st * TMath::Cos(phi));
39 pos.SetY(st * TMath::Sin(phi));
40 pos.SetZ(pZ * r);
41}
42
03896fc4 43//_____________________________________________________________________
b1c2e580 44void MomAntiMom(TLorentzVector &mom, Double_t mass, TLorentzVector &antiMom,
45 Double_t antiMass, Double_t initialMass) {
03896fc4 46 //
47 // perform a 2 - body decay and orientate randomly the product particles momentum vectors
48 //
b1c2e580 49 Double_t r = initialMass * initialMass - mass * mass - antiMass * antiMass;
50 if (r * r - 4 * mass * mass * antiMass * antiMass < 0.) throw "MomAntiMom";
51
52 Double_t pAbs = .5 * TMath::Sqrt(r * r - 4 * mass * mass * antiMass * antiMass) / initialMass;
53 TVector3 mom3;
54 IsotropicR3(pAbs, mom3);
55 mom.SetVectM(mom3, mass);
56 antiMom.SetVectM(- mom3, antiMass);
57}