]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenHIJINGparaBa.cxx
20256cf49aec452311105be5f3b6ac025586d624
[u/mrichter/AliRoot.git] / EVGEN / AliGenHIJINGparaBa.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.1  2002/01/08 09:47:28  morsch
19 HIJING parameterisation including baryons, first commit.
20
21 */
22 ///////////////////////////////////////////////////////////////////
23 // Parameterisation of pi, K, n and p eta and pt distributions   //
24 // eta: according to HIJING (shadowing + quenching)              //
25 // pT : according to CDF measurement at 1.8 TeV                  //
26 // Author: andreas.morsch@cern.ch                                //
27 //                                                               //
28 ///////////////////////////////////////////////////////////////////
29
30 #include <TArrayF.h>
31 #include <TF1.h>
32 #include <TPDGCode.h>
33
34 #include "AliConst.h"
35 #include "AliGenEventHeader.h"
36 #include "AliGenHIJINGparaBa.h"
37 #include "AliRun.h"
38
39 ClassImp(AliGenHIJINGparaBa)
40
41
42 static Double_t ptpi(Double_t *px, Double_t *)
43 {
44   //
45   //     PT-PARAMETERIZATION CDF, PRL 61(88) 1819
46   //     POWER LAW FOR PT > 500 MEV
47   //     MT SCALING BELOW (T=160 MEV)
48   //
49   const Double_t kp0 = 1.3;
50   const Double_t kxn = 8.28;
51   const Double_t kxlim=0.5;
52   const Double_t kt=0.160;
53   const Double_t kxmpi=0.139;
54   const Double_t kb=1.;
55   Double_t y, y1, xmpi2, ynorm, a;
56   Double_t x=*px;
57   //
58   y1=TMath::Power(kp0/(kp0+kxlim),kxn);
59   xmpi2=kxmpi*kxmpi;
60   ynorm=kb*(TMath::Exp(-sqrt(kxlim*kxlim+xmpi2)/kt));
61   a=ynorm/y1;
62   if (x > kxlim)
63     y=a*TMath::Power(kp0/(kp0+x),kxn);
64   else
65     y=kb*TMath::Exp(-sqrt(x*x+xmpi2)/kt);
66   return y*x;
67 }
68
69 //_____________________________________________________________________________
70 static Double_t ptscal(Double_t pt, Int_t np)
71 {
72     //    SCALING EN MASSE PAR RAPPORT A PTPI
73     //     MASS PI,K,ETA,RHO,OMEGA,ETA',PHI
74     const Double_t khm[10] = {.13957,.493,.5488,.769,.7826,.958,1.02,0,0,0};
75     //     VALUE MESON/PI AT 5 GEV
76     const Double_t kfmax[10]={1.,0.3,0.55,1.0,1.0,1.0,1.0,0,0,0};
77     np--;
78     Double_t f5=TMath::Power(((
79         sqrt(100.018215)+2.)/(sqrt(100.+khm[np]*khm[np])+2.0)),12.3);
80     Double_t fmax2=f5/kfmax[np];
81     // PIONS
82     Double_t ptpion=100.*ptpi(&pt, (Double_t*) 0);
83     Double_t fmtscal=TMath::Power(((
84         sqrt(pt*pt+0.018215)+2.)/ (sqrt(pt*pt+khm[np]*khm[np])+2.0)),12.3)/ 
85         fmax2;
86     return fmtscal*ptpion;
87 }
88
89 //_____________________________________________________________________________
90 static Double_t ptka( Double_t *px, Double_t *)
91 {
92     //
93     // pt parametrisation for k
94     //
95     return ptscal(*px,2);
96 }
97
98
99 //_____________________________________________________________________________
100 static Double_t etapic( Double_t *py, Double_t *)
101 {
102   //
103   // eta parametrisation for pi
104   //
105     const Double_t ka1    = 4913.;
106     const Double_t ka2    = 1819.;
107     const Double_t keta1  = 0.22;
108     const Double_t keta2  = 3.66;
109     const Double_t kdeta1 = 1.47;
110     const Double_t kdeta2 = 1.51;
111     Double_t y=TMath::Abs(*py);
112     //
113     Double_t ex1 = (y-keta1)*(y-keta1)/(2*kdeta1*kdeta1);
114     Double_t ex2 = (y-keta2)*(y-keta2)/(2*kdeta2*kdeta2);
115     return ka1*TMath::Exp(-ex1)+ka2*TMath::Exp(-ex2);
116 }
117
118 //_____________________________________________________________________________
119 static Double_t etakac( Double_t *py, Double_t *)
120 {
121     //
122     // eta parametrisation for ka
123     //
124     const Double_t ka1    = 497.6;
125     const Double_t ka2    = 215.6;
126     const Double_t keta1  = 0.79;
127     const Double_t keta2  = 4.09;
128     const Double_t kdeta1 = 1.54;
129     const Double_t kdeta2 = 1.40;
130     Double_t y=TMath::Abs(*py);
131     //
132     Double_t ex1 = (y-keta1)*(y-keta1)/(2*kdeta1*kdeta1);
133     Double_t ex2 = (y-keta2)*(y-keta2)/(2*kdeta2*kdeta2);
134     return ka1*TMath::Exp(-ex1)+ka2*TMath::Exp(-ex2);
135 }
136
137  static Double_t ptbaryon( Double_t *px, Double_t *)
138 {
139 // baryons
140 //                pt-distribution
141 //____________________________________________________________
142
143   return ptscal(*px,7);  //  7==> Baryon in the PtScal function
144 }
145
146  static Double_t etabaryon( Double_t *py, Double_t *)
147 {
148 // eta-distribution
149 //____________________________________________________________
150     const Float_t p0 =  1.10343e+02;
151     const Float_t p1 =  1.73247e+01;
152     const Float_t p2 = -7.23808e+00;
153     const Float_t p3 =  4.48334e-01;
154     const Double_t y = TMath::Abs(*py);
155 //
156     return (p0+p1*y+p2*y*y+p3*y*y*y)/20.;
157 }
158
159 AliGenHIJINGparaBa::AliGenHIJINGparaBa()
160   :AliGenHIJINGpara()
161 {
162     //
163     // Default constructor
164     //
165     fName="HIGINGparaBa";
166     fTitle="HIJING Parametrisation Particle Generator with Baryons";
167     fETAba = 0;
168     fPtba  = 0;
169 }
170
171 //_____________________________________________________________________________
172 AliGenHIJINGparaBa::AliGenHIJINGparaBa(Int_t npart)
173   :AliGenHIJINGpara(npart)
174 {
175   // 
176   // Standard constructor
177   //
178     fName="HIGINGparaBa";
179     fTitle="HIJING Parametrisation Particle Generator with Baryons";
180     fETAba = 0;
181     fPtba  = 0;
182 }
183
184 //_____________________________________________________________________________
185 AliGenHIJINGparaBa::~AliGenHIJINGparaBa()
186 {
187   //
188   // Standard destructor
189   //
190     delete fPtba;
191     delete fETAba;
192 }
193
194 //_____________________________________________________________________________
195 void AliGenHIJINGparaBa::Init()
196 {
197   //
198   // Initialise the HIJING parametrisation
199   //
200     Float_t etaMin =-TMath::Log(TMath::Tan(
201         TMath::Min((Double_t)fThetaMax/2,TMath::Pi()/2-1.e-10)));
202     Float_t etaMax = -TMath::Log(TMath::Tan(
203         TMath::Max((Double_t)fThetaMin/2,1.e-10)));
204     fPtpi   = new TF1("ptpi",&ptpi,0,20,0);
205     fPtka   = new TF1("ptka",&ptka,0,20,0);
206     fPtba   = new TF1("ptbaryon",&ptbaryon,0,20,0);
207     fETApic = new TF1("etapic",&etapic,etaMin,etaMax,0);
208     fETAkac = new TF1("etakac",&etakac,etaMin,etaMax,0);
209     fETAba  = new TF1("etabaryon",&etabaryon,etaMin,etaMax,0);
210
211     TF1 *etaPic0 = new TF1("etapic",&etapic,    -7, 7, 0);
212     TF1 *etaKac0 = new TF1("etakac",&etakac,    -7, 7, 0);
213     TF1 *etaBar0 = new TF1("etabar",&etabaryon, -7, 7, 0);
214     
215     TF1 *ptPic0  = new TF1("ptpi",  &ptpi,     0., 15., 0);
216     TF1 *ptKac0  = new TF1("ptka",  &ptka,     0., 15., 0);
217     TF1 *ptBar0  = new TF1("ptbar", &ptbaryon, 0., 15., 0);
218
219     Float_t intETApi  = etaPic0->Integral(-0.5, 0.5);
220     Float_t intETAka  = etaKac0->Integral(-0.5, 0.5);
221     Float_t intETAba  = etaBar0->Integral(-0.5, 0.5);
222
223     Float_t scalePi   = 6979./(intETApi/1.5);
224     Float_t scaleKa   =  657./(intETAka/2.0);
225     Float_t scaleBa   =  364./(intETAba/2.0);
226
227 //  Fraction of events corresponding to the selected pt-range    
228     Float_t intPt    = (0.837*ptPic0->Integral(0, 15)+
229                         0.105*ptKac0->Integral(0, 15)+
230                         0.058*ptBar0->Integral(0, 15));
231     Float_t intPtSel = (0.837*ptPic0->Integral(fPtMin, fPtMax)+
232                         0.105*ptKac0->Integral(fPtMin, fPtMax)+
233                         0.058*ptBar0->Integral(fPtMin, fPtMax));
234     Float_t ptFrac   = intPtSel/intPt;
235
236 //  Fraction of events corresponding to the selected eta-range    
237     Float_t intETASel  = (scalePi*etaPic0->Integral(etaMin, etaMax)+
238                           scaleKa*etaKac0->Integral(etaMin, etaMax)+
239                           scaleBa*etaBar0->Integral(etaMin, etaMax));
240 //  Fraction of events corresponding to the selected phi-range    
241     Float_t phiFrac    = (fPhiMax-fPhiMin)/2/TMath::Pi();
242
243     fParentWeight = Float_t(fNpart)/(intETASel*ptFrac*phiFrac);
244     
245     printf("%s: The number of particles in the selected kinematic region corresponds to %f percent of a full event \n", 
246            ClassName(),100.*fParentWeight);
247
248 // Issue warning message if etaMin or etaMax are outside the alowed range 
249 // of the parametrization
250     if (etaMin < -8.001 || etaMax > 8.001) {
251         printf("\n \n WARNING FROM AliGenHIJINGParaBa !");
252         printf("\n YOU ARE USING THE PARAMETERISATION OUTSIDE ");       
253         printf("\n THE ALLOWED PSEUDORAPIDITY RANGE (-8. - 8.)");           
254         printf("\n YOUR LIMITS: %f %f \n \n ", etaMin, etaMax);
255     }
256 }
257
258 //_____________________________________________________________________________
259 void AliGenHIJINGparaBa::Generate()
260 {
261   //
262   // Generate one trigger
263   //
264
265   
266     const Float_t kBorne1 = 0.837;
267     const Float_t kBorne2 = kBorne1+0.105;
268     
269     Float_t polar[3]= {0,0,0};
270     //
271     const Int_t kPions[3]   = {kPi0, kPiPlus, kPiMinus};
272     const Int_t kKaons[4]   = {kK0Long, kK0Short, kKPlus, kKMinus};
273     const Int_t kBaryons[4] = {kProton, kProtonBar, kNeutron, kNeutronBar};
274     //
275     Float_t origin[3];
276     Float_t pt, pl, ptot;
277     Float_t phi, theta;
278     Float_t p[3];
279     Int_t i, part, nt, j;
280     //
281     TF1 *ptf;
282     TF1 *etaf;
283     //
284     Float_t random[6];
285     //
286     for (j=0;j<3;j++) origin[j]=fOrigin[j];
287
288     if(fVertexSmear == kPerEvent) {
289         Float_t dv[3];
290         dv[2] = 1.e10;
291         while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
292             Rndm(random,6);
293             for (j=0; j < 3; j++) {
294                 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
295                     TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
296             }
297         }
298         for (j=0; j < 3; j++) origin[j] += dv[j];
299     } // if kPerEvent
300     TArrayF eventVertex;
301     eventVertex.Set(3);
302     eventVertex[0] = origin[0];
303     eventVertex[1] = origin[1];
304     eventVertex[2] = origin[2];
305
306     for(i=0;i<fNpart;i++) {
307         while(1) {
308             Rndm(random,3);
309             if(random[0] < kBorne1) {
310                 part  = kPions[Int_t (random[1]*3)];
311                 ptf   = fPtpi;
312                 etaf  = fETApic;
313             } else if (random[0] < kBorne2) {
314                 part  = kKaons[Int_t (random[1]*4)];
315                 ptf   = fPtka;
316                 etaf  = fETAkac;
317             } else {
318                 part  = kBaryons[Int_t (random[1]*4)];
319                 ptf   = fPtba;
320                 etaf  = fETAba;
321             }
322             
323             phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
324             theta=2*TMath::ATan(TMath::Exp(-etaf->GetRandom()));
325             if(theta<fThetaMin || theta>fThetaMax) continue;
326             pt=ptf->GetRandom();
327             pl=pt/TMath::Tan(theta);
328             ptot=TMath::Sqrt(pt*pt+pl*pl);
329             if(ptot<fPMin || ptot>fPMax) continue;
330             p[0]=pt*TMath::Cos(phi);
331             p[1]=pt*TMath::Sin(phi);
332             p[2]=pl;
333             if(fVertexSmear==kPerTrack) {
334                 Rndm(random,6);
335                 for (j=0;j<3;j++) {
336                     origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
337                         TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
338                 }
339             }
340             SetTrack(fTrackIt,-1,part,p,origin,polar,0,kPPrimary,nt,fParentWeight);
341             break;
342         } // while(1)
343     } // Particle loop
344 // Header
345     AliGenEventHeader* header = new AliGenEventHeader("HIJINGparam");
346 // Event Vertex
347     header->SetPrimaryVertex(eventVertex);
348     gAlice->SetGenEventHeader(header); 
349 }
350
351
352