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 SetJetReconstructionMode();
119 SetTriggerParticle();
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 case kPyCharmppMNRwmi:
292 fParentSelect[0] = 411;
293 fParentSelect[1] = 421;
294 fParentSelect[2] = 431;
295 fParentSelect[3] = 4122;
301 fParentSelect[0] = 421;
304 case kPyDPlusPbPbMNR:
307 fParentSelect[0] = 411;
310 case kPyDPlusStrangePbPbMNR:
311 case kPyDPlusStrangepPbMNR:
312 case kPyDPlusStrangeppMNR:
313 fParentSelect[0] = 431;
317 case kPyBeautyPbPbMNR:
318 case kPyBeautypPbMNR:
320 case kPyBeautyppMNRwmi:
321 fParentSelect[0]= 511;
322 fParentSelect[1]= 521;
323 fParentSelect[2]= 531;
324 fParentSelect[3]= 5122;
325 fParentSelect[4]= 5132;
326 fParentSelect[5]= 5232;
327 fParentSelect[6]= 5332;
330 case kPyBeautyUnforced:
331 fParentSelect[0] = 511;
332 fParentSelect[1] = 521;
333 fParentSelect[2] = 531;
334 fParentSelect[3] = 5122;
335 fParentSelect[4] = 5132;
336 fParentSelect[5] = 5232;
337 fParentSelect[6] = 5332;
342 fParentSelect[0] = 443;
356 // JetFinder for Trigger
358 // Configure detector (EMCAL like)
360 fPythia->SetPARU(51, fPycellEtaMax);
361 fPythia->SetMSTU(51, fPycellNEta);
362 fPythia->SetMSTU(52, fPycellNPhi);
364 // Configure Jet Finder
366 fPythia->SetPARU(58, fPycellThreshold);
367 fPythia->SetPARU(52, fPycellEtSeed);
368 fPythia->SetPARU(53, fPycellMinEtJet);
369 fPythia->SetPARU(54, fPycellMaxRadius);
370 fPythia->SetMSTU(54, 2);
372 // This counts the total number of calls to Pyevnt() per run.
387 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
391 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
395 void AliGenPythia::Generate()
397 // Generate one event
399 fDecayer->ForceDecay();
401 Float_t polar[3] = {0,0,0};
402 Float_t origin[3] = {0,0,0};
404 // converts from mm/c to s
405 const Float_t kconv=0.001/2.999792458e8;
415 // Set collision vertex position
416 if (fVertexSmear == kPerEvent) Vertex();
425 // Switch hadronisation off
427 fPythia->SetMSTJ(1, 0);
429 // Either produce new event or read partons from file
431 if (!fReadFromFile) {
437 fNpartons = fPythia->GetN();
439 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
440 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
442 LoadEvent(fRL->Stack(), 0 , 1);
447 // Run quenching routine
451 } else if (fQuench == 2){
452 fPythia->Pyquen(208., 0, 0.);
455 // Switch hadronisation on
457 fPythia->SetMSTJ(1, 1);
459 // .. and perform hadronisation
460 // printf("Calling hadronisation %d\n", fPythia->GetN());
463 fPythia->ImportParticles(fParticles,"All");
471 Int_t np = fParticles->GetEntriesFast();
473 if (np == 0) continue;
477 Int_t* pParent = new Int_t[np];
478 Int_t* pSelected = new Int_t[np];
479 Int_t* trackIt = new Int_t[np];
480 for (i = 0; i < np; i++) {
486 Int_t nc = 0; // Total n. of selected particles
487 Int_t nParents = 0; // Selected parents
488 Int_t nTkbles = 0; // Trackable particles
489 if (fProcess != kPyMb && fProcess != kPyJets &&
490 fProcess != kPyDirectGamma &&
491 fProcess != kPyMbNonDiffr &&
492 fProcess != kPyMbMSEL1 &&
493 fProcess != kPyW && fProcess != kPyZ &&
494 fProcess != kPyCharmppMNRwmi && fProcess != kPyBeautyppMNRwmi) {
496 for (i = 0; i < np; i++) {
497 TParticle* iparticle = (TParticle *) fParticles->At(i);
498 Int_t ks = iparticle->GetStatusCode();
499 kf = CheckPDGCode(iparticle->GetPdgCode());
500 // No initial state partons
501 if (ks==21) continue;
503 // Heavy Flavor Selection
510 if (kfl > 100000) kfl %= 100000;
511 if (kfl > 10000) kfl %= 10000;
513 if (kfl > 10) kfl/=100;
515 if (kfl > 10) kfl/=10;
516 Int_t ipa = iparticle->GetFirstMother()-1;
519 // Establish mother daughter relation between heavy quarks and mesons
521 if (kf >= fFlavorSelect && kf <= 6) {
522 Int_t idau = iparticle->GetFirstDaughter() - 1;
524 TParticle* daughter = (TParticle *) fParticles->At(idau);
525 Int_t pdgD = daughter->GetPdgCode();
526 if (pdgD == 91 || pdgD == 92) {
527 Int_t jmin = daughter->GetFirstDaughter() - 1;
528 Int_t jmax = daughter->GetLastDaughter() - 1;
529 for (Int_t j = jmin; j <= jmax; j++)
530 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
531 } // is string or cluster
537 TParticle * mother = (TParticle *) fParticles->At(ipa);
538 kfMo = TMath::Abs(mother->GetPdgCode());
541 // What to keep in Stack?
542 Bool_t flavorOK = kFALSE;
543 Bool_t selectOK = kFALSE;
545 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
547 if (kfl > fFlavorSelect) {
551 if (kfl == fFlavorSelect) flavorOK = kTRUE;
553 switch (fStackFillOpt) {
554 case kFlavorSelection:
557 case kParentSelection:
558 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
561 if (flavorOK && selectOK) {
563 // Heavy flavor hadron or quark
565 // Kinematic seletion on final state heavy flavor mesons
566 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
571 if (ParentSelected(kf)) ++nParents; // Update parent count
572 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
574 // Kinematic seletion on decay products
575 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
576 && !KinematicSelection(iparticle, 1))
582 // Select if mother was selected and is not tracked
584 if (pSelected[ipa] &&
585 !trackIt[ipa] && // mother will be tracked ?
586 kfMo != 5 && // mother is b-quark, don't store fragments
587 kfMo != 4 && // mother is c-quark, don't store fragments
588 kf != 92) // don't store string
591 // Semi-stable or de-selected: diselect decay products:
594 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
596 Int_t ipF = iparticle->GetFirstDaughter();
597 Int_t ipL = iparticle->GetLastDaughter();
598 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
600 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
601 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
604 if (pSelected[i] == -1) pSelected[i] = 0;
605 if (!pSelected[i]) continue;
606 // Count quarks only if you did not include fragmentation
607 if (fFragmentation && kf <= 10) continue;
610 // Decision on tracking
613 // Track final state particle
614 if (ks == 1) trackIt[i] = 1;
615 // Track semi-stable particles
616 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
617 // Track particles selected by process if undecayed.
618 if (fForceDecay == kNoDecay) {
619 if (ParentSelected(kf)) trackIt[i] = 1;
621 if (ParentSelected(kf)) trackIt[i] = 0;
623 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
627 } // particle selection loop
629 for (i = 0; i<np; i++) {
630 if (!pSelected[i]) continue;
631 TParticle * iparticle = (TParticle *) fParticles->At(i);
632 kf = CheckPDGCode(iparticle->GetPdgCode());
633 Int_t ks = iparticle->GetStatusCode();
634 p[0] = iparticle->Px();
635 p[1] = iparticle->Py();
636 p[2] = iparticle->Pz();
637 p[3] = iparticle->Energy();
639 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
640 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
641 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
643 Float_t tof = kconv*iparticle->T();
644 Int_t ipa = iparticle->GetFirstMother()-1;
645 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
647 PushTrack(fTrackIt*trackIt[i], iparent, kf,
648 p[0], p[1], p[2], p[3],
649 origin[0], origin[1], origin[2], tof,
650 polar[0], polar[1], polar[2],
651 kPPrimary, nt, 1., ks);
662 if (pParent) delete[] pParent;
663 if (pSelected) delete[] pSelected;
664 if (trackIt) delete[] trackIt;
667 switch (fCountMode) {
669 // printf(" Count all \n");
673 // printf(" Count parents \n");
676 case kCountTrackables:
677 // printf(" Count trackable \n");
681 if (jev >= fNpart || fNpart == -1) {
682 fKineBias=Float_t(fNpart)/Float_t(fTrials);
684 fQ += fPythia->GetVINT(51);
685 fX1 += fPythia->GetVINT(41);
686 fX2 += fPythia->GetVINT(42);
687 fTrialsRun += fTrials;
694 SetHighWaterMark(nt);
695 // adjust weight due to kinematic selection
698 fXsection=fPythia->GetPARI(1);
701 Int_t AliGenPythia::GenerateMB()
704 // Min Bias selection and other global selections
706 Int_t i, kf, nt, iparent;
709 Float_t polar[3] = {0,0,0};
710 Float_t origin[3] = {0,0,0};
711 // converts from mm/c to s
712 const Float_t kconv=0.001/2.999792458e8;
716 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
720 Int_t* pParent = new Int_t[np];
721 for (i=0; i< np; i++) pParent[i] = -1;
722 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
723 TParticle* jet1 = (TParticle *) fParticles->At(6);
724 TParticle* jet2 = (TParticle *) fParticles->At(7);
725 if (!CheckTrigger(jet1, jet2)) return 0;
728 if (fTriggerParticle) {
729 Bool_t triggered = kFALSE;
730 for (i = 0; i < np; i++) {
731 TParticle * iparticle = (TParticle *) fParticles->At(i);
732 kf = CheckPDGCode(iparticle->GetPdgCode());
733 if (kf != fTriggerParticle) continue;
734 if (iparticle->Pt() == 0.) continue;
735 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
739 if (!triggered) return 0;
743 // Check if there is a ccbar or bbbar pair with at least one of the two
744 // in fYMin < y < fYMax
745 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
747 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
750 for(i=0; i<np; i++) {
751 hvq = (TParticle*)fParticles->At(i);
752 pdgQ = hvq->GetPdgCode();
753 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
754 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
755 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
756 (hvq->Energy()-hvq->Pz()+1.e-13));
757 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
759 if (!theQ || !theQbar || !inYcut) {
760 if (pParent) delete[] pParent;
765 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
766 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
767 && (fCutOnChild == 1) ) {
768 if ( !CheckKinematicsOnChild() ) {
769 if (pParent) delete[] pParent;
775 for (i = 0; i < np; i++) {
777 TParticle * iparticle = (TParticle *) fParticles->At(i);
778 kf = CheckPDGCode(iparticle->GetPdgCode());
779 Int_t ks = iparticle->GetStatusCode();
780 Int_t km = iparticle->GetFirstMother();
781 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
783 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
785 if (ks == 1) trackIt = 1;
786 Int_t ipa = iparticle->GetFirstMother()-1;
788 iparent = (ipa > -1) ? pParent[ipa] : -1;
791 // store track information
792 p[0] = iparticle->Px();
793 p[1] = iparticle->Py();
794 p[2] = iparticle->Pz();
795 p[3] = iparticle->Energy();
798 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
799 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
800 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
802 Float_t tof = fEventTime + kconv * iparticle->T();
804 PushTrack(fTrackIt*trackIt, iparent, kf,
805 p[0], p[1], p[2], p[3],
806 origin[0], origin[1], origin[2], tof,
807 polar[0], polar[1], polar[2],
808 kPPrimary, nt, 1., ks);
810 // Special Treatment to store color-flow
812 if (ks == 3 || ks == 13 || ks == 14) {
813 TParticle* particle = 0;
815 particle = fStack->Particle(nt);
817 particle = gAlice->Stack()->Particle(nt);
819 particle->SetFirstDaughter(fPythia->GetK(2, i));
820 particle->SetLastDaughter(fPythia->GetK(3, i));
825 SetHighWaterMark(nt);
830 if (pParent) delete[] pParent;
836 void AliGenPythia::FinishRun()
838 // Print x-section summary
847 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
848 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
851 void AliGenPythia::AdjustWeights()
853 // Adjust the weights after generation of all events
857 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
858 for (Int_t i=0; i<ntrack; i++) {
859 part= gAlice->GetMCApp()->Particle(i);
860 part->SetWeight(part->GetWeight()*fKineBias);
865 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
867 // Treat protons as inside nuclei with mass numbers a1 and a2
875 void AliGenPythia::MakeHeader()
878 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
879 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
882 // Builds the event header, to be called after each event
883 if (fHeader) delete fHeader;
884 fHeader = new AliGenPythiaEventHeader("Pythia");
887 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
890 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
893 fHeader->SetPrimaryVertex(fVertex);
895 // Jets that have triggered
897 if (fProcess == kPyJets)
901 GetJets(njet, ntrig, jets);
904 for (Int_t i = 0; i < ntrig; i++) {
905 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
910 // Copy relevant information from external header, if present.
915 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
916 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
918 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
921 exHeader->TriggerJet(i, uqJet);
922 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
926 // Store quenching parameters
933 fPythia->GetQuenchingParameters(xp, yp, z);
936 Double_t r1 = PARIMP.rb1;
937 Double_t r2 = PARIMP.rb2;
938 Double_t b = PARIMP.b1;
939 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
940 Double_t phi = PARIMP.psib1;
941 xp = r * TMath::Cos(phi);
942 yp = r * TMath::Sin(phi);
945 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
946 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
950 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
957 void AliGenPythia::AddHeader(AliGenEventHeader* header)
959 // Add header to container or runloader
961 fContainer->AddHeader(header);
963 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
968 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
970 // Check the kinematic trigger condition
973 eta[0] = jet1->Eta();
974 eta[1] = jet2->Eta();
976 phi[0] = jet1->Phi();
977 phi[1] = jet2->Phi();
979 pdg[0] = jet1->GetPdgCode();
980 pdg[1] = jet2->GetPdgCode();
981 Bool_t triggered = kFALSE;
983 if (fProcess == kPyJets) {
988 // Use Pythia clustering on parton level to determine jet axis
990 GetJets(njets, ntrig, jets);
992 if (ntrig) triggered = kTRUE;
997 if (pdg[0] == kGamma) {
1001 //Check eta range first...
1002 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1003 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1005 //Eta is okay, now check phi range
1006 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1007 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1017 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1018 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1020 Bool_t checking = kFALSE;
1021 Int_t j, kcode, ks, km;
1022 Int_t nPartAcc = 0; //number of particles in the acceptance range
1023 Int_t numberOfAcceptedParticles = 1;
1024 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1025 Int_t npart = fParticles->GetEntriesFast();
1027 for (j = 0; j<npart; j++) {
1028 TParticle * jparticle = (TParticle *) fParticles->At(j);
1029 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1030 ks = jparticle->GetStatusCode();
1031 km = jparticle->GetFirstMother();
1033 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1036 if( numberOfAcceptedParticles <= nPartAcc){
1046 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1048 // Assignment operator
1053 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1056 // Load event into Pythia Common Block
1059 Int_t npart = stack -> GetNprimary();
1063 (fPythia->GetPyjets())->N = npart;
1065 n0 = (fPythia->GetPyjets())->N;
1066 (fPythia->GetPyjets())->N = n0 + npart;
1070 for (Int_t part = 0; part < npart; part++) {
1071 TParticle *MPart = stack->Particle(part);
1073 Int_t kf = MPart->GetPdgCode();
1074 Int_t ks = MPart->GetStatusCode();
1075 Int_t idf = MPart->GetFirstDaughter();
1076 Int_t idl = MPart->GetLastDaughter();
1079 if (ks == 11 || ks == 12) {
1086 Float_t px = MPart->Px();
1087 Float_t py = MPart->Py();
1088 Float_t pz = MPart->Pz();
1089 Float_t e = MPart->Energy();
1090 Float_t m = MPart->GetCalcMass();
1093 (fPythia->GetPyjets())->P[0][part+n0] = px;
1094 (fPythia->GetPyjets())->P[1][part+n0] = py;
1095 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1096 (fPythia->GetPyjets())->P[3][part+n0] = e;
1097 (fPythia->GetPyjets())->P[4][part+n0] = m;
1099 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1100 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1101 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1102 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1103 (fPythia->GetPyjets())->K[2][part+n0] = MPart->GetFirstMother() + 1;
1108 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1111 // Calls the Pythia jet finding algorithm to find jets in the current event
1116 Int_t n = fPythia->GetN();
1120 fPythia->Pycell(njets);
1122 for (i = 0; i < njets; i++) {
1123 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1124 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1125 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1126 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1137 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1140 // Calls the Pythia clustering algorithm to find jets in the current event
1142 Int_t n = fPythia->GetN();
1145 if (fJetReconstruction == kCluster) {
1147 // Configure cluster algorithm
1149 fPythia->SetPARU(43, 2.);
1150 fPythia->SetMSTU(41, 1);
1152 // Call cluster algorithm
1154 fPythia->Pyclus(nJets);
1156 // Loading jets from common block
1162 fPythia->Pycell(nJets);
1166 for (i = 0; i < nJets; i++) {
1167 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1168 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1169 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1170 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1171 Float_t pt = TMath::Sqrt(px * px + py * py);
1172 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1173 Float_t theta = TMath::ATan2(pt,pz);
1174 Float_t et = e * TMath::Sin(theta);
1175 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1177 eta > fEtaMinJet && eta < fEtaMaxJet &&
1178 phi > fPhiMinJet && phi < fPhiMaxJet &&
1179 et > fEtMinJet && et < fEtMaxJet
1182 jets[0][nJetsTrig] = px;
1183 jets[1][nJetsTrig] = py;
1184 jets[2][nJetsTrig] = pz;
1185 jets[3][nJetsTrig] = e;
1187 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1189 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1194 void AliGenPythia::GetSubEventTime()
1196 // Calculates time of the next subevent
1199 TArrayF &array = *fEventsTime;
1200 fEventTime = array[fCurSubEvent++];
1202 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1207 void AliGenPythia::Streamer(TBuffer &R__b)
1209 // Stream an object of class AliGenPythia.
1211 if (R__b.IsReading()) {
1212 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1213 AliGenerator::Streamer(R__b);
1214 R__b >> (Int_t&)fProcess;
1215 R__b >> (Int_t&)fStrucFunc;
1216 R__b >> (Int_t&)fForceDecay;
1220 fParentSelect.Streamer(R__b);
1221 fChildSelect.Streamer(R__b);
1223 // (AliPythia::Instance())->Streamer(R__b);
1226 // if (fDecayer) fDecayer->Streamer(R__b);
1228 R__b.WriteVersion(AliGenPythia::IsA());
1229 AliGenerator::Streamer(R__b);
1230 R__b << (Int_t)fProcess;
1231 R__b << (Int_t)fStrucFunc;
1232 R__b << (Int_t)fForceDecay;
1236 fParentSelect.Streamer(R__b);
1237 fChildSelect.Streamer(R__b);
1242 // fDecayer->Streamer(R__b);