]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliSimpleGen.cxx
Adding check for pt range in AliGenBox
[u/mrichter/AliRoot.git] / EVGEN / AliSimpleGen.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.6  1999/11/03 17:43:20  fca
19 New version from G.Martinez & A.Morsch
20
21 Revision 1.5  1999/09/29 09:24:14  fca
22 Introduction of the Copyright and cvs Log
23
24 */
25
26 ///////////////////////////////////////////////////////////////////
27 //                                                               //
28 //    Generate the final state of the interaction as the input   //
29 //    to the MonteCarlo                                          //
30 //
31 //Begin_Html
32 /*
33 <img src="picts/AliGeneratorClass.gif">
34 </pre>
35 <br clear=left>
36 <font size=+2 color=red>
37 <p>The responsible person for this module is
38 <a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
39 </font>
40 <pre>
41 */
42 //End_Html
43 //                                                               //
44 ///////////////////////////////////////////////////////////////////
45
46 #include "AliSimpleGen.h"
47 #include "AliRun.h"
48 #include "AliConst.h"
49
50 ClassImp(AliGenHIJINGpara)
51
52 //_____________________________________________________________________________
53 static Double_t ptpi(Double_t *px, Double_t *)
54 {
55   //
56   //     PT-PARAMETERIZATION CDF, PRL 61(88) 1819
57   //     POWER LAW FOR PT > 500 MEV
58   //     MT SCALING BELOW (T=160 MEV)
59   //
60   const Double_t p0 = 1.3;
61   const Double_t xn = 8.28;
62   const Double_t xlim=0.5;
63   const Double_t t=0.160;
64   const Double_t xmpi=0.139;
65   const Double_t b=1.;
66   Double_t y, y1, xmpi2, ynorm, a;
67   Double_t x=*px;
68   //
69   y1=TMath::Power(p0/(p0+xlim),xn);
70   xmpi2=xmpi*xmpi;
71   ynorm=b*(TMath::Exp(-sqrt(xlim*xlim+xmpi2)/t));
72   a=ynorm/y1;
73   if (x > xlim)
74     y=a*TMath::Power(p0/(p0+x),xn);
75   else
76     y=b*TMath::Exp(-sqrt(x*x+xmpi2)/t);
77   return y*x;
78 }
79
80 //_____________________________________________________________________________
81 static Double_t ptscal(Double_t pt, Int_t np)
82 {
83   //    SCALING EN MASSE PAR RAPPORT A PTPI
84   //     MASS PI,K,ETA,RHO,OMEGA,ETA',PHI
85   const Double_t hm[10] = {.13957,.493,.5488,.769,.7826,.958,1.02,0,0,0};
86   //     VALUE MESON/PI AT 5 GEV
87   const Double_t fmax[10]={1.,0.3,0.55,1.0,1.0,1.0,1.0,0,0,0};
88   np--;
89   Double_t f5=TMath::Power(((sqrt(100.018215)+2.)/(sqrt(100.+hm[np]*hm[np])+2.0)),12.3);
90   Double_t fmax2=f5/fmax[np];
91   // PIONS
92   Double_t ptpion=100.*ptpi(&pt, (Double_t*) 0);
93   Double_t fmtscal=TMath::Power(((sqrt(pt*pt+0.018215)+2.)/
94                                  (sqrt(pt*pt+hm[np]*hm[np])+2.0)),12.3)/ fmax2;
95   return fmtscal*ptpion;
96 }
97
98 //_____________________________________________________________________________
99 static Double_t ptka( Double_t *px, Double_t *)
100 {
101   //
102   // pt parametrisation for k
103   //
104   return ptscal(*px,2);
105 }
106
107
108 //_____________________________________________________________________________
109 static Double_t etapic( Double_t *py, Double_t *)
110 {
111   //
112   // eta parametrisation for pi
113   //
114   const Double_t a1    = 4913.;
115   const Double_t a2    = 1819.;
116   const Double_t eta1  = 0.22;
117   const Double_t eta2  = 3.66;
118   const Double_t deta1 = 1.47;
119   const Double_t deta2 = 1.51;
120   Double_t y=TMath::Abs(*py);
121   //
122   Double_t ex1 = (y-eta1)*(y-eta1)/(2*deta1*deta1);
123   Double_t ex2 = (y-eta2)*(y-eta2)/(2*deta2*deta2);
124   return a1*TMath::Exp(-ex1)+a2*TMath::Exp(-ex2);
125 }
126
127 //_____________________________________________________________________________
128 static Double_t etakac( Double_t *py, Double_t *)
129 {
130   //
131   // eta parametrisation for ka
132   //
133   const Double_t a1    = 497.6;
134   const Double_t a2    = 215.6;
135   const Double_t eta1  = 0.79;
136   const Double_t eta2  = 4.09;
137   const Double_t deta1 = 1.54;
138   const Double_t deta2 = 1.40;
139   Double_t y=TMath::Abs(*py);
140   //
141   Double_t ex1 = (y-eta1)*(y-eta1)/(2*deta1*deta1);
142   Double_t ex2 = (y-eta2)*(y-eta2)/(2*deta2*deta2);
143   return a1*TMath::Exp(-ex1)+a2*TMath::Exp(-ex2);
144 }
145
146 //_____________________________________________________________________________
147 AliGenHIJINGpara::AliGenHIJINGpara()
148   :AliGenerator()
149 {
150   //
151   // Default constructor
152   //
153   fPtpi = 0;
154   fPtka = 0;
155   fETApic = 0;
156   fETAkac = 0;
157 }
158
159 //_____________________________________________________________________________
160 AliGenHIJINGpara::AliGenHIJINGpara(Int_t npart)
161   :AliGenerator(npart)
162 {
163   // 
164   // Standard constructor
165   //
166   fName="HIGINGpara";
167   fTitle="HIJING Parametrisation Particle Generator";
168   fPtpi = 0;
169   fPtka = 0;
170   fETApic = 0;
171   fETAkac = 0;
172 }
173
174 //_____________________________________________________________________________
175 AliGenHIJINGpara::~AliGenHIJINGpara()
176 {
177   //
178   // Standard destructor
179   //
180   delete fPtpi;
181   delete fPtka;
182   delete fETApic;
183   delete fETAkac;
184 }
185
186 //_____________________________________________________________________________
187 void AliGenHIJINGpara::Init()
188 {
189   //
190   // Initialise the HIJING parametrisation
191   //
192   Float_t etaMin = -TMath::Log(TMath::Tan(TMath::Min((Double_t)fThetaMax/2,TMath::Pi()/2-1.e-10)));
193   Float_t etaMax = -TMath::Log(TMath::Tan(TMath::Max((Double_t)fThetaMin/2,              1.e-10)));
194   fPtpi = new TF1("ptpi",&ptpi,0,20,0);
195   fPtka = new TF1("ptka",&ptka,0,20,0);
196   fETApic = new TF1("etapic",&etapic,etaMin,etaMax,0);
197   fETAkac = new TF1("etakac",&etakac,etaMin,etaMax,0);
198   TF1 *ETApic0 = new TF1("etapic",&etapic,-7,7,0);
199   TF1 *ETAkac0 = new TF1("etakac",&etakac,-7,7,0);
200   Float_t IntETApi  = ETApic0->Integral(-0.5, 0.5);
201   Float_t IntETAka  = ETAkac0->Integral(-0.5, 0.5);
202   Float_t scalePi=7316/(IntETApi/1.5);
203   Float_t scaleKa= 684/(IntETAka/2.0);
204
205   Float_t IntPt  = (0.877*ETApic0->Integral(0, 15)+
206                     0.123*ETAkac0->Integral(0, 15));
207   Float_t IntPtSel = (0.877*ETApic0->Integral(fPtMin, fPtMax)+
208                       0.123*ETAkac0->Integral(fPtMin, fPtMax));
209   Float_t PtFrac = IntPtSel/IntPt;
210   
211
212   Float_t IntETASel  = (scalePi*ETApic0->Integral(etaMin, etaMax)+
213                         scaleKa*ETAkac0->Integral(etaMin, etaMax));
214   Float_t PhiFrac = (fPhiMax-fPhiMin)/2/TMath::Pi();
215   fParentWeight = Float_t(fNpart)/IntETASel*PtFrac*PhiFrac;
216   
217   printf("\n The number of particles in the selected kinematic region corresponds to %f percent of a full event\n ", 100.*fParentWeight);
218   
219 }
220
221 //_____________________________________________________________________________
222 void AliGenHIJINGpara::Generate()
223 {
224   //
225   // Generate one trigger
226   //
227
228   
229   const Float_t raKpic=0.14;
230   const Float_t borne=1/(1+raKpic);
231   Float_t polar[3]= {0,0,0};
232   //
233   const Int_t pions[3] = {kPi0, kPiPlus, kPiMinus};
234   const Int_t kaons[4] = {kK0Long, kK0Short, kKPlus, kKMinus};
235   //
236   Float_t origin[3];
237   Float_t pt, pl, ptot;
238   Float_t phi, theta;
239   Float_t p[3];
240   Int_t i, part, nt, j;
241   //
242   TF1 *ptf;
243   TF1 *etaf;
244   //
245   Float_t random[6];
246   //
247   for (j=0;j<3;j++) origin[j]=fOrigin[j];
248   if(fVertexSmear==perEvent) {
249     gMC->Rndm(random,6);
250     for (j=0;j<3;j++) {
251       origin[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
252         TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
253     }
254   }
255   for(i=0;i<fNpart;i++) {
256     while(1) {
257       gMC->Rndm(random,3);
258       if(random[0]<borne) {
259         part=pions[Int_t (random[1]*3)];
260         ptf=fPtpi;
261         etaf=fETApic;
262       } else {
263         part=kaons[Int_t (random[1]*4)];
264         ptf=fPtka;
265         etaf=fETAkac;
266       }
267       phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
268       theta=2*TMath::ATan(TMath::Exp(-etaf->GetRandom()));
269       if(theta<fThetaMin || theta>fThetaMax) continue;
270       pt=ptf->GetRandom();
271       pl=pt/TMath::Tan(theta);
272       ptot=TMath::Sqrt(pt*pt+pl*pl);
273       if(ptot<fPMin || ptot>fPMax) continue;
274       p[0]=pt*TMath::Cos(phi);
275       p[1]=pt*TMath::Sin(phi);
276       p[2]=pl;
277       if(fVertexSmear==perTrack) {
278         gMC->Rndm(random,6);
279         for (j=0;j<3;j++) {
280           origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
281             TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
282         }
283       }
284       gAlice->SetTrack(fTrackIt,-1,part,p,origin,polar,0,"Primary",nt,fParentWeight);
285       break;
286     }
287   }
288 }
289   
290 ClassImp(AliGenFixed)
291
292 //_____________________________________________________________________________
293 AliGenFixed::AliGenFixed()
294   :AliGenerator()
295 {
296   //
297   // Default constructor
298   //
299   fIpart = 0;
300 }
301
302 //_____________________________________________________________________________
303 AliGenFixed::AliGenFixed(Int_t npart)
304   :AliGenerator(npart)
305 {
306   //
307   // Standard constructor
308   //
309   fName="Fixed";
310   fTitle="Fixed Particle Generator";
311   // Generate Proton by default
312   fIpart=kProton;
313 }
314
315 //_____________________________________________________________________________
316 void AliGenFixed::Generate()
317 {
318   //
319   // Generate one trigger
320   //
321   Float_t polar[3]= {0,0,0};
322   Float_t p[3] = {fPMin*TMath::Cos(fPhiMin)*TMath::Sin(fThetaMin),
323                   fPMin*TMath::Sin(fPhiMin)*TMath::Sin(fThetaMin),
324                   fPMin*TMath::Cos(fThetaMin)};
325   Int_t i, nt;
326   //
327   for(i=0;i<fNpart;i++) {
328     gAlice->SetTrack(fTrackIt,-1,fIpart,p,fOrigin.GetArray(),polar,0,"Primary",nt);
329   }
330 }
331   
332 //_____________________________________________________________________________
333 void AliGenFixed::SetSigma(Float_t, Float_t, Float_t)
334 {
335   //
336   // Set the interaction point sigma
337   //
338   printf("Vertex smearing not implemented for fixed generator\n");
339 }
340
341
342 ClassImp(AliGenBox)
343
344 //_____________________________________________________________________________
345 AliGenBox::AliGenBox()
346     :AliGenerator()
347 {
348   //
349   // Default constructor
350   //
351   fIpart=0;
352 }
353
354 //_____________________________________________________________________________
355 AliGenBox::AliGenBox(Int_t npart)
356   :AliGenerator(npart)
357 {
358   //
359   // Standard constructor
360   //
361   fName="Box";
362   fTitle="Box particle generator";
363   // Generate Proton by default
364   fIpart=kProton;
365 }
366
367 //_____________________________________________________________________________
368 void AliGenBox::Generate()
369 {
370   //
371   // Generate one trigger
372   //
373   
374   Float_t polar[3]= {0,0,0};
375   //
376   Float_t origin[3];
377   Float_t p[3];
378   Int_t i, j, nt;
379   Float_t pmom, theta, phi;
380   //
381   Float_t random[6];
382   //
383   for (j=0;j<3;j++) origin[j]=fOrigin[j];
384   if(fVertexSmear==perEvent) {
385     gMC->Rndm(random,6);
386     for (j=0;j<3;j++) {
387       origin[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
388         TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
389     }
390   }
391   for(i=0;i<fNpart;i++) {
392     gMC->Rndm(random,3);
393     do {
394       pmom=fPMin+random[0]*(fPMax-fPMin);
395       theta=fThetaMin+random[1]*(fThetaMax-fThetaMin);
396       phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
397       p[0] = pmom*TMath::Cos(phi)*TMath::Sin(theta);
398       p[1] = pmom*TMath::Sin(phi)*TMath::Sin(theta);
399       p[2] = pmom*TMath::Cos(theta);
400     } while (fPtMin<=TMath::Sqrt(p[0]*p[0]+p[1]*p[1]) && 
401              TMath::Sqrt(p[0]*p[0]+p[1]*p[1])<=fPtMax);
402     if(fVertexSmear==perTrack) {
403       gMC->Rndm(random,6);
404       for (j=0;j<3;j++) {
405         origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
406           TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
407       }
408     }
409     gAlice->SetTrack(fTrackIt,-1,fIpart,p,origin,polar,0,"Primary",nt);
410   }
411 }
412
413