]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenGrayParticles.cxx
Corrections introduced by F. Silker:
[u/mrichter/AliRoot.git] / EVGEN / AliGenGrayParticles.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.2  2002/10/14 14:55:35  hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
20
21 Revision 1.1.2.1  2002/10/10 16:40:08  hristov
22 Updating VirtualMC to v3-09-02
23
24 Revision 1.1  2002/10/08 13:53:17  morsch
25 Gray particle generator, first commit.
26
27 */
28
29 /*
30   Generator for gray nucluons in pA interactions. 
31   Source is modelled by a relativistic Maxwell distributions.
32   Original code by  Ferenc Sikler  <sikler@rmki.kfki.hu>
33  */
34 #include "AliGenGrayParticles.h"
35 #include "AliPDG.h"
36 #include <TDatabasePDG.h>
37
38  ClassImp(AliGenGrayParticles)
39     
40  AliGenGrayParticles::AliGenGrayParticles():AliGenerator(-1)
41 {
42 // Default constructor
43 }
44
45 AliGenGrayParticles::AliGenGrayParticles(Int_t npart)
46     :AliGenerator(npart)
47 {
48 // Constructor
49     fName  = "GrayParticles";
50     fTitle = "Generator for gray particles in pA collisions";
51     SetPmax();
52     SetTarget();
53     SetNominalCmsEnergy();
54     SetCharge();
55     SetTemperature();
56     SetBetaSource();
57 }
58
59 //____________________________________________________________
60 AliGenGrayParticles::~AliGenGrayParticles()
61 {
62 // Destructor
63 }
64
65
66 void AliGenGrayParticles::Init()
67 {
68   //
69   // Initialization
70   //
71     Float_t kMass  = TDatabasePDG::Instance()->GetParticle(kProton)->Mass();
72     fMomentum = fCMS/2. * fZTarget / fATarget;
73     fBeta     = fMomentum / TMath::Sqrt(kMass * kMass + fMomentum * fMomentum);
74 }
75
76
77 void AliGenGrayParticles::Generate()
78 {
79   //
80   // Generate one event
81   //
82     Float_t p[3];
83     Float_t origin[3] = {0., 0., 0.};
84     Float_t polar [3] = {0., 0., 0.};    
85     Int_t nt, i;
86     for(i = 0;i < fNpart; i++) {
87         Int_t kf;
88         if(fCharge==1) kf = kProton;
89                   else kf = kNeutron;
90         GenerateSlow(fCharge, fTemperature, fBetaSource, p);
91         
92         SetTrack(fTrackIt, -1, kf, p, origin, polar,
93                  0., kPNoProcess, nt, 1.);
94
95         KeepTrack(nt);
96     }
97 }
98
99
100
101
102 void AliGenGrayParticles::GenerateSlow(Int_t charge, Double_t T, Double_t beta, Float_t* q)
103 /* 
104    Emit a slow nucleon with "temperature" T [GeV], 
105    from a source moving with velocity beta         
106    Three-momentum [GeV/c] is given back in q[3]    
107 */
108
109 {
110  Double_t m, pmax, p, f, theta, phi;
111  
112  TDatabasePDG * pdg = TDatabasePDG::Instance();
113  const Double_t kMassProton  = pdg->GetParticle(kProton) ->Mass();
114  const Double_t kMassNeutron = pdg->GetParticle(kNeutron)->Mass();
115  
116  /* Select nucleon type */
117  if(charge == 0) m = kMassNeutron;
118  else m = kMassProton;
119
120  /* Momentum at maximum of Maxwell-distribution */
121
122  pmax = TMath::Sqrt(2*T*(T+sqrt(T*T+m*m)));
123
124  /* Try until proper momentum                                  */
125  /* for lack of primitive function of the Maxwell-distribution */
126  /* a brute force trial-accept loop, normalized at pmax        */
127
128  do
129  {
130      p = Rndm() * fPmax;
131      f = Maxwell(m, p, T) / Maxwell(m , pmax, T);
132  }
133  while(f < Rndm());
134
135  /* Spherical symmetric emission */
136  theta = TMath::ACos(2. * Rndm() - 1.);
137  phi   = 2. * TMath::Pi() * Rndm();
138
139  /* Determine momentum components in system of the moving source */
140  q[0] = p * TMath::Sin(theta) * TMath::Cos(phi);
141  q[1] = p * TMath::Sin(theta) * TMath::Sin(phi);
142  q[2] = p * TMath::Cos(theta);
143
144  /* Transform to system of the target nucleus                             */
145  /* beta is passed as negative, because the gray nucleons are slowed down */
146  Lorentz(m, -beta, q);
147
148  /* Transform to laboratory system */
149  Lorentz(m, fBeta, q);
150 }
151
152 Double_t AliGenGrayParticles::Maxwell(Double_t m, Double_t p, Double_t T)
153 {
154 /* Relativistic Maxwell-distribution */
155     Double_t ekin;
156     ekin = TMath::Sqrt(p*p+m*m)-m;
157     return (p*p * exp(-ekin/T));
158 }
159
160
161 void AliGenGrayParticles::Lorentz(Double_t m, Double_t beta, Float_t* q)
162 {
163 /* Lorentz transform in the direction of q[2] */
164  
165     Double_t gamma  = 1/sqrt(1-beta*beta); 
166     Double_t energy = sqrt(m*m + q[0]*q[0] + q[1]*q[1] + q[2]*q[2]);
167     q[2] = gamma * (q[2] + beta*energy);
168 }
169
170
171
172
173
174
175