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();
79 if (!AliPythiaRndm::GetPythiaRandom())
80 AliPythiaRndm::SetPythiaRandom(GetRandom());
83 AliGenPythia::AliGenPythia(Int_t npart)
86 // default charm production at 5. 5 TeV
88 // structure function GRVHO
91 fTitle= "Particle Generator using PYTHIA";
95 fInteractionRate = 0.;
105 fDecayer = new AliDecayerPythia();
106 // Set random number generator
107 if (!AliPythiaRndm::GetPythiaRandom())
108 AliPythiaRndm::SetPythiaRandom(GetRandom());
110 // Produced particles
111 fParticles = new TClonesArray("TParticle",1000);
119 SetJetReconstructionMode();
123 SetTriggerParticle();
125 // Options determining what to keep in the stack (Heavy flavour generation)
126 fStackFillOpt = kFlavorSelection; // Keep particle with selected flavor
127 fFeedDownOpt = kTRUE; // allow feed down from higher family
128 // Fragmentation on/off
129 fFragmentation = kTRUE;
130 // Default counting mode
131 fCountMode = kCountAll;
133 SetPycellParameters();
141 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
148 AliGenPythia::~AliGenPythia()
151 if(fEventsTime) delete fEventsTime;
154 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
156 // Generate pileup using user specified rate
157 fInteractionRate = rate;
158 fTimeWindow = timewindow;
162 void AliGenPythia::GeneratePileup()
164 // Generate sub events time for pileup
166 if(fInteractionRate == 0.) {
167 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
171 Int_t npart = NumberParticles();
173 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
177 if(fEventsTime) delete fEventsTime;
178 fEventsTime = new TArrayF(npart);
179 TArrayF &array = *fEventsTime;
180 for(Int_t ipart = 0; ipart < npart; ipart++)
183 Float_t eventtime = 0.;
186 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
187 if(eventtime > fTimeWindow) break;
188 array.Set(array.GetSize()+1);
189 array[array.GetSize()-1] = eventtime;
195 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
196 if(TMath::Abs(eventtime) > fTimeWindow) break;
197 array.Set(array.GetSize()+1);
198 array[array.GetSize()-1] = eventtime;
201 SetNumberParticles(fEventsTime->GetSize());
204 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
205 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
207 // Set pycell parameters
208 fPycellEtaMax = etamax;
211 fPycellThreshold = thresh;
212 fPycellEtSeed = etseed;
213 fPycellMinEtJet = minet;
214 fPycellMaxRadius = r;
219 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
221 // Set a range of event numbers, for which a table
222 // of generated particle will be printed
223 fDebugEventFirst = eventFirst;
224 fDebugEventLast = eventLast;
225 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
228 void AliGenPythia::Init()
232 SetMC(AliPythia::Instance());
233 fPythia=(AliPythia*) fMCEvGen;
236 fParentWeight=1./Float_t(fNpart);
238 // Forward Paramters to the AliPythia object
239 fDecayer->SetForceDecay(fForceDecay);
243 fPythia->SetCKIN(3,fPtHardMin);
244 fPythia->SetCKIN(4,fPtHardMax);
245 fPythia->SetCKIN(7,fYHardMin);
246 fPythia->SetCKIN(8,fYHardMax);
248 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
250 if (fFragmentation) {
251 fPythia->SetMSTP(111,1);
253 fPythia->SetMSTP(111,0);
257 // initial state radiation
258 fPythia->SetMSTP(61,fGinit);
259 // final state radiation
260 fPythia->SetMSTP(71,fGfinal);
263 fPythia->SetMSTP(91,1);
264 fPythia->SetPARP(91,fPtKick);
266 fPythia->SetMSTP(91,0);
271 fRL = AliRunLoader::Open(fFileName, "Partons");
272 fRL->LoadKinematics();
277 // Switch off Heavy Flavors on request
279 fPythia->SetMSTP(58, 3);
280 fPythia->SetMSTJ(45, 3);
281 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
284 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
286 // Parent and Children Selection
289 case kPyOldUEQ2ordered:
290 case kPyOldUEQ2ordered2:
294 case kPyCharmUnforced:
295 case kPyCharmPbPbMNR:
298 case kPyCharmppMNRwmi:
299 fParentSelect[0] = 411;
300 fParentSelect[1] = 421;
301 fParentSelect[2] = 431;
302 fParentSelect[3] = 4122;
308 fParentSelect[0] = 421;
311 case kPyDPlusPbPbMNR:
314 fParentSelect[0] = 411;
317 case kPyDPlusStrangePbPbMNR:
318 case kPyDPlusStrangepPbMNR:
319 case kPyDPlusStrangeppMNR:
320 fParentSelect[0] = 431;
324 case kPyBeautyPbPbMNR:
325 case kPyBeautypPbMNR:
327 case kPyBeautyppMNRwmi:
328 fParentSelect[0]= 511;
329 fParentSelect[1]= 521;
330 fParentSelect[2]= 531;
331 fParentSelect[3]= 5122;
332 fParentSelect[4]= 5132;
333 fParentSelect[5]= 5232;
334 fParentSelect[6]= 5332;
337 case kPyBeautyUnforced:
338 fParentSelect[0] = 511;
339 fParentSelect[1] = 521;
340 fParentSelect[2] = 531;
341 fParentSelect[3] = 5122;
342 fParentSelect[4] = 5132;
343 fParentSelect[5] = 5232;
344 fParentSelect[6] = 5332;
349 fParentSelect[0] = 443;
363 // JetFinder for Trigger
365 // Configure detector (EMCAL like)
367 fPythia->SetPARU(51, fPycellEtaMax);
368 fPythia->SetMSTU(51, fPycellNEta);
369 fPythia->SetMSTU(52, fPycellNPhi);
371 // Configure Jet Finder
373 fPythia->SetPARU(58, fPycellThreshold);
374 fPythia->SetPARU(52, fPycellEtSeed);
375 fPythia->SetPARU(53, fPycellMinEtJet);
376 fPythia->SetPARU(54, fPycellMaxRadius);
377 fPythia->SetMSTU(54, 2);
379 // This counts the total number of calls to Pyevnt() per run.
394 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
398 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
402 void AliGenPythia::Generate()
404 // Generate one event
406 fDecayer->ForceDecay();
408 Float_t polar[3] = {0,0,0};
409 Float_t origin[3] = {0,0,0};
411 // converts from mm/c to s
412 const Float_t kconv=0.001/2.999792458e8;
422 // Set collision vertex position
423 if (fVertexSmear == kPerEvent) Vertex();
432 // Switch hadronisation off
434 fPythia->SetMSTJ(1, 0);
436 // Either produce new event or read partons from file
438 if (!fReadFromFile) {
444 fNpartons = fPythia->GetN();
446 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
447 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
449 LoadEvent(fRL->Stack(), 0 , 1);
454 // Run quenching routine
458 } else if (fQuench == 2){
459 fPythia->Pyquen(208., 0, 0.);
462 // Switch hadronisation on
464 fPythia->SetMSTJ(1, 1);
466 // .. and perform hadronisation
467 // printf("Calling hadronisation %d\n", fPythia->GetN());
470 fPythia->ImportParticles(fParticles,"All");
478 Int_t np = fParticles->GetEntriesFast();
480 if (np == 0) continue;
484 Int_t* pParent = new Int_t[np];
485 Int_t* pSelected = new Int_t[np];
486 Int_t* trackIt = new Int_t[np];
487 for (i = 0; i < np; i++) {
493 Int_t nc = 0; // Total n. of selected particles
494 Int_t nParents = 0; // Selected parents
495 Int_t nTkbles = 0; // Trackable particles
496 if (fProcess != kPyMb && fProcess != kPyJets &&
497 fProcess != kPyDirectGamma &&
498 fProcess != kPyMbNonDiffr &&
499 fProcess != kPyMbMSEL1 &&
500 fProcess != kPyW && fProcess != kPyZ &&
501 fProcess != kPyCharmppMNRwmi && fProcess != kPyBeautyppMNRwmi) {
503 for (i = 0; i < np; i++) {
504 TParticle* iparticle = (TParticle *) fParticles->At(i);
505 Int_t ks = iparticle->GetStatusCode();
506 kf = CheckPDGCode(iparticle->GetPdgCode());
507 // No initial state partons
508 if (ks==21) continue;
510 // Heavy Flavor Selection
517 if (kfl > 100000) kfl %= 100000;
518 if (kfl > 10000) kfl %= 10000;
520 if (kfl > 10) kfl/=100;
522 if (kfl > 10) kfl/=10;
523 Int_t ipa = iparticle->GetFirstMother()-1;
526 // Establish mother daughter relation between heavy quarks and mesons
528 if (kf >= fFlavorSelect && kf <= 6) {
529 Int_t idau = iparticle->GetFirstDaughter() - 1;
531 TParticle* daughter = (TParticle *) fParticles->At(idau);
532 Int_t pdgD = daughter->GetPdgCode();
533 if (pdgD == 91 || pdgD == 92) {
534 Int_t jmin = daughter->GetFirstDaughter() - 1;
535 Int_t jmax = daughter->GetLastDaughter() - 1;
536 for (Int_t j = jmin; j <= jmax; j++)
537 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
538 } // is string or cluster
544 TParticle * mother = (TParticle *) fParticles->At(ipa);
545 kfMo = TMath::Abs(mother->GetPdgCode());
548 // What to keep in Stack?
549 Bool_t flavorOK = kFALSE;
550 Bool_t selectOK = kFALSE;
552 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
554 if (kfl > fFlavorSelect) {
558 if (kfl == fFlavorSelect) flavorOK = kTRUE;
560 switch (fStackFillOpt) {
561 case kFlavorSelection:
564 case kParentSelection:
565 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
568 if (flavorOK && selectOK) {
570 // Heavy flavor hadron or quark
572 // Kinematic seletion on final state heavy flavor mesons
573 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
578 if (ParentSelected(kf)) ++nParents; // Update parent count
579 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
581 // Kinematic seletion on decay products
582 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
583 && !KinematicSelection(iparticle, 1))
589 // Select if mother was selected and is not tracked
591 if (pSelected[ipa] &&
592 !trackIt[ipa] && // mother will be tracked ?
593 kfMo != 5 && // mother is b-quark, don't store fragments
594 kfMo != 4 && // mother is c-quark, don't store fragments
595 kf != 92) // don't store string
598 // Semi-stable or de-selected: diselect decay products:
601 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
603 Int_t ipF = iparticle->GetFirstDaughter();
604 Int_t ipL = iparticle->GetLastDaughter();
605 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
607 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
608 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
611 if (pSelected[i] == -1) pSelected[i] = 0;
612 if (!pSelected[i]) continue;
613 // Count quarks only if you did not include fragmentation
614 if (fFragmentation && kf <= 10) continue;
617 // Decision on tracking
620 // Track final state particle
621 if (ks == 1) trackIt[i] = 1;
622 // Track semi-stable particles
623 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
624 // Track particles selected by process if undecayed.
625 if (fForceDecay == kNoDecay) {
626 if (ParentSelected(kf)) trackIt[i] = 1;
628 if (ParentSelected(kf)) trackIt[i] = 0;
630 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
634 } // particle selection loop
636 for (i = 0; i<np; i++) {
637 if (!pSelected[i]) continue;
638 TParticle * iparticle = (TParticle *) fParticles->At(i);
639 kf = CheckPDGCode(iparticle->GetPdgCode());
640 Int_t ks = iparticle->GetStatusCode();
641 p[0] = iparticle->Px();
642 p[1] = iparticle->Py();
643 p[2] = iparticle->Pz();
644 p[3] = iparticle->Energy();
646 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
647 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
648 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
650 Float_t tof = kconv*iparticle->T();
651 Int_t ipa = iparticle->GetFirstMother()-1;
652 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
654 PushTrack(fTrackIt*trackIt[i], iparent, kf,
655 p[0], p[1], p[2], p[3],
656 origin[0], origin[1], origin[2], tof,
657 polar[0], polar[1], polar[2],
658 kPPrimary, nt, 1., ks);
674 switch (fCountMode) {
676 // printf(" Count all \n");
680 // printf(" Count parents \n");
683 case kCountTrackables:
684 // printf(" Count trackable \n");
688 if (jev >= fNpart || fNpart == -1) {
689 fKineBias=Float_t(fNpart)/Float_t(fTrials);
691 fQ += fPythia->GetVINT(51);
692 fX1 += fPythia->GetVINT(41);
693 fX2 += fPythia->GetVINT(42);
694 fTrialsRun += fTrials;
701 SetHighWaterMark(nt);
702 // adjust weight due to kinematic selection
705 fXsection=fPythia->GetPARI(1);
708 Int_t AliGenPythia::GenerateMB()
711 // Min Bias selection and other global selections
713 Int_t i, kf, nt, iparent;
716 Float_t polar[3] = {0,0,0};
717 Float_t origin[3] = {0,0,0};
718 // converts from mm/c to s
719 const Float_t kconv=0.001/2.999792458e8;
723 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
727 Int_t* pParent = new Int_t[np];
728 for (i=0; i< np; i++) pParent[i] = -1;
729 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
730 TParticle* jet1 = (TParticle *) fParticles->At(6);
731 TParticle* jet2 = (TParticle *) fParticles->At(7);
732 if (!CheckTrigger(jet1, jet2)) {
738 if (fTriggerParticle) {
739 Bool_t triggered = kFALSE;
740 for (i = 0; i < np; i++) {
741 TParticle * iparticle = (TParticle *) fParticles->At(i);
742 kf = CheckPDGCode(iparticle->GetPdgCode());
743 if (kf != fTriggerParticle) continue;
744 if (iparticle->Pt() == 0.) continue;
745 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
756 // Check if there is a ccbar or bbbar pair with at least one of the two
757 // in fYMin < y < fYMax
758 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
760 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
763 for(i=0; i<np; i++) {
764 hvq = (TParticle*)fParticles->At(i);
765 pdgQ = hvq->GetPdgCode();
766 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
767 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
768 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
769 (hvq->Energy()-hvq->Pz()+1.e-13));
770 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
772 if (!theQ || !theQbar || !inYcut) {
778 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
779 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
780 && (fCutOnChild == 1) ) {
781 if ( !CheckKinematicsOnChild() ) {
788 for (i = 0; i < np; i++) {
790 TParticle * iparticle = (TParticle *) fParticles->At(i);
791 kf = CheckPDGCode(iparticle->GetPdgCode());
792 Int_t ks = iparticle->GetStatusCode();
793 Int_t km = iparticle->GetFirstMother();
794 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
796 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
798 if (ks == 1) trackIt = 1;
799 Int_t ipa = iparticle->GetFirstMother()-1;
801 iparent = (ipa > -1) ? pParent[ipa] : -1;
804 // store track information
805 p[0] = iparticle->Px();
806 p[1] = iparticle->Py();
807 p[2] = iparticle->Pz();
808 p[3] = iparticle->Energy();
811 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
812 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
813 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
815 Float_t tof = fEventTime + kconv * iparticle->T();
817 PushTrack(fTrackIt*trackIt, iparent, kf,
818 p[0], p[1], p[2], p[3],
819 origin[0], origin[1], origin[2], tof,
820 polar[0], polar[1], polar[2],
821 kPPrimary, nt, 1., ks);
823 // Special Treatment to store color-flow
825 if (ks == 3 || ks == 13 || ks == 14) {
826 TParticle* particle = 0;
828 particle = fStack->Particle(nt);
830 particle = gAlice->Stack()->Particle(nt);
832 particle->SetFirstDaughter(fPythia->GetK(2, i));
833 particle->SetLastDaughter(fPythia->GetK(3, i));
838 SetHighWaterMark(nt);
849 void AliGenPythia::FinishRun()
851 // Print x-section summary
860 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
861 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
864 void AliGenPythia::AdjustWeights() const
866 // Adjust the weights after generation of all events
870 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
871 for (Int_t i=0; i<ntrack; i++) {
872 part= gAlice->GetMCApp()->Particle(i);
873 part->SetWeight(part->GetWeight()*fKineBias);
878 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
880 // Treat protons as inside nuclei with mass numbers a1 and a2
888 void AliGenPythia::MakeHeader()
891 // Make header for the simulated event
894 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
895 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
898 // Builds the event header, to be called after each event
899 if (fHeader) delete fHeader;
900 fHeader = new AliGenPythiaEventHeader("Pythia");
903 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
906 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
909 fHeader->SetPrimaryVertex(fVertex);
911 // Jets that have triggered
913 if (fProcess == kPyJets)
917 GetJets(njet, ntrig, jets);
920 for (Int_t i = 0; i < ntrig; i++) {
921 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
926 // Copy relevant information from external header, if present.
931 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
932 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
934 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
937 exHeader->TriggerJet(i, uqJet);
938 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
942 // Store quenching parameters
949 fPythia->GetQuenchingParameters(xp, yp, z);
952 Double_t r1 = PARIMP.rb1;
953 Double_t r2 = PARIMP.rb2;
954 Double_t b = PARIMP.b1;
955 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
956 Double_t phi = PARIMP.psib1;
957 xp = r * TMath::Cos(phi);
958 yp = r * TMath::Sin(phi);
961 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
962 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
966 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
973 void AliGenPythia::AddHeader(AliGenEventHeader* header)
975 // Add header to container or runloader
977 fContainer->AddHeader(header);
979 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
984 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
986 // Check the kinematic trigger condition
989 eta[0] = jet1->Eta();
990 eta[1] = jet2->Eta();
992 phi[0] = jet1->Phi();
993 phi[1] = jet2->Phi();
995 pdg[0] = jet1->GetPdgCode();
996 pdg[1] = jet2->GetPdgCode();
997 Bool_t triggered = kFALSE;
999 if (fProcess == kPyJets) {
1002 Float_t jets[4][10];
1004 // Use Pythia clustering on parton level to determine jet axis
1006 GetJets(njets, ntrig, jets);
1008 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1013 if (pdg[0] == kGamma) {
1017 //Check eta range first...
1018 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1019 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1021 //Eta is okay, now check phi range
1022 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1023 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1034 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1036 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1038 Bool_t checking = kFALSE;
1039 Int_t j, kcode, ks, km;
1040 Int_t nPartAcc = 0; //number of particles in the acceptance range
1041 Int_t numberOfAcceptedParticles = 1;
1042 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1043 Int_t npart = fParticles->GetEntriesFast();
1045 for (j = 0; j<npart; j++) {
1046 TParticle * jparticle = (TParticle *) fParticles->At(j);
1047 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1048 ks = jparticle->GetStatusCode();
1049 km = jparticle->GetFirstMother();
1051 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1054 if( numberOfAcceptedParticles <= nPartAcc){
1064 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1066 // Assignment operator
1071 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1074 // Load event into Pythia Common Block
1077 Int_t npart = stack -> GetNprimary();
1081 (fPythia->GetPyjets())->N = npart;
1083 n0 = (fPythia->GetPyjets())->N;
1084 (fPythia->GetPyjets())->N = n0 + npart;
1088 for (Int_t part = 0; part < npart; part++) {
1089 TParticle *mPart = stack->Particle(part);
1091 Int_t kf = mPart->GetPdgCode();
1092 Int_t ks = mPart->GetStatusCode();
1093 Int_t idf = mPart->GetFirstDaughter();
1094 Int_t idl = mPart->GetLastDaughter();
1097 if (ks == 11 || ks == 12) {
1104 Float_t px = mPart->Px();
1105 Float_t py = mPart->Py();
1106 Float_t pz = mPart->Pz();
1107 Float_t e = mPart->Energy();
1108 Float_t m = mPart->GetCalcMass();
1111 (fPythia->GetPyjets())->P[0][part+n0] = px;
1112 (fPythia->GetPyjets())->P[1][part+n0] = py;
1113 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1114 (fPythia->GetPyjets())->P[3][part+n0] = e;
1115 (fPythia->GetPyjets())->P[4][part+n0] = m;
1117 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1118 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1119 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1120 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1121 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1126 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1129 // Calls the Pythia jet finding algorithm to find jets in the current event
1134 Int_t n = fPythia->GetN();
1138 fPythia->Pycell(njets);
1140 for (i = 0; i < njets; i++) {
1141 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1142 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1143 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1144 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1155 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1158 // Calls the Pythia clustering algorithm to find jets in the current event
1160 Int_t n = fPythia->GetN();
1163 if (fJetReconstruction == kCluster) {
1165 // Configure cluster algorithm
1167 fPythia->SetPARU(43, 2.);
1168 fPythia->SetMSTU(41, 1);
1170 // Call cluster algorithm
1172 fPythia->Pyclus(nJets);
1174 // Loading jets from common block
1180 fPythia->Pycell(nJets);
1184 for (i = 0; i < nJets; i++) {
1185 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1186 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1187 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1188 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1189 Float_t pt = TMath::Sqrt(px * px + py * py);
1190 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1191 Float_t theta = TMath::ATan2(pt,pz);
1192 Float_t et = e * TMath::Sin(theta);
1193 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1195 eta > fEtaMinJet && eta < fEtaMaxJet &&
1196 phi > fPhiMinJet && phi < fPhiMaxJet &&
1197 et > fEtMinJet && et < fEtMaxJet
1200 jets[0][nJetsTrig] = px;
1201 jets[1][nJetsTrig] = py;
1202 jets[2][nJetsTrig] = pz;
1203 jets[3][nJetsTrig] = e;
1205 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1207 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1212 void AliGenPythia::GetSubEventTime()
1214 // Calculates time of the next subevent
1217 TArrayF &array = *fEventsTime;
1218 fEventTime = array[fCurSubEvent++];
1220 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1225 void AliGenPythia::Streamer(TBuffer &R__b)
1227 // Stream an object of class AliGenPythia.
1229 if (R__b.IsReading()) {
1230 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1231 AliGenerator::Streamer(R__b);
1232 R__b >> (Int_t&)fProcess;
1233 R__b >> (Int_t&)fStrucFunc;
1234 R__b >> (Int_t&)fForceDecay;
1238 fParentSelect.Streamer(R__b);
1239 fChildSelect.Streamer(R__b);
1241 // (AliPythia::Instance())->Streamer(R__b);
1244 // if (fDecayer) fDecayer->Streamer(R__b);
1246 R__b.WriteVersion(AliGenPythia::IsA());
1247 AliGenerator::Streamer(R__b);
1248 R__b << (Int_t)fProcess;
1249 R__b << (Int_t)fStrucFunc;
1250 R__b << (Int_t)fForceDecay;
1254 fParentSelect.Streamer(R__b);
1255 fChildSelect.Streamer(R__b);
1260 // fDecayer->Streamer(R__b);