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