]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | ||
16 | /* | |
17 | $Log$ | |
18edb254 | 18 | Revision 1.19 2000/07/11 18:24:56 fca |
19 | Coding convention corrections + few minor bug fixes | |
20 | ||
aee8290b | 21 | Revision 1.18 2000/06/30 12:40:34 morsch |
22 | Pythia takes care of vertex smearing. Correct conversion from Pythia units (mm) to | |
23 | Geant units (cm). | |
24 | ||
1512e357 | 25 | Revision 1.17 2000/06/09 20:34:07 morsch |
26 | All coding rule violations except RS3 corrected | |
27 | ||
f87cfe57 | 28 | Revision 1.16 2000/05/15 15:04:20 morsch |
29 | The full event is written for fNtrack = -1 | |
30 | Coding rule violations corrected. | |
31 | ||
5ddeb374 | 32 | Revision 1.15 2000/04/26 10:14:24 morsch |
33 | Particles array has one entry more than pythia particle list. Upper bound of | |
34 | particle loop changed to np-1 (R. Guernane, AM) | |
35 | ||
2a0e6f5b | 36 | Revision 1.14 2000/04/05 08:36:13 morsch |
37 | Check status code of particles in Pythia event | |
38 | to avoid double counting as partonic state and final state particle. | |
39 | ||
23211d3e | 40 | Revision 1.13 1999/11/09 07:38:48 fca |
41 | Changes for compatibility with version 2.23 of ROOT | |
42 | ||
084c1b4a | 43 | Revision 1.12 1999/11/03 17:43:20 fca |
44 | New version from G.Martinez & A.Morsch | |
45 | ||
886b6f73 | 46 | Revision 1.11 1999/09/29 09:24:14 fca |
47 | Introduction of the Copyright and cvs Log | |
4c039060 | 48 | */ |
49 | ||
fe4da5cc | 50 | #include "AliGenPythia.h" |
18edb254 | 51 | #include "AliDecayerPythia.h" |
fe4da5cc | 52 | #include "AliRun.h" |
53 | #include "AliPythia.h" | |
18edb254 | 54 | #include "AliPDG.h" |
1578254f | 55 | #include <TParticle.h> |
18edb254 | 56 | #include <TSystem.h> |
f87cfe57 | 57 | |
fe4da5cc | 58 | ClassImp(AliGenPythia) |
59 | ||
60 | AliGenPythia::AliGenPythia() | |
61 | :AliGenerator() | |
62 | { | |
18edb254 | 63 | // Default Constructor |
64 | fDecayer = new AliDecayerPythia(); | |
fe4da5cc | 65 | } |
66 | ||
67 | AliGenPythia::AliGenPythia(Int_t npart) | |
68 | :AliGenerator(npart) | |
69 | { | |
70 | // default charm production at 5. 5 TeV | |
71 | // semimuonic decay | |
72 | // structure function GRVHO | |
73 | // | |
74 | fXsection = 0.; | |
75 | fParentSelect.Set(5); | |
76 | fChildSelect.Set(5); | |
77 | for (Int_t i=0; i<5; i++) fParentSelect[i]=fChildSelect[i]=0; | |
78 | SetProcess(); | |
79 | SetStrucFunc(); | |
886b6f73 | 80 | SetForceDecay(); |
fe4da5cc | 81 | SetPtHard(); |
82 | SetEnergyCMS(); | |
18edb254 | 83 | fDecayer = new AliDecayerPythia(); |
fe4da5cc | 84 | } |
85 | ||
f87cfe57 | 86 | AliGenPythia::AliGenPythia(const AliGenPythia & Pythia) |
87 | { | |
88 | // copy constructor | |
89 | } | |
90 | ||
fe4da5cc | 91 | AliGenPythia::~AliGenPythia() |
92 | { | |
5ddeb374 | 93 | // Destructor |
fe4da5cc | 94 | } |
95 | ||
96 | void AliGenPythia::Init() | |
97 | { | |
5ddeb374 | 98 | // Initialisation |
18edb254 | 99 | SetMC(AliPythia::Instance()); |
fe4da5cc | 100 | fPythia=(AliPythia*) fgMCEvGen; |
101 | // | |
102 | fParentWeight=1./Float_t(fNpart); | |
103 | // | |
104 | // Forward Paramters to the AliPythia object | |
18edb254 | 105 | // gSystem->Exec("ln -s $ALICE_ROOT/data/Decay.table fort.1"); |
106 | // fPythia->Pyupda(2,1); | |
107 | // gSystem->Exec("rm fort.1"); | |
108 | ||
109 | fDecayer->Init(); | |
110 | fDecayer->ForceDecay(fForceDecay); | |
111 | ||
fe4da5cc | 112 | fPythia->SetCKIN(3,fPtHardMin); |
113 | fPythia->SetCKIN(4,fPtHardMax); | |
114 | fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc); | |
18edb254 | 115 | |
116 | // fPythia->Pylist(0); | |
117 | // fPythia->Pystat(2); | |
fe4da5cc | 118 | // Parent and Children Selection |
119 | switch (fProcess) | |
120 | { | |
121 | case charm: | |
122 | ||
123 | fParentSelect[0]=411; | |
124 | fParentSelect[1]=421; | |
125 | fParentSelect[2]=431; | |
126 | fParentSelect[3]=4122; | |
127 | break; | |
128 | case charm_unforced: | |
129 | ||
130 | fParentSelect[0]=411; | |
131 | fParentSelect[1]=421; | |
132 | fParentSelect[2]=431; | |
133 | fParentSelect[3]=4122; | |
134 | break; | |
135 | case beauty: | |
136 | fParentSelect[0]=511; | |
137 | fParentSelect[1]=521; | |
138 | fParentSelect[2]=531; | |
139 | fParentSelect[3]=5122; | |
140 | break; | |
141 | case beauty_unforced: | |
142 | fParentSelect[0]=511; | |
143 | fParentSelect[1]=521; | |
144 | fParentSelect[2]=531; | |
145 | fParentSelect[3]=5122; | |
146 | break; | |
147 | case jpsi_chi: | |
148 | case jpsi: | |
149 | fParentSelect[0]=443; | |
150 | break; | |
5be1fe76 | 151 | case mb: |
152 | break; | |
fe4da5cc | 153 | } |
154 | ||
155 | switch (fForceDecay) | |
156 | { | |
157 | case semielectronic: | |
158 | case dielectron: | |
159 | case b_jpsi_dielectron: | |
160 | case b_psip_dielectron: | |
18edb254 | 161 | fChildSelect[0]=kElectron; |
fe4da5cc | 162 | break; |
163 | case semimuonic: | |
164 | case dimuon: | |
165 | case b_jpsi_dimuon: | |
166 | case b_psip_dimuon: | |
5be1fe76 | 167 | case pitomu: |
168 | case katomu: | |
18edb254 | 169 | fChildSelect[0]=kMuonMinus; |
fe4da5cc | 170 | break; |
18edb254 | 171 | case hadronicD: |
172 | fChildSelect[0]=kPiPlus; | |
173 | fChildSelect[1]=kKPlus; | |
174 | break; | |
886b6f73 | 175 | case all: |
176 | case nodecay: | |
18edb254 | 177 | break; |
fe4da5cc | 178 | } |
179 | } | |
180 | ||
181 | void AliGenPythia::Generate() | |
182 | { | |
5ddeb374 | 183 | // Generate one event |
18edb254 | 184 | fDecayer->ForceDecay(fForceDecay); |
fe4da5cc | 185 | |
5be1fe76 | 186 | Float_t polar[3] = {0,0,0}; |
187 | Float_t origin[3]= {0,0,0}; | |
5ddeb374 | 188 | Float_t originP[3]= {0,0,0}; |
5be1fe76 | 189 | Float_t origin0[3]= {0,0,0}; |
1512e357 | 190 | Float_t p[3], pP[4]; |
191 | // Float_t random[6]; | |
09fd3ea2 | 192 | static TClonesArray *particles; |
5be1fe76 | 193 | // converts from mm/c to s |
194 | const Float_t kconv=0.001/2.999792458e8; | |
fe4da5cc | 195 | |
196 | ||
197 | // | |
fe4da5cc | 198 | Int_t nt=0; |
5ddeb374 | 199 | Int_t ntP=0; |
fe4da5cc | 200 | Int_t jev=0; |
7921755b | 201 | Int_t j, kf; |
09fd3ea2 | 202 | |
203 | if(!particles) particles=new TClonesArray("TParticle",1000); | |
fe4da5cc | 204 | |
205 | fTrials=0; | |
206 | for (j=0;j<3;j++) origin0[j]=fOrigin[j]; | |
aee8290b | 207 | if(fVertexSmear==kPerEvent) { |
1512e357 | 208 | fPythia->SetMSTP(151,1); |
fe4da5cc | 209 | for (j=0;j<3;j++) { |
1512e357 | 210 | fPythia->SetPARP(151+j, fOsigma[j]/10.); |
fe4da5cc | 211 | } |
aee8290b | 212 | } else if (fVertexSmear==kPerTrack) { |
fe4da5cc | 213 | fPythia->SetMSTP(151,0); |
fe4da5cc | 214 | } |
1512e357 | 215 | |
fe4da5cc | 216 | while(1) |
217 | { | |
084c1b4a | 218 | fPythia->Pyevnt(); |
18edb254 | 219 | // fPythia->Pylist(1); |
fe4da5cc | 220 | fTrials++; |
f1092809 | 221 | fPythia->ImportParticles(particles,"All"); |
fe4da5cc | 222 | Int_t np = particles->GetEntriesFast(); |
223 | printf("\n **************************************************%d\n",np); | |
224 | Int_t nc=0; | |
225 | if (np == 0 ) continue; | |
5be1fe76 | 226 | if (fProcess != mb) { |
2a0e6f5b | 227 | for (Int_t i = 0; i<np-1; i++) { |
1578254f | 228 | TParticle * iparticle = (TParticle *) particles->At(i); |
23211d3e | 229 | Int_t ks = iparticle->GetStatusCode(); |
a8228d85 | 230 | kf = CheckPDGCode(iparticle->GetPdgCode()); |
2a0e6f5b | 231 | if (ks==21) continue; |
232 | ||
18edb254 | 233 | fChildWeight=(fDecayer->GetPartialBranchingRatio(kf))*fParentWeight; |
fe4da5cc | 234 | // |
235 | // Parent | |
5be1fe76 | 236 | if (ParentSelected(TMath::Abs(kf))) { |
237 | if (KinematicSelection(iparticle)) { | |
238 | if (nc==0) { | |
239 | // | |
240 | // Store information concerning the hard scattering process | |
241 | // | |
5ddeb374 | 242 | Float_t massP = fPythia->GetPARI(13); |
243 | Float_t ptP = fPythia->GetPARI(17); | |
244 | Float_t yP = fPythia->GetPARI(37); | |
245 | Float_t xmtP = sqrt(ptP*ptP+massP*massP); | |
246 | Float_t ty = Float_t(TMath::TanH(yP)); | |
247 | pP[0] = ptP; | |
248 | pP[1] = 0; | |
249 | pP[2] = xmtP*ty/sqrt(1.-ty*ty); | |
250 | pP[3] = massP; | |
5be1fe76 | 251 | gAlice->SetTrack(0,-1,-1, |
5ddeb374 | 252 | pP,originP,polar, |
253 | 0,"Hard Scat.",ntP,fParentWeight); | |
254 | gAlice->KeepTrack(ntP); | |
5be1fe76 | 255 | } |
256 | nc++; | |
fe4da5cc | 257 | // |
258 | // store parent track information | |
1578254f | 259 | p[0]=iparticle->Px(); |
260 | p[1]=iparticle->Py(); | |
261 | p[2]=iparticle->Pz(); | |
1512e357 | 262 | origin[0]=origin0[0]+iparticle->Vx()*10.; |
263 | origin[1]=origin0[1]+iparticle->Vy()*10.; | |
264 | origin[2]=origin0[2]+iparticle->Vz()*10.; | |
fe4da5cc | 265 | |
1578254f | 266 | Int_t ifch=iparticle->GetFirstDaughter(); |
267 | Int_t ilch=iparticle->GetLastDaughter(); | |
18edb254 | 268 | |
269 | if ((ifch !=0 && ilch !=0) || fForceDecay == nodecay) { | |
270 | Int_t trackit=0; | |
271 | if (fForceDecay == nodecay) trackit = 1; | |
272 | gAlice->SetTrack(trackit,ntP,kf, | |
5be1fe76 | 273 | p,origin,polar, |
274 | 0,"Primary",nt,fParentWeight); | |
275 | gAlice->KeepTrack(nt); | |
276 | Int_t iparent = nt; | |
fe4da5cc | 277 | // |
278 | // Children | |
18edb254 | 279 | if (fForceDecay != nodecay) { |
280 | for (j=ifch; j<=ilch; j++) | |
281 | { | |
282 | TParticle * ichild = | |
1578254f | 283 | (TParticle *) particles->At(j-1); |
18edb254 | 284 | kf = CheckPDGCode(ichild->GetPdgCode()); |
fe4da5cc | 285 | // |
286 | // | |
18edb254 | 287 | if (ChildSelected(TMath::Abs(kf))) { |
1512e357 | 288 | origin[0]=origin0[0]+ichild->Vx()*10.; |
289 | origin[1]=origin0[1]+ichild->Vy()*10.; | |
290 | origin[2]=origin0[2]+ichild->Vz()*10.; | |
1578254f | 291 | p[0]=ichild->Px(); |
292 | p[1]=ichild->Py(); | |
293 | p[2]=ichild->Pz(); | |
294 | Float_t tof=kconv*ichild->T(); | |
295 | gAlice->SetTrack(fTrackIt, iparent, kf, | |
5be1fe76 | 296 | p,origin,polar, |
297 | tof,"Decay",nt,fChildWeight); | |
298 | gAlice->KeepTrack(nt); | |
18edb254 | 299 | } // select child |
300 | } // child loop | |
301 | } | |
5be1fe76 | 302 | } |
303 | } // kinematic selection | |
304 | } // select particle | |
305 | } // particle loop | |
306 | } else { | |
2a0e6f5b | 307 | for (Int_t i = 0; i<np-1; i++) { |
1578254f | 308 | TParticle * iparticle = (TParticle *) particles->At(i); |
a8228d85 | 309 | kf = CheckPDGCode(iparticle->GetPdgCode()); |
1578254f | 310 | Int_t ks = iparticle->GetStatusCode(); |
2a0e6f5b | 311 | |
1578254f | 312 | if (ks==1 && kf!=0 && KinematicSelection(iparticle)) { |
5be1fe76 | 313 | nc++; |
314 | // | |
315 | // store track information | |
1578254f | 316 | p[0]=iparticle->Px(); |
317 | p[1]=iparticle->Py(); | |
318 | p[2]=iparticle->Pz(); | |
1512e357 | 319 | origin[0]=origin0[0]+iparticle->Vx()*10; |
320 | origin[1]=origin0[1]+iparticle->Vy()*10; | |
321 | origin[2]=origin0[2]+iparticle->Vz()*10; | |
1578254f | 322 | Float_t tof=kconv*iparticle->T(); |
323 | gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar, | |
5be1fe76 | 324 | tof,"Primary",nt); |
325 | gAlice->KeepTrack(nt); | |
326 | } // select particle | |
327 | } // particle loop | |
328 | printf("\n I've put %i particles on the stack \n",nc); | |
329 | } // mb ? | |
fe4da5cc | 330 | if (nc > 0) { |
5be1fe76 | 331 | jev+=nc; |
5ddeb374 | 332 | if (jev >= fNpart || fNpart == -1) { |
fe4da5cc | 333 | fKineBias=Float_t(fNpart)/Float_t(fTrials); |
23211d3e | 334 | printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev); |
fe4da5cc | 335 | break; |
336 | } | |
337 | } | |
338 | } // event loop | |
339 | // adjust weight due to kinematic selection | |
340 | AdjustWeights(); | |
341 | // get cross-section | |
342 | fXsection=fPythia->GetPARI(1); | |
343 | } | |
344 | ||
345 | Bool_t AliGenPythia::ParentSelected(Int_t ip) | |
346 | { | |
5ddeb374 | 347 | // True if particle is in list of parent particles to be selected |
fe4da5cc | 348 | for (Int_t i=0; i<5; i++) |
349 | { | |
350 | if (fParentSelect[i]==ip) return kTRUE; | |
351 | } | |
352 | return kFALSE; | |
353 | } | |
354 | ||
355 | Bool_t AliGenPythia::ChildSelected(Int_t ip) | |
356 | { | |
5ddeb374 | 357 | // True if particle is in list of decay products to be selected |
fe4da5cc | 358 | for (Int_t i=0; i<5; i++) |
359 | { | |
360 | if (fChildSelect[i]==ip) return kTRUE; | |
361 | } | |
362 | return kFALSE; | |
363 | } | |
364 | ||
1578254f | 365 | Bool_t AliGenPythia::KinematicSelection(TParticle *particle) |
fe4da5cc | 366 | { |
5ddeb374 | 367 | // Perform kinematic selection |
1578254f | 368 | Float_t px=particle->Px(); |
369 | Float_t py=particle->Py(); | |
370 | Float_t pz=particle->Pz(); | |
371 | Float_t e=particle->Energy(); | |
fe4da5cc | 372 | |
373 | // | |
374 | // transverse momentum cut | |
375 | Float_t pt=TMath::Sqrt(px*px+py*py); | |
376 | if (pt > fPtMax || pt < fPtMin) | |
377 | { | |
378 | // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax); | |
379 | return kFALSE; | |
380 | } | |
381 | // | |
382 | // momentum cut | |
383 | Float_t p=TMath::Sqrt(px*px+py*py+pz*pz); | |
384 | if (p > fPMax || p < fPMin) | |
385 | { | |
386 | // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax); | |
387 | return kFALSE; | |
388 | } | |
389 | ||
390 | // | |
391 | // theta cut | |
5be1fe76 | 392 | Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz))); |
fe4da5cc | 393 | if (theta > fThetaMax || theta < fThetaMin) |
394 | { | |
395 | // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax); | |
396 | return kFALSE; | |
397 | } | |
398 | ||
399 | // | |
400 | // rapidity cut | |
401 | Float_t y = 0.5*TMath::Log((e+pz)/(e-pz)); | |
402 | if (y > fYMax || y < fYMin) | |
403 | { | |
404 | // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax); | |
405 | return kFALSE; | |
406 | } | |
407 | ||
408 | // | |
409 | // phi cut | |
f87cfe57 | 410 | Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px))); |
fe4da5cc | 411 | if (phi > fPhiMax || phi < fPhiMin) |
412 | { | |
413 | // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax); | |
414 | return kFALSE; | |
415 | } | |
416 | ||
417 | return kTRUE; | |
418 | } | |
419 | void AliGenPythia::AdjustWeights() | |
420 | { | |
5ddeb374 | 421 | // Adjust the weights after generation of all events |
422 | // | |
423 | TClonesArray *partArray = gAlice->Particles(); | |
424 | TParticle *part; | |
fe4da5cc | 425 | Int_t ntrack=gAlice->GetNtrack(); |
426 | for (Int_t i=0; i<ntrack; i++) { | |
5ddeb374 | 427 | part= (TParticle*) partArray->UncheckedAt(i); |
428 | part->SetWeight(part->GetWeight()*fKineBias); | |
fe4da5cc | 429 | } |
430 | } | |
431 | ||
a8228d85 | 432 | Int_t AliGenPythia::CheckPDGCode(Int_t pdgcode) |
433 | { | |
434 | // | |
23211d3e | 435 | // If the particle is in a diffractive state, then take action accordingly |
a8228d85 | 436 | switch (pdgcode) { |
18edb254 | 437 | case 91: |
438 | return 92; | |
a8228d85 | 439 | case 110: |
440 | //rho_diff0 -- difficult to translate, return rho0 | |
441 | return 113; | |
442 | case 210: | |
443 | //pi_diffr+ -- change to pi+ | |
444 | return 211; | |
445 | case 220: | |
446 | //omega_di0 -- change to omega0 | |
447 | return 223; | |
448 | case 330: | |
449 | //phi_diff0 -- return phi0 | |
450 | return 333; | |
451 | case 440: | |
452 | //J/psi_di0 -- return J/psi | |
453 | return 443; | |
454 | case 2110: | |
455 | //n_diffr -- return neutron | |
456 | return 2112; | |
457 | case 2210: | |
458 | //p_diffr+ -- return proton | |
459 | return 2212; | |
460 | } | |
461 | //non diffractive state -- return code unchanged | |
462 | return pdgcode; | |
463 | } | |
464 | ||
f87cfe57 | 465 | AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs) |
466 | { | |
467 | // Assignment operator | |
468 | return *this; | |
469 | } | |
fe4da5cc | 470 | |
471 | ||
18edb254 | 472 | void AliGenPythia::Streamer(TBuffer &R__b) |
473 | { | |
474 | // Stream an object of class AliGenPythia. | |
475 | ||
476 | if (R__b.IsReading()) { | |
477 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
478 | AliGenerator::Streamer(R__b); | |
479 | R__b >> (Int_t&)fProcess; | |
480 | R__b >> (Int_t&)fStrucFunc; | |
481 | R__b >> (Int_t&)fForceDecay; | |
482 | R__b >> fEnergyCMS; | |
483 | R__b >> fKineBias; | |
484 | R__b >> fTrials; | |
485 | fParentSelect.Streamer(R__b); | |
486 | fChildSelect.Streamer(R__b); | |
487 | R__b >> fXsection; | |
488 | // (AliPythia::Instance())->Streamer(R__b); | |
489 | R__b >> fPtHardMin; | |
490 | R__b >> fPtHardMax; | |
491 | // if (fDecayer) fDecayer->Streamer(R__b); | |
492 | } else { | |
493 | R__b.WriteVersion(AliGenPythia::IsA()); | |
494 | AliGenerator::Streamer(R__b); | |
495 | R__b << (Int_t)fProcess; | |
496 | R__b << (Int_t)fStrucFunc; | |
497 | R__b << (Int_t)fForceDecay; | |
498 | R__b << fEnergyCMS; | |
499 | R__b << fKineBias; | |
500 | R__b << fTrials; | |
501 | fParentSelect.Streamer(R__b); | |
502 | fChildSelect.Streamer(R__b); | |
503 | R__b << fXsection; | |
504 | // R__b << fPythia; | |
505 | R__b << fPtHardMin; | |
506 | R__b << fPtHardMax; | |
507 | // fDecayer->Streamer(R__b); | |
508 | } | |
509 | } | |
510 | ||
511 | ||
512 | ||
fe4da5cc | 513 | |
5be1fe76 | 514 | |
515 | ||
516 | ||
517 |