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.11 1999/09/29 09:24:14 fca
19 Introduction of the Copyright and cvs Log
22 #include "AliGenerator.h"
23 #include "AliGenPythia.h"
25 #include "AliPythia.h"
26 #include <TDirectory.h>
30 #include <AliPythia.h>
31 #include <TParticle.h>
32 //#include <GParticle.h>
33 ClassImp(AliGenPythia)
35 AliGenPythia::AliGenPythia()
40 AliGenPythia::AliGenPythia(Int_t npart)
43 // default charm production at 5. 5 TeV
45 // structure function GRVHO
50 for (Int_t i=0; i<5; i++) fParentSelect[i]=fChildSelect[i]=0;
58 AliGenPythia::~AliGenPythia()
62 void AliGenPythia::Init()
64 SetMC(new AliPythia());
65 fPythia=(AliPythia*) fgMCEvGen;
67 fParentWeight=1./Float_t(fNpart);
69 // Forward Paramters to the AliPythia object
70 fPythia->DefineParticles();
71 fPythia->SetCKIN(3,fPtHardMin);
72 fPythia->SetCKIN(4,fPtHardMax);
73 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
74 fPythia->ForceDecay(fForceDecay);
77 // Parent and Children Selection
85 fParentSelect[3]=4122;
92 fParentSelect[3]=4122;
98 fParentSelect[3]=5122;
100 case beauty_unforced:
101 fParentSelect[0]=511;
102 fParentSelect[1]=521;
103 fParentSelect[2]=531;
104 fParentSelect[3]=5122;
108 fParentSelect[0]=443;
118 case b_jpsi_dielectron:
119 case b_psip_dielectron:
136 void AliGenPythia::Generate()
139 Float_t polar[3] = {0,0,0};
140 Float_t origin[3]= {0,0,0};
141 Float_t origin_p[3]= {0,0,0};
142 Float_t origin0[3]= {0,0,0};
143 Float_t p[3], p_p[4], random[6];
144 static TClonesArray *particles;
145 // converts from mm/c to s
146 const Float_t kconv=0.001/2.999792458e8;
155 if(!particles) particles=new TClonesArray("TParticle",1000);
158 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
159 if(fVertexSmear==perEvent) {
162 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
163 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
164 fPythia->SetMSTP(151,0);
166 } else if (fVertexSmear==perTrack) {
167 fPythia->SetMSTP(151,0);
169 fPythia->SetPARP(151+j, fOsigma[j]*10.);
176 fPythia->ImportParticles(particles,"All");
177 Int_t np = particles->GetEntriesFast();
178 printf("\n **************************************************%d\n",np);
180 if (np == 0 ) continue;
181 if (fProcess != mb) {
182 for (Int_t i = 0; i<np; i++) {
183 TParticle * iparticle = (TParticle *) particles->At(i);
184 kf = CheckPDGCode(iparticle->GetPdgCode());
185 fChildWeight=(fPythia->GetBraPart(kf))*fParentWeight;
188 if (ParentSelected(TMath::Abs(kf))) {
189 if (KinematicSelection(iparticle)) {
192 // Store information concerning the hard scattering process
194 Float_t mass_p = fPythia->GetPARI(13);
195 Float_t pt_p = fPythia->GetPARI(17);
196 Float_t y_p = fPythia->GetPARI(37);
197 Float_t xmt_p = sqrt(pt_p*pt_p+mass_p*mass_p);
198 Float_t ty = Float_t(TMath::TanH(y_p));
201 p_p[2] = xmt_p*ty/sqrt(1.-ty*ty);
203 gAlice->SetTrack(0,-1,-1,
205 0,"Hard Scat.",nt_p,fParentWeight);
206 gAlice->KeepTrack(nt_p);
210 // store parent track information
211 p[0]=iparticle->Px();
212 p[1]=iparticle->Py();
213 p[2]=iparticle->Pz();
214 origin[0]=origin0[0]+iparticle->Vx()/10;
215 origin[1]=origin0[1]+iparticle->Vy()/10;
216 origin[2]=origin0[2]+iparticle->Vz()/10;
218 Int_t ifch=iparticle->GetFirstDaughter();
219 Int_t ilch=iparticle->GetLastDaughter();
220 if (ifch !=0 && ilch !=0) {
221 gAlice->SetTrack(0,nt_p,kf,
223 0,"Primary",nt,fParentWeight);
224 gAlice->KeepTrack(nt);
229 for (j=ifch; j<=ilch; j++)
232 (TParticle *) particles->At(j-1);
233 kf = CheckPDGCode(ichild->GetPdgCode());
236 if (ChildSelected(TMath::Abs(kf))) {
237 origin[0]=ichild->Vx();
238 origin[1]=ichild->Vy();
239 origin[2]=ichild->Vz();
243 Float_t tof=kconv*ichild->T();
244 gAlice->SetTrack(fTrackIt, iparent, kf,
246 tof,"Decay",nt,fChildWeight);
247 gAlice->KeepTrack(nt);
251 } // kinematic selection
255 for (Int_t i = 0; i<np; i++) {
256 TParticle * iparticle = (TParticle *) particles->At(i);
257 kf = CheckPDGCode(iparticle->GetPdgCode());
258 Int_t ks = iparticle->GetStatusCode();
259 if (ks==1 && kf!=0 && KinematicSelection(iparticle)) {
262 // store track information
263 p[0]=iparticle->Px();
264 p[1]=iparticle->Py();
265 p[2]=iparticle->Pz();
266 origin[0]=origin0[0]+iparticle->Vx()/10;
267 origin[1]=origin0[1]+iparticle->Vy()/10;
268 origin[2]=origin0[2]+iparticle->Vz()/10;
269 Float_t tof=kconv*iparticle->T();
270 gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar,
272 gAlice->KeepTrack(nt);
275 printf("\n I've put %i particles on the stack \n",nc);
280 fKineBias=Float_t(fNpart)/Float_t(fTrials);
281 printf("\n Trials: %i\n",fTrials);
286 // adjust weight due to kinematic selection
289 fXsection=fPythia->GetPARI(1);
292 Bool_t AliGenPythia::ParentSelected(Int_t ip)
294 for (Int_t i=0; i<5; i++)
296 if (fParentSelect[i]==ip) return kTRUE;
301 Bool_t AliGenPythia::ChildSelected(Int_t ip)
303 for (Int_t i=0; i<5; i++)
305 if (fChildSelect[i]==ip) return kTRUE;
310 Bool_t AliGenPythia::KinematicSelection(TParticle *particle)
312 Float_t px=particle->Px();
313 Float_t py=particle->Py();
314 Float_t pz=particle->Pz();
315 Float_t e=particle->Energy();
318 // transverse momentum cut
319 Float_t pt=TMath::Sqrt(px*px+py*py);
320 if (pt > fPtMax || pt < fPtMin)
322 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
327 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
328 if (p > fPMax || p < fPMin)
330 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
336 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz)));
337 if (theta > fThetaMax || theta < fThetaMin)
339 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
345 Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
346 if (y > fYMax || y < fYMin)
348 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
354 Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)))+TMath::Pi();
355 if (phi > fPhiMax || phi < fPhiMin)
357 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
363 void AliGenPythia::AdjustWeights()
365 TClonesArray *PartArray = gAlice->Particles();
367 Int_t ntrack=gAlice->GetNtrack();
368 for (Int_t i=0; i<ntrack; i++) {
369 Part= (TParticle*) PartArray->UncheckedAt(i);
370 Part->SetWeight(Part->GetWeight()*fKineBias);
374 Int_t AliGenPythia::CheckPDGCode(Int_t pdgcode)
377 // If the particle is in a diffractive state, then take action accordigly
380 //rho_diff0 -- difficult to translate, return rho0
383 //pi_diffr+ -- change to pi+
386 //omega_di0 -- change to omega0
389 //phi_diff0 -- return phi0
392 //J/psi_di0 -- return J/psi
395 //n_diffr -- return neutron
398 //p_diffr+ -- return proton
401 //non diffractive state -- return code unchanged