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);
339 fPythia->SetPARP(93, 4. * fPtKick);
341 fPythia->SetMSTP(91,0);
346 fRL = AliRunLoader::Open(fFileName, "Partons");
347 fRL->LoadKinematics();
353 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
354 // Forward Paramters to the AliPythia object
355 fDecayer->SetForceDecay(fForceDecay);
356 // Switch off Heavy Flavors on request
358 // Maximum number of quark flavours used in pdf
359 fPythia->SetMSTP(58, 3);
360 // Maximum number of flavors that can be used in showers
361 fPythia->SetMSTJ(45, 3);
362 // Switch off g->QQbar splitting in decay table
363 ((AliDecayerPythia*) fDecayer)->HeavyFlavourOff();
369 // Parent and Children Selection
372 case kPyOldUEQ2ordered:
373 case kPyOldUEQ2ordered2:
377 case kPyCharmUnforced:
378 case kPyCharmPbPbMNR:
381 case kPyCharmppMNRwmi:
382 fParentSelect[0] = 411;
383 fParentSelect[1] = 421;
384 fParentSelect[2] = 431;
385 fParentSelect[3] = 4122;
391 fParentSelect[0] = 421;
394 case kPyDPlusPbPbMNR:
397 fParentSelect[0] = 411;
400 case kPyDPlusStrangePbPbMNR:
401 case kPyDPlusStrangepPbMNR:
402 case kPyDPlusStrangeppMNR:
403 fParentSelect[0] = 431;
407 case kPyBeautyPbPbMNR:
408 case kPyBeautypPbMNR:
410 case kPyBeautyppMNRwmi:
411 fParentSelect[0]= 511;
412 fParentSelect[1]= 521;
413 fParentSelect[2]= 531;
414 fParentSelect[3]= 5122;
415 fParentSelect[4]= 5132;
416 fParentSelect[5]= 5232;
417 fParentSelect[6]= 5332;
420 case kPyBeautyUnforced:
421 fParentSelect[0] = 511;
422 fParentSelect[1] = 521;
423 fParentSelect[2] = 531;
424 fParentSelect[3] = 5122;
425 fParentSelect[4] = 5132;
426 fParentSelect[5] = 5232;
427 fParentSelect[6] = 5332;
432 fParentSelect[0] = 443;
448 // JetFinder for Trigger
450 // Configure detector (EMCAL like)
452 fPythia->SetPARU(51, fPycellEtaMax);
453 fPythia->SetMSTU(51, fPycellNEta);
454 fPythia->SetMSTU(52, fPycellNPhi);
456 // Configure Jet Finder
458 fPythia->SetPARU(58, fPycellThreshold);
459 fPythia->SetPARU(52, fPycellEtSeed);
460 fPythia->SetPARU(53, fPycellMinEtJet);
461 fPythia->SetPARU(54, fPycellMaxRadius);
462 fPythia->SetMSTU(54, 2);
464 // This counts the total number of calls to Pyevnt() per run.
479 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
483 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
485 fPythia->SetPARJ(200, 0.0);
488 // Nestor's change of the splittings
489 fPythia->SetPARJ(200, 0.8);
490 fPythia->SetMSTJ(41, 1); // QCD radiation only
491 fPythia->SetMSTJ(42, 2); // angular ordering
492 fPythia->SetMSTJ(44, 2); // option to run alpha_s
493 fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
494 fPythia->SetMSTJ(50, 0); // No coherence in first branching
495 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
499 void AliGenPythia::Generate()
501 // Generate one event
503 fDecayer->ForceDecay();
505 Float_t polar[3] = {0,0,0};
506 Float_t origin[3] = {0,0,0};
508 // converts from mm/c to s
509 const Float_t kconv=0.001/2.999792458e8;
519 // Set collision vertex position
520 if (fVertexSmear == kPerEvent) Vertex();
529 // Switch hadronisation off
531 fPythia->SetMSTJ(1, 0);
533 // Either produce new event or read partons from file
535 if (!fReadFromFile) {
541 fNpartons = fPythia->GetN();
543 printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber());
544 fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber());
546 LoadEvent(fRL->Stack(), 0 , 1);
551 // Run quenching routine
555 } else if (fQuench == 2){
556 fPythia->Pyquen(208., 0, 0.);
557 } else if (fQuench == 3) {
558 // Quenching is via multiplicative correction of the splittings
562 // Switch hadronisation on
564 fPythia->SetMSTJ(1, 1);
566 // .. and perform hadronisation
567 // printf("Calling hadronisation %d\n", fPythia->GetN());
570 fPythia->ImportParticles(fParticles,"All");
578 Int_t np = fParticles->GetEntriesFast();
580 if (np == 0) continue;
584 Int_t* pParent = new Int_t[np];
585 Int_t* pSelected = new Int_t[np];
586 Int_t* trackIt = new Int_t[np];
587 for (i = 0; i < np; i++) {
593 Int_t nc = 0; // Total n. of selected particles
594 Int_t nParents = 0; // Selected parents
595 Int_t nTkbles = 0; // Trackable particles
596 if (fProcess != kPyMbDefault &&
598 fProcess != kPyJets &&
599 fProcess != kPyDirectGamma &&
600 fProcess != kPyMbNonDiffr &&
601 fProcess != kPyMbMSEL1 &&
604 fProcess != kPyCharmppMNRwmi &&
605 fProcess != kPyBeautyppMNRwmi) {
607 for (i = 0; i < np; i++) {
608 TParticle* iparticle = (TParticle *) fParticles->At(i);
609 Int_t ks = iparticle->GetStatusCode();
610 kf = CheckPDGCode(iparticle->GetPdgCode());
611 // No initial state partons
612 if (ks==21) continue;
614 // Heavy Flavor Selection
621 if (kfl > 100000) kfl %= 100000;
622 if (kfl > 10000) kfl %= 10000;
624 if (kfl > 10) kfl/=100;
626 if (kfl > 10) kfl/=10;
627 Int_t ipa = iparticle->GetFirstMother()-1;
630 // Establish mother daughter relation between heavy quarks and mesons
632 if (kf >= fFlavorSelect && kf <= 6) {
633 Int_t idau = iparticle->GetFirstDaughter() - 1;
635 TParticle* daughter = (TParticle *) fParticles->At(idau);
636 Int_t pdgD = daughter->GetPdgCode();
637 if (pdgD == 91 || pdgD == 92) {
638 Int_t jmin = daughter->GetFirstDaughter() - 1;
639 Int_t jmax = daughter->GetLastDaughter() - 1;
640 for (Int_t j = jmin; j <= jmax; j++)
641 ((TParticle *) fParticles->At(j))->SetFirstMother(i+1);
642 } // is string or cluster
648 TParticle * mother = (TParticle *) fParticles->At(ipa);
649 kfMo = TMath::Abs(mother->GetPdgCode());
652 // What to keep in Stack?
653 Bool_t flavorOK = kFALSE;
654 Bool_t selectOK = kFALSE;
656 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
658 if (kfl > fFlavorSelect) {
662 if (kfl == fFlavorSelect) flavorOK = kTRUE;
664 switch (fStackFillOpt) {
665 case kFlavorSelection:
668 case kParentSelection:
669 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
672 if (flavorOK && selectOK) {
674 // Heavy flavor hadron or quark
676 // Kinematic seletion on final state heavy flavor mesons
677 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
682 if (ParentSelected(kf)) ++nParents; // Update parent count
683 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
685 // Kinematic seletion on decay products
686 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
687 && !KinematicSelection(iparticle, 1))
693 // Select if mother was selected and is not tracked
695 if (pSelected[ipa] &&
696 !trackIt[ipa] && // mother will be tracked ?
697 kfMo != 5 && // mother is b-quark, don't store fragments
698 kfMo != 4 && // mother is c-quark, don't store fragments
699 kf != 92) // don't store string
702 // Semi-stable or de-selected: diselect decay products:
705 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
707 Int_t ipF = iparticle->GetFirstDaughter();
708 Int_t ipL = iparticle->GetLastDaughter();
709 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
711 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
712 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
715 if (pSelected[i] == -1) pSelected[i] = 0;
716 if (!pSelected[i]) continue;
717 // Count quarks only if you did not include fragmentation
718 if (fFragmentation && kf <= 10) continue;
721 // Decision on tracking
724 // Track final state particle
725 if (ks == 1) trackIt[i] = 1;
726 // Track semi-stable particles
727 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
728 // Track particles selected by process if undecayed.
729 if (fForceDecay == kNoDecay) {
730 if (ParentSelected(kf)) trackIt[i] = 1;
732 if (ParentSelected(kf)) trackIt[i] = 0;
734 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
738 } // particle selection loop
740 for (i = 0; i<np; i++) {
741 if (!pSelected[i]) continue;
742 TParticle * iparticle = (TParticle *) fParticles->At(i);
743 kf = CheckPDGCode(iparticle->GetPdgCode());
744 Int_t ks = iparticle->GetStatusCode();
745 p[0] = iparticle->Px();
746 p[1] = iparticle->Py();
747 p[2] = iparticle->Pz();
748 p[3] = iparticle->Energy();
750 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
751 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
752 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
754 Float_t tof = kconv*iparticle->T();
755 Int_t ipa = iparticle->GetFirstMother()-1;
756 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
758 PushTrack(fTrackIt*trackIt[i], iparent, kf,
759 p[0], p[1], p[2], p[3],
760 origin[0], origin[1], origin[2], tof,
761 polar[0], polar[1], polar[2],
762 kPPrimary, nt, 1., ks);
779 switch (fCountMode) {
781 // printf(" Count all \n");
785 // printf(" Count parents \n");
788 case kCountTrackables:
789 // printf(" Count trackable \n");
793 if (jev >= fNpart || fNpart == -1) {
794 fKineBias=Float_t(fNpart)/Float_t(fTrials);
796 fQ += fPythia->GetVINT(51);
797 fX1 += fPythia->GetVINT(41);
798 fX2 += fPythia->GetVINT(42);
799 fTrialsRun += fTrials;
806 SetHighWaterMark(nt);
807 // adjust weight due to kinematic selection
810 fXsection=fPythia->GetPARI(1);
813 Int_t AliGenPythia::GenerateMB()
816 // Min Bias selection and other global selections
818 Int_t i, kf, nt, iparent;
821 Float_t polar[3] = {0,0,0};
822 Float_t origin[3] = {0,0,0};
823 // converts from mm/c to s
824 const Float_t kconv=0.001/2.999792458e8;
828 Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons;
832 Int_t* pParent = new Int_t[np];
833 for (i=0; i< np; i++) pParent[i] = -1;
834 if (fProcess == kPyJets || fProcess == kPyDirectGamma) {
835 TParticle* jet1 = (TParticle *) fParticles->At(6);
836 TParticle* jet2 = (TParticle *) fParticles->At(7);
837 if (!CheckTrigger(jet1, jet2)) {
843 // Select jets with fragmentation photon or pi0 going to PHOS or EMCAL
844 if (fProcess == kPyJets && (fFragPhotonInCalo || fPi0InCalo) ) {
849 if (fFragPhotonInCalo) pdg = 22 ; // Photon
850 else if (fPi0InCalo) pdg = 111 ; // Pi0
852 for (i=0; i< np; i++) {
853 TParticle* iparticle = (TParticle *) fParticles->At(i);
854 if(iparticle->GetStatusCode()==1 && iparticle->GetPdgCode()==pdg &&
855 iparticle->Pt() > fFragPhotonOrPi0MinPt){
856 Int_t imother = iparticle->GetFirstMother() - 1;
857 TParticle* pmother = (TParticle *) fParticles->At(imother);
859 (pdg == 22 && pmother->GetStatusCode() != 11))//No photon from hadron decay
861 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
862 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
863 if((fCheckEMCAL && IsInEMCAL(phi,eta)) ||
864 (fCheckPHOS && IsInPHOS(phi,eta)) )
873 if (fTriggerParticle) {
874 Bool_t triggered = kFALSE;
875 for (i = 0; i < np; i++) {
876 TParticle * iparticle = (TParticle *) fParticles->At(i);
877 kf = CheckPDGCode(iparticle->GetPdgCode());
878 if (kf != fTriggerParticle) continue;
879 if (iparticle->Pt() == 0.) continue;
880 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
891 // Check if there is a ccbar or bbbar pair with at least one of the two
892 // in fYMin < y < fYMax
893 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
895 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
898 for(i=0; i<np; i++) {
899 hvq = (TParticle*)fParticles->At(i);
900 pdgQ = hvq->GetPdgCode();
901 if(TMath::Abs(pdgQ) != fFlavorSelect) continue;
902 if(pdgQ>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
903 yQ = 0.5*TMath::Log((hvq->Energy()+hvq->Pz()+1.e-13)/
904 (hvq->Energy()-hvq->Pz()+1.e-13));
905 if(yQ>fYMin && yQ<fYMax) inYcut=kTRUE;
907 if (!theQ || !theQbar || !inYcut) {
913 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
914 if ( (fProcess == kPyW ||
916 fProcess == kPyMbDefault ||
918 fProcess == kPyMbNonDiffr)
919 && (fCutOnChild == 1) ) {
920 if ( !CheckKinematicsOnChild() ) {
927 for (i = 0; i < np; i++) {
929 TParticle * iparticle = (TParticle *) fParticles->At(i);
930 kf = CheckPDGCode(iparticle->GetPdgCode());
931 Int_t ks = iparticle->GetStatusCode();
932 Int_t km = iparticle->GetFirstMother();
933 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
935 (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) {
937 if (ks == 1) trackIt = 1;
938 Int_t ipa = iparticle->GetFirstMother()-1;
940 iparent = (ipa > -1) ? pParent[ipa] : -1;
943 // store track information
944 p[0] = iparticle->Px();
945 p[1] = iparticle->Py();
946 p[2] = iparticle->Pz();
947 p[3] = iparticle->Energy();
950 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
951 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
952 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
954 Float_t tof = fEventTime + kconv * iparticle->T();
956 PushTrack(fTrackIt*trackIt, iparent, kf,
957 p[0], p[1], p[2], p[3],
958 origin[0], origin[1], origin[2], tof,
959 polar[0], polar[1], polar[2],
960 kPPrimary, nt, 1., ks);
963 // Special Treatment to store color-flow
965 if (ks == 3 || ks == 13 || ks == 14) {
966 TParticle* particle = 0;
968 particle = fStack->Particle(nt);
970 particle = gAlice->Stack()->Particle(nt);
972 particle->SetFirstDaughter(fPythia->GetK(2, i));
973 particle->SetLastDaughter(fPythia->GetK(3, i));
978 SetHighWaterMark(nt);
989 void AliGenPythia::FinishRun()
991 // Print x-section summary
1000 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
1001 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
1004 void AliGenPythia::AdjustWeights() const
1006 // Adjust the weights after generation of all events
1010 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1011 for (Int_t i=0; i<ntrack; i++) {
1012 part= gAlice->GetMCApp()->Particle(i);
1013 part->SetWeight(part->GetWeight()*fKineBias);
1018 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
1020 // Treat protons as inside nuclei with mass numbers a1 and a2
1028 void AliGenPythia::MakeHeader()
1031 // Make header for the simulated event
1034 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1035 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1038 // Builds the event header, to be called after each event
1039 if (fHeader) delete fHeader;
1040 fHeader = new AliGenPythiaEventHeader("Pythia");
1043 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1046 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1049 fHeader->SetPrimaryVertex(fVertex);
1052 // Number of primaries
1053 fHeader->SetNProduced(fNprimaries);
1055 // Jets that have triggered
1057 if (fProcess == kPyJets)
1060 Float_t jets[4][10];
1061 GetJets(njet, ntrig, jets);
1064 for (Int_t i = 0; i < ntrig; i++) {
1065 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1070 // Copy relevant information from external header, if present.
1075 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1076 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1078 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1081 exHeader->TriggerJet(i, uqJet);
1082 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1086 // Store quenching parameters
1093 fPythia->GetQuenchingParameters(xp, yp, z);
1096 Double_t r1 = PARIMP.rb1;
1097 Double_t r2 = PARIMP.rb2;
1098 Double_t b = PARIMP.b1;
1099 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1100 Double_t phi = PARIMP.psib1;
1101 xp = r * TMath::Cos(phi);
1102 yp = r * TMath::Sin(phi);
1105 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1106 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1110 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
1117 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1119 // Check the kinematic trigger condition
1122 eta[0] = jet1->Eta();
1123 eta[1] = jet2->Eta();
1125 phi[0] = jet1->Phi();
1126 phi[1] = jet2->Phi();
1128 pdg[0] = jet1->GetPdgCode();
1129 pdg[1] = jet2->GetPdgCode();
1130 Bool_t triggered = kFALSE;
1132 if (fProcess == kPyJets) {
1135 Float_t jets[4][10];
1137 // Use Pythia clustering on parton level to determine jet axis
1139 GetJets(njets, ntrig, jets);
1141 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1146 if (pdg[0] == kGamma) {
1150 //Check eta range first...
1151 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1152 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1154 //Eta is okay, now check phi range
1155 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1156 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1167 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1169 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1171 Bool_t checking = kFALSE;
1172 Int_t j, kcode, ks, km;
1173 Int_t nPartAcc = 0; //number of particles in the acceptance range
1174 Int_t numberOfAcceptedParticles = 1;
1175 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1176 Int_t npart = fParticles->GetEntriesFast();
1178 for (j = 0; j<npart; j++) {
1179 TParticle * jparticle = (TParticle *) fParticles->At(j);
1180 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1181 ks = jparticle->GetStatusCode();
1182 km = jparticle->GetFirstMother();
1184 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1187 if( numberOfAcceptedParticles <= nPartAcc){
1196 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1199 // Load event into Pythia Common Block
1202 Int_t npart = stack -> GetNprimary();
1206 (fPythia->GetPyjets())->N = npart;
1208 n0 = (fPythia->GetPyjets())->N;
1209 (fPythia->GetPyjets())->N = n0 + npart;
1213 for (Int_t part = 0; part < npart; part++) {
1214 TParticle *mPart = stack->Particle(part);
1216 Int_t kf = mPart->GetPdgCode();
1217 Int_t ks = mPart->GetStatusCode();
1218 Int_t idf = mPart->GetFirstDaughter();
1219 Int_t idl = mPart->GetLastDaughter();
1222 if (ks == 11 || ks == 12) {
1229 Float_t px = mPart->Px();
1230 Float_t py = mPart->Py();
1231 Float_t pz = mPart->Pz();
1232 Float_t e = mPart->Energy();
1233 Float_t m = mPart->GetCalcMass();
1236 (fPythia->GetPyjets())->P[0][part+n0] = px;
1237 (fPythia->GetPyjets())->P[1][part+n0] = py;
1238 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1239 (fPythia->GetPyjets())->P[3][part+n0] = e;
1240 (fPythia->GetPyjets())->P[4][part+n0] = m;
1242 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1243 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1244 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1245 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1246 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1251 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1254 // Calls the Pythia jet finding algorithm to find jets in the current event
1259 Int_t n = fPythia->GetN();
1263 fPythia->Pycell(njets);
1265 for (i = 0; i < njets; i++) {
1266 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1267 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1268 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1269 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1280 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1283 // Calls the Pythia clustering algorithm to find jets in the current event
1285 Int_t n = fPythia->GetN();
1288 if (fJetReconstruction == kCluster) {
1290 // Configure cluster algorithm
1292 fPythia->SetPARU(43, 2.);
1293 fPythia->SetMSTU(41, 1);
1295 // Call cluster algorithm
1297 fPythia->Pyclus(nJets);
1299 // Loading jets from common block
1305 fPythia->Pycell(nJets);
1309 for (i = 0; i < nJets; i++) {
1310 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1311 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1312 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1313 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1314 Float_t pt = TMath::Sqrt(px * px + py * py);
1315 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1316 Float_t theta = TMath::ATan2(pt,pz);
1317 Float_t et = e * TMath::Sin(theta);
1318 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1320 eta > fEtaMinJet && eta < fEtaMaxJet &&
1321 phi > fPhiMinJet && phi < fPhiMaxJet &&
1322 et > fEtMinJet && et < fEtMaxJet
1325 jets[0][nJetsTrig] = px;
1326 jets[1][nJetsTrig] = py;
1327 jets[2][nJetsTrig] = pz;
1328 jets[3][nJetsTrig] = e;
1330 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1332 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1337 void AliGenPythia::GetSubEventTime()
1339 // Calculates time of the next subevent
1342 TArrayF &array = *fEventsTime;
1343 fEventTime = array[fCurSubEvent++];
1345 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1349 Bool_t AliGenPythia::IsInEMCAL(Float_t phi, Float_t eta)
1351 // Is particle in EMCAL acceptance?
1352 // phi in degrees, etamin=-etamax
1353 if(phi > fEMCALMinPhi && phi < fEMCALMaxPhi &&
1360 Bool_t AliGenPythia::IsInPHOS(Float_t phi, Float_t eta)
1362 // Is particle in PHOS acceptance?
1363 // Acceptance slightly larger considered.
1364 // phi in degrees, etamin=-etamax
1365 if(phi > fPHOSMinPhi && phi < fPHOSMaxPhi &&
1375 void AliGenPythia::Streamer(TBuffer &R__b)
1377 // Stream an object of class AliGenPythia.
1379 if (R__b.IsReading()) {
1380 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1381 AliGenerator::Streamer(R__b);
1382 R__b >> (Int_t&)fProcess;
1383 R__b >> (Int_t&)fStrucFunc;
1384 R__b >> (Int_t&)fForceDecay;
1388 fParentSelect.Streamer(R__b);
1389 fChildSelect.Streamer(R__b);
1391 // (AliPythia::Instance())->Streamer(R__b);
1394 // if (fDecayer) fDecayer->Streamer(R__b);
1396 R__b.WriteVersion(AliGenPythia::IsA());
1397 AliGenerator::Streamer(R__b);
1398 R__b << (Int_t)fProcess;
1399 R__b << (Int_t)fStrucFunc;
1400 R__b << (Int_t)fForceDecay;
1404 fParentSelect.Streamer(R__b);
1405 fChildSelect.Streamer(R__b);
1410 // fDecayer->Streamer(R__b);