]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenHIJINGpara.cxx
Further integration of the HLT reconstruction (C.Cheshkov)
[u/mrichter/AliRoot.git] / EVGEN / AliGenHIJINGpara.cxx
CommitLineData
790bbabf 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
88cb7938 16/* $Id$ */
675e9664 17
18// Parameterisation of pi and K, eta and pt distributions
19// used for the ALICE TDRs.
20// eta: according to HIJING (shadowing + quenching)
21// pT : according to CDF measurement at 1.8 TeV
22// Author: andreas.morsch@cern.ch
23
24
790bbabf 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
971816d4 40#include <TArrayF.h>
ac3faee4 41#include <TCanvas.h>
2067f62c 42#include <TClonesArray.h>
116cbefd 43#include <TDatabasePDG.h>
44#include <TF1.h>
cc692c80 45#include <TH1.h>
116cbefd 46#include <TPDGCode.h>
ac3faee4 47#include <TParticle.h>
828fff0d 48#include <TROOT.h>
ac3faee4 49#include <TVirtualMC.h>
116cbefd 50
51#include "AliConst.h"
52#include "AliDecayer.h"
116cbefd 53#include "AliGenEventHeader.h"
54#include "AliGenHIJINGpara.h"
55#include "AliRun.h"
971816d4 56
790bbabf 57ClassImp(AliGenHIJINGpara)
58
198bb1c7 59
60AliGenHIJINGpara::AliGenHIJINGpara(const AliGenHIJINGpara & para):
61 AliGenerator(para)
790bbabf 62{
198bb1c7 63// Copy constructor
64 para.Copy(*this);
790bbabf 65}
66
67//_____________________________________________________________________________
68static Double_t ptpi(Double_t *px, Double_t *)
69{
70 //
71 // PT-PARAMETERIZATION CDF, PRL 61(88) 1819
72 // POWER LAW FOR PT > 500 MEV
73 // MT SCALING BELOW (T=160 MEV)
74 //
cc692c80 75 const Double_t kp0 = 1.3;
76 const Double_t kxn = 8.28;
77 const Double_t kxlim = 0.5;
78 const Double_t kt = 0.160;
79 const Double_t kxmpi = 0.139;
80 const Double_t kb = 1.;
790bbabf 81 Double_t y, y1, xmpi2, ynorm, a;
cc692c80 82 Double_t x = *px;
790bbabf 83 //
cc692c80 84 y1 = TMath::Power(kp0 / (kp0 + kxlim), kxn);
85 xmpi2 = kxmpi * kxmpi;
86 ynorm = kb * (TMath::Exp(-sqrt(kxlim * kxlim + xmpi2) / kt ));
87 a = ynorm / y1;
790bbabf 88 if (x > kxlim)
cc692c80 89 y = a * TMath::Power(kp0 / (kp0 + x), kxn);
790bbabf 90 else
cc692c80 91 y = kb* TMath::Exp(-sqrt(x * x + xmpi2) / kt);
92
790bbabf 93 return y*x;
94}
95
96//_____________________________________________________________________________
97static Double_t ptscal(Double_t pt, Int_t np)
98{
99 // SCALING EN MASSE PAR RAPPORT A PTPI
100 // MASS PI,K,ETA,RHO,OMEGA,ETA',PHI
101 const Double_t khm[10] = {.13957,.493,.5488,.769,.7826,.958,1.02,0,0,0};
102 // VALUE MESON/PI AT 5 GEV
103 const Double_t kfmax[10]={1.,0.3,0.55,1.0,1.0,1.0,1.0,0,0,0};
104 np--;
105 Double_t f5=TMath::Power(((
106 sqrt(100.018215)+2.)/(sqrt(100.+khm[np]*khm[np])+2.0)),12.3);
107 Double_t fmax2=f5/kfmax[np];
108 // PIONS
109 Double_t ptpion=100.*ptpi(&pt, (Double_t*) 0);
110 Double_t fmtscal=TMath::Power(((
111 sqrt(pt*pt+0.018215)+2.)/ (sqrt(pt*pt+khm[np]*khm[np])+2.0)),12.3)/
112 fmax2;
113 return fmtscal*ptpion;
114}
115
116//_____________________________________________________________________________
117static Double_t ptka( Double_t *px, Double_t *)
118{
119 //
120 // pt parametrisation for k
121 //
122 return ptscal(*px,2);
123}
124
125
126//_____________________________________________________________________________
127static Double_t etapic( Double_t *py, Double_t *)
128{
129 //
130 // eta parametrisation for pi
131 //
132 const Double_t ka1 = 4913.;
133 const Double_t ka2 = 1819.;
134 const Double_t keta1 = 0.22;
135 const Double_t keta2 = 3.66;
136 const Double_t kdeta1 = 1.47;
137 const Double_t kdeta2 = 1.51;
138 Double_t y=TMath::Abs(*py);
139 //
140 Double_t ex1 = (y-keta1)*(y-keta1)/(2*kdeta1*kdeta1);
141 Double_t ex2 = (y-keta2)*(y-keta2)/(2*kdeta2*kdeta2);
142 return ka1*TMath::Exp(-ex1)+ka2*TMath::Exp(-ex2);
143}
144
145//_____________________________________________________________________________
146static Double_t etakac( Double_t *py, Double_t *)
147{
148 //
149 // eta parametrisation for ka
150 //
151 const Double_t ka1 = 497.6;
152 const Double_t ka2 = 215.6;
153 const Double_t keta1 = 0.79;
154 const Double_t keta2 = 4.09;
155 const Double_t kdeta1 = 1.54;
156 const Double_t kdeta2 = 1.40;
157 Double_t y=TMath::Abs(*py);
158 //
159 Double_t ex1 = (y-keta1)*(y-keta1)/(2*kdeta1*kdeta1);
160 Double_t ex2 = (y-keta2)*(y-keta2)/(2*kdeta2*kdeta2);
161 return ka1*TMath::Exp(-ex1)+ka2*TMath::Exp(-ex2);
162}
163
164//_____________________________________________________________________________
165AliGenHIJINGpara::AliGenHIJINGpara()
166 :AliGenerator()
167{
168 //
169 // Default constructor
170 //
1e66857c 171 fPtpi = 0;
172 fPtka = 0;
173 fETApic = 0;
174 fETAkac = 0;
175 fDecayer = 0;
176 fNt = -1;
971816d4 177 SetCutVertexZ();
6b236b6f 178 SetPtRange();
2067f62c 179 SetPi0Decays();
790bbabf 180}
181
182//_____________________________________________________________________________
183AliGenHIJINGpara::AliGenHIJINGpara(Int_t npart)
184 :AliGenerator(npart)
185{
186 //
187 // Standard constructor
188 //
edbba5db 189 fName="HIJINGpara";
790bbabf 190 fTitle="HIJING Parametrisation Particle Generator";
1e66857c 191 fPtpi = 0;
192 fPtka = 0;
193 fETApic = 0;
194 fETAkac = 0;
195 fDecayer = 0;
196 fNt = -1;
971816d4 197 SetCutVertexZ();
6b236b6f 198 SetPtRange();
2067f62c 199 SetPi0Decays();
790bbabf 200}
201
202//_____________________________________________________________________________
203AliGenHIJINGpara::~AliGenHIJINGpara()
204{
205 //
206 // Standard destructor
207 //
208 delete fPtpi;
209 delete fPtka;
210 delete fETApic;
211 delete fETAkac;
212}
213
214//_____________________________________________________________________________
215void AliGenHIJINGpara::Init()
216{
217 //
218 // Initialise the HIJING parametrisation
219 //
220 Float_t etaMin =-TMath::Log(TMath::Tan(
221 TMath::Min((Double_t)fThetaMax/2,TMath::Pi()/2-1.e-10)));
222 Float_t etaMax = -TMath::Log(TMath::Tan(
223 TMath::Max((Double_t)fThetaMin/2,1.e-10)));
f25521b2 224 fPtpi = new TF1("ptpi",&ptpi,0,20,0);
828fff0d 225 gROOT->GetListOfFunctions()->Remove(fPtpi);
f25521b2 226 fPtka = new TF1("ptka",&ptka,0,20,0);
828fff0d 227 gROOT->GetListOfFunctions()->Remove(fPtka);
cc692c80 228 fPtpi->SetNpx(1000);
229 fPtka->SetNpx(1000);
790bbabf 230 fETApic = new TF1("etapic",&etapic,etaMin,etaMax,0);
828fff0d 231 gROOT->GetListOfFunctions()->Remove(fETApic);
790bbabf 232 fETAkac = new TF1("etakac",&etakac,etaMin,etaMax,0);
828fff0d 233 gROOT->GetListOfFunctions()->Remove(fETAkac);
f25521b2 234
bbbc190a 235 TF1 etaPic0("etaPic0",&etapic,-7,7,0);
236 TF1 etaKac0("etaKac0",&etakac,-7,7,0);
f25521b2 237
bbbc190a 238 TF1 ptPic0("ptPic0",&ptpi,0.,15.,0);
239 TF1 ptKac0("ptKac0",&ptka,0.,15.,0);
f25521b2 240
aecf26a3 241 Float_t intETApi = etaPic0.Integral(-0.5, 0.5);
242 Float_t intETAka = etaKac0.Integral(-0.5, 0.5);
f25521b2 243 Float_t scalePi = 7316/(intETApi/1.5);
244 Float_t scaleKa = 684/(intETAka/2.0);
245
246// Fraction of events corresponding to the selected pt-range
aecf26a3 247 Float_t intPt = (0.877*ptPic0.Integral(0, 15)+
248 0.123*ptKac0.Integral(0, 15));
249 Float_t intPtSel = (0.877*ptPic0.Integral(fPtMin, fPtMax)+
250 0.123*ptKac0.Integral(fPtMin, fPtMax));
f25521b2 251 Float_t ptFrac = intPtSel/intPt;
252
253// Fraction of events corresponding to the selected eta-range
aecf26a3 254 Float_t intETASel = (scalePi*etaPic0.Integral(etaMin, etaMax)+
255 scaleKa*etaKac0.Integral(etaMin, etaMax));
f25521b2 256// Fraction of events corresponding to the selected phi-range
257 Float_t phiFrac = (fPhiMax-fPhiMin)/2/TMath::Pi();
258
0af12c00 259
f25521b2 260 fParentWeight = Float_t(fNpart)/(intETASel*ptFrac*phiFrac);
790bbabf 261
0af12c00 262 if (fAnalog != 0) {
263 fPtWgtPi = (fPtMax - fPtMin) / fPtpi->Integral(0., 20.);
264 fPtWgtKa = (fPtMax - fPtMin) / fPtka->Integral(0., 20.);
265 fParentWeight = Float_t(fNpart)/(intETASel*phiFrac);
266 }
267
268
9e1a0ddb 269 printf("%s: The number of particles in the selected kinematic region corresponds to %f percent of a full event\n ",
270 ClassName(),100.*fParentWeight);
5b0e4c0f 271
272// Issue warning message if etaMin or etaMax are outside the alowed range
273// of the parametrization
274 if (etaMin < -8.001 || etaMax > 8.001) {
275 printf("\n \n WARNING FROM AliGenHIJINGPara !");
276 printf("\n YOU ARE USING THE PARAMETERISATION OUTSIDE ");
277 printf("\n THE ALLOWED PSEUDORAPIDITY RANGE (-8. - 8.)");
278 printf("\n YOUR LIMITS: %f %f \n \n ", etaMin, etaMax);
279 }
2067f62c 280//
281//
2904363f 282 if (fPi0Decays && gMC)
283 fDecayer = gMC->GetDecayer();
790bbabf 284}
285
2067f62c 286
790bbabf 287//_____________________________________________________________________________
288void AliGenHIJINGpara::Generate()
289{
290 //
291 // Generate one trigger
292 //
293
294
295 const Float_t kRaKpic=0.14;
296 const Float_t kBorne=1/(1+kRaKpic);
297 Float_t polar[3]= {0,0,0};
298 //
299 const Int_t kPions[3] = {kPi0, kPiPlus, kPiMinus};
300 const Int_t kKaons[4] = {kK0Long, kK0Short, kKPlus, kKMinus};
301 //
302 Float_t origin[3];
0af12c00 303 Float_t pt, pl, ptot, wgt;
790bbabf 304 Float_t phi, theta;
305 Float_t p[3];
1e66857c 306 Int_t i, part, j;
790bbabf 307 //
308 TF1 *ptf;
309 TF1 *etaf;
310 //
311 Float_t random[6];
312 //
313 for (j=0;j<3;j++) origin[j]=fOrigin[j];
971816d4 314
315 if(fVertexSmear == kPerEvent) {
c8f7f6f9 316 Vertex();
317 for (j=0; j < 3; j++) origin[j] = fVertex[j];
971816d4 318 } // if kPerEvent
319 TArrayF eventVertex;
320 eventVertex.Set(3);
321 eventVertex[0] = origin[0];
322 eventVertex[1] = origin[1];
323 eventVertex[2] = origin[2];
0af12c00 324
790bbabf 325 for(i=0;i<fNpart;i++) {
326 while(1) {
0af12c00 327 Rndm(random,4);
790bbabf 328 if(random[0]<kBorne) {
329 part=kPions[Int_t (random[1]*3)];
330 ptf=fPtpi;
2067f62c 331 etaf=fETApic;
0af12c00 332 wgt = fPtWgtPi;
790bbabf 333 } else {
334 part=kKaons[Int_t (random[1]*4)];
335 ptf=fPtka;
336 etaf=fETAkac;
0af12c00 337 wgt = fPtWgtKa;
790bbabf 338 }
339 phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
340 theta=2*TMath::ATan(TMath::Exp(-etaf->GetRandom()));
341 if(theta<fThetaMin || theta>fThetaMax) continue;
0af12c00 342
343 if (fAnalog == 0) {
344 pt = ptf->GetRandom();
345 } else {
346 pt = fPtMin + random[3] * (fPtMax - fPtMin);
347 }
348
349
790bbabf 350 pl=pt/TMath::Tan(theta);
351 ptot=TMath::Sqrt(pt*pt+pl*pl);
352 if(ptot<fPMin || ptot>fPMax) continue;
353 p[0]=pt*TMath::Cos(phi);
354 p[1]=pt*TMath::Sin(phi);
355 p[2]=pl;
aee8290b 356 if(fVertexSmear==kPerTrack) {
65fb704d 357 Rndm(random,6);
790bbabf 358 for (j=0;j<3;j++) {
359 origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
360 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
361 }
362 }
0af12c00 363
364 if (fAnalog == 0) {
365 wgt = fParentWeight;
366 } else {
367 wgt *= (fParentWeight * ptf->Eval(pt));
368 }
369
370
1ef5f15d 371 if (part == kPi0 && fPi0Decays){
2067f62c 372//
373// Decay pi0 if requested
642f15cf 374 PushTrack(0,-1,part,p,origin,polar,0,kPPrimary,fNt,fParentWeight);
1e66857c 375 KeepTrack(fNt);
1ef5f15d 376 DecayPi0(origin, p);
377 } else {
642f15cf 378 PushTrack(fTrackIt,-1,part,p,origin,polar,0,kPPrimary,fNt,fParentWeight);
1e66857c 379 KeepTrack(fNt);
1ef5f15d 380 }
381
790bbabf 382 break;
383 }
1e66857c 384 SetHighWaterMark(fNt);
790bbabf 385 }
1e66857c 386//
387
971816d4 388// Header
389 AliGenEventHeader* header = new AliGenEventHeader("HIJINGparam");
390// Event Vertex
391 header->SetPrimaryVertex(eventVertex);
392 gAlice->SetGenEventHeader(header);
790bbabf 393}
394
6b236b6f 395void AliGenHIJINGpara::SetPtRange(Float_t ptmin, Float_t ptmax) {
2067f62c 396 AliGenerator::SetPtRange(ptmin, ptmax);
6b236b6f 397}
790bbabf 398
2067f62c 399void AliGenHIJINGpara::DecayPi0(Float_t* orig, Float_t * p)
400{
401//
402// Decay the pi0
403// and put decay products on the stack
404//
405 static TClonesArray *particles;
406 if(!particles) particles = new TClonesArray("TParticle",1000);
407//
408 const Float_t kMass = TDatabasePDG::Instance()->GetParticle(kPi0)->Mass();
56fcdfe6 409 Float_t e = TMath::Sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]+ kMass * kMass);
2067f62c 410//
411// Decay the pi0
412 TLorentzVector pmom(p[0], p[1], p[2], e);
413 fDecayer->Decay(kPi0, &pmom);
56fcdfe6 414
2067f62c 415//
416// Put decay particles on the stack
417//
2067f62c 418 Float_t polar[3] = {0., 0., 0.};
419 Int_t np = fDecayer->ImportParticles(particles);
1e66857c 420 Int_t nt;
2067f62c 421 for (Int_t i = 1; i < np; i++)
422 {
7b33c00a 423 TParticle* iParticle = (TParticle *) particles->At(i);
424 p[0] = iParticle->Px();
425 p[1] = iParticle->Py();
426 p[2] = iParticle->Pz();
2067f62c 427 Int_t part = iParticle->GetPdgCode();
1e66857c 428
642f15cf 429 PushTrack(fTrackIt, fNt, part, p, orig, polar, 0, kPDecay, nt, fParentWeight);
1e66857c 430 KeepTrack(nt);
2067f62c 431 }
1e66857c 432 fNt = nt;
2067f62c 433}
198bb1c7 434
dc1d768c 435void AliGenHIJINGpara::Copy(TObject &) const
198bb1c7 436{
437 Fatal("Copy","Not implemented!\n");
438}
cc692c80 439
440
441void AliGenHIJINGpara::Draw( const char * /*opt*/)
442{
443 //
444 // Draw the pT and y Distributions
445 //
446 TCanvas *c0 = new TCanvas("c0","Canvas 0",400,10,600,700);
447 c0->Divide(2,1);
448 c0->cd(1);
449 fPtpi->Draw();
450 fPtpi->GetHistogram()->SetXTitle("p_{T} (GeV)");
451 c0->cd(2);
452 fPtka->Draw();
453 fPtka->GetHistogram()->SetXTitle("p_{T} (GeV)");
454
455}