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 **************************************************************************/
19 // Generator using the TPythia interface (via AliPythia)
20 // to generate pp collisions.
21 // Using SetNuclei() also nuclear modifications to the structure functions
22 // can be taken into account. This makes, of course, only sense for the
23 // generation of the products of hard processes (heavy flavor, jets ...)
25 // andreas.morsch@cern.ch
28 #include <TDatabasePDG.h>
29 #include <TParticle.h>
34 #include "AliDecayerPythia.h"
35 #include "AliGenPythia.h"
36 #include "AliHeader.h"
37 #include "AliGenPythiaEventHeader.h"
38 #include "AliPythia.h"
39 #include "AliPythiaRndm.h"
42 #include "AliRunLoader.h"
44 #include "pyquenCommon.h"
46 ClassImp(AliGenPythia)
48 AliGenPythia::AliGenPythia()
51 // Default Constructor
57 fInteractionRate = 0.;
61 fDecayer = new AliDecayerPythia();
75 if (!AliPythiaRndm::GetPythiaRandom())
76 AliPythiaRndm::SetPythiaRandom(GetRandom());
79 AliGenPythia::AliGenPythia(Int_t npart)
82 // default charm production at 5. 5 TeV
84 // structure function GRVHO
87 fTitle= "Particle Generator using PYTHIA";
91 fInteractionRate = 0.;
101 fDecayer = new AliDecayerPythia();
102 // Set random number generator
103 if (!AliPythiaRndm::GetPythiaRandom())
104 AliPythiaRndm::SetPythiaRandom(GetRandom());
106 // Produced particles
107 fParticles = new TClonesArray("TParticle",1000);
115 SetTriggerParticle();
116 SetJetReconstructionMode();
120 // Options determining what to keep in the stack (Heavy flavour generation)
121 fStackFillOpt = kFlavorSelection; // Keep particle with selected flavor
122 fFeedDownOpt = kTRUE; // allow feed down from higher family
123 // Fragmentation on/off
124 fFragmentation = kTRUE;
125 // Default counting mode
126 fCountMode = kCountAll;
128 SetPycellParameters();
134 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
141 AliGenPythia::~AliGenPythia()
144 if(fEventsTime) delete fEventsTime;
147 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
149 // Generate pileup using user specified rate
150 fInteractionRate = rate;
151 fTimeWindow = timewindow;
155 void AliGenPythia::GeneratePileup()
157 // Generate sub events time for pileup
159 if(fInteractionRate == 0.) {
160 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
164 Int_t npart = NumberParticles();
166 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
170 if(fEventsTime) delete fEventsTime;
171 fEventsTime = new TArrayF(npart);
172 TArrayF &array = *fEventsTime;
173 for(Int_t ipart = 0; ipart < npart; ipart++)
176 Float_t eventtime = 0.;
179 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
180 if(eventtime > fTimeWindow) break;
181 array.Set(array.GetSize()+1);
182 array[array.GetSize()-1] = eventtime;
188 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
189 if(TMath::Abs(eventtime) > fTimeWindow) break;
190 array.Set(array.GetSize()+1);
191 array[array.GetSize()-1] = eventtime;
194 SetNumberParticles(fEventsTime->GetSize());
197 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
198 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
200 // Set pycell parameters
201 fPycellEtaMax = etamax;
204 fPycellThreshold = thresh;
205 fPycellEtSeed = etseed;
206 fPycellMinEtJet = minet;
207 fPycellMaxRadius = r;
212 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
214 // Set a range of event numbers, for which a table
215 // of generated particle will be printed
216 fDebugEventFirst = eventFirst;
217 fDebugEventLast = eventLast;
218 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
221 void AliGenPythia::Init()
225 SetMC(AliPythia::Instance());
226 fPythia=(AliPythia*) fMCEvGen;
229 fParentWeight=1./Float_t(fNpart);
231 // Forward Paramters to the AliPythia object
232 fDecayer->SetForceDecay(fForceDecay);
236 fPythia->SetCKIN(3,fPtHardMin);
237 fPythia->SetCKIN(4,fPtHardMax);
238 fPythia->SetCKIN(7,fYHardMin);
239 fPythia->SetCKIN(8,fYHardMax);
241 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
243 if (fFragmentation) {
244 fPythia->SetMSTP(111,1);
246 fPythia->SetMSTP(111,0);
250 // initial state radiation
251 fPythia->SetMSTP(61,fGinit);
252 // final state radiation
253 fPythia->SetMSTP(71,fGfinal);
256 fPythia->SetMSTP(91,1);
257 fPythia->SetPARP(91,fPtKick);
259 fPythia->SetMSTP(91,0);
264 fRL = AliRunLoader::Open(fFileName, "Partons");
265 fRL->LoadKinematics();
270 // Switch off Heavy Flavors on request
272 fPythia->SetMSTP(58, 3);
273 fPythia->SetMSTJ(45, 3);
274 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
277 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
279 // Parent and Children Selection
282 case kPyOldUEQ2ordered:
283 case kPyOldUEQ2ordered2:
287 case kPyCharmUnforced:
288 case kPyCharmPbPbMNR:
291 fParentSelect[0] = 411;
292 fParentSelect[1] = 421;
293 fParentSelect[2] = 431;
294 fParentSelect[3] = 4122;
300 fParentSelect[0] = 421;
303 case kPyDPlusPbPbMNR:
306 fParentSelect[0] = 411;
310 case kPyBeautyPbPbMNR:
311 case kPyBeautypPbMNR:
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;
322 case kPyBeautyUnforced:
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;
334 fParentSelect[0] = 443;
347 // JetFinder for Trigger
349 // Configure detector (EMCAL like)
351 fPythia->SetPARU(51, fPycellEtaMax);
352 fPythia->SetMSTU(51, fPycellNEta);
353 fPythia->SetMSTU(52, fPycellNPhi);
355 // Configure Jet Finder
357 fPythia->SetPARU(58, fPycellThreshold);
358 fPythia->SetPARU(52, fPycellEtSeed);
359 fPythia->SetPARU(53, fPycellMinEtJet);
360 fPythia->SetPARU(54, fPycellMaxRadius);
361 fPythia->SetMSTU(54, 2);
363 // This counts the total number of calls to Pyevnt() per run.
378 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
382 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
387 void AliGenPythia::Generate()
389 // Generate one event
391 fDecayer->ForceDecay();
393 Float_t polar[3] = {0,0,0};
394 Float_t origin[3] = {0,0,0};
396 // converts from mm/c to s
397 const Float_t kconv=0.001/2.999792458e8;
407 // Set collision vertex position
408 if (fVertexSmear == kPerEvent) Vertex();
417 // Switch hadronisation off
419 fPythia->SetMSTJ(1, 0);
421 // Either produce new event or read partons from file
423 if (!fReadFromFile) {
429 fNpartons = fPythia->GetN();
431 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
432 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
434 LoadEvent(fRL->Stack(), 0 , 1);
439 // Run quenching routine
443 } else if (fQuench == 2){
444 fPythia->Pyquen(208., 0, 0.);
447 // Switch hadronisation on
449 fPythia->SetMSTJ(1, 1);
451 // .. and perform hadronisation
452 // printf("Calling hadronisation %d\n", fPythia->GetN());
455 fPythia->ImportParticles(fParticles,"All");
463 Int_t np = fParticles->GetEntriesFast();
465 if (np == 0) continue;
469 Int_t* pParent = new Int_t[np];
470 Int_t* pSelected = new Int_t[np];
471 Int_t* trackIt = new Int_t[np];
472 for (i = 0; i < np; i++) {
478 Int_t nc = 0; // Total n. of selected particles
479 Int_t nParents = 0; // Selected parents
480 Int_t nTkbles = 0; // Trackable particles
481 if (fProcess != kPyMb && fProcess != kPyJets &&
482 fProcess != kPyDirectGamma &&
483 fProcess != kPyMbNonDiffr &&
484 fProcess != kPyW && fProcess != kPyZ ) {
486 for (i = 0; i < np; i++) {
487 TParticle* iparticle = (TParticle *) fParticles->At(i);
488 Int_t ks = iparticle->GetStatusCode();
489 kf = CheckPDGCode(iparticle->GetPdgCode());
490 // No initial state partons
491 if (ks==21) continue;
493 // Heavy Flavor Selection
500 if (kfl > 100000) kfl %= 100000;
501 if (kfl > 10000) kfl %= 10000;
503 if (kfl > 10) kfl/=100;
505 if (kfl > 10) kfl/=10;
506 Int_t ipa = iparticle->GetFirstMother()-1;
509 // Establish mother daughter relation between heavy quarks and mesons
511 if (kf >= fFlavorSelect && kf <= 6) {
512 Int_t idau = iparticle->GetFirstDaughter() - 1;
514 TParticle* daughter = (TParticle *) fParticles->At(idau);
515 Int_t pdgD = daughter->GetPdgCode();
516 if (pdgD == 91 || pdgD == 92) {
517 Int_t jmin = daughter->GetFirstDaughter() - 1;
518 Int_t jmax = daughter->GetLastDaughter() - 1;
519 for (Int_t j = jmin; j <= jmax; j++)
520 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
521 } // is string or cluster
527 TParticle * mother = (TParticle *) fParticles->At(ipa);
528 kfMo = TMath::Abs(mother->GetPdgCode());
531 // What to keep in Stack?
532 Bool_t flavorOK = kFALSE;
533 Bool_t selectOK = kFALSE;
535 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
537 if (kfl > fFlavorSelect) {
541 if (kfl == fFlavorSelect) flavorOK = kTRUE;
543 switch (fStackFillOpt) {
544 case kFlavorSelection:
547 case kParentSelection:
548 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
551 if (flavorOK && selectOK) {
553 // Heavy flavor hadron or quark
555 // Kinematic seletion on final state heavy flavor mesons
556 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
561 if (ParentSelected(kf)) ++nParents; // Update parent count
562 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
564 // Kinematic seletion on decay products
565 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
566 && !KinematicSelection(iparticle, 1))
572 // Select if mother was selected and is not tracked
574 if (pSelected[ipa] &&
575 !trackIt[ipa] && // mother will be tracked ?
576 kfMo != 5 && // mother is b-quark, don't store fragments
577 kfMo != 4 && // mother is c-quark, don't store fragments
578 kf != 92) // don't store string
581 // Semi-stable or de-selected: diselect decay products:
584 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
586 Int_t ipF = iparticle->GetFirstDaughter();
587 Int_t ipL = iparticle->GetLastDaughter();
588 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
590 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
591 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
594 if (pSelected[i] == -1) pSelected[i] = 0;
595 if (!pSelected[i]) continue;
596 // Count quarks only if you did not include fragmentation
597 if (fFragmentation && kf <= 10) continue;
600 // Decision on tracking
603 // Track final state particle
604 if (ks == 1) trackIt[i] = 1;
605 // Track semi-stable particles
606 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
607 // Track particles selected by process if undecayed.
608 if (fForceDecay == kNoDecay) {
609 if (ParentSelected(kf)) trackIt[i] = 1;
611 if (ParentSelected(kf)) trackIt[i] = 0;
613 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
617 } // particle selection loop
619 for (i = 0; i<np; i++) {
620 if (!pSelected[i]) continue;
621 TParticle * iparticle = (TParticle *) fParticles->At(i);
622 kf = CheckPDGCode(iparticle->GetPdgCode());
623 Int_t ks = iparticle->GetStatusCode();
624 p[0] = iparticle->Px();
625 p[1] = iparticle->Py();
626 p[2] = iparticle->Pz();
627 p[3] = iparticle->Energy();
629 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
630 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
631 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
633 Float_t tof = kconv*iparticle->T();
634 Int_t ipa = iparticle->GetFirstMother()-1;
635 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
637 PushTrack(fTrackIt*trackIt[i], iparent, kf,
638 p[0], p[1], p[2], p[3],
639 origin[0], origin[1], origin[2], tof,
640 polar[0], polar[1], polar[2],
641 kPPrimary, nt, 1., ks);
652 if (pParent) delete[] pParent;
653 if (pSelected) delete[] pSelected;
654 if (trackIt) delete[] trackIt;
657 switch (fCountMode) {
659 // printf(" Count all \n");
663 // printf(" Count parents \n");
666 case kCountTrackables:
667 // printf(" Count trackable \n");
671 if (jev >= fNpart || fNpart == -1) {
672 fKineBias=Float_t(fNpart)/Float_t(fTrials);
673 fQ += fPythia->GetVINT(51);
674 fX1 += fPythia->GetVINT(41);
675 fX2 += fPythia->GetVINT(42);
676 fTrialsRun += fTrials;
683 SetHighWaterMark(nt);
684 // adjust weight due to kinematic selection
687 fXsection=fPythia->GetPARI(1);
690 Int_t AliGenPythia::GenerateMB()
693 // Min Bias selection and other global selections
695 Int_t i, kf, nt, iparent;
698 Float_t polar[3] = {0,0,0};
699 Float_t origin[3] = {0,0,0};
700 // converts from mm/c to s
701 const Float_t kconv=0.001/2.999792458e8;
703 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
706 Int_t* pParent = new Int_t[np];
707 for (i=0; i< np; i++) pParent[i] = -1;
708 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
709 TParticle* jet1 = (TParticle *) fParticles->At(6);
710 TParticle* jet2 = (TParticle *) fParticles->At(7);
711 if (!CheckTrigger(jet1, jet2)) return 0;
714 if (fTriggerParticle) {
715 Bool_t triggered = kFALSE;
716 for (i = 0; i < np; i++) {
717 TParticle * iparticle = (TParticle *) fParticles->At(i);
718 kf = CheckPDGCode(iparticle->GetPdgCode());
719 if (TMath::Abs(kf) != fTriggerParticle) continue;
720 if (iparticle->Pt() == 0.) continue;
721 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
725 if (!triggered) return 0;
729 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
730 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
731 && (fCutOnChild == 1) ) {
732 if ( !CheckKinematicsOnChild() ) {
733 if (pParent) delete[] pParent;
740 for (i = 0; i < np; i++) {
742 TParticle * iparticle = (TParticle *) fParticles->At(i);
743 kf = CheckPDGCode(iparticle->GetPdgCode());
744 Int_t ks = iparticle->GetStatusCode();
745 Int_t km = iparticle->GetFirstMother();
746 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
748 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
750 if (ks == 1) trackIt = 1;
751 Int_t ipa = iparticle->GetFirstMother()-1;
753 iparent = (ipa > -1) ? pParent[ipa] : -1;
756 // store track information
757 p[0] = iparticle->Px();
758 p[1] = iparticle->Py();
759 p[2] = iparticle->Pz();
760 p[3] = iparticle->Energy();
763 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
764 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
765 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
767 Float_t tof = fEventTime + kconv * iparticle->T();
769 PushTrack(fTrackIt*trackIt, iparent, kf,
770 p[0], p[1], p[2], p[3],
771 origin[0], origin[1], origin[2], tof,
772 polar[0], polar[1], polar[2],
773 kPPrimary, nt, 1., ks);
775 // Special Treatment to store color-flow
777 if (ks == 3 || ks == 13 || ks == 14) {
778 TParticle* particle = 0;
780 particle = fStack->Particle(nt);
782 particle = gAlice->Stack()->Particle(nt);
784 particle->SetFirstDaughter(fPythia->GetK(2, i));
785 particle->SetLastDaughter(fPythia->GetK(3, i));
790 SetHighWaterMark(nt);
795 if (pParent) delete[] pParent;
800 void AliGenPythia::FinishRun()
802 // Print x-section summary
811 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
812 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
815 void AliGenPythia::AdjustWeights()
817 // Adjust the weights after generation of all events
821 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
822 for (Int_t i=0; i<ntrack; i++) {
823 part= gAlice->GetMCApp()->Particle(i);
824 part->SetWeight(part->GetWeight()*fKineBias);
829 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
831 // Treat protons as inside nuclei with mass numbers a1 and a2
839 void AliGenPythia::MakeHeader()
842 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
843 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
846 // Builds the event header, to be called after each event
847 if (fHeader) delete fHeader;
848 fHeader = new AliGenPythiaEventHeader("Pythia");
851 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
854 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
857 fHeader->SetPrimaryVertex(fVertex);
859 // Jets that have triggered
861 if (fProcess == kPyJets)
865 GetJets(njet, ntrig, jets);
868 for (Int_t i = 0; i < ntrig; i++) {
869 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
874 // Copy relevant information from external header, if present.
879 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
880 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
882 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
885 exHeader->TriggerJet(i, uqJet);
886 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
890 // Store quenching parameters
897 fPythia->GetQuenchingParameters(xp, yp, z);
900 Double_t r1 = PARIMP.rb1;
901 Double_t r2 = PARIMP.rb2;
902 Double_t b = PARIMP.b1;
903 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
904 Double_t phi = PARIMP.psib1;
905 xp = r * TMath::Cos(phi);
906 yp = r * TMath::Sin(phi);
909 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
910 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
914 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
921 void AliGenPythia::AddHeader(AliGenEventHeader* header)
923 // Add header to container or runloader
925 fContainer->AddHeader(header);
927 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
932 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
934 // Check the kinematic trigger condition
937 eta[0] = jet1->Eta();
938 eta[1] = jet2->Eta();
940 phi[0] = jet1->Phi();
941 phi[1] = jet2->Phi();
943 pdg[0] = jet1->GetPdgCode();
944 pdg[1] = jet2->GetPdgCode();
945 Bool_t triggered = kFALSE;
947 if (fProcess == kPyJets) {
952 // Use Pythia clustering on parton level to determine jet axis
954 GetJets(njets, ntrig, jets);
956 if (ntrig) triggered = kTRUE;
961 if (pdg[0] == kGamma) {
965 //Check eta range first...
966 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
967 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
969 //Eta is okay, now check phi range
970 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
971 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
981 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
982 Bool_t AliGenPythia::CheckKinematicsOnChild(){
984 Bool_t checking = kFALSE;
985 Int_t j, kcode, ks, km;
986 Int_t nPartAcc = 0; //number of particles in the acceptance range
987 Int_t numberOfAcceptedParticles = 1;
988 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
989 Int_t npart = fParticles->GetEntriesFast();
991 for (j = 0; j<npart; j++) {
992 TParticle * jparticle = (TParticle *) fParticles->At(j);
993 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
994 ks = jparticle->GetStatusCode();
995 km = jparticle->GetFirstMother();
997 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1000 if( numberOfAcceptedParticles <= nPartAcc){
1010 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1012 // Assignment operator
1017 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1020 // Load event into Pythia Common Block
1023 Int_t npart = stack -> GetNprimary();
1027 (fPythia->GetPyjets())->N = npart;
1029 n0 = (fPythia->GetPyjets())->N;
1030 (fPythia->GetPyjets())->N = n0 + npart;
1034 for (Int_t part = 0; part < npart; part++) {
1035 TParticle *MPart = stack->Particle(part);
1037 Int_t kf = MPart->GetPdgCode();
1038 Int_t ks = MPart->GetStatusCode();
1039 Int_t idf = MPart->GetFirstDaughter();
1040 Int_t idl = MPart->GetLastDaughter();
1043 if (ks == 11 || ks == 12) {
1050 Float_t px = MPart->Px();
1051 Float_t py = MPart->Py();
1052 Float_t pz = MPart->Pz();
1053 Float_t e = MPart->Energy();
1054 Float_t m = MPart->GetCalcMass();
1057 (fPythia->GetPyjets())->P[0][part+n0] = px;
1058 (fPythia->GetPyjets())->P[1][part+n0] = py;
1059 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1060 (fPythia->GetPyjets())->P[3][part+n0] = e;
1061 (fPythia->GetPyjets())->P[4][part+n0] = m;
1063 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1064 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1065 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1066 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1067 (fPythia->GetPyjets())->K[2][part+n0] = MPart->GetFirstMother() + 1;
1072 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1075 // Calls the Pythia jet finding algorithm to find jets in the current event
1080 Int_t n = fPythia->GetN();
1084 fPythia->Pycell(njets);
1086 for (i = 0; i < njets; i++) {
1087 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1088 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1089 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1090 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1101 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1104 // Calls the Pythia clustering algorithm to find jets in the current event
1106 Int_t n = fPythia->GetN();
1109 if (fJetReconstruction == kCluster) {
1111 // Configure cluster algorithm
1113 fPythia->SetPARU(43, 2.);
1114 fPythia->SetMSTU(41, 1);
1116 // Call cluster algorithm
1118 fPythia->Pyclus(nJets);
1120 // Loading jets from common block
1126 fPythia->Pycell(nJets);
1130 for (i = 0; i < nJets; i++) {
1131 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1132 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1133 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1134 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1135 Float_t pt = TMath::Sqrt(px * px + py * py);
1136 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1137 Float_t theta = TMath::ATan2(pt,pz);
1138 Float_t et = e * TMath::Sin(theta);
1139 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1141 eta > fEtaMinJet && eta < fEtaMaxJet &&
1142 phi > fPhiMinJet && phi < fPhiMaxJet &&
1143 et > fEtMinJet && et < fEtMaxJet
1146 jets[0][nJetsTrig] = px;
1147 jets[1][nJetsTrig] = py;
1148 jets[2][nJetsTrig] = pz;
1149 jets[3][nJetsTrig] = e;
1151 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1153 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1158 void AliGenPythia::GetSubEventTime()
1160 // Calculates time of the next subevent
1163 TArrayF &array = *fEventsTime;
1164 fEventTime = array[fCurSubEvent++];
1166 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1171 void AliGenPythia::Streamer(TBuffer &R__b)
1173 // Stream an object of class AliGenPythia.
1175 if (R__b.IsReading()) {
1176 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1177 AliGenerator::Streamer(R__b);
1178 R__b >> (Int_t&)fProcess;
1179 R__b >> (Int_t&)fStrucFunc;
1180 R__b >> (Int_t&)fForceDecay;
1184 fParentSelect.Streamer(R__b);
1185 fChildSelect.Streamer(R__b);
1187 // (AliPythia::Instance())->Streamer(R__b);
1190 // if (fDecayer) fDecayer->Streamer(R__b);
1192 R__b.WriteVersion(AliGenPythia::IsA());
1193 AliGenerator::Streamer(R__b);
1194 R__b << (Int_t)fProcess;
1195 R__b << (Int_t)fStrucFunc;
1196 R__b << (Int_t)fForceDecay;
1200 fParentSelect.Streamer(R__b);
1201 fChildSelect.Streamer(R__b);
1206 // fDecayer->Streamer(R__b);