1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 // Generator for slow nucleons in pA interactions.
20 // Source is modelled by a relativistic Maxwell distributions.
21 // This class cooparates with AliCollisionGeometry if used inside AliGenCocktail.
22 // In this case the number of slow nucleons is determined from the number of wounded nuclei
23 // using a realisation of AliSlowNucleonModel.
24 // Original code by Ferenc Sikler <sikler@rmki.kfki.hu>
27 #include <TDatabasePDG.h>
34 #include "AliCollisionGeometry.h"
35 #include "AliGenSlowNucleons.h"
36 #include "AliSlowNucleonModel.h"
38 ClassImp(AliGenSlowNucleons)
41 AliGenSlowNucleons::AliGenSlowNucleons()
65 // Default constructor
66 fCollisionGeometry = 0;
69 AliGenSlowNucleons::AliGenSlowNucleons(Int_t npart)
91 fSlowNucleonModel(new AliSlowNucleonModel())
94 fName = "SlowNucleons";
95 fTitle = "Generator for gray particles in pA collisions";
96 fCollisionGeometry = 0;
99 //____________________________________________________________
100 AliGenSlowNucleons::~AliGenSlowNucleons()
103 delete fSlowNucleonModel;
106 void AliGenSlowNucleons::SetProtonDirection(Float_t dir) {
107 // Set direction of the proton to change between pA (1) and Ap (-1)
108 fProtonDirection = dir / TMath::Abs(dir);
111 void AliGenSlowNucleons::Init()
116 Float_t kMass = TDatabasePDG::Instance()->GetParticle(kProton)->Mass();
117 fMomentum = fCMS/2. * Float_t(fZTarget) / Float_t(fATarget);
118 fBeta = fMomentum / TMath::Sqrt(kMass * kMass + fMomentum * fMomentum);
120 fDebugHist1 = new TH2F("DebugHist1", "nu vs N_slow", 100, 0., 100., 20, 0., 20.);
121 fDebugHist2 = new TH2F("DebugHist2", "b vs N_slow", 100, 0., 100., 15, 0., 15.);
122 fCosThetaGrayHist = new TH1F("fCosThetaGrayHist", "Gray particles angle", 100, -1., 1.);
125 // non-uniform cos(theta) distribution
127 if(fThetaDistribution != 0) {
128 fCosTheta = new TF1("fCosTheta",
129 "(2./3.14159265358979312)/(exp(2./3.14159265358979312)-exp(-2./3.14159265358979312))*exp(2.*x/3.14159265358979312)",
134 void AliGenSlowNucleons::FinishRun()
137 // Show histogram for debugging if requested.
139 TCanvas *c = new TCanvas("c","Canvas 1",400,10,600,700);
146 fCosThetaGrayHist->Draw();
151 void AliGenSlowNucleons::Generate()
154 // Generate one event
157 // Communication with Gray Particle Model
159 if (fCollisionGeometry) {
160 Float_t b = fCollisionGeometry->ImpactParameter();
161 Int_t nn = fCollisionGeometry->NN();
162 Int_t nwn = fCollisionGeometry->NwN();
163 Int_t nnw = fCollisionGeometry->NNw();
164 Int_t nwnw = fCollisionGeometry->NwNw();
166 fSlowNucleonModel->GetNumberOfSlowNucleons(fCollisionGeometry, fNgp, fNgn, fNbp, fNbn);
168 printf("Nucleons %d %d %d %d \n", fNgp, fNgn, fNbp, fNbn);
169 fDebugHist1->Fill(Float_t(fNgp + fNgn + fNbp + fNbn), fCollisionGeometry->NwN(), 1.);
170 fDebugHist2->Fill(Float_t(fNgp + fNgn + fNbp + fNbn), b, 1.);
171 printf("AliGenSlowNucleons: Impact parameter from Collision Geometry %f %d %d %d %d\n",
172 b, nn, nwn, nnw, nwnw);
177 Float_t p[3], theta=0;
178 Float_t origin[3] = {0., 0., 0.};
180 Float_t polar [3] = {0., 0., 0.};
184 if(fVertexSmear == kPerEvent) {
186 for (j=0; j < 3; j++) origin[j] = fVertex[j];
194 for(i = 0; i < fNgp; i++) {
195 GenerateSlow(fCharge, fTemperatureG, fBetaSourceG, p, theta);
196 if (fDebug) fCosThetaGrayHist->Fill(TMath::Cos(theta));
197 PushTrack(fTrackIt, -1, kf, p, origin, polar,
198 time, kPNoProcess, nt, 1.);
206 for(i = 0; i < fNgn; i++) {
207 GenerateSlow(fCharge, fTemperatureG, fBetaSourceG, p, theta);
208 if (fDebug) fCosThetaGrayHist->Fill(TMath::Cos(theta));
209 PushTrack(fTrackIt, -1, kf, p, origin, polar,
210 time, kPNoProcess, nt, 1.);
218 for(i = 0; i < fNbp; i++) {
219 GenerateSlow(fCharge, fTemperatureB, fBetaSourceB, p, theta);
220 PushTrack(fTrackIt, -1, kf, p, origin, polar,
221 time, kPNoProcess, nt, 1.);
229 for(i = 0; i < fNbn; i++) {
230 GenerateSlow(fCharge, fTemperatureB, fBetaSourceB, p, theta);
231 PushTrack(fTrackIt, -1, kf, p, origin, polar,
232 time, kPNoProcess, nt, 1.);
240 void AliGenSlowNucleons::GenerateSlow(Int_t charge, Double_t T,
241 Double_t beta, Float_t* q, Float_t &theta)
245 Emit a slow nucleon with "temperature" T [GeV],
246 from a source moving with velocity beta
247 Three-momentum [GeV/c] is given back in q[3]
250 Double_t m, pmax, p, f, phi;
251 TDatabasePDG * pdg = TDatabasePDG::Instance();
252 const Double_t kMassProton = pdg->GetParticle(kProton) ->Mass();
253 const Double_t kMassNeutron = pdg->GetParticle(kNeutron)->Mass();
255 /* Select nucleon type */
256 if(charge == 0) m = kMassNeutron;
257 else m = kMassProton;
259 /* Momentum at maximum of Maxwell-distribution */
261 pmax = TMath::Sqrt(2*T*(T+sqrt(T*T+m*m)));
263 /* Try until proper momentum */
264 /* for lack of primitive function of the Maxwell-distribution */
265 /* a brute force trial-accept loop, normalized at pmax */
270 f = Maxwell(m, p, T) / Maxwell(m , pmax, T);
274 /* Spherical symmetric emission for black particles (beta=0)*/
275 if(beta==0 || fThetaDistribution==0) theta = TMath::ACos(2. * Rndm() - 1.);
276 /* cos theta distributed according to experimental results for gray particles (beta=0.05)*/
277 else if(fThetaDistribution!=0){
278 Double_t costheta = fCosTheta->GetRandom();
279 theta = TMath::ACos(costheta);
282 phi = 2. * TMath::Pi() * Rndm();
284 /* Determine momentum components in system of the moving source */
285 q[0] = p * TMath::Sin(theta) * TMath::Cos(phi);
286 q[1] = p * TMath::Sin(theta) * TMath::Sin(phi);
287 q[2] = p * TMath::Cos(theta);
289 /* Transform to system of the target nucleus */
290 /* beta is passed as negative, because the gray nucleons are slowed down */
291 Lorentz(m, -beta, q);
293 /* Transform to laboratory system */
294 Lorentz(m, fBeta, q);
295 q[2] *= fProtonDirection;
298 Double_t AliGenSlowNucleons::Maxwell(Double_t m, Double_t p, Double_t T)
300 /* Relativistic Maxwell-distribution */
302 ekin = TMath::Sqrt(p*p+m*m)-m;
303 return (p*p * exp(-ekin/T));
307 void AliGenSlowNucleons::Lorentz(Double_t m, Double_t beta, Float_t* q)
309 /* Lorentz transform in the direction of q[2] */
311 Double_t gamma = 1./sqrt((1.-beta)*(1.+beta));
312 Double_t energy = sqrt(m*m + q[0]*q[0] + q[1]*q[1] + q[2]*q[2]);
313 q[2] = gamma * (q[2] + beta*energy);