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 <TClonesArray.h>
29 #include <TDatabasePDG.h>
30 #include <TParticle.h>
35 #include "AliDecayerPythia.h"
36 #include "AliGenPythia.h"
37 #include "AliHeader.h"
38 #include "AliGenPythiaEventHeader.h"
39 #include "AliPythia.h"
40 #include "AliPythiaRndm.h"
43 #include "AliRunLoader.h"
45 #include "pyquenCommon.h"
47 ClassImp(AliGenPythia)
50 AliGenPythia::AliGenPythia():
82 fDecayer(new AliDecayerPythia()),
90 fPhiMaxJet(2.* TMath::Pi()),
91 fJetReconstruction(kCell),
95 fPhiMaxGamma(2. * TMath::Pi()),
101 fPycellMinEtJet(10.),
102 fPycellMaxRadius(1.),
103 fStackFillOpt(kFlavorSelection),
105 fFragmentation(kTRUE),
111 fCountMode(kCountAll),
115 fFragPhotonInCalo(kFALSE),
119 fFragPhotonOrPi0MinPt(0),
128 // Default Constructor
130 if (!AliPythiaRndm::GetPythiaRandom())
131 AliPythiaRndm::SetPythiaRandom(GetRandom());
134 AliGenPythia::AliGenPythia(Int_t npart)
146 fInteractionRate(0.),
160 fHadronisation(kTRUE),
162 fReadFromFile(kFALSE),
166 fDecayer(new AliDecayerPythia()),
167 fDebugEventFirst(-1),
174 fPhiMaxJet(2.* TMath::Pi()),
175 fJetReconstruction(kCell),
179 fPhiMaxGamma(2. * TMath::Pi()),
183 fPycellThreshold(0.),
185 fPycellMinEtJet(10.),
186 fPycellMaxRadius(1.),
187 fStackFillOpt(kFlavorSelection),
189 fFragmentation(kTRUE),
195 fCountMode(kCountAll),
199 fFragPhotonInCalo(kFALSE),
203 fFragPhotonOrPi0MinPt(0),
211 // default charm production at 5. 5 TeV
213 // structure function GRVHO
216 fTitle= "Particle Generator using PYTHIA";
218 // Set random number generator
219 if (!AliPythiaRndm::GetPythiaRandom())
220 AliPythiaRndm::SetPythiaRandom(GetRandom());
221 fParticles = new TClonesArray("TParticle",1000);
225 AliGenPythia::~AliGenPythia()
228 if(fEventsTime) delete fEventsTime;
231 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
233 // Generate pileup using user specified rate
234 fInteractionRate = rate;
235 fTimeWindow = timewindow;
239 void AliGenPythia::GeneratePileup()
241 // Generate sub events time for pileup
243 if(fInteractionRate == 0.) {
244 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
248 Int_t npart = NumberParticles();
250 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
254 if(fEventsTime) delete fEventsTime;
255 fEventsTime = new TArrayF(npart);
256 TArrayF &array = *fEventsTime;
257 for(Int_t ipart = 0; ipart < npart; ipart++)
260 Float_t eventtime = 0.;
263 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
264 if(eventtime > fTimeWindow) break;
265 array.Set(array.GetSize()+1);
266 array[array.GetSize()-1] = eventtime;
272 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
273 if(TMath::Abs(eventtime) > fTimeWindow) break;
274 array.Set(array.GetSize()+1);
275 array[array.GetSize()-1] = eventtime;
278 SetNumberParticles(fEventsTime->GetSize());
281 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
282 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
284 // Set pycell parameters
285 fPycellEtaMax = etamax;
288 fPycellThreshold = thresh;
289 fPycellEtSeed = etseed;
290 fPycellMinEtJet = minet;
291 fPycellMaxRadius = r;
296 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
298 // Set a range of event numbers, for which a table
299 // of generated particle will be printed
300 fDebugEventFirst = eventFirst;
301 fDebugEventLast = eventLast;
302 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
305 void AliGenPythia::Init()
309 SetMC(AliPythia::Instance());
310 fPythia=(AliPythia*) fMCEvGen;
313 fParentWeight=1./Float_t(fNpart);
317 fPythia->SetCKIN(3,fPtHardMin);
318 fPythia->SetCKIN(4,fPtHardMax);
319 fPythia->SetCKIN(7,fYHardMin);
320 fPythia->SetCKIN(8,fYHardMax);
322 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
324 if (fFragmentation) {
325 fPythia->SetMSTP(111,1);
327 fPythia->SetMSTP(111,0);
331 // initial state radiation
332 fPythia->SetMSTP(61,fGinit);
333 // final state radiation
334 fPythia->SetMSTP(71,fGfinal);
337 fPythia->SetMSTP(91,1);
338 fPythia->SetPARP(91,fPtKick);
340 fPythia->SetMSTP(91,0);
345 fRL = AliRunLoader::Open(fFileName, "Partons");
346 fRL->LoadKinematics();
351 // Switch off Heavy Flavors on request
353 fPythia->SetMSTP(58, 3);
354 fPythia->SetMSTJ(45, 3);
355 for (Int_t i = 156; i <= 160; i++) fPythia->SetMDME(i, 1, 0);
358 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
359 // Forward Paramters to the AliPythia object
360 fDecayer->SetForceDecay(fForceDecay);
363 // Parent and Children Selection
366 case kPyOldUEQ2ordered:
367 case kPyOldUEQ2ordered2:
371 case kPyCharmUnforced:
372 case kPyCharmPbPbMNR:
375 case kPyCharmppMNRwmi:
376 fParentSelect[0] = 411;
377 fParentSelect[1] = 421;
378 fParentSelect[2] = 431;
379 fParentSelect[3] = 4122;
385 fParentSelect[0] = 421;
388 case kPyDPlusPbPbMNR:
391 fParentSelect[0] = 411;
394 case kPyDPlusStrangePbPbMNR:
395 case kPyDPlusStrangepPbMNR:
396 case kPyDPlusStrangeppMNR:
397 fParentSelect[0] = 431;
401 case kPyBeautyPbPbMNR:
402 case kPyBeautypPbMNR:
404 case kPyBeautyppMNRwmi:
405 fParentSelect[0]= 511;
406 fParentSelect[1]= 521;
407 fParentSelect[2]= 531;
408 fParentSelect[3]= 5122;
409 fParentSelect[4]= 5132;
410 fParentSelect[5]= 5232;
411 fParentSelect[6]= 5332;
414 case kPyBeautyUnforced:
415 fParentSelect[0] = 511;
416 fParentSelect[1] = 521;
417 fParentSelect[2] = 531;
418 fParentSelect[3] = 5122;
419 fParentSelect[4] = 5132;
420 fParentSelect[5] = 5232;
421 fParentSelect[6] = 5332;
426 fParentSelect[0] = 443;
442 // JetFinder for Trigger
444 // Configure detector (EMCAL like)
446 fPythia->SetPARU(51, fPycellEtaMax);
447 fPythia->SetMSTU(51, fPycellNEta);
448 fPythia->SetMSTU(52, fPycellNPhi);
450 // Configure Jet Finder
452 fPythia->SetPARU(58, fPycellThreshold);
453 fPythia->SetPARU(52, fPycellEtSeed);
454 fPythia->SetPARU(53, fPycellMinEtJet);
455 fPythia->SetPARU(54, fPycellMaxRadius);
456 fPythia->SetMSTU(54, 2);
458 // This counts the total number of calls to Pyevnt() per run.
473 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
477 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
479 fPythia->SetPARJ(200, 0.0);
482 // Nestor's change of the splittings
483 fPythia->SetPARJ(200, 0.8);
484 fPythia->SetMSTJ(41, 1); // QCD radiation only
485 fPythia->SetMSTJ(42, 2); // angular ordering
486 fPythia->SetMSTJ(44, 2); // option to run alpha_s
487 fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
488 fPythia->SetMSTJ(50, 0); // No coherence in first branching
489 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
493 void AliGenPythia::Generate()
495 // Generate one event
497 fDecayer->ForceDecay();
499 Float_t polar[3] = {0,0,0};
500 Float_t origin[3] = {0,0,0};
502 // converts from mm/c to s
503 const Float_t kconv=0.001/2.999792458e8;
513 // Set collision vertex position
514 if (fVertexSmear == kPerEvent) Vertex();
523 // Switch hadronisation off
525 fPythia->SetMSTJ(1, 0);
527 // Either produce new event or read partons from file
529 if (!fReadFromFile) {
535 fNpartons = fPythia->GetN();
537 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
538 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
540 LoadEvent(fRL->Stack(), 0 , 1);
545 // Run quenching routine
549 } else if (fQuench == 2){
550 fPythia->Pyquen(208., 0, 0.);
551 } else if (fQuench == 3) {
552 // Quenching is via multiplicative correction of the splittings
556 // Switch hadronisation on
558 fPythia->SetMSTJ(1, 1);
560 // .. and perform hadronisation
561 // printf("Calling hadronisation %d\n", fPythia->GetN());
564 fPythia->ImportParticles(fParticles,"All");
572 Int_t np = fParticles->GetEntriesFast();
574 if (np == 0) continue;
578 Int_t* pParent = new Int_t[np];
579 Int_t* pSelected = new Int_t[np];
580 Int_t* trackIt = new Int_t[np];
581 for (i = 0; i < np; i++) {
587 Int_t nc = 0; // Total n. of selected particles
588 Int_t nParents = 0; // Selected parents
589 Int_t nTkbles = 0; // Trackable particles
590 if (fProcess != kPyMbDefault &&
592 fProcess != kPyJets &&
593 fProcess != kPyDirectGamma &&
594 fProcess != kPyMbNonDiffr &&
595 fProcess != kPyMbMSEL1 &&
598 fProcess != kPyCharmppMNRwmi &&
599 fProcess != kPyBeautyppMNRwmi) {
601 for (i = 0; i < np; i++) {
602 TParticle* iparticle = (TParticle *) fParticles->At(i);
603 Int_t ks = iparticle->GetStatusCode();
604 kf = CheckPDGCode(iparticle->GetPdgCode());
605 // No initial state partons
606 if (ks==21) continue;
608 // Heavy Flavor Selection
615 if (kfl > 100000) kfl %= 100000;
616 if (kfl > 10000) kfl %= 10000;
618 if (kfl > 10) kfl/=100;
620 if (kfl > 10) kfl/=10;
621 Int_t ipa = iparticle->GetFirstMother()-1;
624 // Establish mother daughter relation between heavy quarks and mesons
626 if (kf >= fFlavorSelect && kf <= 6) {
627 Int_t idau = iparticle->GetFirstDaughter() - 1;
629 TParticle* daughter = (TParticle *) fParticles->At(idau);
630 Int_t pdgD = daughter->GetPdgCode();
631 if (pdgD == 91 || pdgD == 92) {
632 Int_t jmin = daughter->GetFirstDaughter() - 1;
633 Int_t jmax = daughter->GetLastDaughter() - 1;
634 for (Int_t j = jmin; j <= jmax; j++)
635 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
636 } // is string or cluster
642 TParticle * mother = (TParticle *) fParticles->At(ipa);
643 kfMo = TMath::Abs(mother->GetPdgCode());
646 // What to keep in Stack?
647 Bool_t flavorOK = kFALSE;
648 Bool_t selectOK = kFALSE;
650 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
652 if (kfl > fFlavorSelect) {
656 if (kfl == fFlavorSelect) flavorOK = kTRUE;
658 switch (fStackFillOpt) {
659 case kFlavorSelection:
662 case kParentSelection:
663 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
666 if (flavorOK && selectOK) {
668 // Heavy flavor hadron or quark
670 // Kinematic seletion on final state heavy flavor mesons
671 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
676 if (ParentSelected(kf)) ++nParents; // Update parent count
677 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
679 // Kinematic seletion on decay products
680 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
681 && !KinematicSelection(iparticle, 1))
687 // Select if mother was selected and is not tracked
689 if (pSelected[ipa] &&
690 !trackIt[ipa] && // mother will be tracked ?
691 kfMo != 5 && // mother is b-quark, don't store fragments
692 kfMo != 4 && // mother is c-quark, don't store fragments
693 kf != 92) // don't store string
696 // Semi-stable or de-selected: diselect decay products:
699 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
701 Int_t ipF = iparticle->GetFirstDaughter();
702 Int_t ipL = iparticle->GetLastDaughter();
703 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
705 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
706 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
709 if (pSelected[i] == -1) pSelected[i] = 0;
710 if (!pSelected[i]) continue;
711 // Count quarks only if you did not include fragmentation
712 if (fFragmentation && kf <= 10) continue;
715 // Decision on tracking
718 // Track final state particle
719 if (ks == 1) trackIt[i] = 1;
720 // Track semi-stable particles
721 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
722 // Track particles selected by process if undecayed.
723 if (fForceDecay == kNoDecay) {
724 if (ParentSelected(kf)) trackIt[i] = 1;
726 if (ParentSelected(kf)) trackIt[i] = 0;
728 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
732 } // particle selection loop
734 for (i = 0; i<np; i++) {
735 if (!pSelected[i]) continue;
736 TParticle * iparticle = (TParticle *) fParticles->At(i);
737 kf = CheckPDGCode(iparticle->GetPdgCode());
738 Int_t ks = iparticle->GetStatusCode();
739 p[0] = iparticle->Px();
740 p[1] = iparticle->Py();
741 p[2] = iparticle->Pz();
742 p[3] = iparticle->Energy();
744 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
745 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
746 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
748 Float_t tof = kconv*iparticle->T();
749 Int_t ipa = iparticle->GetFirstMother()-1;
750 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
752 PushTrack(fTrackIt*trackIt[i], iparent, kf,
753 p[0], p[1], p[2], p[3],
754 origin[0], origin[1], origin[2], tof,
755 polar[0], polar[1], polar[2],
756 kPPrimary, nt, 1., ks);
773 switch (fCountMode) {
775 // printf(" Count all \n");
779 // printf(" Count parents \n");
782 case kCountTrackables:
783 // printf(" Count trackable \n");
787 if (jev >= fNpart || fNpart == -1) {
788 fKineBias=Float_t(fNpart)/Float_t(fTrials);
790 fQ += fPythia->GetVINT(51);
791 fX1 += fPythia->GetVINT(41);
792 fX2 += fPythia->GetVINT(42);
793 fTrialsRun += fTrials;
800 SetHighWaterMark(nt);
801 // adjust weight due to kinematic selection
804 fXsection=fPythia->GetPARI(1);
807 Int_t AliGenPythia::GenerateMB()
810 // Min Bias selection and other global selections
812 Int_t i, kf, nt, iparent;
815 Float_t polar[3] = {0,0,0};
816 Float_t origin[3] = {0,0,0};
817 // converts from mm/c to s
818 const Float_t kconv=0.001/2.999792458e8;
822 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
826 Int_t* pParent = new Int_t[np];
827 for (i=0; i< np; i++) pParent[i] = -1;
828 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
829 TParticle* jet1 = (TParticle *) fParticles->At(6);
830 TParticle* jet2 = (TParticle *) fParticles->At(7);
831 if (!CheckTrigger(jet1, jet2)) {
837 // Select jets with fragmentation photon or pi0 going to PHOS or EMCAL
838 if (fProcess == kPyJets && (fFragPhotonInCalo || fPi0InCalo) ) {
843 if (fFragPhotonInCalo) pdg = 22 ; // Photon
844 else if (fPi0InCalo) pdg = 111 ; // Pi0
846 for (i=0; i< np; i++) {
847 TParticle* iparticle = (TParticle *) fParticles->At(i);
848 if(iparticle->GetStatusCode()==1 && iparticle->GetPdgCode()==pdg &&
849 iparticle->Pt() > fFragPhotonOrPi0MinPt){
850 Int_t imother = iparticle->GetFirstMother() - 1;
851 TParticle* pmother = (TParticle *) fParticles->At(imother);
853 (pdg == 22 && pmother->GetStatusCode() != 11))//No photon from hadron decay
855 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
856 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
857 if((fCheckEMCAL && IsInEMCAL(phi,eta)) ||
858 (fCheckPHOS && IsInPHOS(phi,eta)) )
867 if (fTriggerParticle) {
868 Bool_t triggered = kFALSE;
869 for (i = 0; i < np; i++) {
870 TParticle * iparticle = (TParticle *) fParticles->At(i);
871 kf = CheckPDGCode(iparticle->GetPdgCode());
872 if (kf != fTriggerParticle) continue;
873 if (iparticle->Pt() == 0.) continue;
874 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
885 // Check if there is a ccbar or bbbar pair with at least one of the two
886 // in fYMin < y < fYMax
887 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
889 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
892 for(i=0; i<np; i++) {
893 hvq = (TParticle*)fParticles->At(i);
894 pdgQ = hvq->GetPdgCode();
895 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
896 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
897 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
898 (hvq->Energy()-hvq->Pz()+1.e-13));
899 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
901 if (!theQ || !theQbar || !inYcut) {
907 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
908 if ( (fProcess == kPyW ||
910 fProcess == kPyMbDefault ||
912 fProcess == kPyMbNonDiffr)
913 && (fCutOnChild == 1) ) {
914 if ( !CheckKinematicsOnChild() ) {
921 for (i = 0; i < np; i++) {
923 TParticle * iparticle = (TParticle *) fParticles->At(i);
924 kf = CheckPDGCode(iparticle->GetPdgCode());
925 Int_t ks = iparticle->GetStatusCode();
926 Int_t km = iparticle->GetFirstMother();
927 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
929 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
931 if (ks == 1) trackIt = 1;
932 Int_t ipa = iparticle->GetFirstMother()-1;
934 iparent = (ipa > -1) ? pParent[ipa] : -1;
937 // store track information
938 p[0] = iparticle->Px();
939 p[1] = iparticle->Py();
940 p[2] = iparticle->Pz();
941 p[3] = iparticle->Energy();
944 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
945 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
946 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
948 Float_t tof = fEventTime + kconv * iparticle->T();
950 PushTrack(fTrackIt*trackIt, iparent, kf,
951 p[0], p[1], p[2], p[3],
952 origin[0], origin[1], origin[2], tof,
953 polar[0], polar[1], polar[2],
954 kPPrimary, nt, 1., ks);
957 // Special Treatment to store color-flow
959 if (ks == 3 || ks == 13 || ks == 14) {
960 TParticle* particle = 0;
962 particle = fStack->Particle(nt);
964 particle = gAlice->Stack()->Particle(nt);
966 particle->SetFirstDaughter(fPythia->GetK(2, i));
967 particle->SetLastDaughter(fPythia->GetK(3, i));
972 SetHighWaterMark(nt);
983 void AliGenPythia::FinishRun()
985 // Print x-section summary
994 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
995 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
998 void AliGenPythia::AdjustWeights() const
1000 // Adjust the weights after generation of all events
1004 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1005 for (Int_t i=0; i<ntrack; i++) {
1006 part= gAlice->GetMCApp()->Particle(i);
1007 part->SetWeight(part->GetWeight()*fKineBias);
1012 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
1014 // Treat protons as inside nuclei with mass numbers a1 and a2
1022 void AliGenPythia::MakeHeader()
1025 // Make header for the simulated event
1028 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1029 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1032 // Builds the event header, to be called after each event
1033 if (fHeader) delete fHeader;
1034 fHeader = new AliGenPythiaEventHeader("Pythia");
1037 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1040 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1043 fHeader->SetPrimaryVertex(fVertex);
1046 // Number of primaries
1047 fHeader->SetNProduced(fNprimaries);
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 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1113 // Check the kinematic trigger condition
1116 eta[0] = jet1->Eta();
1117 eta[1] = jet2->Eta();
1119 phi[0] = jet1->Phi();
1120 phi[1] = jet2->Phi();
1122 pdg[0] = jet1->GetPdgCode();
1123 pdg[1] = jet2->GetPdgCode();
1124 Bool_t triggered = kFALSE;
1126 if (fProcess == kPyJets) {
1129 Float_t jets[4][10];
1131 // Use Pythia clustering on parton level to determine jet axis
1133 GetJets(njets, ntrig, jets);
1135 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1140 if (pdg[0] == kGamma) {
1144 //Check eta range first...
1145 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1146 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1148 //Eta is okay, now check phi range
1149 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1150 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1161 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1163 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1165 Bool_t checking = kFALSE;
1166 Int_t j, kcode, ks, km;
1167 Int_t nPartAcc = 0; //number of particles in the acceptance range
1168 Int_t numberOfAcceptedParticles = 1;
1169 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1170 Int_t npart = fParticles->GetEntriesFast();
1172 for (j = 0; j<npart; j++) {
1173 TParticle * jparticle = (TParticle *) fParticles->At(j);
1174 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1175 ks = jparticle->GetStatusCode();
1176 km = jparticle->GetFirstMother();
1178 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1181 if( numberOfAcceptedParticles <= nPartAcc){
1190 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1193 // Load event into Pythia Common Block
1196 Int_t npart = stack -> GetNprimary();
1200 (fPythia->GetPyjets())->N = npart;
1202 n0 = (fPythia->GetPyjets())->N;
1203 (fPythia->GetPyjets())->N = n0 + npart;
1207 for (Int_t part = 0; part < npart; part++) {
1208 TParticle *mPart = stack->Particle(part);
1210 Int_t kf = mPart->GetPdgCode();
1211 Int_t ks = mPart->GetStatusCode();
1212 Int_t idf = mPart->GetFirstDaughter();
1213 Int_t idl = mPart->GetLastDaughter();
1216 if (ks == 11 || ks == 12) {
1223 Float_t px = mPart->Px();
1224 Float_t py = mPart->Py();
1225 Float_t pz = mPart->Pz();
1226 Float_t e = mPart->Energy();
1227 Float_t m = mPart->GetCalcMass();
1230 (fPythia->GetPyjets())->P[0][part+n0] = px;
1231 (fPythia->GetPyjets())->P[1][part+n0] = py;
1232 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1233 (fPythia->GetPyjets())->P[3][part+n0] = e;
1234 (fPythia->GetPyjets())->P[4][part+n0] = m;
1236 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1237 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1238 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1239 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1240 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1245 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1248 // Calls the Pythia jet finding algorithm to find jets in the current event
1253 Int_t n = fPythia->GetN();
1257 fPythia->Pycell(njets);
1259 for (i = 0; i < njets; i++) {
1260 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1261 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1262 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1263 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1274 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1277 // Calls the Pythia clustering algorithm to find jets in the current event
1279 Int_t n = fPythia->GetN();
1282 if (fJetReconstruction == kCluster) {
1284 // Configure cluster algorithm
1286 fPythia->SetPARU(43, 2.);
1287 fPythia->SetMSTU(41, 1);
1289 // Call cluster algorithm
1291 fPythia->Pyclus(nJets);
1293 // Loading jets from common block
1299 fPythia->Pycell(nJets);
1303 for (i = 0; i < nJets; i++) {
1304 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1305 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1306 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1307 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1308 Float_t pt = TMath::Sqrt(px * px + py * py);
1309 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1310 Float_t theta = TMath::ATan2(pt,pz);
1311 Float_t et = e * TMath::Sin(theta);
1312 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1314 eta > fEtaMinJet && eta < fEtaMaxJet &&
1315 phi > fPhiMinJet && phi < fPhiMaxJet &&
1316 et > fEtMinJet && et < fEtMaxJet
1319 jets[0][nJetsTrig] = px;
1320 jets[1][nJetsTrig] = py;
1321 jets[2][nJetsTrig] = pz;
1322 jets[3][nJetsTrig] = e;
1324 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1326 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1331 void AliGenPythia::GetSubEventTime()
1333 // Calculates time of the next subevent
1336 TArrayF &array = *fEventsTime;
1337 fEventTime = array[fCurSubEvent++];
1339 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1343 Bool_t AliGenPythia::IsInEMCAL(Float_t phi, Float_t eta)
1345 // Is particle in EMCAL acceptance?
1346 // phi in degrees, etamin=-etamax
1347 if(phi > fEMCALMinPhi && phi < fEMCALMaxPhi &&
1354 Bool_t AliGenPythia::IsInPHOS(Float_t phi, Float_t eta)
1356 // Is particle in PHOS acceptance?
1357 // Acceptance slightly larger considered.
1358 // phi in degrees, etamin=-etamax
1359 if(phi > fPHOSMinPhi && phi < fPHOSMaxPhi &&
1369 void AliGenPythia::Streamer(TBuffer &R__b)
1371 // Stream an object of class AliGenPythia.
1373 if (R__b.IsReading()) {
1374 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1375 AliGenerator::Streamer(R__b);
1376 R__b >> (Int_t&)fProcess;
1377 R__b >> (Int_t&)fStrucFunc;
1378 R__b >> (Int_t&)fForceDecay;
1382 fParentSelect.Streamer(R__b);
1383 fChildSelect.Streamer(R__b);
1385 // (AliPythia::Instance())->Streamer(R__b);
1388 // if (fDecayer) fDecayer->Streamer(R__b);
1390 R__b.WriteVersion(AliGenPythia::IsA());
1391 AliGenerator::Streamer(R__b);
1392 R__b << (Int_t)fProcess;
1393 R__b << (Int_t)fStrucFunc;
1394 R__b << (Int_t)fForceDecay;
1398 fParentSelect.Streamer(R__b);
1399 fChildSelect.Streamer(R__b);
1404 // fDecayer->Streamer(R__b);