1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.3 2003/03/31 15:47:16 morsch
19 Unhandled cases added.
21 Revision 1.2 2003/03/27 09:28:38 morsch
22 Charm production process configuration for pPb and pp added
23 (A. Dainese, N. Carrer)
25 Revision 1.1 2003/03/15 15:00:48 morsch
26 Classed imported from EVGEN.
28 Revision 1.69 2003/01/14 10:50:19 alibrary
29 Cleanup of STEER coding conventions
31 Revision 1.68 2002/12/11 09:16:16 morsch
32 Use GetJets to fill header.
34 Revision 1.67 2002/12/09 15:24:09 morsch
35 Same trigger routine can use Pycell or Pyclus.
37 Revision 1.66 2002/12/09 08:22:56 morsch
38 UA1 jet finder (Pycell) for software triggering added.
40 Revision 1.65 2002/11/19 08:57:10 morsch
41 Configuration of pt-kick added.
43 Revision 1.64 2002/11/15 00:43:06 morsch
45 - initial and final state g-radiation + pt-kick default
46 - trigger based on parton clusters (using pyclus)
47 - trigger jets are stored in header.
49 Revision 1.63 2002/10/14 14:55:35 hristov
50 Merging the VirtualMC branch to the main development branch (HEAD)
52 Revision 1.52.4.4 2002/10/10 16:40:08 hristov
53 Updating VirtualMC to v3-09-02
55 Revision 1.62 2002/09/24 10:00:01 morsch
56 CheckTrigger() corrected.
58 Revision 1.61 2002/07/30 09:52:38 morsch
59 Call SetGammaPhiRange() and SetGammaEtaRange() in the constructor.
61 Revision 1.60 2002/07/19 14:49:03 morsch
64 Revision 1.59 2002/07/19 14:35:36 morsch
65 Count total number of trials. Print mean Q, x1, x2.
67 Revision 1.58 2002/07/17 10:04:09 morsch
68 SetYHard method added.
70 Revision 1.57 2002/05/22 13:22:53 morsch
71 Process kPyMbNonDiffr added.
73 Revision 1.56 2002/04/26 10:30:01 morsch
74 Option kPyBeautyPbMNR added. (N. Carrer).
76 Revision 1.55 2002/04/17 10:23:56 morsch
77 Coding Rule violations corrected.
79 Revision 1.54 2002/03/28 11:49:10 morsch
80 Pass status code in SetTrack.
82 Revision 1.53 2002/03/25 14:51:13 morsch
83 New stack-fill and count options introduced (N. Carrer).
85 Revision 1.51 2002/03/06 08:46:57 morsch
87 - delete dyn. alloc. arrays (N. Carrer)
89 Revision 1.50 2002/03/03 13:48:50 morsch
90 Option kPyCharmPbMNR added. Produce charm pairs in agreement with MNR
91 NLO calculations (Nicola Carrer).
93 Revision 1.49 2002/02/08 16:50:50 morsch
94 Add name and title in constructor.
96 Revision 1.48 2001/12/20 11:44:28 morsch
97 Add kinematic bias for direct gamma production.
99 Revision 1.47 2001/12/19 14:45:00 morsch
100 Store number of trials in header.
102 Revision 1.46 2001/12/19 10:36:19 morsch
103 Add possibility if jet kinematic biasing.
105 Revision 1.45 2001/11/28 08:06:52 morsch
106 Use fMaxLifeTime parameter.
108 Revision 1.44 2001/11/27 13:13:07 morsch
109 Maximum lifetime for long-lived particles to be put on the stack is parameter.
110 It can be set via SetMaximumLifetime(..).
112 Revision 1.43 2001/10/21 18:35:56 hristov
113 Several pointers were set to zero in the default constructors to avoid memory management problems
115 Revision 1.42 2001/10/15 08:21:55 morsch
116 Vertex truncation settings moved to AliGenMC.
118 Revision 1.41 2001/10/08 08:45:42 morsch
119 Possibility of vertex cut added.
121 Revision 1.40 2001/09/25 11:30:23 morsch
122 Pass event vertex to header.
124 Revision 1.39 2001/07/27 17:09:36 morsch
125 Use local SetTrack, KeepTrack and SetHighWaterMark methods
126 to delegate either to local stack or to stack owned by AliRun.
127 (Piotr Skowronski, A.M.)
129 Revision 1.38 2001/07/13 10:58:54 morsch
130 - Some coded moved to AliGenMC
131 - Improved handling of secondary vertices.
133 Revision 1.37 2001/06/28 11:17:28 morsch
134 SetEventListRange setter added. Events in specified range are listed for
135 debugging. (Yuri Kharlov)
137 Revision 1.36 2001/03/30 07:05:49 morsch
138 Final print-out in finish run.
139 Write parton system for jet-production (preliminary solution).
141 Revision 1.35 2001/03/09 13:03:40 morsch
142 Process_t and Struc_Func_t moved to AliPythia.h
144 Revision 1.34 2001/02/14 15:50:40 hristov
145 The last particle in event marked using SetHighWaterMark
147 Revision 1.33 2001/01/30 09:23:12 hristov
148 Streamers removed (R.Brun)
150 Revision 1.32 2001/01/26 19:55:51 hristov
151 Major upgrade of AliRoot code
153 Revision 1.31 2001/01/17 10:54:31 hristov
154 Better protection against FPE
156 Revision 1.30 2000/12/18 08:55:35 morsch
157 Make AliPythia dependent generartors work with new scheme of random number generation
159 Revision 1.29 2000/12/04 11:22:03 morsch
160 Init of sRandom as in 1.15
162 Revision 1.28 2000/12/02 11:41:39 morsch
163 Use SetRandom() to initialize random number generator in constructor.
165 Revision 1.27 2000/11/30 20:29:02 morsch
166 Initialise static variable sRandom in constructor: sRandom = fRandom;
168 Revision 1.26 2000/11/30 07:12:50 alibrary
169 Introducing new Rndm and QA classes
171 Revision 1.25 2000/10/18 19:11:27 hristov
172 Division by zero fixed
174 Revision 1.24 2000/09/18 10:41:35 morsch
175 Add possibility to use nuclear structure functions from PDF library V8.
177 Revision 1.23 2000/09/14 14:05:40 morsch
180 Revision 1.22 2000/09/14 14:02:22 morsch
181 - Correct conversion from mm to cm when passing particle vertex to MC.
182 - Correct handling of fForceDecay == all.
184 Revision 1.21 2000/09/12 14:14:55 morsch
185 Call fDecayer->ForceDecay() at the beginning of Generate().
187 Revision 1.20 2000/09/06 14:29:33 morsch
188 Use AliPythia for event generation an AliDecayPythia for decays.
189 Correct handling of "nodecay" option
191 Revision 1.19 2000/07/11 18:24:56 fca
192 Coding convention corrections + few minor bug fixes
194 Revision 1.18 2000/06/30 12:40:34 morsch
195 Pythia takes care of vertex smearing. Correct conversion from Pythia units (mm) to
198 Revision 1.17 2000/06/09 20:34:07 morsch
199 All coding rule violations except RS3 corrected
201 Revision 1.16 2000/05/15 15:04:20 morsch
202 The full event is written for fNtrack = -1
203 Coding rule violations corrected.
205 Revision 1.15 2000/04/26 10:14:24 morsch
206 Particles array has one entry more than pythia particle list. Upper bound of
207 particle loop changed to np-1 (R. Guernane, AM)
209 Revision 1.14 2000/04/05 08:36:13 morsch
210 Check status code of particles in Pythia event
211 to avoid double counting as partonic state and final state particle.
213 Revision 1.13 1999/11/09 07:38:48 fca
214 Changes for compatibility with version 2.23 of ROOT
216 Revision 1.12 1999/11/03 17:43:20 fca
217 New version from G.Martinez & A.Morsch
219 Revision 1.11 1999/09/29 09:24:14 fca
220 Introduction of the Copyright and cvs Log
224 // Generator using the TPythia interface (via AliPythia)
225 // to generate pp collisions.
226 // Using SetNuclei() also nuclear modifications to the structure functions
227 // can be taken into account. This makes, of course, only sense for the
228 // generation of the products of hard processes (heavy flavor, jets ...)
230 // andreas.morsch@cern.ch
233 #include <TDatabasePDG.h>
234 #include <TParticle.h>
235 #include <TPDGCode.h>
239 #include "AliConst.h"
240 #include "AliDecayerPythia.h"
241 #include "AliGenPythia.h"
242 #include "AliGenPythiaEventHeader.h"
243 #include "AliPythia.h"
246 ClassImp(AliGenPythia)
248 AliGenPythia::AliGenPythia()
251 // Default Constructor
254 fDecayer = new AliDecayerPythia();
264 AliGenPythia::AliGenPythia(Int_t npart)
267 // default charm production at 5. 5 TeV
269 // structure function GRVHO
272 fTitle= "Particle Generator using PYTHIA";
282 fDecayer = new AliDecayerPythia();
283 // Set random number generator
286 // Produced particles
287 fParticles = new TClonesArray("TParticle",1000);
295 SetJetReconstructionMode();
297 // Options determining what to keep in the stack (Heavy flavour generation)
298 fStackFillOpt = kFlavorSelection; // Keep particle with selected flavor
299 fFeedDownOpt = kTRUE; // allow feed down from higher family
300 // Fragmentation on/off
301 fFragmentation = kTRUE;
302 // Default counting mode
303 fCountMode = kCountAll;
305 SetPycellParameters();
308 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
314 AliGenPythia::~AliGenPythia()
319 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
320 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
322 // Set pycell parameters
323 fPycellEtaMax = etamax;
326 fPycellThreshold = thresh;
327 fPycellEtSeed = etseed;
328 fPycellMinEtJet = minet;
329 fPycellMaxRadius = r;
334 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
336 // Set a range of event numbers, for which a table
337 // of generated particle will be printed
338 fDebugEventFirst = eventFirst;
339 fDebugEventLast = eventLast;
340 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
343 void AliGenPythia::Init()
347 SetMC(AliPythia::Instance());
348 fPythia=(AliPythia*) fgMCEvGen;
350 fParentWeight=1./Float_t(fNpart);
352 // Forward Paramters to the AliPythia object
353 fDecayer->SetForceDecay(fForceDecay);
357 fPythia->SetCKIN(3,fPtHardMin);
358 fPythia->SetCKIN(4,fPtHardMax);
359 fPythia->SetCKIN(7,fYHardMin);
360 fPythia->SetCKIN(8,fYHardMax);
362 if (fNucA1 > 0 && fNucA2 > 0) fPythia->SetNuclei(fNucA1, fNucA2);
364 if (fFragmentation) {
365 fPythia->SetMSTP(111,1);
367 fPythia->SetMSTP(111,0);
371 // initial state radiation
372 fPythia->SetMSTP(61,fGinit);
373 // final state radiation
374 fPythia->SetMSTP(71,fGfinal);
377 fPythia->SetMSTP(91,1);
378 fPythia->SetPARP(91,fPtKick);
380 fPythia->SetMSTP(91,0);
383 // fPythia->SetMSTJ(1,2);
385 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
387 // Parent and Children Selection
391 case kPyCharmUnforced:
392 case kPyCharmPbPbMNR:
395 fParentSelect[0] = 411;
396 fParentSelect[1] = 421;
397 fParentSelect[2] = 431;
398 fParentSelect[3] = 4122;
404 fParentSelect[0] = 421;
408 case kPyBeautyPbPbMNR:
409 case kPyBeautypPbMNR:
411 fParentSelect[0]= 511;
412 fParentSelect[1]= 521;
413 fParentSelect[2]= 531;
414 fParentSelect[3]= 5122;
415 fParentSelect[4]= 5132;
416 fParentSelect[5]= 5232;
417 fParentSelect[6]= 5332;
420 case kPyBeautyUnforced:
421 fParentSelect[0] = 511;
422 fParentSelect[1] = 521;
423 fParentSelect[2] = 531;
424 fParentSelect[3] = 5122;
425 fParentSelect[4] = 5132;
426 fParentSelect[5] = 5232;
427 fParentSelect[6] = 5332;
432 fParentSelect[0] = 443;
442 // JetFinder for Trigger
444 // Configure detector (EMCAL like)
446 fPythia->SetPARU(51, fPycellEtaMax);
447 fPythia->SetMSTU(51, fPycellNEta);
448 fPythia->SetMSTU(52, fPycellNPhi);
450 // Configure Jet Finder
452 fPythia->SetPARU(58, fPycellThreshold);
453 fPythia->SetPARU(52, fPycellEtSeed);
454 fPythia->SetPARU(53, fPycellMinEtJet);
455 fPythia->SetPARU(54, fPycellMaxRadius);
456 fPythia->SetMSTU(54, 2);
458 // This counts the total number of calls to Pyevnt() per run.
468 void AliGenPythia::Generate()
470 // Generate one event
471 fDecayer->ForceDecay();
473 Float_t polar[3] = {0,0,0};
474 Float_t origin[3] = {0,0,0};
476 // converts from mm/c to s
477 const Float_t kconv=0.001/2.999792458e8;
484 // Set collision vertex position
485 if(fVertexSmear==kPerEvent) {
486 fPythia->SetMSTP(151,1);
488 fPythia->SetPARP(151+j, fOsigma[j]*10.);
490 } else if (fVertexSmear==kPerTrack) {
491 fPythia->SetMSTP(151,0);
497 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
498 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1);
501 fPythia->ImportParticles(fParticles,"All");
508 Int_t np = fParticles->GetEntriesFast();
509 if (np == 0 ) continue;
510 // Get event vertex and discard the event if the Z coord. is too big
511 TParticle *iparticle = (TParticle *) fParticles->At(0);
512 Float_t distz = iparticle->Vz()/10.;
513 if(TMath::Abs(distz)>fCutVertexZ*fOsigma[2]) continue;
515 fEventVertex[0] = iparticle->Vx()/10.+fOrigin.At(0);
516 fEventVertex[1] = iparticle->Vy()/10.+fOrigin.At(1);
517 fEventVertex[2] = iparticle->Vz()/10.+fOrigin.At(2);
519 Int_t* pParent = new Int_t[np];
520 Int_t* pSelected = new Int_t[np];
521 Int_t* trackIt = new Int_t[np];
522 for (i=0; i< np; i++) {
528 Int_t nc = 0; // Total n. of selected particles
529 Int_t nParents = 0; // Selected parents
530 Int_t nTkbles = 0; // Trackable particles
531 if (fProcess != kPyMb && fProcess != kPyJets &&
532 fProcess != kPyDirectGamma &&
533 fProcess != kPyMbNonDiffr) {
535 for (i = 0; i<np; i++) {
536 iparticle = (TParticle *) fParticles->At(i);
537 Int_t ks = iparticle->GetStatusCode();
538 kf = CheckPDGCode(iparticle->GetPdgCode());
539 // No initial state partons
540 if (ks==21) continue;
542 // Heavy Flavor Selection
548 if (kfl > 10) kfl/=100;
550 if (kfl > 10) kfl/=10;
551 if (kfl > 10) kfl/=10;
553 Int_t ipa = iparticle->GetFirstMother()-1;
557 TParticle * mother = (TParticle *) fParticles->At(ipa);
558 kfMo = TMath::Abs(mother->GetPdgCode());
560 // What to keep in Stack?
561 Bool_t flavorOK = kFALSE;
562 Bool_t selectOK = kFALSE;
564 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
566 if (kfl > fFlavorSelect) {
570 if (kfl == fFlavorSelect) flavorOK = kTRUE;
572 switch (fStackFillOpt) {
573 case kFlavorSelection:
576 case kParentSelection:
577 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
580 if (flavorOK && selectOK) {
582 // Heavy flavor hadron or quark
584 // Kinematic seletion on final state heavy flavor mesons
585 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
590 if (ParentSelected(kf)) ++nParents; // Update parent count
591 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
593 // Kinematic seletion on decay products
594 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
595 && !KinematicSelection(iparticle, 1))
601 // Select if mother was selected and is not tracked
603 if (pSelected[ipa] &&
604 !trackIt[ipa] && // mother will be tracked ?
605 kfMo != 5 && // mother is b-quark, don't store fragments
606 kfMo != 4 && // mother is c-quark, don't store fragments
607 kf != 92) // don't store string
610 // Semi-stable or de-selected: diselect decay products:
613 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
615 Int_t ipF = iparticle->GetFirstDaughter();
616 Int_t ipL = iparticle->GetLastDaughter();
617 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
619 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
620 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
623 if (pSelected[i] == -1) pSelected[i] = 0;
624 if (!pSelected[i]) continue;
625 // Count quarks only if you did not include fragmentation
626 if (fFragmentation && kf <= 10) continue;
628 // Decision on tracking
631 // Track final state particle
632 if (ks == 1) trackIt[i] = 1;
633 // Track semi-stable particles
634 if ((ks ==1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
635 // Track particles selected by process if undecayed.
636 if (fForceDecay == kNoDecay) {
637 if (ParentSelected(kf)) trackIt[i] = 1;
639 if (ParentSelected(kf)) trackIt[i] = 0;
641 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
645 } // particle selection loop
647 for (i = 0; i<np; i++) {
648 if (!pSelected[i]) continue;
649 TParticle * iparticle = (TParticle *) fParticles->At(i);
650 kf = CheckPDGCode(iparticle->GetPdgCode());
651 Int_t ks = iparticle->GetStatusCode();
652 p[0] = iparticle->Px();
653 p[1] = iparticle->Py();
654 p[2] = iparticle->Pz();
655 origin[0] = fOrigin[0]+iparticle->Vx()/10.;
656 origin[1] = fOrigin[1]+iparticle->Vy()/10.;
657 origin[2] = fOrigin[2]+iparticle->Vz()/10.;
658 Float_t tof = kconv*iparticle->T();
659 Int_t ipa = iparticle->GetFirstMother()-1;
660 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
661 SetTrack(fTrackIt*trackIt[i] ,
662 iparent, kf, p, origin, polar, tof, kPPrimary, nt, 1., ks);
671 if (pParent) delete[] pParent;
672 if (pSelected) delete[] pSelected;
673 if (trackIt) delete[] trackIt;
676 switch (fCountMode) {
678 // printf(" Count all \n");
682 // printf(" Count parents \n");
685 case kCountTrackables:
686 // printf(" Count trackable \n");
690 if (jev >= fNpart || fNpart == -1) {
691 fKineBias=Float_t(fNpart)/Float_t(fTrials);
692 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
694 fQ += fPythia->GetVINT(51);
695 fX1 += fPythia->GetVINT(41);
696 fX2 += fPythia->GetVINT(42);
697 fTrialsRun += fTrials;
704 SetHighWaterMark(nt);
705 // adjust weight due to kinematic selection
708 fXsection=fPythia->GetPARI(1);
711 Int_t AliGenPythia::GenerateMB()
714 // Min Bias selection and other global selections
716 Int_t i, kf, nt, iparent;
719 Float_t polar[3] = {0,0,0};
720 Float_t origin[3] = {0,0,0};
721 // converts from mm/c to s
722 const Float_t kconv=0.001/2.999792458e8;
724 Int_t np = fParticles->GetEntriesFast();
725 Int_t* pParent = new Int_t[np];
726 for (i=0; i< np; i++) pParent[i] = -1;
727 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
728 TParticle* jet1 = (TParticle *) fParticles->At(6);
729 TParticle* jet2 = (TParticle *) fParticles->At(7);
730 if (!CheckTrigger(jet1, jet2)) return 0;
733 for (i = 0; i<np; i++) {
735 TParticle * iparticle = (TParticle *) fParticles->At(i);
736 kf = CheckPDGCode(iparticle->GetPdgCode());
737 Int_t ks = iparticle->GetStatusCode();
738 Int_t km = iparticle->GetFirstMother();
739 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
741 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
743 if (ks == 1) trackIt = 1;
744 Int_t ipa = iparticle->GetFirstMother()-1;
746 iparent = (ipa > -1) ? pParent[ipa] : -1;
749 // store track information
750 p[0] = iparticle->Px();
751 p[1] = iparticle->Py();
752 p[2] = iparticle->Pz();
753 origin[0] = fOrigin[0]+iparticle->Vx()/10.;
754 origin[1] = fOrigin[1]+iparticle->Vy()/10.;
755 origin[2] = fOrigin[2]+iparticle->Vz()/10.;
756 Float_t tof=kconv*iparticle->T();
757 SetTrack(fTrackIt*trackIt, iparent, kf, p, origin, polar,
758 tof, kPPrimary, nt, 1., ks);
764 if (pParent) delete[] pParent;
766 printf("\n I've put %i particles on the stack \n",nc);
771 void AliGenPythia::FinishRun()
773 // Print x-section summary
778 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
779 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
784 void AliGenPythia::AdjustWeights()
786 // Adjust the weights after generation of all events
789 Int_t ntrack=gAlice->GetNtrack();
790 for (Int_t i=0; i<ntrack; i++) {
791 part= gAlice->Particle(i);
792 part->SetWeight(part->GetWeight()*fKineBias);
796 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
798 // Treat protons as inside nuclei with mass numbers a1 and a2
804 void AliGenPythia::MakeHeader()
806 // Builds the event header, to be called after each event
807 AliGenEventHeader* header = new AliGenPythiaEventHeader("Pythia");
810 ((AliGenPythiaEventHeader*) header)->SetProcessType(fPythia->GetMSTI(1));
813 ((AliGenPythiaEventHeader*) header)->SetTrials(fTrials);
816 header->SetPrimaryVertex(fEventVertex);
818 // Jets that have triggered
819 if (fProcess == kPyJets)
823 GetJets(njet, ntrig, jets);
825 for (Int_t i = 0; i < ntrig; i++) {
826 ((AliGenPythiaEventHeader*) header)->AddJet(jets[0][i], jets[1][i], jets[2][i],
830 gAlice->SetGenEventHeader(header);
834 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
836 // Check the kinematic trigger condition
839 eta[0] = jet1->Eta();
840 eta[1] = jet2->Eta();
842 phi[0] = jet1->Phi();
843 phi[1] = jet2->Phi();
845 pdg[0] = jet1->GetPdgCode();
846 pdg[1] = jet2->GetPdgCode();
847 Bool_t triggered = kFALSE;
849 if (fProcess == kPyJets) {
854 // Use Pythia clustering on parton level to determine jet axis
856 GetJets(njets, ntrig, jets);
858 if (ntrig) triggered = kTRUE;
863 if (pdg[0] == kGamma) {
867 //Check eta range first...
868 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
869 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
871 //Eta is okay, now check phi range
872 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
873 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
882 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
884 // Assignment operator
888 void AliGenPythia::LoadEvent()
891 // Load event into Pythia Common Block
895 Int_t npart = (Int_t) (gAlice->TreeK())->GetEntries();
896 (fPythia->GetPyjets())->N = npart;
898 for (Int_t part = 0; part < npart; part++) {
899 TParticle *MPart = gAlice->Particle(part);
900 Int_t kf = MPart->GetPdgCode();
901 Int_t ks = MPart->GetStatusCode();
902 Float_t px = MPart->Px();
903 Float_t py = MPart->Py();
904 Float_t pz = MPart->Pz();
905 Float_t e = MPart->Energy();
906 Float_t p = TMath::Sqrt(px * px + py * py + pz * pz);
907 Float_t m = TMath::Sqrt(e * e - p * p);
910 (fPythia->GetPyjets())->P[0][part] = px;
911 (fPythia->GetPyjets())->P[1][part] = py;
912 (fPythia->GetPyjets())->P[2][part] = pz;
913 (fPythia->GetPyjets())->P[3][part] = e;
914 (fPythia->GetPyjets())->P[4][part] = m;
916 (fPythia->GetPyjets())->K[1][part] = kf;
917 (fPythia->GetPyjets())->K[0][part] = ks;
921 void AliGenPythia::RecJetsUA1(Float_t eCellMin, Float_t eCellSeed, Float_t eMin, Float_t rMax,
922 Int_t& njets, Float_t jets [4][50])
925 // Calls the Pythia jet finding algorithm to find jets in the current event
930 Int_t n = fPythia->GetN();
934 fPythia->Pycell(njets);
936 for (i = 0; i < njets; i++) {
937 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
938 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
939 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
940 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
951 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
954 // Calls the Pythia clustering algorithm to find jets in the current event
956 Int_t n = fPythia->GetN();
959 if (fJetReconstruction == kCluster) {
961 // Configure cluster algorithm
963 fPythia->SetPARU(43, 2.);
964 fPythia->SetMSTU(41, 1);
966 // Call cluster algorithm
968 fPythia->Pyclus(nJets);
970 // Loading jets from common block
976 fPythia->Pycell(nJets);
980 for (i = 0; i < nJets; i++) {
981 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
982 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
983 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
984 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
985 Float_t pt = TMath::Sqrt(px * px + py * py);
986 Float_t phi = TMath::ATan2(py,px);
987 Float_t theta = TMath::ATan2(pt,pz);
988 Float_t et = e * TMath::Sin(theta);
989 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
992 eta > fEtaMinJet && eta < fEtaMaxJet &&
993 phi > fPhiMinJet && eta < fPhiMaxJet &&
994 et > fEtMinJet && et < fEtMaxJet
997 jets[0][nJetsTrig] = px;
998 jets[1][nJetsTrig] = py;
999 jets[2][nJetsTrig] = pz;
1000 jets[3][nJetsTrig] = e;
1004 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1011 void AliGenPythia::Streamer(TBuffer &R__b)
1013 // Stream an object of class AliGenPythia.
1015 if (R__b.IsReading()) {
1016 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1017 AliGenerator::Streamer(R__b);
1018 R__b >> (Int_t&)fProcess;
1019 R__b >> (Int_t&)fStrucFunc;
1020 R__b >> (Int_t&)fForceDecay;
1024 fParentSelect.Streamer(R__b);
1025 fChildSelect.Streamer(R__b);
1027 // (AliPythia::Instance())->Streamer(R__b);
1030 // if (fDecayer) fDecayer->Streamer(R__b);
1032 R__b.WriteVersion(AliGenPythia::IsA());
1033 AliGenerator::Streamer(R__b);
1034 R__b << (Int_t)fProcess;
1035 R__b << (Int_t)fStrucFunc;
1036 R__b << (Int_t)fForceDecay;
1040 fParentSelect.Streamer(R__b);
1041 fChildSelect.Streamer(R__b);
1046 // fDecayer->Streamer(R__b);