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