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