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