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)
49 AliGenPythia::AliGenPythia():
81 fDecayer(new AliDecayerPythia()),
89 fPhiMaxJet(2.* TMath::Pi()),
90 fJetReconstruction(kCell),
94 fPhiMaxGamma(2. * TMath::Pi()),
100 fPycellMinEtJet(10.),
101 fPycellMaxRadius(1.),
102 fStackFillOpt(kFlavorSelection),
104 fFragmentation(kTRUE),
110 fCountMode(kCountAll),
114 fFragPhotonInCalo(kFALSE),
118 fFragPhotonOrPi0MinPt(0),
127 // Default Constructor
129 if (!AliPythiaRndm::GetPythiaRandom())
130 AliPythiaRndm::SetPythiaRandom(GetRandom());
133 AliGenPythia::AliGenPythia(Int_t npart)
145 fInteractionRate(0.),
159 fHadronisation(kTRUE),
161 fReadFromFile(kFALSE),
165 fDecayer(new AliDecayerPythia()),
166 fDebugEventFirst(-1),
173 fPhiMaxJet(2.* TMath::Pi()),
174 fJetReconstruction(kCell),
178 fPhiMaxGamma(2. * TMath::Pi()),
182 fPycellThreshold(0.),
184 fPycellMinEtJet(10.),
185 fPycellMaxRadius(1.),
186 fStackFillOpt(kFlavorSelection),
188 fFragmentation(kTRUE),
194 fCountMode(kCountAll),
198 fFragPhotonInCalo(kFALSE),
202 fFragPhotonOrPi0MinPt(0),
210 // default charm production at 5. 5 TeV
212 // structure function GRVHO
215 fTitle= "Particle Generator using PYTHIA";
217 // Set random number generator
218 if (!AliPythiaRndm::GetPythiaRandom())
219 AliPythiaRndm::SetPythiaRandom(GetRandom());
220 fParticles = new TClonesArray("TParticle",1000);
224 AliGenPythia::~AliGenPythia()
227 if(fEventsTime) delete fEventsTime;
230 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
232 // Generate pileup using user specified rate
233 fInteractionRate = rate;
234 fTimeWindow = timewindow;
238 void AliGenPythia::GeneratePileup()
240 // Generate sub events time for pileup
242 if(fInteractionRate == 0.) {
243 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
247 Int_t npart = NumberParticles();
249 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
253 if(fEventsTime) delete fEventsTime;
254 fEventsTime = new TArrayF(npart);
255 TArrayF &array = *fEventsTime;
256 for(Int_t ipart = 0; ipart < npart; ipart++)
259 Float_t eventtime = 0.;
262 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
263 if(eventtime > fTimeWindow) break;
264 array.Set(array.GetSize()+1);
265 array[array.GetSize()-1] = eventtime;
271 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
272 if(TMath::Abs(eventtime) > fTimeWindow) break;
273 array.Set(array.GetSize()+1);
274 array[array.GetSize()-1] = eventtime;
277 SetNumberParticles(fEventsTime->GetSize());
280 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
281 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
283 // Set pycell parameters
284 fPycellEtaMax = etamax;
287 fPycellThreshold = thresh;
288 fPycellEtSeed = etseed;
289 fPycellMinEtJet = minet;
290 fPycellMaxRadius = r;
295 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
297 // Set a range of event numbers, for which a table
298 // of generated particle will be printed
299 fDebugEventFirst = eventFirst;
300 fDebugEventLast = eventLast;
301 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
304 void AliGenPythia::Init()
308 SetMC(AliPythia::Instance());
309 fPythia=(AliPythia*) fMCEvGen;
312 fParentWeight=1./Float_t(fNpart);
314 // Forward Paramters to the AliPythia object
315 fDecayer->SetForceDecay(fForceDecay);
319 fPythia->SetCKIN(3,fPtHardMin);
320 fPythia->SetCKIN(4,fPtHardMax);
321 fPythia->SetCKIN(7,fYHardMin);
322 fPythia->SetCKIN(8,fYHardMax);
324 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
326 if (fFragmentation) {
327 fPythia->SetMSTP(111,1);
329 fPythia->SetMSTP(111,0);
333 // initial state radiation
334 fPythia->SetMSTP(61,fGinit);
335 // final state radiation
336 fPythia->SetMSTP(71,fGfinal);
339 fPythia->SetMSTP(91,1);
340 fPythia->SetPARP(91,fPtKick);
342 fPythia->SetMSTP(91,0);
347 fRL = AliRunLoader::Open(fFileName, "Partons");
348 fRL->LoadKinematics();
353 // Switch off Heavy Flavors on request
355 fPythia->SetMSTP(58, 3);
356 fPythia->SetMSTJ(45, 3);
357 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
360 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
362 // Parent and Children Selection
365 case kPyOldUEQ2ordered:
366 case kPyOldUEQ2ordered2:
370 case kPyCharmUnforced:
371 case kPyCharmPbPbMNR:
374 case kPyCharmppMNRwmi:
375 fParentSelect[0] = 411;
376 fParentSelect[1] = 421;
377 fParentSelect[2] = 431;
378 fParentSelect[3] = 4122;
384 fParentSelect[0] = 421;
387 case kPyDPlusPbPbMNR:
390 fParentSelect[0] = 411;
393 case kPyDPlusStrangePbPbMNR:
394 case kPyDPlusStrangepPbMNR:
395 case kPyDPlusStrangeppMNR:
396 fParentSelect[0] = 431;
400 case kPyBeautyPbPbMNR:
401 case kPyBeautypPbMNR:
403 case kPyBeautyppMNRwmi:
404 fParentSelect[0]= 511;
405 fParentSelect[1]= 521;
406 fParentSelect[2]= 531;
407 fParentSelect[3]= 5122;
408 fParentSelect[4]= 5132;
409 fParentSelect[5]= 5232;
410 fParentSelect[6]= 5332;
413 case kPyBeautyUnforced:
414 fParentSelect[0] = 511;
415 fParentSelect[1] = 521;
416 fParentSelect[2] = 531;
417 fParentSelect[3] = 5122;
418 fParentSelect[4] = 5132;
419 fParentSelect[5] = 5232;
420 fParentSelect[6] = 5332;
425 fParentSelect[0] = 443;
440 // JetFinder for Trigger
442 // Configure detector (EMCAL like)
444 fPythia->SetPARU(51, fPycellEtaMax);
445 fPythia->SetMSTU(51, fPycellNEta);
446 fPythia->SetMSTU(52, fPycellNPhi);
448 // Configure Jet Finder
450 fPythia->SetPARU(58, fPycellThreshold);
451 fPythia->SetPARU(52, fPycellEtSeed);
452 fPythia->SetPARU(53, fPycellMinEtJet);
453 fPythia->SetPARU(54, fPycellMaxRadius);
454 fPythia->SetMSTU(54, 2);
456 // This counts the total number of calls to Pyevnt() per run.
471 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
475 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
477 fPythia->SetPARJ(200, 0.0);
480 // Nestor's change of the splittings
481 fPythia->SetPARJ(200, 0.8);
482 fPythia->SetMSTJ(41, 1); // QCD radiation only
483 fPythia->SetMSTJ(42, 2); // angular ordering
484 fPythia->SetMSTJ(44, 2); // option to run alpha_s
485 fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
486 fPythia->SetMSTJ(50, 0); // No coherence in first branching
487 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
491 void AliGenPythia::Generate()
493 // Generate one event
495 fDecayer->ForceDecay();
497 Float_t polar[3] = {0,0,0};
498 Float_t origin[3] = {0,0,0};
500 // converts from mm/c to s
501 const Float_t kconv=0.001/2.999792458e8;
511 // Set collision vertex position
512 if (fVertexSmear == kPerEvent) Vertex();
521 // Switch hadronisation off
523 fPythia->SetMSTJ(1, 0);
525 // Either produce new event or read partons from file
527 if (!fReadFromFile) {
533 fNpartons = fPythia->GetN();
535 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
536 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
538 LoadEvent(fRL->Stack(), 0 , 1);
543 // Run quenching routine
547 } else if (fQuench == 2){
548 fPythia->Pyquen(208., 0, 0.);
549 } else if (fQuench == 3) {
550 // Quenching is via multiplicative correction of the splittings
554 // Switch hadronisation on
556 fPythia->SetMSTJ(1, 1);
558 // .. and perform hadronisation
559 // printf("Calling hadronisation %d\n", fPythia->GetN());
562 fPythia->ImportParticles(fParticles,"All");
570 Int_t np = fParticles->GetEntriesFast();
572 if (np == 0) continue;
576 Int_t* pParent = new Int_t[np];
577 Int_t* pSelected = new Int_t[np];
578 Int_t* trackIt = new Int_t[np];
579 for (i = 0; i < np; i++) {
585 Int_t nc = 0; // Total n. of selected particles
586 Int_t nParents = 0; // Selected parents
587 Int_t nTkbles = 0; // Trackable particles
588 if (fProcess != kPyMb && fProcess != kPyJets &&
589 fProcess != kPyDirectGamma &&
590 fProcess != kPyMbNonDiffr &&
591 fProcess != kPyMbMSEL1 &&
592 fProcess != kPyW && fProcess != kPyZ &&
593 fProcess != kPyCharmppMNRwmi && fProcess != kPyBeautyppMNRwmi) {
595 for (i = 0; i < np; i++) {
596 TParticle* iparticle = (TParticle *) fParticles->At(i);
597 Int_t ks = iparticle->GetStatusCode();
598 kf = CheckPDGCode(iparticle->GetPdgCode());
599 // No initial state partons
600 if (ks==21) continue;
602 // Heavy Flavor Selection
609 if (kfl > 100000) kfl %= 100000;
610 if (kfl > 10000) kfl %= 10000;
612 if (kfl > 10) kfl/=100;
614 if (kfl > 10) kfl/=10;
615 Int_t ipa = iparticle->GetFirstMother()-1;
618 // Establish mother daughter relation between heavy quarks and mesons
620 if (kf >= fFlavorSelect && kf <= 6) {
621 Int_t idau = iparticle->GetFirstDaughter() - 1;
623 TParticle* daughter = (TParticle *) fParticles->At(idau);
624 Int_t pdgD = daughter->GetPdgCode();
625 if (pdgD == 91 || pdgD == 92) {
626 Int_t jmin = daughter->GetFirstDaughter() - 1;
627 Int_t jmax = daughter->GetLastDaughter() - 1;
628 for (Int_t j = jmin; j <= jmax; j++)
629 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
630 } // is string or cluster
636 TParticle * mother = (TParticle *) fParticles->At(ipa);
637 kfMo = TMath::Abs(mother->GetPdgCode());
640 // What to keep in Stack?
641 Bool_t flavorOK = kFALSE;
642 Bool_t selectOK = kFALSE;
644 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
646 if (kfl > fFlavorSelect) {
650 if (kfl == fFlavorSelect) flavorOK = kTRUE;
652 switch (fStackFillOpt) {
653 case kFlavorSelection:
656 case kParentSelection:
657 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
660 if (flavorOK && selectOK) {
662 // Heavy flavor hadron or quark
664 // Kinematic seletion on final state heavy flavor mesons
665 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
670 if (ParentSelected(kf)) ++nParents; // Update parent count
671 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
673 // Kinematic seletion on decay products
674 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
675 && !KinematicSelection(iparticle, 1))
681 // Select if mother was selected and is not tracked
683 if (pSelected[ipa] &&
684 !trackIt[ipa] && // mother will be tracked ?
685 kfMo != 5 && // mother is b-quark, don't store fragments
686 kfMo != 4 && // mother is c-quark, don't store fragments
687 kf != 92) // don't store string
690 // Semi-stable or de-selected: diselect decay products:
693 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
695 Int_t ipF = iparticle->GetFirstDaughter();
696 Int_t ipL = iparticle->GetLastDaughter();
697 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
699 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
700 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
703 if (pSelected[i] == -1) pSelected[i] = 0;
704 if (!pSelected[i]) continue;
705 // Count quarks only if you did not include fragmentation
706 if (fFragmentation && kf <= 10) continue;
709 // Decision on tracking
712 // Track final state particle
713 if (ks == 1) trackIt[i] = 1;
714 // Track semi-stable particles
715 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
716 // Track particles selected by process if undecayed.
717 if (fForceDecay == kNoDecay) {
718 if (ParentSelected(kf)) trackIt[i] = 1;
720 if (ParentSelected(kf)) trackIt[i] = 0;
722 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
726 } // particle selection loop
728 for (i = 0; i<np; i++) {
729 if (!pSelected[i]) continue;
730 TParticle * iparticle = (TParticle *) fParticles->At(i);
731 kf = CheckPDGCode(iparticle->GetPdgCode());
732 Int_t ks = iparticle->GetStatusCode();
733 p[0] = iparticle->Px();
734 p[1] = iparticle->Py();
735 p[2] = iparticle->Pz();
736 p[3] = iparticle->Energy();
738 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
739 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
740 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
742 Float_t tof = kconv*iparticle->T();
743 Int_t ipa = iparticle->GetFirstMother()-1;
744 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
746 PushTrack(fTrackIt*trackIt[i], iparent, kf,
747 p[0], p[1], p[2], p[3],
748 origin[0], origin[1], origin[2], tof,
749 polar[0], polar[1], polar[2],
750 kPPrimary, nt, 1., ks);
766 switch (fCountMode) {
768 // printf(" Count all \n");
772 // printf(" Count parents \n");
775 case kCountTrackables:
776 // printf(" Count trackable \n");
780 if (jev >= fNpart || fNpart == -1) {
781 fKineBias=Float_t(fNpart)/Float_t(fTrials);
783 fQ += fPythia->GetVINT(51);
784 fX1 += fPythia->GetVINT(41);
785 fX2 += fPythia->GetVINT(42);
786 fTrialsRun += fTrials;
793 SetHighWaterMark(nt);
794 // adjust weight due to kinematic selection
797 fXsection=fPythia->GetPARI(1);
800 Int_t AliGenPythia::GenerateMB()
803 // Min Bias selection and other global selections
805 Int_t i, kf, nt, iparent;
808 Float_t polar[3] = {0,0,0};
809 Float_t origin[3] = {0,0,0};
810 // converts from mm/c to s
811 const Float_t kconv=0.001/2.999792458e8;
815 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
819 Int_t* pParent = new Int_t[np];
820 for (i=0; i< np; i++) pParent[i] = -1;
821 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
822 TParticle* jet1 = (TParticle *) fParticles->At(6);
823 TParticle* jet2 = (TParticle *) fParticles->At(7);
824 if (!CheckTrigger(jet1, jet2)) {
830 // Select jets with fragmentation photon or pi0 going to PHOS or EMCAL
831 if (fProcess == kPyJets && (fFragPhotonInCalo || fPi0InCalo) ) {
836 if (fFragPhotonInCalo) pdg = 22 ; // Photon
837 else if (fPi0InCalo) pdg = 111 ; // Pi0
839 for (i=0; i< np; i++) {
840 TParticle* iparticle = (TParticle *) fParticles->At(i);
841 if(iparticle->GetStatusCode()==1 && iparticle->GetPdgCode()==pdg &&
842 iparticle->Pt() > fFragPhotonOrPi0MinPt){
843 Int_t imother = iparticle->GetFirstMother() - 1;
844 TParticle* pmother = (TParticle *) fParticles->At(imother);
846 (pdg == 22 && pmother->GetStatusCode() != 11))//No photon from hadron decay
848 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
849 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
850 if((fCheckEMCAL && IsInEMCAL(phi,eta)) ||
851 (fCheckPHOS && IsInPHOS(phi,eta)) )
860 if (fTriggerParticle) {
861 Bool_t triggered = kFALSE;
862 for (i = 0; i < np; i++) {
863 TParticle * iparticle = (TParticle *) fParticles->At(i);
864 kf = CheckPDGCode(iparticle->GetPdgCode());
865 if (kf != fTriggerParticle) continue;
866 if (iparticle->Pt() == 0.) continue;
867 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
878 // Check if there is a ccbar or bbbar pair with at least one of the two
879 // in fYMin < y < fYMax
880 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
882 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
885 for(i=0; i<np; i++) {
886 hvq = (TParticle*)fParticles->At(i);
887 pdgQ = hvq->GetPdgCode();
888 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
889 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
890 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
891 (hvq->Energy()-hvq->Pz()+1.e-13));
892 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
894 if (!theQ || !theQbar || !inYcut) {
900 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
901 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
902 && (fCutOnChild == 1) ) {
903 if ( !CheckKinematicsOnChild() ) {
910 for (i = 0; i < np; i++) {
912 TParticle * iparticle = (TParticle *) fParticles->At(i);
913 kf = CheckPDGCode(iparticle->GetPdgCode());
914 Int_t ks = iparticle->GetStatusCode();
915 Int_t km = iparticle->GetFirstMother();
916 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
918 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
920 if (ks == 1) trackIt = 1;
921 Int_t ipa = iparticle->GetFirstMother()-1;
923 iparent = (ipa > -1) ? pParent[ipa] : -1;
926 // store track information
927 p[0] = iparticle->Px();
928 p[1] = iparticle->Py();
929 p[2] = iparticle->Pz();
930 p[3] = iparticle->Energy();
933 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
934 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
935 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
937 Float_t tof = fEventTime + kconv * iparticle->T();
939 PushTrack(fTrackIt*trackIt, iparent, kf,
940 p[0], p[1], p[2], p[3],
941 origin[0], origin[1], origin[2], tof,
942 polar[0], polar[1], polar[2],
943 kPPrimary, nt, 1., ks);
945 // Special Treatment to store color-flow
947 if (ks == 3 || ks == 13 || ks == 14) {
948 TParticle* particle = 0;
950 particle = fStack->Particle(nt);
952 particle = gAlice->Stack()->Particle(nt);
954 particle->SetFirstDaughter(fPythia->GetK(2, i));
955 particle->SetLastDaughter(fPythia->GetK(3, i));
960 SetHighWaterMark(nt);
971 void AliGenPythia::FinishRun()
973 // Print x-section summary
982 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
983 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
986 void AliGenPythia::AdjustWeights() const
988 // Adjust the weights after generation of all events
992 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
993 for (Int_t i=0; i<ntrack; i++) {
994 part= gAlice->GetMCApp()->Particle(i);
995 part->SetWeight(part->GetWeight()*fKineBias);
1000 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
1002 // Treat protons as inside nuclei with mass numbers a1 and a2
1010 void AliGenPythia::MakeHeader()
1013 // Make header for the simulated event
1016 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1017 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1020 // Builds the event header, to be called after each event
1021 if (fHeader) delete fHeader;
1022 fHeader = new AliGenPythiaEventHeader("Pythia");
1025 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1028 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1031 fHeader->SetPrimaryVertex(fVertex);
1033 // Jets that have triggered
1035 if (fProcess == kPyJets)
1038 Float_t jets[4][10];
1039 GetJets(njet, ntrig, jets);
1042 for (Int_t i = 0; i < ntrig; i++) {
1043 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1048 // Copy relevant information from external header, if present.
1053 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1054 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1056 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1059 exHeader->TriggerJet(i, uqJet);
1060 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1064 // Store quenching parameters
1071 fPythia->GetQuenchingParameters(xp, yp, z);
1074 Double_t r1 = PARIMP.rb1;
1075 Double_t r2 = PARIMP.rb2;
1076 Double_t b = PARIMP.b1;
1077 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1078 Double_t phi = PARIMP.psib1;
1079 xp = r * TMath::Cos(phi);
1080 yp = r * TMath::Sin(phi);
1083 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1084 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1088 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
1095 void AliGenPythia::AddHeader(AliGenEventHeader* header)
1097 // Add header to container or runloader
1099 fContainer->AddHeader(header);
1101 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
1106 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1108 // Check the kinematic trigger condition
1111 eta[0] = jet1->Eta();
1112 eta[1] = jet2->Eta();
1114 phi[0] = jet1->Phi();
1115 phi[1] = jet2->Phi();
1117 pdg[0] = jet1->GetPdgCode();
1118 pdg[1] = jet2->GetPdgCode();
1119 Bool_t triggered = kFALSE;
1121 if (fProcess == kPyJets) {
1124 Float_t jets[4][10];
1126 // Use Pythia clustering on parton level to determine jet axis
1128 GetJets(njets, ntrig, jets);
1130 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1135 if (pdg[0] == kGamma) {
1139 //Check eta range first...
1140 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1141 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1143 //Eta is okay, now check phi range
1144 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1145 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1156 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1158 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1160 Bool_t checking = kFALSE;
1161 Int_t j, kcode, ks, km;
1162 Int_t nPartAcc = 0; //number of particles in the acceptance range
1163 Int_t numberOfAcceptedParticles = 1;
1164 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1165 Int_t npart = fParticles->GetEntriesFast();
1167 for (j = 0; j<npart; j++) {
1168 TParticle * jparticle = (TParticle *) fParticles->At(j);
1169 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1170 ks = jparticle->GetStatusCode();
1171 km = jparticle->GetFirstMother();
1173 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1176 if( numberOfAcceptedParticles <= nPartAcc){
1185 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1188 // Load event into Pythia Common Block
1191 Int_t npart = stack -> GetNprimary();
1195 (fPythia->GetPyjets())->N = npart;
1197 n0 = (fPythia->GetPyjets())->N;
1198 (fPythia->GetPyjets())->N = n0 + npart;
1202 for (Int_t part = 0; part < npart; part++) {
1203 TParticle *mPart = stack->Particle(part);
1205 Int_t kf = mPart->GetPdgCode();
1206 Int_t ks = mPart->GetStatusCode();
1207 Int_t idf = mPart->GetFirstDaughter();
1208 Int_t idl = mPart->GetLastDaughter();
1211 if (ks == 11 || ks == 12) {
1218 Float_t px = mPart->Px();
1219 Float_t py = mPart->Py();
1220 Float_t pz = mPart->Pz();
1221 Float_t e = mPart->Energy();
1222 Float_t m = mPart->GetCalcMass();
1225 (fPythia->GetPyjets())->P[0][part+n0] = px;
1226 (fPythia->GetPyjets())->P[1][part+n0] = py;
1227 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1228 (fPythia->GetPyjets())->P[3][part+n0] = e;
1229 (fPythia->GetPyjets())->P[4][part+n0] = m;
1231 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1232 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1233 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1234 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1235 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1240 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1243 // Calls the Pythia jet finding algorithm to find jets in the current event
1248 Int_t n = fPythia->GetN();
1252 fPythia->Pycell(njets);
1254 for (i = 0; i < njets; i++) {
1255 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1256 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1257 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1258 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1269 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1272 // Calls the Pythia clustering algorithm to find jets in the current event
1274 Int_t n = fPythia->GetN();
1277 if (fJetReconstruction == kCluster) {
1279 // Configure cluster algorithm
1281 fPythia->SetPARU(43, 2.);
1282 fPythia->SetMSTU(41, 1);
1284 // Call cluster algorithm
1286 fPythia->Pyclus(nJets);
1288 // Loading jets from common block
1294 fPythia->Pycell(nJets);
1298 for (i = 0; i < nJets; i++) {
1299 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1300 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1301 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1302 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1303 Float_t pt = TMath::Sqrt(px * px + py * py);
1304 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1305 Float_t theta = TMath::ATan2(pt,pz);
1306 Float_t et = e * TMath::Sin(theta);
1307 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1309 eta > fEtaMinJet && eta < fEtaMaxJet &&
1310 phi > fPhiMinJet && phi < fPhiMaxJet &&
1311 et > fEtMinJet && et < fEtMaxJet
1314 jets[0][nJetsTrig] = px;
1315 jets[1][nJetsTrig] = py;
1316 jets[2][nJetsTrig] = pz;
1317 jets[3][nJetsTrig] = e;
1319 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1321 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1326 void AliGenPythia::GetSubEventTime()
1328 // Calculates time of the next subevent
1331 TArrayF &array = *fEventsTime;
1332 fEventTime = array[fCurSubEvent++];
1334 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1338 Bool_t AliGenPythia::IsInEMCAL(Float_t phi, Float_t eta)
1340 // Is particle in EMCAL acceptance?
1341 // phi in degrees, etamin=-etamax
1342 if(phi > fEMCALMinPhi && phi < fEMCALMaxPhi &&
1349 Bool_t AliGenPythia::IsInPHOS(Float_t phi, Float_t eta)
1351 // Is particle in PHOS acceptance?
1352 // Acceptance slightly larger considered.
1353 // phi in degrees, etamin=-etamax
1354 if(phi > fPHOSMinPhi && phi < fPHOSMaxPhi &&
1364 void AliGenPythia::Streamer(TBuffer &R__b)
1366 // Stream an object of class AliGenPythia.
1368 if (R__b.IsReading()) {
1369 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1370 AliGenerator::Streamer(R__b);
1371 R__b >> (Int_t&)fProcess;
1372 R__b >> (Int_t&)fStrucFunc;
1373 R__b >> (Int_t&)fForceDecay;
1377 fParentSelect.Streamer(R__b);
1378 fChildSelect.Streamer(R__b);
1380 // (AliPythia::Instance())->Streamer(R__b);
1383 // if (fDecayer) fDecayer->Streamer(R__b);
1385 R__b.WriteVersion(AliGenPythia::IsA());
1386 AliGenerator::Streamer(R__b);
1387 R__b << (Int_t)fProcess;
1388 R__b << (Int_t)fStrucFunc;
1389 R__b << (Int_t)fForceDecay;
1393 fParentSelect.Streamer(R__b);
1394 fChildSelect.Streamer(R__b);
1399 // fDecayer->Streamer(R__b);