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.21 2000/09/12 14:14:55 morsch
19 Call fDecayer->ForceDecay() at the beginning of Generate().
21 Revision 1.20 2000/09/06 14:29:33 morsch
22 Use AliPythia for event generation an AliDecayPythia for decays.
23 Correct handling of "nodecay" option
25 Revision 1.19 2000/07/11 18:24:56 fca
26 Coding convention corrections + few minor bug fixes
28 Revision 1.18 2000/06/30 12:40:34 morsch
29 Pythia takes care of vertex smearing. Correct conversion from Pythia units (mm) to
32 Revision 1.17 2000/06/09 20:34:07 morsch
33 All coding rule violations except RS3 corrected
35 Revision 1.16 2000/05/15 15:04:20 morsch
36 The full event is written for fNtrack = -1
37 Coding rule violations corrected.
39 Revision 1.15 2000/04/26 10:14:24 morsch
40 Particles array has one entry more than pythia particle list. Upper bound of
41 particle loop changed to np-1 (R. Guernane, AM)
43 Revision 1.14 2000/04/05 08:36:13 morsch
44 Check status code of particles in Pythia event
45 to avoid double counting as partonic state and final state particle.
47 Revision 1.13 1999/11/09 07:38:48 fca
48 Changes for compatibility with version 2.23 of ROOT
50 Revision 1.12 1999/11/03 17:43:20 fca
51 New version from G.Martinez & A.Morsch
53 Revision 1.11 1999/09/29 09:24:14 fca
54 Introduction of the Copyright and cvs Log
57 #include "AliGenPythia.h"
58 #include "AliDecayerPythia.h"
60 #include "AliPythia.h"
62 #include <TParticle.h>
65 ClassImp(AliGenPythia)
67 AliGenPythia::AliGenPythia()
70 // Default Constructor
71 fDecayer = new AliDecayerPythia();
74 AliGenPythia::AliGenPythia(Int_t npart)
77 // default charm production at 5. 5 TeV
79 // structure function GRVHO
84 for (Int_t i=0; i<5; i++) fParentSelect[i]=fChildSelect[i]=0;
90 fDecayer = new AliDecayerPythia();
93 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
98 AliGenPythia::~AliGenPythia()
103 void AliGenPythia::Init()
106 SetMC(AliPythia::Instance());
107 fPythia=(AliPythia*) fgMCEvGen;
109 fParentWeight=1./Float_t(fNpart);
111 // Forward Paramters to the AliPythia object
112 // gSystem->Exec("ln -s $ALICE_ROOT/data/Decay.table fort.1");
113 // fPythia->Pyupda(2,1);
114 // gSystem->Exec("rm fort.1");
116 fDecayer->SetForceDecay(fForceDecay);
120 fPythia->SetCKIN(3,fPtHardMin);
121 fPythia->SetCKIN(4,fPtHardMax);
122 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
124 // fPythia->Pylist(0);
125 // fPythia->Pystat(2);
126 // Parent and Children Selection
131 fParentSelect[0]=411;
132 fParentSelect[1]=421;
133 fParentSelect[2]=431;
134 fParentSelect[3]=4122;
138 fParentSelect[0]=411;
139 fParentSelect[1]=421;
140 fParentSelect[2]=431;
141 fParentSelect[3]=4122;
144 fParentSelect[0]=511;
145 fParentSelect[1]=521;
146 fParentSelect[2]=531;
147 fParentSelect[3]=5122;
149 case beauty_unforced:
150 fParentSelect[0]=511;
151 fParentSelect[1]=521;
152 fParentSelect[2]=531;
153 fParentSelect[3]=5122;
157 fParentSelect[0]=443;
167 case b_jpsi_dielectron:
168 case b_psip_dielectron:
169 fChildSelect[0]=kElectron;
177 fChildSelect[0]=kMuonMinus;
180 fChildSelect[0]=kPiPlus;
181 fChildSelect[1]=kKPlus;
189 void AliGenPythia::Generate()
191 // Generate one event
192 fDecayer->ForceDecay();
194 Float_t polar[3] = {0,0,0};
195 Float_t origin[3]= {0,0,0};
196 Float_t originP[3]= {0,0,0};
197 Float_t origin0[3]= {0,0,0};
199 // Float_t random[6];
200 static TClonesArray *particles;
201 // converts from mm/c to s
202 const Float_t kconv=0.001/2.999792458e8;
211 if(!particles) particles=new TClonesArray("TParticle",1000);
214 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
215 if(fVertexSmear==kPerEvent) {
216 fPythia->SetMSTP(151,1);
218 fPythia->SetPARP(151+j, fOsigma[j]/10.);
220 } else if (fVertexSmear==kPerTrack) {
221 fPythia->SetMSTP(151,0);
227 // fPythia->Pylist(1);
229 fPythia->ImportParticles(particles,"All");
230 Int_t np = particles->GetEntriesFast();
231 printf("\n **************************************************%d\n",np);
233 if (np == 0 ) continue;
234 if (fProcess != mb) {
235 for (Int_t i = 0; i<np-1; i++) {
236 TParticle * iparticle = (TParticle *) particles->At(i);
237 Int_t ks = iparticle->GetStatusCode();
238 kf = CheckPDGCode(iparticle->GetPdgCode());
239 if (ks==21) continue;
241 fChildWeight=(fDecayer->GetPartialBranchingRatio(kf))*fParentWeight;
244 if (ParentSelected(TMath::Abs(kf))) {
245 if (KinematicSelection(iparticle)) {
248 // Store information concerning the hard scattering process
250 Float_t massP = fPythia->GetPARI(13);
251 Float_t ptP = fPythia->GetPARI(17);
252 Float_t yP = fPythia->GetPARI(37);
253 Float_t xmtP = sqrt(ptP*ptP+massP*massP);
254 Float_t ty = Float_t(TMath::TanH(yP));
257 pP[2] = xmtP*ty/sqrt(1.-ty*ty);
259 gAlice->SetTrack(0,-1,-1,
261 0,"Hard Scat.",ntP,fParentWeight);
262 gAlice->KeepTrack(ntP);
266 // store parent track information
267 p[0]=iparticle->Px();
268 p[1]=iparticle->Py();
269 p[2]=iparticle->Pz();
270 origin[0]=origin0[0]+iparticle->Vx()*10.;
271 origin[1]=origin0[1]+iparticle->Vy()*10.;
272 origin[2]=origin0[2]+iparticle->Vz()*10.;
274 Int_t ifch=iparticle->GetFirstDaughter();
275 Int_t ilch=iparticle->GetLastDaughter();
277 if ((ifch !=0 && ilch !=0) || fForceDecay == nodecay) {
279 if (fForceDecay == nodecay) trackit = 1;
280 gAlice->SetTrack(trackit,ntP,kf,
282 0,"Primary",nt,fParentWeight);
283 gAlice->KeepTrack(nt);
287 if (fForceDecay != nodecay) {
288 for (j=ifch; j<=ilch; j++)
291 (TParticle *) particles->At(j-1);
292 kf = CheckPDGCode(ichild->GetPdgCode());
295 if (ChildSelected(TMath::Abs(kf))) {
296 origin[0]=origin0[0]+ichild->Vx()/10.;
297 origin[1]=origin0[1]+ichild->Vy()/10.;
298 origin[2]=origin0[2]+ichild->Vz()/10.;
302 Float_t tof=kconv*ichild->T();
303 gAlice->SetTrack(fTrackIt, iparent, kf,
305 tof,"Decay",nt,fChildWeight);
306 gAlice->KeepTrack(nt);
311 } // kinematic selection
315 for (Int_t i = 0; i<np-1; i++) {
316 TParticle * iparticle = (TParticle *) particles->At(i);
317 kf = CheckPDGCode(iparticle->GetPdgCode());
318 Int_t ks = iparticle->GetStatusCode();
320 if (ks==1 && kf!=0 && KinematicSelection(iparticle)) {
323 // store track information
324 p[0]=iparticle->Px();
325 p[1]=iparticle->Py();
326 p[2]=iparticle->Pz();
327 origin[0]=origin0[0]+iparticle->Vx()/10.;
328 origin[1]=origin0[1]+iparticle->Vy()/10.;
329 origin[2]=origin0[2]+iparticle->Vz()/10.;
330 Float_t tof=kconv*iparticle->T();
331 gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar,
333 gAlice->KeepTrack(nt);
336 printf("\n I've put %i particles on the stack \n",nc);
340 if (jev >= fNpart || fNpart == -1) {
341 fKineBias=Float_t(fNpart)/Float_t(fTrials);
342 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
347 // adjust weight due to kinematic selection
350 fXsection=fPythia->GetPARI(1);
353 Bool_t AliGenPythia::ParentSelected(Int_t ip)
355 // True if particle is in list of parent particles to be selected
356 for (Int_t i=0; i<5; i++)
358 if (fParentSelect[i]==ip) return kTRUE;
363 Bool_t AliGenPythia::ChildSelected(Int_t ip)
365 // True if particle is in list of decay products to be selected
366 if (fForceDecay == all) return kTRUE;
368 for (Int_t i=0; i<5; i++)
370 if (fChildSelect[i]==ip) return kTRUE;
375 Bool_t AliGenPythia::KinematicSelection(TParticle *particle)
377 // Perform kinematic selection
378 Float_t px=particle->Px();
379 Float_t py=particle->Py();
380 Float_t pz=particle->Pz();
381 Float_t e=particle->Energy();
384 // transverse momentum cut
385 Float_t pt=TMath::Sqrt(px*px+py*py);
386 if (pt > fPtMax || pt < fPtMin)
388 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
393 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
394 if (p > fPMax || p < fPMin)
396 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
402 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz)));
403 if (theta > fThetaMax || theta < fThetaMin)
405 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
411 Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
412 if (y > fYMax || y < fYMin)
414 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
420 Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
421 if (phi > fPhiMax || phi < fPhiMin)
423 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
429 void AliGenPythia::AdjustWeights()
431 // Adjust the weights after generation of all events
433 TClonesArray *partArray = gAlice->Particles();
435 Int_t ntrack=gAlice->GetNtrack();
436 for (Int_t i=0; i<ntrack; i++) {
437 part= (TParticle*) partArray->UncheckedAt(i);
438 part->SetWeight(part->GetWeight()*fKineBias);
442 Int_t AliGenPythia::CheckPDGCode(Int_t pdgcode)
445 // If the particle is in a diffractive state, then take action accordingly
450 //rho_diff0 -- difficult to translate, return rho0
453 //pi_diffr+ -- change to pi+
456 //omega_di0 -- change to omega0
459 //phi_diff0 -- return phi0
462 //J/psi_di0 -- return J/psi
465 //n_diffr -- return neutron
468 //p_diffr+ -- return proton
471 //non diffractive state -- return code unchanged
475 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
477 // Assignment operator
482 void AliGenPythia::Streamer(TBuffer &R__b)
484 // Stream an object of class AliGenPythia.
486 if (R__b.IsReading()) {
487 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
488 AliGenerator::Streamer(R__b);
489 R__b >> (Int_t&)fProcess;
490 R__b >> (Int_t&)fStrucFunc;
491 R__b >> (Int_t&)fForceDecay;
495 fParentSelect.Streamer(R__b);
496 fChildSelect.Streamer(R__b);
498 // (AliPythia::Instance())->Streamer(R__b);
501 // if (fDecayer) fDecayer->Streamer(R__b);
503 R__b.WriteVersion(AliGenPythia::IsA());
504 AliGenerator::Streamer(R__b);
505 R__b << (Int_t)fProcess;
506 R__b << (Int_t)fStrucFunc;
507 R__b << (Int_t)fForceDecay;
511 fParentSelect.Streamer(R__b);
512 fChildSelect.Streamer(R__b);
517 // fDecayer->Streamer(R__b);