]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TUHKMgen/UHKM/UKUtility.cxx
Coding violations
[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 #ifndef PARTICLE_INCLUDED
14 #include "Particle.h"
15 #endif
16 #ifndef UKUTILITY_INCLUDED
17 #include "UKUtility.h" 
18 #endif
19
20 const Double_t GeV = 1.;
21 const Double_t fermi = 1.;
22 const Double_t hbarc = 0.197 * GeV * fermi; 
23 const Double_t w = 1.0 / 0.1973;
24 const Double_t hbarc_squared = hbarc * hbarc;
25
26 void IsotropicR3(Double_t r, Double_t *x, Double_t *y, Double_t *z) {
27   Double_t pZ  = 1. - 2.*(gRandom->Rndm());
28   Double_t st  = TMath::Sqrt((1.-pZ)*(1.+pZ)) * r;
29   Double_t phi = 2. * TMath::Pi() * (gRandom->Rndm());
30
31   *x = st * cos(phi);
32   *y = st * sin(phi);
33   *z = pZ * r;
34 }
35
36 void IsotropicR3(Double_t r, TVector3 &pos) {
37   Double_t pZ  = 1. - 2.* (gRandom->Rndm());  
38   Double_t st  = TMath::Sqrt((1.-pZ)*(1.+pZ)) * r;
39   Double_t phi = 2. * TMath::Pi() * (gRandom->Rndm());
40
41   pos.SetX(st * TMath::Cos(phi));
42   pos.SetY(st * TMath::Sin(phi));
43   pos.SetZ(pZ * r);
44 }
45
46 void MomAntiMom(TLorentzVector &mom, Double_t mass, TLorentzVector &antiMom, 
47                 Double_t antiMass, Double_t initialMass) {
48   Double_t r = initialMass * initialMass - mass * mass - antiMass * antiMass;
49   if (r * r - 4 * mass * mass * antiMass * antiMass < 0.) throw "MomAntiMom";
50       
51   Double_t pAbs = .5 * TMath::Sqrt(r * r - 4 * mass * mass * antiMass * antiMass) / initialMass;
52   TVector3 mom3;
53   IsotropicR3(pAbs, mom3);
54   mom.SetVectM(mom3, mass);
55   antiMom.SetVectM(- mom3, antiMass);
56 }
57
58