]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenPythia.cxx
New options kPi0Flat y kEtaFlat (Gustavo Conesa)
[u/mrichter/AliRoot.git] / EVGEN / AliGenPythia.cxx
CommitLineData
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$
6d4dd317 18Revision 1.54 2002/03/28 11:49:10 morsch
19Pass status code in SetTrack.
20
5ec84200 21Revision 1.53 2002/03/25 14:51:13 morsch
22New stack-fill and count options introduced (N. Carrer).
23
0d7c70a0 24Revision 1.51 2002/03/06 08:46:57 morsch
25- Loop until np-1
26- delete dyn. alloc. arrays (N. Carrer)
27
b9817493 28Revision 1.50 2002/03/03 13:48:50 morsch
29Option kPyCharmPbMNR added. Produce charm pairs in agreement with MNR
30NLO calculations (Nicola Carrer).
31
fbd1348b 32Revision 1.49 2002/02/08 16:50:50 morsch
33Add name and title in constructor.
34
8b31bfac 35Revision 1.48 2001/12/20 11:44:28 morsch
36Add kinematic bias for direct gamma production.
37
b2bb450d 38Revision 1.47 2001/12/19 14:45:00 morsch
39Store number of trials in header.
40
fd8fb861 41Revision 1.46 2001/12/19 10:36:19 morsch
42Add possibility if jet kinematic biasing.
43
988b118b 44Revision 1.45 2001/11/28 08:06:52 morsch
45Use fMaxLifeTime parameter.
46
8cdfd303 47Revision 1.44 2001/11/27 13:13:07 morsch
48Maximum lifetime for long-lived particles to be put on the stack is parameter.
49It can be set via SetMaximumLifetime(..).
50
47fc6bd5 51Revision 1.43 2001/10/21 18:35:56 hristov
52Several pointers were set to zero in the default constructors to avoid memory management problems
53
2685bf00 54Revision 1.42 2001/10/15 08:21:55 morsch
55Vertex truncation settings moved to AliGenMC.
56
4c07486d 57Revision 1.41 2001/10/08 08:45:42 morsch
58Possibility of vertex cut added.
59
a0b2b296 60Revision 1.40 2001/09/25 11:30:23 morsch
61Pass event vertex to header.
62
c5d36e84 63Revision 1.39 2001/07/27 17:09:36 morsch
64Use local SetTrack, KeepTrack and SetHighWaterMark methods
65to delegate either to local stack or to stack owned by AliRun.
66(Piotr Skowronski, A.M.)
67
a99cf51f 68Revision 1.38 2001/07/13 10:58:54 morsch
69- Some coded moved to AliGenMC
70- Improved handling of secondary vertices.
71
fff02fee 72Revision 1.37 2001/06/28 11:17:28 morsch
73SetEventListRange setter added. Events in specified range are listed for
74debugging. (Yuri Kharlov)
75
11dfaf8d 76Revision 1.36 2001/03/30 07:05:49 morsch
77Final print-out in finish run.
78Write parton system for jet-production (preliminary solution).
79
9be6226f 80Revision 1.35 2001/03/09 13:03:40 morsch
81Process_t and Struc_Func_t moved to AliPythia.h
82
f1a48a38 83Revision 1.34 2001/02/14 15:50:40 hristov
84The last particle in event marked using SetHighWaterMark
85
28adac24 86Revision 1.33 2001/01/30 09:23:12 hristov
87Streamers removed (R.Brun)
88
a8a6107b 89Revision 1.32 2001/01/26 19:55:51 hristov
90Major upgrade of AliRoot code
91
2ab0c725 92Revision 1.31 2001/01/17 10:54:31 hristov
93Better protection against FPE
94
0f9e52a3 95Revision 1.30 2000/12/18 08:55:35 morsch
96Make AliPythia dependent generartors work with new scheme of random number generation
97
3356c022 98Revision 1.29 2000/12/04 11:22:03 morsch
99Init of sRandom as in 1.15
100
097ec7c1 101Revision 1.28 2000/12/02 11:41:39 morsch
102Use SetRandom() to initialize random number generator in constructor.
103
1ed25e11 104Revision 1.27 2000/11/30 20:29:02 morsch
105Initialise static variable sRandom in constructor: sRandom = fRandom;
106
ad1df918 107Revision 1.26 2000/11/30 07:12:50 alibrary
108Introducing new Rndm and QA classes
109
65fb704d 110Revision 1.25 2000/10/18 19:11:27 hristov
111Division by zero fixed
112
919c2096 113Revision 1.24 2000/09/18 10:41:35 morsch
114Add possibility to use nuclear structure functions from PDF library V8.
115
811826d8 116Revision 1.23 2000/09/14 14:05:40 morsch
117dito
118
819f84ad 119Revision 1.22 2000/09/14 14:02:22 morsch
120- Correct conversion from mm to cm when passing particle vertex to MC.
121- Correct handling of fForceDecay == all.
122
4451ef92 123Revision 1.21 2000/09/12 14:14:55 morsch
124Call fDecayer->ForceDecay() at the beginning of Generate().
125
00d6ce7d 126Revision 1.20 2000/09/06 14:29:33 morsch
127Use AliPythia for event generation an AliDecayPythia for decays.
128Correct handling of "nodecay" option
129
18edb254 130Revision 1.19 2000/07/11 18:24:56 fca
131Coding convention corrections + few minor bug fixes
132
aee8290b 133Revision 1.18 2000/06/30 12:40:34 morsch
134Pythia takes care of vertex smearing. Correct conversion from Pythia units (mm) to
135Geant units (cm).
136
1512e357 137Revision 1.17 2000/06/09 20:34:07 morsch
138All coding rule violations except RS3 corrected
139
f87cfe57 140Revision 1.16 2000/05/15 15:04:20 morsch
141The full event is written for fNtrack = -1
142Coding rule violations corrected.
143
5ddeb374 144Revision 1.15 2000/04/26 10:14:24 morsch
145Particles array has one entry more than pythia particle list. Upper bound of
146particle loop changed to np-1 (R. Guernane, AM)
147
2a0e6f5b 148Revision 1.14 2000/04/05 08:36:13 morsch
149Check status code of particles in Pythia event
150to avoid double counting as partonic state and final state particle.
151
23211d3e 152Revision 1.13 1999/11/09 07:38:48 fca
153Changes for compatibility with version 2.23 of ROOT
154
084c1b4a 155Revision 1.12 1999/11/03 17:43:20 fca
156New version from G.Martinez & A.Morsch
157
886b6f73 158Revision 1.11 1999/09/29 09:24:14 fca
159Introduction of the Copyright and cvs Log
4c039060 160*/
161
6d4dd317 162//
163// Generator using the TPythia interface (via AliPythia)
164// to generate pp collisions.
165// Using SetNuclei() also nuclear modifications to the structure functions
166// can be taken into account. This makes, of course, only sense for the
167// generation of the products of hard processes (heavy flavor, jets ...)
168//
169// andreas.morsch@cern.ch
170//
171
172
fe4da5cc 173#include "AliGenPythia.h"
fff02fee 174#include "AliGenPythiaEventHeader.h"
18edb254 175#include "AliDecayerPythia.h"
fe4da5cc 176#include "AliRun.h"
177#include "AliPythia.h"
18edb254 178#include "AliPDG.h"
1578254f 179#include <TParticle.h>
18edb254 180#include <TSystem.h>
f87cfe57 181
fe4da5cc 182 ClassImp(AliGenPythia)
183
184AliGenPythia::AliGenPythia()
fff02fee 185 :AliGenMC()
fe4da5cc 186{
18edb254 187// Default Constructor
2685bf00 188 fParticles = 0;
189 fPythia = 0;
988b118b 190 fDecayer = new AliDecayerPythia();
11dfaf8d 191 SetEventListRange();
988b118b 192 SetJetPhiRange();
193 SetJetEtaRange();
fe4da5cc 194}
195
196AliGenPythia::AliGenPythia(Int_t npart)
fff02fee 197 :AliGenMC(npart)
fe4da5cc 198{
199// default charm production at 5. 5 TeV
200// semimuonic decay
201// structure function GRVHO
202//
8b31bfac 203 fName = "Pythia";
204 fTitle= "Particle Generator using PYTHIA";
fe4da5cc 205 fXsection = 0.;
811826d8 206 fNucA1=0;
207 fNucA2=0;
fe4da5cc 208 SetProcess();
209 SetStrucFunc();
886b6f73 210 SetForceDecay();
fe4da5cc 211 SetPtHard();
212 SetEnergyCMS();
18edb254 213 fDecayer = new AliDecayerPythia();
1ed25e11 214 // Set random number generator
097ec7c1 215 sRandom=fRandom;
fff02fee 216 fFlavorSelect = 0;
217 // Produced particles
218 fParticles = new TClonesArray("TParticle",1000);
c5d36e84 219 fEventVertex.Set(3);
988b118b 220 SetEventListRange();
221 SetJetPhiRange();
222 SetJetEtaRange();
719b6b8a 223 // Options determining what to keep in the stack (Heavy flavour generation)
224 fStackFillOpt = kFlavorSelection; // Keep particle with selected flavor
225 fFeedDownOpt = kTRUE; // allow feed down from higher family
226 // Fragmentation on/off
227 fFragmentation = kTRUE;
228 // Default counting mode
229 fCountMode = kCountAll;
fe4da5cc 230}
231
f87cfe57 232AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
233{
234// copy constructor
6d4dd317 235 Pythia.Copy(*this);
f87cfe57 236}
237
fe4da5cc 238AliGenPythia::~AliGenPythia()
239{
5ddeb374 240// Destructor
fe4da5cc 241}
242
11dfaf8d 243void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
244{
245 // Set a range of event numbers, for which a table
246 // of generated particle will be printed
247 fDebugEventFirst = eventFirst;
248 fDebugEventLast = eventLast;
249 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
250}
251
fe4da5cc 252void AliGenPythia::Init()
253{
5ddeb374 254// Initialisation
18edb254 255 SetMC(AliPythia::Instance());
fe4da5cc 256 fPythia=(AliPythia*) fgMCEvGen;
257//
258 fParentWeight=1./Float_t(fNpart);
259//
260// Forward Paramters to the AliPythia object
00d6ce7d 261 fDecayer->SetForceDecay(fForceDecay);
18edb254 262 fDecayer->Init();
00d6ce7d 263
18edb254 264
fe4da5cc 265 fPythia->SetCKIN(3,fPtHardMin);
266 fPythia->SetCKIN(4,fPtHardMax);
811826d8 267 if (fNucA1 > 0 && fNucA2 > 0) fPythia->SetNuclei(fNucA1, fNucA2);
719b6b8a 268 // Fragmentation?
269 if (fFragmentation) {
270 fPythia->SetMSTP(111,1);
271 } else {
272 fPythia->SetMSTP(111,0);
273 }
274
fe4da5cc 275 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
18edb254 276
277 // fPythia->Pylist(0);
278 // fPythia->Pystat(2);
fe4da5cc 279// Parent and Children Selection
280 switch (fProcess)
281 {
f1a48a38 282 case kPyCharm:
f1a48a38 283 case kPyCharmUnforced:
fbd1348b 284 case kPyCharmPbMNR:
b2bb450d 285 fParentSelect[0] = 411;
286 fParentSelect[1] = 421;
287 fParentSelect[2] = 431;
288 fParentSelect[3] = 4122;
8b31bfac 289 fFlavorSelect = 4;
fe4da5cc 290 break;
719b6b8a 291 case kPyD0PbMNR:
292 fParentSelect[0] = 421;
293 fFlavorSelect = 4;
294 break;
f1a48a38 295 case kPyBeauty:
fff02fee 296 fParentSelect[0]= 511;
297 fParentSelect[1]= 521;
298 fParentSelect[2]= 531;
299 fParentSelect[3]= 5122;
300 fParentSelect[4]= 5132;
301 fParentSelect[5]= 5232;
302 fParentSelect[6]= 5332;
303 fFlavorSelect = 5;
fe4da5cc 304 break;
f1a48a38 305 case kPyBeautyUnforced:
fff02fee 306 fParentSelect[0] = 511;
307 fParentSelect[1] = 521;
308 fParentSelect[2] = 531;
309 fParentSelect[3] = 5122;
310 fParentSelect[4] = 5132;
311 fParentSelect[5] = 5232;
312 fParentSelect[6] = 5332;
313 fFlavorSelect = 5;
fe4da5cc 314 break;
f1a48a38 315 case kPyJpsiChi:
316 case kPyJpsi:
fff02fee 317 fParentSelect[0] = 443;
fe4da5cc 318 break;
f1a48a38 319 case kPyMb:
320 case kPyJets:
321 case kPyDirectGamma:
5be1fe76 322 break;
fe4da5cc 323 }
fff02fee 324 AliGenMC::Init();
fe4da5cc 325}
326
327void AliGenPythia::Generate()
328{
5ddeb374 329// Generate one event
00d6ce7d 330 fDecayer->ForceDecay();
a0b2b296 331
9be6226f 332 Float_t polar[3] = {0,0,0};
333 Float_t origin[3] = {0,0,0};
fff02fee 334 Float_t p[3];
5be1fe76 335// converts from mm/c to s
336 const Float_t kconv=0.001/2.999792458e8;
fe4da5cc 337//
fe4da5cc 338 Int_t nt=0;
339 Int_t jev=0;
7921755b 340 Int_t j, kf;
fe4da5cc 341 fTrials=0;
fff02fee 342
fd8fb861 343 // Set collision vertex position
aee8290b 344 if(fVertexSmear==kPerEvent) {
1512e357 345 fPythia->SetMSTP(151,1);
fe4da5cc 346 for (j=0;j<3;j++) {
fff02fee 347 fPythia->SetPARP(151+j, fOsigma[j]*10.);
fe4da5cc 348 }
aee8290b 349 } else if (fVertexSmear==kPerTrack) {
fe4da5cc 350 fPythia->SetMSTP(151,0);
fe4da5cc 351 }
fff02fee 352// event loop
fe4da5cc 353 while(1)
354 {
084c1b4a 355 fPythia->Pyevnt();
11dfaf8d 356 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
357 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1);
fe4da5cc 358 fTrials++;
47fc6bd5 359
fff02fee 360 fPythia->ImportParticles(fParticles,"All");
361
362//
363//
364//
365 Int_t i;
366
367 Int_t np = fParticles->GetEntriesFast();
a0b2b296 368 if (np == 0 ) continue;
369// Get event vertex and discard the event if the Z coord. is too big
4c07486d 370 TParticle *iparticle = (TParticle *) fParticles->At(0);
371 Float_t distz = iparticle->Vz()/10.;
372 if(TMath::Abs(distz)>fCutVertexZ*fOsigma[2]) continue;
a0b2b296 373//
4c07486d 374 fEventVertex[0] = iparticle->Vx()/10.+fOrigin.At(0);
375 fEventVertex[1] = iparticle->Vy()/10.+fOrigin.At(1);
376 fEventVertex[2] = iparticle->Vz()/10.+fOrigin.At(2);
a0b2b296 377//
fff02fee 378 Int_t* pParent = new Int_t[np];
379 Int_t* pSelected = new Int_t[np];
380 Int_t* trackIt = new Int_t[np];
b9817493 381 for (i=0; i< np; i++) {
fff02fee 382 pParent[i] = -1;
383 pSelected[i] = 0;
719b6b8a 384 trackIt[i] = 0;
fff02fee 385 }
719b6b8a 386 // printf("\n **************************************************%d\n",np);
387 Int_t nc = 0; // Total n. of selected particles
388 Int_t nParents = 0; // Selected parents
389 Int_t nTkbles = 0; // Trackable particles
f1a48a38 390 if (fProcess != kPyMb && fProcess != kPyJets && fProcess != kPyDirectGamma) {
fd8fb861 391
b9817493 392 for (i = 0; i<np; i++) {
c5d36e84 393 iparticle = (TParticle *) fParticles->At(i);
23211d3e 394 Int_t ks = iparticle->GetStatusCode();
a8228d85 395 kf = CheckPDGCode(iparticle->GetPdgCode());
fff02fee 396// No initial state partons
2a0e6f5b 397 if (ks==21) continue;
fe4da5cc 398//
fff02fee 399// Heavy Flavor Selection
5be1fe76 400//
fff02fee 401 // quark ?
402 kf = TMath::Abs(kf);
403 Int_t kfl = kf;
404 // meson ?
405 if (kfl > 10) kfl/=100;
406 // baryon
407 if (kfl > 10) kfl/=10;
408 if (kfl > 10) kfl/=10;
409
410 Int_t ipa = iparticle->GetFirstMother()-1;
411 Int_t kfMo = 0;
412
413 if (ipa > -1) {
414 TParticle * mother = (TParticle *) fParticles->At(ipa);
415 kfMo = TMath::Abs(mother->GetPdgCode());
416 }
417// printf("\n particle (all) %d %d %d", i, pSelected[i], kf);
719b6b8a 418 // What to keep in Stack?
419 Bool_t flavorOK = kFALSE;
420 Bool_t selectOK = kFALSE;
421 if (fFeedDownOpt) {
422 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
423 } else {
424 if (kfl > fFlavorSelect) {
425 nc = -1;
426 break;
427 }
428 if (kfl == fFlavorSelect) flavorOK = kTRUE;
429 }
430 switch (fStackFillOpt) {
431 case kFlavorSelection:
432 selectOK = kTRUE;
433 break;
434 case kParentSelection:
435 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
436 break;
437 }
438 if (flavorOK && selectOK) {
5be1fe76 439//
fff02fee 440// Heavy flavor hadron or quark
fe4da5cc 441//
fff02fee 442// Kinematic seletion on final state heavy flavor mesons
443 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
444 {
719b6b8a 445 continue;
fff02fee 446 }
447 pSelected[i] = 1;
719b6b8a 448 if (ParentSelected(kf)) ++nParents; // Update parent count
fff02fee 449// printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
450 } else {
451// Kinematic seletion on decay products
452 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
453 && !KinematicSelection(iparticle, 1))
454 {
719b6b8a 455 continue;
fff02fee 456 }
fe4da5cc 457//
fff02fee 458// Decay products
459// Select if mother was selected and is not tracked
460
461 if (pSelected[ipa] &&
462 !trackIt[ipa] && // mother will be tracked ?
463 kfMo != 5 && // mother is b-quark, don't store fragments
464 kfMo != 4 && // mother is c-quark, don't store fragments
465 kf != 92) // don't store string
466 {
fe4da5cc 467//
fff02fee 468// Semi-stable or de-selected: diselect decay products:
fe4da5cc 469//
5be1fe76 470//
47fc6bd5 471 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
fff02fee 472 {
473 Int_t ipF = iparticle->GetFirstDaughter();
474 Int_t ipL = iparticle->GetLastDaughter();
475 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
476 }
477// printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
478 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
479 }
480 }
481 if (pSelected[i] == -1) pSelected[i] = 0;
482 if (!pSelected[i]) continue;
719b6b8a 483 // Count quarks only if you did not include fragmentation
484 if (fFragmentation && kf <= 10) continue;
fff02fee 485 nc++;
486// Decision on tracking
487 trackIt[i] = 0;
488//
489// Track final state particle
490 if (ks == 1) trackIt[i] = 1;
491// Track semi-stable particles
8cdfd303 492 if ((ks ==1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
fff02fee 493// Track particles selected by process if undecayed.
494 if (fForceDecay == kNoDecay) {
495 if (ParentSelected(kf)) trackIt[i] = 1;
496 } else {
497 if (ParentSelected(kf)) trackIt[i] = 0;
498 }
719b6b8a 499 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
fff02fee 500//
501//
502
503 } // particle selection loop
719b6b8a 504 if (nc > 0) {
b9817493 505 for (i = 0; i<np; i++) {
fff02fee 506 if (!pSelected[i]) continue;
507 TParticle * iparticle = (TParticle *) fParticles->At(i);
508 kf = CheckPDGCode(iparticle->GetPdgCode());
5ec84200 509 Int_t ks = iparticle->GetStatusCode();
a0b2b296 510 p[0] = iparticle->Px();
511 p[1] = iparticle->Py();
512 p[2] = iparticle->Pz();
513 origin[0] = fOrigin[0]+iparticle->Vx()/10.;
514 origin[1] = fOrigin[1]+iparticle->Vy()/10.;
515 origin[2] = fOrigin[2]+iparticle->Vz()/10.;
516 Float_t tof = kconv*iparticle->T();
517 Int_t ipa = iparticle->GetFirstMother()-1;
fff02fee 518 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
a99cf51f 519 SetTrack(fTrackIt*trackIt[i] ,
5ec84200 520 iparent, kf, p, origin, polar, tof, kPPrimary, nt, 1., ks);
fff02fee 521 pParent[i] = nt;
a99cf51f 522 KeepTrack(nt);
fff02fee 523 } // SetTrack loop
524 }
525 } else {
526 nc = GenerateMB();
5be1fe76 527 } // mb ?
fff02fee 528
b9817493 529 if (pParent) delete[] pParent;
530 if (pSelected) delete[] pSelected;
531 if (trackIt) delete[] trackIt;
532
fe4da5cc 533 if (nc > 0) {
719b6b8a 534 switch (fCountMode) {
535 case kCountAll:
536 // printf(" Count all \n");
537 jev += nc;
538 break;
539 case kCountParents:
540 // printf(" Count parents \n");
541 jev += nParents;
542 break;
543 case kCountTrackables:
544 // printf(" Count trackable \n");
545 jev += nTkbles;
546 break;
547 }
5ddeb374 548 if (jev >= fNpart || fNpart == -1) {
fe4da5cc 549 fKineBias=Float_t(fNpart)/Float_t(fTrials);
23211d3e 550 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
fd8fb861 551 MakeHeader();
fe4da5cc 552 break;
553 }
554 }
555 } // event loop
a99cf51f 556 SetHighWaterMark(nt);
fe4da5cc 557// adjust weight due to kinematic selection
558 AdjustWeights();
559// get cross-section
560 fXsection=fPythia->GetPARI(1);
561}
562
fff02fee 563Int_t AliGenPythia::GenerateMB()
fe4da5cc 564{
5ec84200 565//
566// Min Bias selection and other global selections
567//
fff02fee 568 Int_t i, kf, nt, iparent;
569 Int_t nc = 0;
570 Float_t p[3];
571 Float_t polar[3] = {0,0,0};
572 Float_t origin[3] = {0,0,0};
fff02fee 573// converts from mm/c to s
574 const Float_t kconv=0.001/2.999792458e8;
4451ef92 575
fff02fee 576 Int_t np = fParticles->GetEntriesFast();
577 Int_t* pParent = new Int_t[np];
b9817493 578 for (i=0; i< np; i++) pParent[i] = -1;
b2bb450d 579 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
988b118b 580 TParticle* jet1 = (TParticle *) fParticles->At(6);
581 TParticle* jet2 = (TParticle *) fParticles->At(7);
582 if (!CheckTrigger(jet1, jet2)) return 0;
583 }
584
b9817493 585 for (i = 0; i<np; i++) {
fff02fee 586 Int_t trackIt = 0;
587 TParticle * iparticle = (TParticle *) fParticles->At(i);
588 kf = CheckPDGCode(iparticle->GetPdgCode());
589 Int_t ks = iparticle->GetStatusCode();
590 Int_t km = iparticle->GetFirstMother();
591// printf("\n Particle: %d %d %d", i, kf, ks);
592
593 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
594 (ks != 1) ||
595 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
596 nc++;
597 if (ks == 1) trackIt = 1;
598 Int_t ipa = iparticle->GetFirstMother()-1;
fe4da5cc 599
fff02fee 600 iparent = (ipa > -1) ? pParent[ipa] : -1;
fe4da5cc 601
602//
fff02fee 603// store track information
a0b2b296 604 p[0] = iparticle->Px();
605 p[1] = iparticle->Py();
606 p[2] = iparticle->Pz();
607 origin[0] = fOrigin[0]+iparticle->Vx()/10.;
608 origin[1] = fOrigin[1]+iparticle->Vy()/10.;
609 origin[2] = fOrigin[2]+iparticle->Vz()/10.;
fff02fee 610 Float_t tof=kconv*iparticle->T();
a99cf51f 611 SetTrack(fTrackIt*trackIt, iparent, kf, p, origin, polar,
5ec84200 612 tof, kPPrimary, nt, 1., ks);
a99cf51f 613 KeepTrack(nt);
fff02fee 614 pParent[i] = nt;
615 } // select particle
616 } // particle loop
617
618 if (pParent) delete[] pParent;
fe4da5cc 619
fff02fee 620 printf("\n I've put %i particles on the stack \n",nc);
fff02fee 621 return nc;
622}
fe4da5cc 623
fe4da5cc 624
fff02fee 625void AliGenPythia::FinishRun()
626{
627// Print x-section summary
628 fPythia->Pystat(1);
fe4da5cc 629}
fff02fee 630
fe4da5cc 631void AliGenPythia::AdjustWeights()
632{
5ddeb374 633// Adjust the weights after generation of all events
634//
5ddeb374 635 TParticle *part;
fe4da5cc 636 Int_t ntrack=gAlice->GetNtrack();
637 for (Int_t i=0; i<ntrack; i++) {
2ab0c725 638 part= gAlice->Particle(i);
5ddeb374 639 part->SetWeight(part->GetWeight()*fKineBias);
fe4da5cc 640 }
641}
811826d8 642
643void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
644{
645// Treat protons as inside nuclei with mass numbers a1 and a2
646 fNucA1 = a1;
647 fNucA2 = a2;
648}
fff02fee 649
650
6d4dd317 651void AliGenPythia::MakeHeader() const
fff02fee 652{
653// Builds the event header, to be called after each event
654 AliGenEventHeader* header = new AliGenPythiaEventHeader("Pythia");
c5d36e84 655 ((AliGenPythiaEventHeader*) header)->SetProcessType(fPythia->GetMSTI(1));
fd8fb861 656 ((AliGenPythiaEventHeader*) header)->SetTrials(fTrials);
c5d36e84 657 header->SetPrimaryVertex(fEventVertex);
658 gAlice->SetGenEventHeader(header);
fff02fee 659}
811826d8 660
988b118b 661
5ec84200 662Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2) const
988b118b 663{
664// Check the kinematic trigger condition
665//
b2bb450d 666 Double_t eta[2];
667 eta[0] = jet1->Eta();
668 eta[1] = jet2->Eta();
669 Double_t phi[2];
670 phi[0] = jet1->Phi();
671 phi[1] = jet2->Phi();
672 Int_t pdg[2];
673 pdg[0] = jet1->GetPdgCode();
674 pdg[1] = jet2->GetPdgCode();
988b118b 675 Bool_t triggered = kFALSE;
b2bb450d 676
677 if (fProcess == kPyJets) {
678 //Check eta range first...
679 if ((eta[0] < fEtaMaxJet && eta[0] > fEtaMinJet) ||
680 (eta[1] < fEtaMaxJet && eta[1] > fEtaMinJet))
681 {
682 //Eta is okay, now check phi range
683 if ((phi[0] < fPhiMaxJet && phi[0] > fPhiMinJet) ||
684 (phi[1] < fPhiMaxJet && phi[1] > fPhiMinJet))
685 {
686 triggered = kTRUE;
687 }
688 }
689 } else {
690 Int_t ij = 0;
691 Int_t ig = 1;
692 if (pdg[0] == kGamma) {
693 ij = 1;
694 ig = 0;
695 }
696 //Check eta range first...
697 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
698 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
699 {
700 //Eta is okay, now check phi range
701 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
702 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
703 {
704 triggered = kTRUE;
705 }
706 }
988b118b 707 }
b2bb450d 708
709
988b118b 710 return triggered;
711}
811826d8 712
f87cfe57 713AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
714{
715// Assignment operator
716 return *this;
717}
fe4da5cc 718
719
811826d8 720
a8a6107b 721#ifdef never
18edb254 722void AliGenPythia::Streamer(TBuffer &R__b)
723{
724 // Stream an object of class AliGenPythia.
725
726 if (R__b.IsReading()) {
727 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
728 AliGenerator::Streamer(R__b);
729 R__b >> (Int_t&)fProcess;
730 R__b >> (Int_t&)fStrucFunc;
731 R__b >> (Int_t&)fForceDecay;
732 R__b >> fEnergyCMS;
733 R__b >> fKineBias;
734 R__b >> fTrials;
735 fParentSelect.Streamer(R__b);
736 fChildSelect.Streamer(R__b);
737 R__b >> fXsection;
738// (AliPythia::Instance())->Streamer(R__b);
739 R__b >> fPtHardMin;
740 R__b >> fPtHardMax;
741// if (fDecayer) fDecayer->Streamer(R__b);
742 } else {
743 R__b.WriteVersion(AliGenPythia::IsA());
744 AliGenerator::Streamer(R__b);
745 R__b << (Int_t)fProcess;
746 R__b << (Int_t)fStrucFunc;
747 R__b << (Int_t)fForceDecay;
748 R__b << fEnergyCMS;
749 R__b << fKineBias;
750 R__b << fTrials;
751 fParentSelect.Streamer(R__b);
752 fChildSelect.Streamer(R__b);
753 R__b << fXsection;
754// R__b << fPythia;
755 R__b << fPtHardMin;
756 R__b << fPtHardMax;
757 // fDecayer->Streamer(R__b);
758 }
759}
a8a6107b 760#endif
18edb254 761