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