1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.12 1999/11/03 17:43:20 fca
19 New version from G.Martinez & A.Morsch
21 Revision 1.11 1999/09/29 09:24:14 fca
22 Introduction of the Copyright and cvs Log
25 #include "AliGenerator.h"
26 #include "AliGenPythia.h"
28 #include "AliPythia.h"
29 #include <TDirectory.h>
33 #include <AliPythia.h>
34 #include <TParticle.h>
35 //#include <GParticle.h>
36 ClassImp(AliGenPythia)
38 AliGenPythia::AliGenPythia()
43 AliGenPythia::AliGenPythia(Int_t npart)
46 // default charm production at 5. 5 TeV
48 // structure function GRVHO
53 for (Int_t i=0; i<5; i++) fParentSelect[i]=fChildSelect[i]=0;
61 AliGenPythia::~AliGenPythia()
65 void AliGenPythia::Init()
67 SetMC(new AliPythia());
68 fPythia=(AliPythia*) fgMCEvGen;
70 fParentWeight=1./Float_t(fNpart);
72 // Forward Paramters to the AliPythia object
73 fPythia->DefineParticles();
74 fPythia->SetCKIN(3,fPtHardMin);
75 fPythia->SetCKIN(4,fPtHardMax);
76 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
77 fPythia->ForceDecay(fForceDecay);
80 // Parent and Children Selection
88 fParentSelect[3]=4122;
95 fParentSelect[3]=4122;
100 fParentSelect[2]=531;
101 fParentSelect[3]=5122;
103 case beauty_unforced:
104 fParentSelect[0]=511;
105 fParentSelect[1]=521;
106 fParentSelect[2]=531;
107 fParentSelect[3]=5122;
111 fParentSelect[0]=443;
121 case b_jpsi_dielectron:
122 case b_psip_dielectron:
139 void AliGenPythia::Generate()
142 Float_t polar[3] = {0,0,0};
143 Float_t origin[3]= {0,0,0};
144 Float_t origin_p[3]= {0,0,0};
145 Float_t origin0[3]= {0,0,0};
146 Float_t p[3], p_p[4], random[6];
147 static TClonesArray *particles;
148 // converts from mm/c to s
149 const Float_t kconv=0.001/2.999792458e8;
158 if(!particles) particles=new TClonesArray("TParticle",1000);
161 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
162 if(fVertexSmear==perEvent) {
165 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
166 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
167 fPythia->SetMSTP(151,0);
169 } else if (fVertexSmear==perTrack) {
170 fPythia->SetMSTP(151,0);
172 fPythia->SetPARP(151+j, fOsigma[j]*10.);
179 fPythia->ImportParticles(particles,"All");
180 Int_t np = particles->GetEntriesFast();
181 printf("\n **************************************************%d\n",np);
183 if (np == 0 ) continue;
184 if (fProcess != mb) {
185 for (Int_t i = 0; i<np; i++) {
186 TParticle * iparticle = (TParticle *) particles->At(i);
187 kf = CheckPDGCode(iparticle->GetPdgCode());
188 fChildWeight=(fPythia->GetBraPart(kf))*fParentWeight;
191 if (ParentSelected(TMath::Abs(kf))) {
192 if (KinematicSelection(iparticle)) {
195 // Store information concerning the hard scattering process
197 Float_t mass_p = fPythia->GetPARI(13);
198 Float_t pt_p = fPythia->GetPARI(17);
199 Float_t y_p = fPythia->GetPARI(37);
200 Float_t xmt_p = sqrt(pt_p*pt_p+mass_p*mass_p);
201 Float_t ty = Float_t(TMath::TanH(y_p));
204 p_p[2] = xmt_p*ty/sqrt(1.-ty*ty);
206 gAlice->SetTrack(0,-1,-1,
208 0,"Hard Scat.",nt_p,fParentWeight);
209 gAlice->KeepTrack(nt_p);
213 // store parent track information
214 p[0]=iparticle->Px();
215 p[1]=iparticle->Py();
216 p[2]=iparticle->Pz();
217 origin[0]=origin0[0]+iparticle->Vx()/10;
218 origin[1]=origin0[1]+iparticle->Vy()/10;
219 origin[2]=origin0[2]+iparticle->Vz()/10;
221 Int_t ifch=iparticle->GetFirstDaughter();
222 Int_t ilch=iparticle->GetLastDaughter();
223 if (ifch !=0 && ilch !=0) {
224 gAlice->SetTrack(0,nt_p,kf,
226 0,"Primary",nt,fParentWeight);
227 gAlice->KeepTrack(nt);
232 for (j=ifch; j<=ilch; j++)
235 (TParticle *) particles->At(j-1);
236 kf = CheckPDGCode(ichild->GetPdgCode());
239 if (ChildSelected(TMath::Abs(kf))) {
240 origin[0]=ichild->Vx();
241 origin[1]=ichild->Vy();
242 origin[2]=ichild->Vz();
246 Float_t tof=kconv*ichild->T();
247 gAlice->SetTrack(fTrackIt, iparent, kf,
249 tof,"Decay",nt,fChildWeight);
250 gAlice->KeepTrack(nt);
254 } // kinematic selection
258 for (Int_t i = 0; i<np; i++) {
259 TParticle * iparticle = (TParticle *) particles->At(i);
260 kf = CheckPDGCode(iparticle->GetPdgCode());
261 Int_t ks = iparticle->GetStatusCode();
262 if (ks==1 && kf!=0 && KinematicSelection(iparticle)) {
265 // store track information
266 p[0]=iparticle->Px();
267 p[1]=iparticle->Py();
268 p[2]=iparticle->Pz();
269 origin[0]=origin0[0]+iparticle->Vx()/10;
270 origin[1]=origin0[1]+iparticle->Vy()/10;
271 origin[2]=origin0[2]+iparticle->Vz()/10;
272 Float_t tof=kconv*iparticle->T();
273 gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar,
275 gAlice->KeepTrack(nt);
278 printf("\n I've put %i particles on the stack \n",nc);
283 fKineBias=Float_t(fNpart)/Float_t(fTrials);
284 printf("\n Trials: %i\n",fTrials);
289 // adjust weight due to kinematic selection
292 fXsection=fPythia->GetPARI(1);
295 Bool_t AliGenPythia::ParentSelected(Int_t ip)
297 for (Int_t i=0; i<5; i++)
299 if (fParentSelect[i]==ip) return kTRUE;
304 Bool_t AliGenPythia::ChildSelected(Int_t ip)
306 for (Int_t i=0; i<5; i++)
308 if (fChildSelect[i]==ip) return kTRUE;
313 Bool_t AliGenPythia::KinematicSelection(TParticle *particle)
315 Float_t px=particle->Px();
316 Float_t py=particle->Py();
317 Float_t pz=particle->Pz();
318 Float_t e=particle->Energy();
321 // transverse momentum cut
322 Float_t pt=TMath::Sqrt(px*px+py*py);
323 if (pt > fPtMax || pt < fPtMin)
325 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
330 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
331 if (p > fPMax || p < fPMin)
333 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
339 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz)));
340 if (theta > fThetaMax || theta < fThetaMin)
342 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
348 Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
349 if (y > fYMax || y < fYMin)
351 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
357 Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)))+TMath::Pi();
358 if (phi > fPhiMax || phi < fPhiMin)
360 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
366 void AliGenPythia::AdjustWeights()
368 TClonesArray *PartArray = gAlice->Particles();
370 Int_t ntrack=gAlice->GetNtrack();
371 for (Int_t i=0; i<ntrack; i++) {
372 Part= (TParticle*) PartArray->UncheckedAt(i);
373 Part->SetWeight(Part->GetWeight()*fKineBias);
377 Int_t AliGenPythia::CheckPDGCode(Int_t pdgcode)
380 // If the particle is in a diffractive state, then take action accordigly
383 //rho_diff0 -- difficult to translate, return rho0
386 //pi_diffr+ -- change to pi+
389 //omega_di0 -- change to omega0
392 //phi_diff0 -- return phi0
395 //J/psi_di0 -- return J/psi
398 //n_diffr -- return neutron
401 //p_diffr+ -- return proton
404 //non diffractive state -- return code unchanged