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),
115 // Default Constructor
117 if (!AliPythiaRndm::GetPythiaRandom())
118 AliPythiaRndm::SetPythiaRandom(GetRandom());
121 AliGenPythia::AliGenPythia(Int_t npart)
133 fInteractionRate(0.),
147 fHadronisation(kTRUE),
149 fReadFromFile(kFALSE),
153 fDecayer(new AliDecayerPythia()),
154 fDebugEventFirst(-1),
161 fPhiMaxJet(2.* TMath::Pi()),
162 fJetReconstruction(kCell),
166 fPhiMaxGamma(2. * TMath::Pi()),
170 fPycellThreshold(0.),
172 fPycellMinEtJet(10.),
173 fPycellMaxRadius(1.),
174 fStackFillOpt(kFlavorSelection),
176 fFragmentation(kTRUE),
182 fCountMode(kCountAll),
187 // default charm production at 5. 5 TeV
189 // structure function GRVHO
192 fTitle= "Particle Generator using PYTHIA";
194 // Set random number generator
195 if (!AliPythiaRndm::GetPythiaRandom())
196 AliPythiaRndm::SetPythiaRandom(GetRandom());
197 fParticles = new TClonesArray("TParticle",1000);
201 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
213 fInteractionRate(0.),
227 fHadronisation(kTRUE),
229 fReadFromFile(kFALSE),
233 fDecayer(new AliDecayerPythia()),
234 fDebugEventFirst(-1),
241 fPhiMaxJet(2.* TMath::Pi()),
242 fJetReconstruction(kCell),
246 fPhiMaxGamma(2. * TMath::Pi()),
250 fPycellThreshold(0.),
252 fPycellMinEtJet(10.),
253 fPycellMaxRadius(1.),
254 fStackFillOpt(kFlavorSelection),
256 fFragmentation(kTRUE),
262 fCountMode(kCountAll),
271 AliGenPythia::~AliGenPythia()
274 if(fEventsTime) delete fEventsTime;
277 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
279 // Generate pileup using user specified rate
280 fInteractionRate = rate;
281 fTimeWindow = timewindow;
285 void AliGenPythia::GeneratePileup()
287 // Generate sub events time for pileup
289 if(fInteractionRate == 0.) {
290 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
294 Int_t npart = NumberParticles();
296 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
300 if(fEventsTime) delete fEventsTime;
301 fEventsTime = new TArrayF(npart);
302 TArrayF &array = *fEventsTime;
303 for(Int_t ipart = 0; ipart < npart; ipart++)
306 Float_t eventtime = 0.;
309 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
310 if(eventtime > fTimeWindow) break;
311 array.Set(array.GetSize()+1);
312 array[array.GetSize()-1] = eventtime;
318 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
319 if(TMath::Abs(eventtime) > fTimeWindow) break;
320 array.Set(array.GetSize()+1);
321 array[array.GetSize()-1] = eventtime;
324 SetNumberParticles(fEventsTime->GetSize());
327 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
328 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
330 // Set pycell parameters
331 fPycellEtaMax = etamax;
334 fPycellThreshold = thresh;
335 fPycellEtSeed = etseed;
336 fPycellMinEtJet = minet;
337 fPycellMaxRadius = r;
342 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
344 // Set a range of event numbers, for which a table
345 // of generated particle will be printed
346 fDebugEventFirst = eventFirst;
347 fDebugEventLast = eventLast;
348 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
351 void AliGenPythia::Init()
355 SetMC(AliPythia::Instance());
356 fPythia=(AliPythia*) fMCEvGen;
359 fParentWeight=1./Float_t(fNpart);
361 // Forward Paramters to the AliPythia object
362 fDecayer->SetForceDecay(fForceDecay);
366 fPythia->SetCKIN(3,fPtHardMin);
367 fPythia->SetCKIN(4,fPtHardMax);
368 fPythia->SetCKIN(7,fYHardMin);
369 fPythia->SetCKIN(8,fYHardMax);
371 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
373 if (fFragmentation) {
374 fPythia->SetMSTP(111,1);
376 fPythia->SetMSTP(111,0);
380 // initial state radiation
381 fPythia->SetMSTP(61,fGinit);
382 // final state radiation
383 fPythia->SetMSTP(71,fGfinal);
386 fPythia->SetMSTP(91,1);
387 fPythia->SetPARP(91,fPtKick);
389 fPythia->SetMSTP(91,0);
394 fRL = AliRunLoader::Open(fFileName, "Partons");
395 fRL->LoadKinematics();
400 // Switch off Heavy Flavors on request
402 fPythia->SetMSTP(58, 3);
403 fPythia->SetMSTJ(45, 3);
404 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
407 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
409 // Parent and Children Selection
412 case kPyOldUEQ2ordered:
413 case kPyOldUEQ2ordered2:
417 case kPyCharmUnforced:
418 case kPyCharmPbPbMNR:
421 case kPyCharmppMNRwmi:
422 fParentSelect[0] = 411;
423 fParentSelect[1] = 421;
424 fParentSelect[2] = 431;
425 fParentSelect[3] = 4122;
431 fParentSelect[0] = 421;
434 case kPyDPlusPbPbMNR:
437 fParentSelect[0] = 411;
440 case kPyDPlusStrangePbPbMNR:
441 case kPyDPlusStrangepPbMNR:
442 case kPyDPlusStrangeppMNR:
443 fParentSelect[0] = 431;
447 case kPyBeautyPbPbMNR:
448 case kPyBeautypPbMNR:
450 case kPyBeautyppMNRwmi:
451 fParentSelect[0]= 511;
452 fParentSelect[1]= 521;
453 fParentSelect[2]= 531;
454 fParentSelect[3]= 5122;
455 fParentSelect[4]= 5132;
456 fParentSelect[5]= 5232;
457 fParentSelect[6]= 5332;
460 case kPyBeautyUnforced:
461 fParentSelect[0] = 511;
462 fParentSelect[1] = 521;
463 fParentSelect[2] = 531;
464 fParentSelect[3] = 5122;
465 fParentSelect[4] = 5132;
466 fParentSelect[5] = 5232;
467 fParentSelect[6] = 5332;
472 fParentSelect[0] = 443;
486 // JetFinder for Trigger
488 // Configure detector (EMCAL like)
490 fPythia->SetPARU(51, fPycellEtaMax);
491 fPythia->SetMSTU(51, fPycellNEta);
492 fPythia->SetMSTU(52, fPycellNPhi);
494 // Configure Jet Finder
496 fPythia->SetPARU(58, fPycellThreshold);
497 fPythia->SetPARU(52, fPycellEtSeed);
498 fPythia->SetPARU(53, fPycellMinEtJet);
499 fPythia->SetPARU(54, fPycellMaxRadius);
500 fPythia->SetMSTU(54, 2);
502 // This counts the total number of calls to Pyevnt() per run.
517 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
521 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
523 fPythia->SetPARJ(200, 0.0);
526 // Nestor's change of the splittings
527 fPythia->SetPARJ(200, 0.8);
528 fPythia->SetMSTJ(41, 1); // QCD radiation only
529 fPythia->SetMSTJ(42, 2); // angular ordering
530 fPythia->SetMSTJ(44, 2); // option to run alpha_s
531 fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
532 fPythia->SetMSTJ(50, 0); // No coherence in first branching
533 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
537 void AliGenPythia::Generate()
539 // Generate one event
541 fDecayer->ForceDecay();
543 Float_t polar[3] = {0,0,0};
544 Float_t origin[3] = {0,0,0};
546 // converts from mm/c to s
547 const Float_t kconv=0.001/2.999792458e8;
557 // Set collision vertex position
558 if (fVertexSmear == kPerEvent) Vertex();
567 // Switch hadronisation off
569 fPythia->SetMSTJ(1, 0);
571 // Either produce new event or read partons from file
573 if (!fReadFromFile) {
579 fNpartons = fPythia->GetN();
581 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
582 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
584 LoadEvent(fRL->Stack(), 0 , 1);
589 // Run quenching routine
593 } else if (fQuench == 2){
594 fPythia->Pyquen(208., 0, 0.);
595 } else if (fQuench == 3) {
596 // Quenching is via multiplicative correction of the splittings
600 // Switch hadronisation on
602 fPythia->SetMSTJ(1, 1);
604 // .. and perform hadronisation
605 // printf("Calling hadronisation %d\n", fPythia->GetN());
608 fPythia->ImportParticles(fParticles,"All");
616 Int_t np = fParticles->GetEntriesFast();
618 if (np == 0) continue;
622 Int_t* pParent = new Int_t[np];
623 Int_t* pSelected = new Int_t[np];
624 Int_t* trackIt = new Int_t[np];
625 for (i = 0; i < np; i++) {
631 Int_t nc = 0; // Total n. of selected particles
632 Int_t nParents = 0; // Selected parents
633 Int_t nTkbles = 0; // Trackable particles
634 if (fProcess != kPyMb && fProcess != kPyJets &&
635 fProcess != kPyDirectGamma &&
636 fProcess != kPyMbNonDiffr &&
637 fProcess != kPyMbMSEL1 &&
638 fProcess != kPyW && fProcess != kPyZ &&
639 fProcess != kPyCharmppMNRwmi && fProcess != kPyBeautyppMNRwmi) {
641 for (i = 0; i < np; i++) {
642 TParticle* iparticle = (TParticle *) fParticles->At(i);
643 Int_t ks = iparticle->GetStatusCode();
644 kf = CheckPDGCode(iparticle->GetPdgCode());
645 // No initial state partons
646 if (ks==21) continue;
648 // Heavy Flavor Selection
655 if (kfl > 100000) kfl %= 100000;
656 if (kfl > 10000) kfl %= 10000;
658 if (kfl > 10) kfl/=100;
660 if (kfl > 10) kfl/=10;
661 Int_t ipa = iparticle->GetFirstMother()-1;
664 // Establish mother daughter relation between heavy quarks and mesons
666 if (kf >= fFlavorSelect && kf <= 6) {
667 Int_t idau = iparticle->GetFirstDaughter() - 1;
669 TParticle* daughter = (TParticle *) fParticles->At(idau);
670 Int_t pdgD = daughter->GetPdgCode();
671 if (pdgD == 91 || pdgD == 92) {
672 Int_t jmin = daughter->GetFirstDaughter() - 1;
673 Int_t jmax = daughter->GetLastDaughter() - 1;
674 for (Int_t j = jmin; j <= jmax; j++)
675 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
676 } // is string or cluster
682 TParticle * mother = (TParticle *) fParticles->At(ipa);
683 kfMo = TMath::Abs(mother->GetPdgCode());
686 // What to keep in Stack?
687 Bool_t flavorOK = kFALSE;
688 Bool_t selectOK = kFALSE;
690 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
692 if (kfl > fFlavorSelect) {
696 if (kfl == fFlavorSelect) flavorOK = kTRUE;
698 switch (fStackFillOpt) {
699 case kFlavorSelection:
702 case kParentSelection:
703 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
706 if (flavorOK && selectOK) {
708 // Heavy flavor hadron or quark
710 // Kinematic seletion on final state heavy flavor mesons
711 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
716 if (ParentSelected(kf)) ++nParents; // Update parent count
717 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
719 // Kinematic seletion on decay products
720 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
721 && !KinematicSelection(iparticle, 1))
727 // Select if mother was selected and is not tracked
729 if (pSelected[ipa] &&
730 !trackIt[ipa] && // mother will be tracked ?
731 kfMo != 5 && // mother is b-quark, don't store fragments
732 kfMo != 4 && // mother is c-quark, don't store fragments
733 kf != 92) // don't store string
736 // Semi-stable or de-selected: diselect decay products:
739 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
741 Int_t ipF = iparticle->GetFirstDaughter();
742 Int_t ipL = iparticle->GetLastDaughter();
743 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
745 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
746 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
749 if (pSelected[i] == -1) pSelected[i] = 0;
750 if (!pSelected[i]) continue;
751 // Count quarks only if you did not include fragmentation
752 if (fFragmentation && kf <= 10) continue;
755 // Decision on tracking
758 // Track final state particle
759 if (ks == 1) trackIt[i] = 1;
760 // Track semi-stable particles
761 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
762 // Track particles selected by process if undecayed.
763 if (fForceDecay == kNoDecay) {
764 if (ParentSelected(kf)) trackIt[i] = 1;
766 if (ParentSelected(kf)) trackIt[i] = 0;
768 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
772 } // particle selection loop
774 for (i = 0; i<np; i++) {
775 if (!pSelected[i]) continue;
776 TParticle * iparticle = (TParticle *) fParticles->At(i);
777 kf = CheckPDGCode(iparticle->GetPdgCode());
778 Int_t ks = iparticle->GetStatusCode();
779 p[0] = iparticle->Px();
780 p[1] = iparticle->Py();
781 p[2] = iparticle->Pz();
782 p[3] = iparticle->Energy();
784 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
785 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
786 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
788 Float_t tof = kconv*iparticle->T();
789 Int_t ipa = iparticle->GetFirstMother()-1;
790 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
792 PushTrack(fTrackIt*trackIt[i], iparent, kf,
793 p[0], p[1], p[2], p[3],
794 origin[0], origin[1], origin[2], tof,
795 polar[0], polar[1], polar[2],
796 kPPrimary, nt, 1., ks);
812 switch (fCountMode) {
814 // printf(" Count all \n");
818 // printf(" Count parents \n");
821 case kCountTrackables:
822 // printf(" Count trackable \n");
826 if (jev >= fNpart || fNpart == -1) {
827 fKineBias=Float_t(fNpart)/Float_t(fTrials);
829 fQ += fPythia->GetVINT(51);
830 fX1 += fPythia->GetVINT(41);
831 fX2 += fPythia->GetVINT(42);
832 fTrialsRun += fTrials;
839 SetHighWaterMark(nt);
840 // adjust weight due to kinematic selection
843 fXsection=fPythia->GetPARI(1);
846 Int_t AliGenPythia::GenerateMB()
849 // Min Bias selection and other global selections
851 Int_t i, kf, nt, iparent;
854 Float_t polar[3] = {0,0,0};
855 Float_t origin[3] = {0,0,0};
856 // converts from mm/c to s
857 const Float_t kconv=0.001/2.999792458e8;
861 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
865 Int_t* pParent = new Int_t[np];
866 for (i=0; i< np; i++) pParent[i] = -1;
867 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
868 TParticle* jet1 = (TParticle *) fParticles->At(6);
869 TParticle* jet2 = (TParticle *) fParticles->At(7);
870 if (!CheckTrigger(jet1, jet2)) {
876 if (fTriggerParticle) {
877 Bool_t triggered = kFALSE;
878 for (i = 0; i < np; i++) {
879 TParticle * iparticle = (TParticle *) fParticles->At(i);
880 kf = CheckPDGCode(iparticle->GetPdgCode());
881 if (kf != fTriggerParticle) continue;
882 if (iparticle->Pt() == 0.) continue;
883 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
894 // Check if there is a ccbar or bbbar pair with at least one of the two
895 // in fYMin < y < fYMax
896 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
898 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
901 for(i=0; i<np; i++) {
902 hvq = (TParticle*)fParticles->At(i);
903 pdgQ = hvq->GetPdgCode();
904 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
905 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
906 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
907 (hvq->Energy()-hvq->Pz()+1.e-13));
908 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
910 if (!theQ || !theQbar || !inYcut) {
916 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
917 if ( (fProcess == kPyW || fProcess == kPyZ || fProcess == kPyMb || fProcess == kPyMbNonDiffr)
918 && (fCutOnChild == 1) ) {
919 if ( !CheckKinematicsOnChild() ) {
926 for (i = 0; i < np; i++) {
928 TParticle * iparticle = (TParticle *) fParticles->At(i);
929 kf = CheckPDGCode(iparticle->GetPdgCode());
930 Int_t ks = iparticle->GetStatusCode();
931 Int_t km = iparticle->GetFirstMother();
932 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
934 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
936 if (ks == 1) trackIt = 1;
937 Int_t ipa = iparticle->GetFirstMother()-1;
939 iparent = (ipa > -1) ? pParent[ipa] : -1;
942 // store track information
943 p[0] = iparticle->Px();
944 p[1] = iparticle->Py();
945 p[2] = iparticle->Pz();
946 p[3] = iparticle->Energy();
949 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
950 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
951 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
953 Float_t tof = fEventTime + kconv * iparticle->T();
955 PushTrack(fTrackIt*trackIt, iparent, kf,
956 p[0], p[1], p[2], p[3],
957 origin[0], origin[1], origin[2], tof,
958 polar[0], polar[1], polar[2],
959 kPPrimary, nt, 1., ks);
961 // Special Treatment to store color-flow
963 if (ks == 3 || ks == 13 || ks == 14) {
964 TParticle* particle = 0;
966 particle = fStack->Particle(nt);
968 particle = gAlice->Stack()->Particle(nt);
970 particle->SetFirstDaughter(fPythia->GetK(2, i));
971 particle->SetLastDaughter(fPythia->GetK(3, i));
976 SetHighWaterMark(nt);
987 void AliGenPythia::FinishRun()
989 // Print x-section summary
998 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
999 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
1002 void AliGenPythia::AdjustWeights() const
1004 // Adjust the weights after generation of all events
1008 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1009 for (Int_t i=0; i<ntrack; i++) {
1010 part= gAlice->GetMCApp()->Particle(i);
1011 part->SetWeight(part->GetWeight()*fKineBias);
1016 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
1018 // Treat protons as inside nuclei with mass numbers a1 and a2
1026 void AliGenPythia::MakeHeader()
1029 // Make header for the simulated event
1032 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1033 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1036 // Builds the event header, to be called after each event
1037 if (fHeader) delete fHeader;
1038 fHeader = new AliGenPythiaEventHeader("Pythia");
1041 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1044 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1047 fHeader->SetPrimaryVertex(fVertex);
1049 // Jets that have triggered
1051 if (fProcess == kPyJets)
1054 Float_t jets[4][10];
1055 GetJets(njet, ntrig, jets);
1058 for (Int_t i = 0; i < ntrig; i++) {
1059 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1064 // Copy relevant information from external header, if present.
1069 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1070 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1072 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1075 exHeader->TriggerJet(i, uqJet);
1076 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1080 // Store quenching parameters
1087 fPythia->GetQuenchingParameters(xp, yp, z);
1090 Double_t r1 = PARIMP.rb1;
1091 Double_t r2 = PARIMP.rb2;
1092 Double_t b = PARIMP.b1;
1093 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1094 Double_t phi = PARIMP.psib1;
1095 xp = r * TMath::Cos(phi);
1096 yp = r * TMath::Sin(phi);
1099 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1100 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1104 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
1111 void AliGenPythia::AddHeader(AliGenEventHeader* header)
1113 // Add header to container or runloader
1115 fContainer->AddHeader(header);
1117 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
1122 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1124 // Check the kinematic trigger condition
1127 eta[0] = jet1->Eta();
1128 eta[1] = jet2->Eta();
1130 phi[0] = jet1->Phi();
1131 phi[1] = jet2->Phi();
1133 pdg[0] = jet1->GetPdgCode();
1134 pdg[1] = jet2->GetPdgCode();
1135 Bool_t triggered = kFALSE;
1137 if (fProcess == kPyJets) {
1140 Float_t jets[4][10];
1142 // Use Pythia clustering on parton level to determine jet axis
1144 GetJets(njets, ntrig, jets);
1146 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1151 if (pdg[0] == kGamma) {
1155 //Check eta range first...
1156 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1157 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1159 //Eta is okay, now check phi range
1160 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1161 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1172 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1174 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1176 Bool_t checking = kFALSE;
1177 Int_t j, kcode, ks, km;
1178 Int_t nPartAcc = 0; //number of particles in the acceptance range
1179 Int_t numberOfAcceptedParticles = 1;
1180 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1181 Int_t npart = fParticles->GetEntriesFast();
1183 for (j = 0; j<npart; j++) {
1184 TParticle * jparticle = (TParticle *) fParticles->At(j);
1185 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1186 ks = jparticle->GetStatusCode();
1187 km = jparticle->GetFirstMother();
1189 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1192 if( numberOfAcceptedParticles <= nPartAcc){
1202 AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs)
1204 // Assignment operator
1209 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1212 // Load event into Pythia Common Block
1215 Int_t npart = stack -> GetNprimary();
1219 (fPythia->GetPyjets())->N = npart;
1221 n0 = (fPythia->GetPyjets())->N;
1222 (fPythia->GetPyjets())->N = n0 + npart;
1226 for (Int_t part = 0; part < npart; part++) {
1227 TParticle *mPart = stack->Particle(part);
1229 Int_t kf = mPart->GetPdgCode();
1230 Int_t ks = mPart->GetStatusCode();
1231 Int_t idf = mPart->GetFirstDaughter();
1232 Int_t idl = mPart->GetLastDaughter();
1235 if (ks == 11 || ks == 12) {
1242 Float_t px = mPart->Px();
1243 Float_t py = mPart->Py();
1244 Float_t pz = mPart->Pz();
1245 Float_t e = mPart->Energy();
1246 Float_t m = mPart->GetCalcMass();
1249 (fPythia->GetPyjets())->P[0][part+n0] = px;
1250 (fPythia->GetPyjets())->P[1][part+n0] = py;
1251 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1252 (fPythia->GetPyjets())->P[3][part+n0] = e;
1253 (fPythia->GetPyjets())->P[4][part+n0] = m;
1255 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1256 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1257 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1258 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1259 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1264 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1267 // Calls the Pythia jet finding algorithm to find jets in the current event
1272 Int_t n = fPythia->GetN();
1276 fPythia->Pycell(njets);
1278 for (i = 0; i < njets; i++) {
1279 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1280 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1281 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1282 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1293 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1296 // Calls the Pythia clustering algorithm to find jets in the current event
1298 Int_t n = fPythia->GetN();
1301 if (fJetReconstruction == kCluster) {
1303 // Configure cluster algorithm
1305 fPythia->SetPARU(43, 2.);
1306 fPythia->SetMSTU(41, 1);
1308 // Call cluster algorithm
1310 fPythia->Pyclus(nJets);
1312 // Loading jets from common block
1318 fPythia->Pycell(nJets);
1322 for (i = 0; i < nJets; i++) {
1323 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1324 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1325 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1326 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1327 Float_t pt = TMath::Sqrt(px * px + py * py);
1328 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1329 Float_t theta = TMath::ATan2(pt,pz);
1330 Float_t et = e * TMath::Sin(theta);
1331 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1333 eta > fEtaMinJet && eta < fEtaMaxJet &&
1334 phi > fPhiMinJet && phi < fPhiMaxJet &&
1335 et > fEtMinJet && et < fEtMaxJet
1338 jets[0][nJetsTrig] = px;
1339 jets[1][nJetsTrig] = py;
1340 jets[2][nJetsTrig] = pz;
1341 jets[3][nJetsTrig] = e;
1343 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1345 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1350 void AliGenPythia::GetSubEventTime()
1352 // Calculates time of the next subevent
1355 TArrayF &array = *fEventsTime;
1356 fEventTime = array[fCurSubEvent++];
1358 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1363 void AliGenPythia::Streamer(TBuffer &R__b)
1365 // Stream an object of class AliGenPythia.
1367 if (R__b.IsReading()) {
1368 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1369 AliGenerator::Streamer(R__b);
1370 R__b >> (Int_t&)fProcess;
1371 R__b >> (Int_t&)fStrucFunc;
1372 R__b >> (Int_t&)fForceDecay;
1376 fParentSelect.Streamer(R__b);
1377 fChildSelect.Streamer(R__b);
1379 // (AliPythia::Instance())->Streamer(R__b);
1382 // if (fDecayer) fDecayer->Streamer(R__b);
1384 R__b.WriteVersion(AliGenPythia::IsA());
1385 AliGenerator::Streamer(R__b);
1386 R__b << (Int_t)fProcess;
1387 R__b << (Int_t)fStrucFunc;
1388 R__b << (Int_t)fForceDecay;
1392 fParentSelect.Streamer(R__b);
1393 fChildSelect.Streamer(R__b);
1398 // fDecayer->Streamer(R__b);