]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TUHKMgen/UHKM/UKUtility.cxx
Updated macro
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / UKUtility.cxx
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 //
8
9 #include "TLorentzVector.h"
10 #include "TVector3.h"
11 #include "TRandom.h"
12
13 #include "UKUtility.h" 
14
15 //_____________________________________________________________________
16 void IsotropicR3(Double_t r, Double_t *x, Double_t *y, Double_t *z) {
17   //
18   // return a random isotropic orientation
19   //
20   Double_t pZ  = 1. - 2.*(gRandom->Rndm());
21   Double_t st  = TMath::Sqrt((1.-pZ)*(1.+pZ)) * r;
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
29 //_____________________________________________________________________
30 void IsotropicR3(Double_t r, TVector3 &pos) {
31   //
32   // return a random isotropic orientation
33   //
34   Double_t pZ  = 1. - 2.* (gRandom->Rndm());  
35   Double_t st  = TMath::Sqrt((1.-pZ)*(1.+pZ)) * r;
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
43 //_____________________________________________________________________
44 void MomAntiMom(TLorentzVector &mom, Double_t mass, TLorentzVector &antiMom, 
45                 Double_t antiMass, Double_t initialMass) {
46   //
47   // perform a 2 - body decay and orientate randomly the product particles momentum vectors
48   //
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 }