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 fBremssInCalo(kFALSE),
116 fBremssPi0InEMCAL(kFALSE),
117 fBremssPi0InPHOS(kFALSE),
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 fBremssInCalo(kFALSE),
200 fBremssPi0InEMCAL(kFALSE),
201 fBremssPi0InPHOS(kFALSE),
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 fBremssInCalo(kFALSE),
291 fBremssPi0InEMCAL(kFALSE),
292 fBremssPi0InPHOS(kFALSE),
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 bremsstrahlung or pi0 going to PHOS or EMCAL
912 if (fProcess == kPyJets && (fBremssInCalo || fPi0InCalo) ) {
917 if (fBremssInCalo) 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() > fBremssPi0MinPt){
924 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
925 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
926 if((fBremssPi0InEMCAL && IsInEMCAL(phi,eta)) ||
927 fBremssPi0InPHOS && IsInPHOS(phi,eta))
935 if (fTriggerParticle) {
936 Bool_t triggered = kFALSE;
937 for (i = 0; i < np; i++) {
938 TParticle * iparticle = (TParticle *) fParticles->At(i);
939 kf = CheckPDGCode(iparticle->GetPdgCode());
940 if (kf != fTriggerParticle) continue;
941 if (iparticle->Pt() == 0.) continue;
942 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
953 // Check if there is a ccbar or bbbar pair with at least one of the two
954 // in fYMin < y < fYMax
955 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
957 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
960 for(i=0; i<np; i++) {
961 hvq = (TParticle*)fParticles->At(i);
962 pdgQ = hvq->GetPdgCode();
963 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
964 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
965 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
966 (hvq->Energy()-hvq->Pz()+1.e-13));
967 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
969 if (!theQ || !theQbar || !inYcut) {
975 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
976 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
977 && (fCutOnChild == 1) ) {
978 if ( !CheckKinematicsOnChild() ) {
985 for (i = 0; i < np; i++) {
987 TParticle * iparticle = (TParticle *) fParticles->At(i);
988 kf = CheckPDGCode(iparticle->GetPdgCode());
989 Int_t ks = iparticle->GetStatusCode();
990 Int_t km = iparticle->GetFirstMother();
991 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
993 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
995 if (ks == 1) trackIt = 1;
996 Int_t ipa = iparticle->GetFirstMother()-1;
998 iparent = (ipa > -1) ? pParent[ipa] : -1;
1001 // store track information
1002 p[0] = iparticle->Px();
1003 p[1] = iparticle->Py();
1004 p[2] = iparticle->Pz();
1005 p[3] = iparticle->Energy();
1008 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
1009 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
1010 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
1012 Float_t tof = fEventTime + kconv * iparticle->T();
1014 PushTrack(fTrackIt*trackIt, iparent, kf,
1015 p[0], p[1], p[2], p[3],
1016 origin[0], origin[1], origin[2], tof,
1017 polar[0], polar[1], polar[2],
1018 kPPrimary, nt, 1., ks);
1020 // Special Treatment to store color-flow
1022 if (ks == 3 || ks == 13 || ks == 14) {
1023 TParticle* particle = 0;
1025 particle = fStack->Particle(nt);
1027 particle = gAlice->Stack()->Particle(nt);
1029 particle->SetFirstDaughter(fPythia->GetK(2, i));
1030 particle->SetLastDaughter(fPythia->GetK(3, i));
1035 SetHighWaterMark(nt);
1037 } // select particle
1046 void AliGenPythia::FinishRun()
1048 // Print x-section summary
1057 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
1058 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
1061 void AliGenPythia::AdjustWeights() const
1063 // Adjust the weights after generation of all events
1067 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1068 for (Int_t i=0; i<ntrack; i++) {
1069 part= gAlice->GetMCApp()->Particle(i);
1070 part->SetWeight(part->GetWeight()*fKineBias);
1075 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
1077 // Treat protons as inside nuclei with mass numbers a1 and a2
1085 void AliGenPythia::MakeHeader()
1088 // Make header for the simulated event
1091 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1092 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1095 // Builds the event header, to be called after each event
1096 if (fHeader) delete fHeader;
1097 fHeader = new AliGenPythiaEventHeader("Pythia");
1100 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1103 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1106 fHeader->SetPrimaryVertex(fVertex);
1108 // Jets that have triggered
1110 if (fProcess == kPyJets)
1113 Float_t jets[4][10];
1114 GetJets(njet, ntrig, jets);
1117 for (Int_t i = 0; i < ntrig; i++) {
1118 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1123 // Copy relevant information from external header, if present.
1128 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1129 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1131 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1134 exHeader->TriggerJet(i, uqJet);
1135 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1139 // Store quenching parameters
1146 fPythia->GetQuenchingParameters(xp, yp, z);
1149 Double_t r1 = PARIMP.rb1;
1150 Double_t r2 = PARIMP.rb2;
1151 Double_t b = PARIMP.b1;
1152 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1153 Double_t phi = PARIMP.psib1;
1154 xp = r * TMath::Cos(phi);
1155 yp = r * TMath::Sin(phi);
1158 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1159 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1163 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
1170 void AliGenPythia::AddHeader(AliGenEventHeader* header)
1172 // Add header to container or runloader
1174 fContainer->AddHeader(header);
1176 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
1181 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1183 // Check the kinematic trigger condition
1186 eta[0] = jet1->Eta();
1187 eta[1] = jet2->Eta();
1189 phi[0] = jet1->Phi();
1190 phi[1] = jet2->Phi();
1192 pdg[0] = jet1->GetPdgCode();
1193 pdg[1] = jet2->GetPdgCode();
1194 Bool_t triggered = kFALSE;
1196 if (fProcess == kPyJets) {
1199 Float_t jets[4][10];
1201 // Use Pythia clustering on parton level to determine jet axis
1203 GetJets(njets, ntrig, jets);
1205 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1210 if (pdg[0] == kGamma) {
1214 //Check eta range first...
1215 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1216 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1218 //Eta is okay, now check phi range
1219 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1220 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1231 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1233 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1235 Bool_t checking = kFALSE;
1236 Int_t j, kcode, ks, km;
1237 Int_t nPartAcc = 0; //number of particles in the acceptance range
1238 Int_t numberOfAcceptedParticles = 1;
1239 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1240 Int_t npart = fParticles->GetEntriesFast();
1242 for (j = 0; j<npart; j++) {
1243 TParticle * jparticle = (TParticle *) fParticles->At(j);
1244 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1245 ks = jparticle->GetStatusCode();
1246 km = jparticle->GetFirstMother();
1248 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1251 if( numberOfAcceptedParticles <= nPartAcc){
1261 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1263 // Assignment operator
1268 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1271 // Load event into Pythia Common Block
1274 Int_t npart = stack -> GetNprimary();
1278 (fPythia->GetPyjets())->N = npart;
1280 n0 = (fPythia->GetPyjets())->N;
1281 (fPythia->GetPyjets())->N = n0 + npart;
1285 for (Int_t part = 0; part < npart; part++) {
1286 TParticle *mPart = stack->Particle(part);
1288 Int_t kf = mPart->GetPdgCode();
1289 Int_t ks = mPart->GetStatusCode();
1290 Int_t idf = mPart->GetFirstDaughter();
1291 Int_t idl = mPart->GetLastDaughter();
1294 if (ks == 11 || ks == 12) {
1301 Float_t px = mPart->Px();
1302 Float_t py = mPart->Py();
1303 Float_t pz = mPart->Pz();
1304 Float_t e = mPart->Energy();
1305 Float_t m = mPart->GetCalcMass();
1308 (fPythia->GetPyjets())->P[0][part+n0] = px;
1309 (fPythia->GetPyjets())->P[1][part+n0] = py;
1310 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1311 (fPythia->GetPyjets())->P[3][part+n0] = e;
1312 (fPythia->GetPyjets())->P[4][part+n0] = m;
1314 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1315 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1316 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1317 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1318 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1323 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1326 // Calls the Pythia jet finding algorithm to find jets in the current event
1331 Int_t n = fPythia->GetN();
1335 fPythia->Pycell(njets);
1337 for (i = 0; i < njets; i++) {
1338 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1339 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1340 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1341 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1352 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1355 // Calls the Pythia clustering algorithm to find jets in the current event
1357 Int_t n = fPythia->GetN();
1360 if (fJetReconstruction == kCluster) {
1362 // Configure cluster algorithm
1364 fPythia->SetPARU(43, 2.);
1365 fPythia->SetMSTU(41, 1);
1367 // Call cluster algorithm
1369 fPythia->Pyclus(nJets);
1371 // Loading jets from common block
1377 fPythia->Pycell(nJets);
1381 for (i = 0; i < nJets; i++) {
1382 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1383 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1384 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1385 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1386 Float_t pt = TMath::Sqrt(px * px + py * py);
1387 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1388 Float_t theta = TMath::ATan2(pt,pz);
1389 Float_t et = e * TMath::Sin(theta);
1390 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1392 eta > fEtaMinJet && eta < fEtaMaxJet &&
1393 phi > fPhiMinJet && phi < fPhiMaxJet &&
1394 et > fEtMinJet && et < fEtMaxJet
1397 jets[0][nJetsTrig] = px;
1398 jets[1][nJetsTrig] = py;
1399 jets[2][nJetsTrig] = pz;
1400 jets[3][nJetsTrig] = e;
1402 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1404 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1409 void AliGenPythia::GetSubEventTime()
1411 // Calculates time of the next subevent
1414 TArrayF &array = *fEventsTime;
1415 fEventTime = array[fCurSubEvent++];
1417 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1421 Bool_t AliGenPythia::IsInEMCAL(Float_t phi, Float_t eta)
1423 // Is particle in EMCAL acceptance?
1424 // Acceptance slightly larger considered.
1425 // phi in degrees, etamin=-etamax
1426 if(phi > fEMCALMinPhi-0.1 && phi < fEMCALMaxPhi+0.1 &&
1427 eta < fEMCALEta+0.01 )
1433 Bool_t AliGenPythia::IsInPHOS(Float_t phi, Float_t eta)
1435 // Is particle in PHOS acceptance?
1436 // Acceptance slightly larger considered.
1437 // phi in degrees, etamin=-etamax
1438 if(phi > fPHOSMinPhi-0.1 && phi < fPHOSMaxPhi+0.1 &&
1439 eta < fPHOSEta+0.01 )
1448 void AliGenPythia::Streamer(TBuffer &R__b)
1450 // Stream an object of class AliGenPythia.
1452 if (R__b.IsReading()) {
1453 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1454 AliGenerator::Streamer(R__b);
1455 R__b >> (Int_t&)fProcess;
1456 R__b >> (Int_t&)fStrucFunc;
1457 R__b >> (Int_t&)fForceDecay;
1461 fParentSelect.Streamer(R__b);
1462 fChildSelect.Streamer(R__b);
1464 // (AliPythia::Instance())->Streamer(R__b);
1467 // if (fDecayer) fDecayer->Streamer(R__b);
1469 R__b.WriteVersion(AliGenPythia::IsA());
1470 AliGenerator::Streamer(R__b);
1471 R__b << (Int_t)fProcess;
1472 R__b << (Int_t)fStrucFunc;
1473 R__b << (Int_t)fForceDecay;
1477 fParentSelect.Streamer(R__b);
1478 fChildSelect.Streamer(R__b);
1483 // fDecayer->Streamer(R__b);