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