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(const AliGenPythia & Pythia)
236 fInteractionRate(0.),
250 fHadronisation(kTRUE),
252 fReadFromFile(kFALSE),
256 fDecayer(new AliDecayerPythia()),
257 fDebugEventFirst(-1),
264 fPhiMaxJet(2.* TMath::Pi()),
265 fJetReconstruction(kCell),
269 fPhiMaxGamma(2. * TMath::Pi()),
273 fPycellThreshold(0.),
275 fPycellMinEtJet(10.),
276 fPycellMaxRadius(1.),
277 fStackFillOpt(kFlavorSelection),
279 fFragmentation(kTRUE),
285 fCountMode(kCountAll),
289 fFragPhotonInCalo(kFALSE),
293 fFragPhotonOrPi0MinPt(0),
305 AliGenPythia::~AliGenPythia()
308 if(fEventsTime) delete fEventsTime;
311 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
313 // Generate pileup using user specified rate
314 fInteractionRate = rate;
315 fTimeWindow = timewindow;
319 void AliGenPythia::GeneratePileup()
321 // Generate sub events time for pileup
323 if(fInteractionRate == 0.) {
324 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
328 Int_t npart = NumberParticles();
330 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
334 if(fEventsTime) delete fEventsTime;
335 fEventsTime = new TArrayF(npart);
336 TArrayF &array = *fEventsTime;
337 for(Int_t ipart = 0; ipart < npart; ipart++)
340 Float_t eventtime = 0.;
343 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
344 if(eventtime > fTimeWindow) break;
345 array.Set(array.GetSize()+1);
346 array[array.GetSize()-1] = eventtime;
352 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
353 if(TMath::Abs(eventtime) > fTimeWindow) break;
354 array.Set(array.GetSize()+1);
355 array[array.GetSize()-1] = eventtime;
358 SetNumberParticles(fEventsTime->GetSize());
361 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
362 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
364 // Set pycell parameters
365 fPycellEtaMax = etamax;
368 fPycellThreshold = thresh;
369 fPycellEtSeed = etseed;
370 fPycellMinEtJet = minet;
371 fPycellMaxRadius = r;
376 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
378 // Set a range of event numbers, for which a table
379 // of generated particle will be printed
380 fDebugEventFirst = eventFirst;
381 fDebugEventLast = eventLast;
382 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
385 void AliGenPythia::Init()
389 SetMC(AliPythia::Instance());
390 fPythia=(AliPythia*) fMCEvGen;
393 fParentWeight=1./Float_t(fNpart);
395 // Forward Paramters to the AliPythia object
396 fDecayer->SetForceDecay(fForceDecay);
400 fPythia->SetCKIN(3,fPtHardMin);
401 fPythia->SetCKIN(4,fPtHardMax);
402 fPythia->SetCKIN(7,fYHardMin);
403 fPythia->SetCKIN(8,fYHardMax);
405 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
407 if (fFragmentation) {
408 fPythia->SetMSTP(111,1);
410 fPythia->SetMSTP(111,0);
414 // initial state radiation
415 fPythia->SetMSTP(61,fGinit);
416 // final state radiation
417 fPythia->SetMSTP(71,fGfinal);
420 fPythia->SetMSTP(91,1);
421 fPythia->SetPARP(91,fPtKick);
423 fPythia->SetMSTP(91,0);
428 fRL = AliRunLoader::Open(fFileName, "Partons");
429 fRL->LoadKinematics();
434 // Switch off Heavy Flavors on request
436 fPythia->SetMSTP(58, 3);
437 fPythia->SetMSTJ(45, 3);
438 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
441 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
443 // Parent and Children Selection
446 case kPyOldUEQ2ordered:
447 case kPyOldUEQ2ordered2:
451 case kPyCharmUnforced:
452 case kPyCharmPbPbMNR:
455 case kPyCharmppMNRwmi:
456 fParentSelect[0] = 411;
457 fParentSelect[1] = 421;
458 fParentSelect[2] = 431;
459 fParentSelect[3] = 4122;
465 fParentSelect[0] = 421;
468 case kPyDPlusPbPbMNR:
471 fParentSelect[0] = 411;
474 case kPyDPlusStrangePbPbMNR:
475 case kPyDPlusStrangepPbMNR:
476 case kPyDPlusStrangeppMNR:
477 fParentSelect[0] = 431;
481 case kPyBeautyPbPbMNR:
482 case kPyBeautypPbMNR:
484 case kPyBeautyppMNRwmi:
485 fParentSelect[0]= 511;
486 fParentSelect[1]= 521;
487 fParentSelect[2]= 531;
488 fParentSelect[3]= 5122;
489 fParentSelect[4]= 5132;
490 fParentSelect[5]= 5232;
491 fParentSelect[6]= 5332;
494 case kPyBeautyUnforced:
495 fParentSelect[0] = 511;
496 fParentSelect[1] = 521;
497 fParentSelect[2] = 531;
498 fParentSelect[3] = 5122;
499 fParentSelect[4] = 5132;
500 fParentSelect[5] = 5232;
501 fParentSelect[6] = 5332;
506 fParentSelect[0] = 443;
521 // JetFinder for Trigger
523 // Configure detector (EMCAL like)
525 fPythia->SetPARU(51, fPycellEtaMax);
526 fPythia->SetMSTU(51, fPycellNEta);
527 fPythia->SetMSTU(52, fPycellNPhi);
529 // Configure Jet Finder
531 fPythia->SetPARU(58, fPycellThreshold);
532 fPythia->SetPARU(52, fPycellEtSeed);
533 fPythia->SetPARU(53, fPycellMinEtJet);
534 fPythia->SetPARU(54, fPycellMaxRadius);
535 fPythia->SetMSTU(54, 2);
537 // This counts the total number of calls to Pyevnt() per run.
552 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
556 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
558 fPythia->SetPARJ(200, 0.0);
561 // Nestor's change of the splittings
562 fPythia->SetPARJ(200, 0.8);
563 fPythia->SetMSTJ(41, 1); // QCD radiation only
564 fPythia->SetMSTJ(42, 2); // angular ordering
565 fPythia->SetMSTJ(44, 2); // option to run alpha_s
566 fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
567 fPythia->SetMSTJ(50, 0); // No coherence in first branching
568 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
572 void AliGenPythia::Generate()
574 // Generate one event
576 fDecayer->ForceDecay();
578 Float_t polar[3] = {0,0,0};
579 Float_t origin[3] = {0,0,0};
581 // converts from mm/c to s
582 const Float_t kconv=0.001/2.999792458e8;
592 // Set collision vertex position
593 if (fVertexSmear == kPerEvent) Vertex();
602 // Switch hadronisation off
604 fPythia->SetMSTJ(1, 0);
606 // Either produce new event or read partons from file
608 if (!fReadFromFile) {
614 fNpartons = fPythia->GetN();
616 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
617 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
619 LoadEvent(fRL->Stack(), 0 , 1);
624 // Run quenching routine
628 } else if (fQuench == 2){
629 fPythia->Pyquen(208., 0, 0.);
630 } else if (fQuench == 3) {
631 // Quenching is via multiplicative correction of the splittings
635 // Switch hadronisation on
637 fPythia->SetMSTJ(1, 1);
639 // .. and perform hadronisation
640 // printf("Calling hadronisation %d\n", fPythia->GetN());
643 fPythia->ImportParticles(fParticles,"All");
651 Int_t np = fParticles->GetEntriesFast();
653 if (np == 0) continue;
657 Int_t* pParent = new Int_t[np];
658 Int_t* pSelected = new Int_t[np];
659 Int_t* trackIt = new Int_t[np];
660 for (i = 0; i < np; i++) {
666 Int_t nc = 0; // Total n. of selected particles
667 Int_t nParents = 0; // Selected parents
668 Int_t nTkbles = 0; // Trackable particles
669 if (fProcess != kPyMb && fProcess != kPyJets &&
670 fProcess != kPyDirectGamma &&
671 fProcess != kPyMbNonDiffr &&
672 fProcess != kPyMbMSEL1 &&
673 fProcess != kPyW && fProcess != kPyZ &&
674 fProcess != kPyCharmppMNRwmi && fProcess != kPyBeautyppMNRwmi) {
676 for (i = 0; i < np; i++) {
677 TParticle* iparticle = (TParticle *) fParticles->At(i);
678 Int_t ks = iparticle->GetStatusCode();
679 kf = CheckPDGCode(iparticle->GetPdgCode());
680 // No initial state partons
681 if (ks==21) continue;
683 // Heavy Flavor Selection
690 if (kfl > 100000) kfl %= 100000;
691 if (kfl > 10000) kfl %= 10000;
693 if (kfl > 10) kfl/=100;
695 if (kfl > 10) kfl/=10;
696 Int_t ipa = iparticle->GetFirstMother()-1;
699 // Establish mother daughter relation between heavy quarks and mesons
701 if (kf >= fFlavorSelect && kf <= 6) {
702 Int_t idau = iparticle->GetFirstDaughter() - 1;
704 TParticle* daughter = (TParticle *) fParticles->At(idau);
705 Int_t pdgD = daughter->GetPdgCode();
706 if (pdgD == 91 || pdgD == 92) {
707 Int_t jmin = daughter->GetFirstDaughter() - 1;
708 Int_t jmax = daughter->GetLastDaughter() - 1;
709 for (Int_t j = jmin; j <= jmax; j++)
710 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
711 } // is string or cluster
717 TParticle * mother = (TParticle *) fParticles->At(ipa);
718 kfMo = TMath::Abs(mother->GetPdgCode());
721 // What to keep in Stack?
722 Bool_t flavorOK = kFALSE;
723 Bool_t selectOK = kFALSE;
725 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
727 if (kfl > fFlavorSelect) {
731 if (kfl == fFlavorSelect) flavorOK = kTRUE;
733 switch (fStackFillOpt) {
734 case kFlavorSelection:
737 case kParentSelection:
738 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
741 if (flavorOK && selectOK) {
743 // Heavy flavor hadron or quark
745 // Kinematic seletion on final state heavy flavor mesons
746 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
751 if (ParentSelected(kf)) ++nParents; // Update parent count
752 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
754 // Kinematic seletion on decay products
755 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
756 && !KinematicSelection(iparticle, 1))
762 // Select if mother was selected and is not tracked
764 if (pSelected[ipa] &&
765 !trackIt[ipa] && // mother will be tracked ?
766 kfMo != 5 && // mother is b-quark, don't store fragments
767 kfMo != 4 && // mother is c-quark, don't store fragments
768 kf != 92) // don't store string
771 // Semi-stable or de-selected: diselect decay products:
774 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
776 Int_t ipF = iparticle->GetFirstDaughter();
777 Int_t ipL = iparticle->GetLastDaughter();
778 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
780 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
781 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
784 if (pSelected[i] == -1) pSelected[i] = 0;
785 if (!pSelected[i]) continue;
786 // Count quarks only if you did not include fragmentation
787 if (fFragmentation && kf <= 10) continue;
790 // Decision on tracking
793 // Track final state particle
794 if (ks == 1) trackIt[i] = 1;
795 // Track semi-stable particles
796 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
797 // Track particles selected by process if undecayed.
798 if (fForceDecay == kNoDecay) {
799 if (ParentSelected(kf)) trackIt[i] = 1;
801 if (ParentSelected(kf)) trackIt[i] = 0;
803 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
807 } // particle selection loop
809 for (i = 0; i<np; i++) {
810 if (!pSelected[i]) continue;
811 TParticle * iparticle = (TParticle *) fParticles->At(i);
812 kf = CheckPDGCode(iparticle->GetPdgCode());
813 Int_t ks = iparticle->GetStatusCode();
814 p[0] = iparticle->Px();
815 p[1] = iparticle->Py();
816 p[2] = iparticle->Pz();
817 p[3] = iparticle->Energy();
819 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
820 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
821 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
823 Float_t tof = kconv*iparticle->T();
824 Int_t ipa = iparticle->GetFirstMother()-1;
825 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
827 PushTrack(fTrackIt*trackIt[i], iparent, kf,
828 p[0], p[1], p[2], p[3],
829 origin[0], origin[1], origin[2], tof,
830 polar[0], polar[1], polar[2],
831 kPPrimary, nt, 1., ks);
847 switch (fCountMode) {
849 // printf(" Count all \n");
853 // printf(" Count parents \n");
856 case kCountTrackables:
857 // printf(" Count trackable \n");
861 if (jev >= fNpart || fNpart == -1) {
862 fKineBias=Float_t(fNpart)/Float_t(fTrials);
864 fQ += fPythia->GetVINT(51);
865 fX1 += fPythia->GetVINT(41);
866 fX2 += fPythia->GetVINT(42);
867 fTrialsRun += fTrials;
874 SetHighWaterMark(nt);
875 // adjust weight due to kinematic selection
878 fXsection=fPythia->GetPARI(1);
881 Int_t AliGenPythia::GenerateMB()
884 // Min Bias selection and other global selections
886 Int_t i, kf, nt, iparent;
889 Float_t polar[3] = {0,0,0};
890 Float_t origin[3] = {0,0,0};
891 // converts from mm/c to s
892 const Float_t kconv=0.001/2.999792458e8;
896 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
900 Int_t* pParent = new Int_t[np];
901 for (i=0; i< np; i++) pParent[i] = -1;
902 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
903 TParticle* jet1 = (TParticle *) fParticles->At(6);
904 TParticle* jet2 = (TParticle *) fParticles->At(7);
905 if (!CheckTrigger(jet1, jet2)) {
911 // Select jets with fragmentation photon or pi0 going to PHOS or EMCAL
912 if (fProcess == kPyJets && (fFragPhotonInCalo || fPi0InCalo) ) {
917 if (fFragPhotonInCalo) pdg = 22 ; // Photon
918 else if (fPi0InCalo) pdg = 111 ; // Pi0
920 for (i=0; i< np; i++) {
921 TParticle* iparticle = (TParticle *) fParticles->At(i);
922 if(iparticle->GetStatusCode()==1 && iparticle->GetPdgCode()==pdg &&
923 iparticle->Pt() > fFragPhotonOrPi0MinPt){
925 (pdg == 22 && iparticle->GetFirstMother() != 11))//No photon from hadron decay
927 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
928 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
929 if((fCheckEMCAL && IsInEMCAL(phi,eta)) ||
930 (fCheckPHOS && IsInPHOS(phi,eta)) )
939 if (fTriggerParticle) {
940 Bool_t triggered = kFALSE;
941 for (i = 0; i < np; i++) {
942 TParticle * iparticle = (TParticle *) fParticles->At(i);
943 kf = CheckPDGCode(iparticle->GetPdgCode());
944 if (kf != fTriggerParticle) continue;
945 if (iparticle->Pt() == 0.) continue;
946 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
957 // Check if there is a ccbar or bbbar pair with at least one of the two
958 // in fYMin < y < fYMax
959 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
961 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
964 for(i=0; i<np; i++) {
965 hvq = (TParticle*)fParticles->At(i);
966 pdgQ = hvq->GetPdgCode();
967 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
968 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
969 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
970 (hvq->Energy()-hvq->Pz()+1.e-13));
971 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
973 if (!theQ || !theQbar || !inYcut) {
979 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
980 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
981 && (fCutOnChild == 1) ) {
982 if ( !CheckKinematicsOnChild() ) {
989 for (i = 0; i < np; i++) {
991 TParticle * iparticle = (TParticle *) fParticles->At(i);
992 kf = CheckPDGCode(iparticle->GetPdgCode());
993 Int_t ks = iparticle->GetStatusCode();
994 Int_t km = iparticle->GetFirstMother();
995 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
997 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
999 if (ks == 1) trackIt = 1;
1000 Int_t ipa = iparticle->GetFirstMother()-1;
1002 iparent = (ipa > -1) ? pParent[ipa] : -1;
1005 // store track information
1006 p[0] = iparticle->Px();
1007 p[1] = iparticle->Py();
1008 p[2] = iparticle->Pz();
1009 p[3] = iparticle->Energy();
1012 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
1013 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
1014 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
1016 Float_t tof = fEventTime + kconv * iparticle->T();
1018 PushTrack(fTrackIt*trackIt, iparent, kf,
1019 p[0], p[1], p[2], p[3],
1020 origin[0], origin[1], origin[2], tof,
1021 polar[0], polar[1], polar[2],
1022 kPPrimary, nt, 1., ks);
1024 // Special Treatment to store color-flow
1026 if (ks == 3 || ks == 13 || ks == 14) {
1027 TParticle* particle = 0;
1029 particle = fStack->Particle(nt);
1031 particle = gAlice->Stack()->Particle(nt);
1033 particle->SetFirstDaughter(fPythia->GetK(2, i));
1034 particle->SetLastDaughter(fPythia->GetK(3, i));
1039 SetHighWaterMark(nt);
1041 } // select particle
1050 void AliGenPythia::FinishRun()
1052 // Print x-section summary
1061 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
1062 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
1065 void AliGenPythia::AdjustWeights() const
1067 // Adjust the weights after generation of all events
1071 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1072 for (Int_t i=0; i<ntrack; i++) {
1073 part= gAlice->GetMCApp()->Particle(i);
1074 part->SetWeight(part->GetWeight()*fKineBias);
1079 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
1081 // Treat protons as inside nuclei with mass numbers a1 and a2
1089 void AliGenPythia::MakeHeader()
1092 // Make header for the simulated event
1095 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1096 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1099 // Builds the event header, to be called after each event
1100 if (fHeader) delete fHeader;
1101 fHeader = new AliGenPythiaEventHeader("Pythia");
1104 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1107 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1110 fHeader->SetPrimaryVertex(fVertex);
1112 // Jets that have triggered
1114 if (fProcess == kPyJets)
1117 Float_t jets[4][10];
1118 GetJets(njet, ntrig, jets);
1121 for (Int_t i = 0; i < ntrig; i++) {
1122 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1127 // Copy relevant information from external header, if present.
1132 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1133 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1135 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1138 exHeader->TriggerJet(i, uqJet);
1139 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1143 // Store quenching parameters
1150 fPythia->GetQuenchingParameters(xp, yp, z);
1153 Double_t r1 = PARIMP.rb1;
1154 Double_t r2 = PARIMP.rb2;
1155 Double_t b = PARIMP.b1;
1156 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1157 Double_t phi = PARIMP.psib1;
1158 xp = r * TMath::Cos(phi);
1159 yp = r * TMath::Sin(phi);
1162 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1163 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1167 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
1174 void AliGenPythia::AddHeader(AliGenEventHeader* header)
1176 // Add header to container or runloader
1178 fContainer->AddHeader(header);
1180 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
1185 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1187 // Check the kinematic trigger condition
1190 eta[0] = jet1->Eta();
1191 eta[1] = jet2->Eta();
1193 phi[0] = jet1->Phi();
1194 phi[1] = jet2->Phi();
1196 pdg[0] = jet1->GetPdgCode();
1197 pdg[1] = jet2->GetPdgCode();
1198 Bool_t triggered = kFALSE;
1200 if (fProcess == kPyJets) {
1203 Float_t jets[4][10];
1205 // Use Pythia clustering on parton level to determine jet axis
1207 GetJets(njets, ntrig, jets);
1209 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1214 if (pdg[0] == kGamma) {
1218 //Check eta range first...
1219 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1220 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1222 //Eta is okay, now check phi range
1223 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1224 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1235 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1237 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1239 Bool_t checking = kFALSE;
1240 Int_t j, kcode, ks, km;
1241 Int_t nPartAcc = 0; //number of particles in the acceptance range
1242 Int_t numberOfAcceptedParticles = 1;
1243 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1244 Int_t npart = fParticles->GetEntriesFast();
1246 for (j = 0; j<npart; j++) {
1247 TParticle * jparticle = (TParticle *) fParticles->At(j);
1248 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1249 ks = jparticle->GetStatusCode();
1250 km = jparticle->GetFirstMother();
1252 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1255 if( numberOfAcceptedParticles <= nPartAcc){
1265 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1267 // Assignment operator
1272 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1275 // Load event into Pythia Common Block
1278 Int_t npart = stack -> GetNprimary();
1282 (fPythia->GetPyjets())->N = npart;
1284 n0 = (fPythia->GetPyjets())->N;
1285 (fPythia->GetPyjets())->N = n0 + npart;
1289 for (Int_t part = 0; part < npart; part++) {
1290 TParticle *mPart = stack->Particle(part);
1292 Int_t kf = mPart->GetPdgCode();
1293 Int_t ks = mPart->GetStatusCode();
1294 Int_t idf = mPart->GetFirstDaughter();
1295 Int_t idl = mPart->GetLastDaughter();
1298 if (ks == 11 || ks == 12) {
1305 Float_t px = mPart->Px();
1306 Float_t py = mPart->Py();
1307 Float_t pz = mPart->Pz();
1308 Float_t e = mPart->Energy();
1309 Float_t m = mPart->GetCalcMass();
1312 (fPythia->GetPyjets())->P[0][part+n0] = px;
1313 (fPythia->GetPyjets())->P[1][part+n0] = py;
1314 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1315 (fPythia->GetPyjets())->P[3][part+n0] = e;
1316 (fPythia->GetPyjets())->P[4][part+n0] = m;
1318 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1319 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1320 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1321 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1322 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1327 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1330 // Calls the Pythia jet finding algorithm to find jets in the current event
1335 Int_t n = fPythia->GetN();
1339 fPythia->Pycell(njets);
1341 for (i = 0; i < njets; i++) {
1342 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1343 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1344 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1345 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1356 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1359 // Calls the Pythia clustering algorithm to find jets in the current event
1361 Int_t n = fPythia->GetN();
1364 if (fJetReconstruction == kCluster) {
1366 // Configure cluster algorithm
1368 fPythia->SetPARU(43, 2.);
1369 fPythia->SetMSTU(41, 1);
1371 // Call cluster algorithm
1373 fPythia->Pyclus(nJets);
1375 // Loading jets from common block
1381 fPythia->Pycell(nJets);
1385 for (i = 0; i < nJets; i++) {
1386 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1387 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1388 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1389 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1390 Float_t pt = TMath::Sqrt(px * px + py * py);
1391 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1392 Float_t theta = TMath::ATan2(pt,pz);
1393 Float_t et = e * TMath::Sin(theta);
1394 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1396 eta > fEtaMinJet && eta < fEtaMaxJet &&
1397 phi > fPhiMinJet && phi < fPhiMaxJet &&
1398 et > fEtMinJet && et < fEtMaxJet
1401 jets[0][nJetsTrig] = px;
1402 jets[1][nJetsTrig] = py;
1403 jets[2][nJetsTrig] = pz;
1404 jets[3][nJetsTrig] = e;
1406 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1408 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1413 void AliGenPythia::GetSubEventTime()
1415 // Calculates time of the next subevent
1418 TArrayF &array = *fEventsTime;
1419 fEventTime = array[fCurSubEvent++];
1421 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1425 Bool_t AliGenPythia::IsInEMCAL(Float_t phi, Float_t eta)
1427 // Is particle in EMCAL acceptance?
1428 // phi in degrees, etamin=-etamax
1429 if(phi > fEMCALMinPhi && phi < fEMCALMaxPhi &&
1436 Bool_t AliGenPythia::IsInPHOS(Float_t phi, Float_t eta)
1438 // Is particle in PHOS acceptance?
1439 // Acceptance slightly larger considered.
1440 // phi in degrees, etamin=-etamax
1441 if(phi > fPHOSMinPhi && phi < fPHOSMaxPhi &&
1451 void AliGenPythia::Streamer(TBuffer &R__b)
1453 // Stream an object of class AliGenPythia.
1455 if (R__b.IsReading()) {
1456 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1457 AliGenerator::Streamer(R__b);
1458 R__b >> (Int_t&)fProcess;
1459 R__b >> (Int_t&)fStrucFunc;
1460 R__b >> (Int_t&)fForceDecay;
1464 fParentSelect.Streamer(R__b);
1465 fChildSelect.Streamer(R__b);
1467 // (AliPythia::Instance())->Streamer(R__b);
1470 // if (fDecayer) fDecayer->Streamer(R__b);
1472 R__b.WriteVersion(AliGenPythia::IsA());
1473 AliGenerator::Streamer(R__b);
1474 R__b << (Int_t)fProcess;
1475 R__b << (Int_t)fStrucFunc;
1476 R__b << (Int_t)fForceDecay;
1480 fParentSelect.Streamer(R__b);
1481 fChildSelect.Streamer(R__b);
1486 // fDecayer->Streamer(R__b);