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();
76 if (!AliPythiaRndm::GetPythiaRandom())
77 AliPythiaRndm::SetPythiaRandom(GetRandom());
80 AliGenPythia::AliGenPythia(Int_t npart)
83 // default charm production at 5. 5 TeV
85 // structure function GRVHO
88 fTitle= "Particle Generator using PYTHIA";
92 fInteractionRate = 0.;
102 fDecayer = new AliDecayerPythia();
103 // Set random number generator
104 if (!AliPythiaRndm::GetPythiaRandom())
105 AliPythiaRndm::SetPythiaRandom(GetRandom());
107 // Produced particles
108 fParticles = new TClonesArray("TParticle",1000);
116 SetJetReconstructionMode();
120 SetTriggerParticle();
122 // Options determining what to keep in the stack (Heavy flavour generation)
123 fStackFillOpt = kFlavorSelection; // Keep particle with selected flavor
124 fFeedDownOpt = kTRUE; // allow feed down from higher family
125 // Fragmentation on/off
126 fFragmentation = kTRUE;
127 // Default counting mode
128 fCountMode = kCountAll;
130 SetPycellParameters();
136 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
143 AliGenPythia::~AliGenPythia()
146 if(fEventsTime) delete fEventsTime;
149 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
151 // Generate pileup using user specified rate
152 fInteractionRate = rate;
153 fTimeWindow = timewindow;
157 void AliGenPythia::GeneratePileup()
159 // Generate sub events time for pileup
161 if(fInteractionRate == 0.) {
162 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
166 Int_t npart = NumberParticles();
168 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
172 if(fEventsTime) delete fEventsTime;
173 fEventsTime = new TArrayF(npart);
174 TArrayF &array = *fEventsTime;
175 for(Int_t ipart = 0; ipart < npart; ipart++)
178 Float_t eventtime = 0.;
181 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
182 if(eventtime > fTimeWindow) break;
183 array.Set(array.GetSize()+1);
184 array[array.GetSize()-1] = eventtime;
190 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
191 if(TMath::Abs(eventtime) > fTimeWindow) break;
192 array.Set(array.GetSize()+1);
193 array[array.GetSize()-1] = eventtime;
196 SetNumberParticles(fEventsTime->GetSize());
199 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
200 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
202 // Set pycell parameters
203 fPycellEtaMax = etamax;
206 fPycellThreshold = thresh;
207 fPycellEtSeed = etseed;
208 fPycellMinEtJet = minet;
209 fPycellMaxRadius = r;
214 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
216 // Set a range of event numbers, for which a table
217 // of generated particle will be printed
218 fDebugEventFirst = eventFirst;
219 fDebugEventLast = eventLast;
220 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
223 void AliGenPythia::Init()
227 SetMC(AliPythia::Instance());
228 fPythia=(AliPythia*) fMCEvGen;
231 fParentWeight=1./Float_t(fNpart);
233 // Forward Paramters to the AliPythia object
234 fDecayer->SetForceDecay(fForceDecay);
238 fPythia->SetCKIN(3,fPtHardMin);
239 fPythia->SetCKIN(4,fPtHardMax);
240 fPythia->SetCKIN(7,fYHardMin);
241 fPythia->SetCKIN(8,fYHardMax);
243 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
245 if (fFragmentation) {
246 fPythia->SetMSTP(111,1);
248 fPythia->SetMSTP(111,0);
252 // initial state radiation
253 fPythia->SetMSTP(61,fGinit);
254 // final state radiation
255 fPythia->SetMSTP(71,fGfinal);
258 fPythia->SetMSTP(91,1);
259 fPythia->SetPARP(91,fPtKick);
261 fPythia->SetMSTP(91,0);
266 fRL = AliRunLoader::Open(fFileName, "Partons");
267 fRL->LoadKinematics();
272 // Switch off Heavy Flavors on request
274 fPythia->SetMSTP(58, 3);
275 fPythia->SetMSTJ(45, 3);
276 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
279 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
281 // Parent and Children Selection
284 case kPyOldUEQ2ordered:
285 case kPyOldUEQ2ordered2:
289 case kPyCharmUnforced:
290 case kPyCharmPbPbMNR:
293 case kPyCharmppMNRwmi:
294 fParentSelect[0] = 411;
295 fParentSelect[1] = 421;
296 fParentSelect[2] = 431;
297 fParentSelect[3] = 4122;
303 fParentSelect[0] = 421;
306 case kPyDPlusPbPbMNR:
309 fParentSelect[0] = 411;
312 case kPyDPlusStrangePbPbMNR:
313 case kPyDPlusStrangepPbMNR:
314 case kPyDPlusStrangeppMNR:
315 fParentSelect[0] = 431;
319 case kPyBeautyPbPbMNR:
320 case kPyBeautypPbMNR:
322 case kPyBeautyppMNRwmi:
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;
332 case kPyBeautyUnforced:
333 fParentSelect[0] = 511;
334 fParentSelect[1] = 521;
335 fParentSelect[2] = 531;
336 fParentSelect[3] = 5122;
337 fParentSelect[4] = 5132;
338 fParentSelect[5] = 5232;
339 fParentSelect[6] = 5332;
344 fParentSelect[0] = 443;
358 // JetFinder for Trigger
360 // Configure detector (EMCAL like)
362 fPythia->SetPARU(51, fPycellEtaMax);
363 fPythia->SetMSTU(51, fPycellNEta);
364 fPythia->SetMSTU(52, fPycellNPhi);
366 // Configure Jet Finder
368 fPythia->SetPARU(58, fPycellThreshold);
369 fPythia->SetPARU(52, fPycellEtSeed);
370 fPythia->SetPARU(53, fPycellMinEtJet);
371 fPythia->SetPARU(54, fPycellMaxRadius);
372 fPythia->SetMSTU(54, 2);
374 // This counts the total number of calls to Pyevnt() per run.
389 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
393 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
397 void AliGenPythia::Generate()
399 // Generate one event
401 fDecayer->ForceDecay();
403 Float_t polar[3] = {0,0,0};
404 Float_t origin[3] = {0,0,0};
406 // converts from mm/c to s
407 const Float_t kconv=0.001/2.999792458e8;
417 // Set collision vertex position
418 if (fVertexSmear == kPerEvent) Vertex();
427 // Switch hadronisation off
429 fPythia->SetMSTJ(1, 0);
431 // Either produce new event or read partons from file
433 if (!fReadFromFile) {
439 fNpartons = fPythia->GetN();
441 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
442 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
444 LoadEvent(fRL->Stack(), 0 , 1);
449 // Run quenching routine
453 } else if (fQuench == 2){
454 fPythia->Pyquen(208., 0, 0.);
457 // Switch hadronisation on
459 fPythia->SetMSTJ(1, 1);
461 // .. and perform hadronisation
462 // printf("Calling hadronisation %d\n", fPythia->GetN());
465 fPythia->ImportParticles(fParticles,"All");
473 Int_t np = fParticles->GetEntriesFast();
475 if (np == 0) continue;
479 Int_t* pParent = new Int_t[np];
480 Int_t* pSelected = new Int_t[np];
481 Int_t* trackIt = new Int_t[np];
482 for (i = 0; i < np; i++) {
488 Int_t nc = 0; // Total n. of selected particles
489 Int_t nParents = 0; // Selected parents
490 Int_t nTkbles = 0; // Trackable particles
491 if (fProcess != kPyMb && fProcess != kPyJets &&
492 fProcess != kPyDirectGamma &&
493 fProcess != kPyMbNonDiffr &&
494 fProcess != kPyMbMSEL1 &&
495 fProcess != kPyW && fProcess != kPyZ &&
496 fProcess != kPyCharmppMNRwmi && fProcess != kPyBeautyppMNRwmi) {
498 for (i = 0; i < np; i++) {
499 TParticle* iparticle = (TParticle *) fParticles->At(i);
500 Int_t ks = iparticle->GetStatusCode();
501 kf = CheckPDGCode(iparticle->GetPdgCode());
502 // No initial state partons
503 if (ks==21) continue;
505 // Heavy Flavor Selection
512 if (kfl > 100000) kfl %= 100000;
513 if (kfl > 10000) kfl %= 10000;
515 if (kfl > 10) kfl/=100;
517 if (kfl > 10) kfl/=10;
518 Int_t ipa = iparticle->GetFirstMother()-1;
521 // Establish mother daughter relation between heavy quarks and mesons
523 if (kf >= fFlavorSelect && kf <= 6) {
524 Int_t idau = iparticle->GetFirstDaughter() - 1;
526 TParticle* daughter = (TParticle *) fParticles->At(idau);
527 Int_t pdgD = daughter->GetPdgCode();
528 if (pdgD == 91 || pdgD == 92) {
529 Int_t jmin = daughter->GetFirstDaughter() - 1;
530 Int_t jmax = daughter->GetLastDaughter() - 1;
531 for (Int_t j = jmin; j <= jmax; j++)
532 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
533 } // is string or cluster
539 TParticle * mother = (TParticle *) fParticles->At(ipa);
540 kfMo = TMath::Abs(mother->GetPdgCode());
543 // What to keep in Stack?
544 Bool_t flavorOK = kFALSE;
545 Bool_t selectOK = kFALSE;
547 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
549 if (kfl > fFlavorSelect) {
553 if (kfl == fFlavorSelect) flavorOK = kTRUE;
555 switch (fStackFillOpt) {
556 case kFlavorSelection:
559 case kParentSelection:
560 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
563 if (flavorOK && selectOK) {
565 // Heavy flavor hadron or quark
567 // Kinematic seletion on final state heavy flavor mesons
568 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
573 if (ParentSelected(kf)) ++nParents; // Update parent count
574 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
576 // Kinematic seletion on decay products
577 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
578 && !KinematicSelection(iparticle, 1))
584 // Select if mother was selected and is not tracked
586 if (pSelected[ipa] &&
587 !trackIt[ipa] && // mother will be tracked ?
588 kfMo != 5 && // mother is b-quark, don't store fragments
589 kfMo != 4 && // mother is c-quark, don't store fragments
590 kf != 92) // don't store string
593 // Semi-stable or de-selected: diselect decay products:
596 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
598 Int_t ipF = iparticle->GetFirstDaughter();
599 Int_t ipL = iparticle->GetLastDaughter();
600 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
602 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
603 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
606 if (pSelected[i] == -1) pSelected[i] = 0;
607 if (!pSelected[i]) continue;
608 // Count quarks only if you did not include fragmentation
609 if (fFragmentation && kf <= 10) continue;
612 // Decision on tracking
615 // Track final state particle
616 if (ks == 1) trackIt[i] = 1;
617 // Track semi-stable particles
618 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
619 // Track particles selected by process if undecayed.
620 if (fForceDecay == kNoDecay) {
621 if (ParentSelected(kf)) trackIt[i] = 1;
623 if (ParentSelected(kf)) trackIt[i] = 0;
625 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
629 } // particle selection loop
631 for (i = 0; i<np; i++) {
632 if (!pSelected[i]) continue;
633 TParticle * iparticle = (TParticle *) fParticles->At(i);
634 kf = CheckPDGCode(iparticle->GetPdgCode());
635 Int_t ks = iparticle->GetStatusCode();
636 p[0] = iparticle->Px();
637 p[1] = iparticle->Py();
638 p[2] = iparticle->Pz();
639 p[3] = iparticle->Energy();
641 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
642 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
643 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
645 Float_t tof = kconv*iparticle->T();
646 Int_t ipa = iparticle->GetFirstMother()-1;
647 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
649 PushTrack(fTrackIt*trackIt[i], iparent, kf,
650 p[0], p[1], p[2], p[3],
651 origin[0], origin[1], origin[2], tof,
652 polar[0], polar[1], polar[2],
653 kPPrimary, nt, 1., ks);
669 switch (fCountMode) {
671 // printf(" Count all \n");
675 // printf(" Count parents \n");
678 case kCountTrackables:
679 // printf(" Count trackable \n");
683 if (jev >= fNpart || fNpart == -1) {
684 fKineBias=Float_t(fNpart)/Float_t(fTrials);
686 fQ += fPythia->GetVINT(51);
687 fX1 += fPythia->GetVINT(41);
688 fX2 += fPythia->GetVINT(42);
689 fTrialsRun += fTrials;
696 SetHighWaterMark(nt);
697 // adjust weight due to kinematic selection
700 fXsection=fPythia->GetPARI(1);
703 Int_t AliGenPythia::GenerateMB()
706 // Min Bias selection and other global selections
708 Int_t i, kf, nt, iparent;
711 Float_t polar[3] = {0,0,0};
712 Float_t origin[3] = {0,0,0};
713 // converts from mm/c to s
714 const Float_t kconv=0.001/2.999792458e8;
718 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
722 Int_t* pParent = new Int_t[np];
723 for (i=0; i< np; i++) pParent[i] = -1;
724 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
725 TParticle* jet1 = (TParticle *) fParticles->At(6);
726 TParticle* jet2 = (TParticle *) fParticles->At(7);
727 if (!CheckTrigger(jet1, jet2)) {
733 if (fTriggerParticle) {
734 Bool_t triggered = kFALSE;
735 for (i = 0; i < np; i++) {
736 TParticle * iparticle = (TParticle *) fParticles->At(i);
737 kf = CheckPDGCode(iparticle->GetPdgCode());
738 if (kf != fTriggerParticle) continue;
739 if (iparticle->Pt() == 0.) continue;
740 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
751 // Check if there is a ccbar or bbbar pair with at least one of the two
752 // in fYMin < y < fYMax
753 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
755 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
758 for(i=0; i<np; i++) {
759 hvq = (TParticle*)fParticles->At(i);
760 pdgQ = hvq->GetPdgCode();
761 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
762 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
763 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
764 (hvq->Energy()-hvq->Pz()+1.e-13));
765 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
767 if (!theQ || !theQbar || !inYcut) {
773 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
774 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
775 && (fCutOnChild == 1) ) {
776 if ( !CheckKinematicsOnChild() ) {
783 for (i = 0; i < np; i++) {
785 TParticle * iparticle = (TParticle *) fParticles->At(i);
786 kf = CheckPDGCode(iparticle->GetPdgCode());
787 Int_t ks = iparticle->GetStatusCode();
788 Int_t km = iparticle->GetFirstMother();
789 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
791 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
793 if (ks == 1) trackIt = 1;
794 Int_t ipa = iparticle->GetFirstMother()-1;
796 iparent = (ipa > -1) ? pParent[ipa] : -1;
799 // store track information
800 p[0] = iparticle->Px();
801 p[1] = iparticle->Py();
802 p[2] = iparticle->Pz();
803 p[3] = iparticle->Energy();
806 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
807 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
808 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
810 Float_t tof = fEventTime + kconv * iparticle->T();
812 PushTrack(fTrackIt*trackIt, iparent, kf,
813 p[0], p[1], p[2], p[3],
814 origin[0], origin[1], origin[2], tof,
815 polar[0], polar[1], polar[2],
816 kPPrimary, nt, 1., ks);
818 // Special Treatment to store color-flow
820 if (ks == 3 || ks == 13 || ks == 14) {
821 TParticle* particle = 0;
823 particle = fStack->Particle(nt);
825 particle = gAlice->Stack()->Particle(nt);
827 particle->SetFirstDaughter(fPythia->GetK(2, i));
828 particle->SetLastDaughter(fPythia->GetK(3, i));
833 SetHighWaterMark(nt);
844 void AliGenPythia::FinishRun()
846 // Print x-section summary
855 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
856 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
859 void AliGenPythia::AdjustWeights() const
861 // Adjust the weights after generation of all events
865 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
866 for (Int_t i=0; i<ntrack; i++) {
867 part= gAlice->GetMCApp()->Particle(i);
868 part->SetWeight(part->GetWeight()*fKineBias);
873 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
875 // Treat protons as inside nuclei with mass numbers a1 and a2
883 void AliGenPythia::MakeHeader()
886 // Make header for the simulated event
889 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
890 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
893 // Builds the event header, to be called after each event
894 if (fHeader) delete fHeader;
895 fHeader = new AliGenPythiaEventHeader("Pythia");
898 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
901 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
904 fHeader->SetPrimaryVertex(fVertex);
906 // Jets that have triggered
908 if (fProcess == kPyJets)
912 GetJets(njet, ntrig, jets);
915 for (Int_t i = 0; i < ntrig; i++) {
916 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
921 // Copy relevant information from external header, if present.
926 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
927 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
929 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
932 exHeader->TriggerJet(i, uqJet);
933 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
937 // Store quenching parameters
944 fPythia->GetQuenchingParameters(xp, yp, z);
947 Double_t r1 = PARIMP.rb1;
948 Double_t r2 = PARIMP.rb2;
949 Double_t b = PARIMP.b1;
950 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
951 Double_t phi = PARIMP.psib1;
952 xp = r * TMath::Cos(phi);
953 yp = r * TMath::Sin(phi);
956 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
957 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
961 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
968 void AliGenPythia::AddHeader(AliGenEventHeader* header)
970 // Add header to container or runloader
972 fContainer->AddHeader(header);
974 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
979 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
981 // Check the kinematic trigger condition
984 eta[0] = jet1->Eta();
985 eta[1] = jet2->Eta();
987 phi[0] = jet1->Phi();
988 phi[1] = jet2->Phi();
990 pdg[0] = jet1->GetPdgCode();
991 pdg[1] = jet2->GetPdgCode();
992 Bool_t triggered = kFALSE;
994 if (fProcess == kPyJets) {
999 // Use Pythia clustering on parton level to determine jet axis
1001 GetJets(njets, ntrig, jets);
1003 if (ntrig) triggered = kTRUE;
1008 if (pdg[0] == kGamma) {
1012 //Check eta range first...
1013 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1014 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1016 //Eta is okay, now check phi range
1017 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1018 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1029 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1031 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1033 Bool_t checking = kFALSE;
1034 Int_t j, kcode, ks, km;
1035 Int_t nPartAcc = 0; //number of particles in the acceptance range
1036 Int_t numberOfAcceptedParticles = 1;
1037 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1038 Int_t npart = fParticles->GetEntriesFast();
1040 for (j = 0; j<npart; j++) {
1041 TParticle * jparticle = (TParticle *) fParticles->At(j);
1042 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1043 ks = jparticle->GetStatusCode();
1044 km = jparticle->GetFirstMother();
1046 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1049 if( numberOfAcceptedParticles <= nPartAcc){
1059 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1061 // Assignment operator
1066 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1069 // Load event into Pythia Common Block
1072 Int_t npart = stack -> GetNprimary();
1076 (fPythia->GetPyjets())->N = npart;
1078 n0 = (fPythia->GetPyjets())->N;
1079 (fPythia->GetPyjets())->N = n0 + npart;
1083 for (Int_t part = 0; part < npart; part++) {
1084 TParticle *mPart = stack->Particle(part);
1086 Int_t kf = mPart->GetPdgCode();
1087 Int_t ks = mPart->GetStatusCode();
1088 Int_t idf = mPart->GetFirstDaughter();
1089 Int_t idl = mPart->GetLastDaughter();
1092 if (ks == 11 || ks == 12) {
1099 Float_t px = mPart->Px();
1100 Float_t py = mPart->Py();
1101 Float_t pz = mPart->Pz();
1102 Float_t e = mPart->Energy();
1103 Float_t m = mPart->GetCalcMass();
1106 (fPythia->GetPyjets())->P[0][part+n0] = px;
1107 (fPythia->GetPyjets())->P[1][part+n0] = py;
1108 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1109 (fPythia->GetPyjets())->P[3][part+n0] = e;
1110 (fPythia->GetPyjets())->P[4][part+n0] = m;
1112 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1113 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1114 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1115 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1116 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1121 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1124 // Calls the Pythia jet finding algorithm to find jets in the current event
1129 Int_t n = fPythia->GetN();
1133 fPythia->Pycell(njets);
1135 for (i = 0; i < njets; i++) {
1136 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1137 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1138 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1139 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1150 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1153 // Calls the Pythia clustering algorithm to find jets in the current event
1155 Int_t n = fPythia->GetN();
1158 if (fJetReconstruction == kCluster) {
1160 // Configure cluster algorithm
1162 fPythia->SetPARU(43, 2.);
1163 fPythia->SetMSTU(41, 1);
1165 // Call cluster algorithm
1167 fPythia->Pyclus(nJets);
1169 // Loading jets from common block
1175 fPythia->Pycell(nJets);
1179 for (i = 0; i < nJets; i++) {
1180 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1181 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1182 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1183 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1184 Float_t pt = TMath::Sqrt(px * px + py * py);
1185 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1186 Float_t theta = TMath::ATan2(pt,pz);
1187 Float_t et = e * TMath::Sin(theta);
1188 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1190 eta > fEtaMinJet && eta < fEtaMaxJet &&
1191 phi > fPhiMinJet && phi < fPhiMaxJet &&
1192 et > fEtMinJet && et < fEtMaxJet
1195 jets[0][nJetsTrig] = px;
1196 jets[1][nJetsTrig] = py;
1197 jets[2][nJetsTrig] = pz;
1198 jets[3][nJetsTrig] = e;
1200 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1202 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1207 void AliGenPythia::GetSubEventTime()
1209 // Calculates time of the next subevent
1212 TArrayF &array = *fEventsTime;
1213 fEventTime = array[fCurSubEvent++];
1215 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1220 void AliGenPythia::Streamer(TBuffer &R__b)
1222 // Stream an object of class AliGenPythia.
1224 if (R__b.IsReading()) {
1225 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1226 AliGenerator::Streamer(R__b);
1227 R__b >> (Int_t&)fProcess;
1228 R__b >> (Int_t&)fStrucFunc;
1229 R__b >> (Int_t&)fForceDecay;
1233 fParentSelect.Streamer(R__b);
1234 fChildSelect.Streamer(R__b);
1236 // (AliPythia::Instance())->Streamer(R__b);
1239 // if (fDecayer) fDecayer->Streamer(R__b);
1241 R__b.WriteVersion(AliGenPythia::IsA());
1242 AliGenerator::Streamer(R__b);
1243 R__b << (Int_t)fProcess;
1244 R__b << (Int_t)fStrucFunc;
1245 R__b << (Int_t)fForceDecay;
1249 fParentSelect.Streamer(R__b);
1250 fChildSelect.Streamer(R__b);
1255 // fDecayer->Streamer(R__b);