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>
32 #include <TObjArray.h>
36 #include "AliDecayerPythia.h"
37 #include "AliGenPythia.h"
38 #include "AliFastGlauber.h"
39 #include "AliHeader.h"
40 #include "AliGenPythiaEventHeader.h"
41 #include "AliPythia.h"
42 #include "AliPythiaRndm.h"
45 #include "AliRunLoader.h"
47 #include "PyquenCommon.h"
49 ClassImp(AliGenPythia)
52 AliGenPythia::AliGenPythia():
85 fDecayer(new AliDecayerPythia()),
93 fPhiMaxJet(2.* TMath::Pi()),
94 fJetReconstruction(kCell),
98 fPhiMaxGamma(2. * TMath::Pi()),
102 fPycellThreshold(0.),
104 fPycellMinEtJet(10.),
105 fPycellMaxRadius(1.),
106 fStackFillOpt(kFlavorSelection),
108 fFragmentation(kTRUE),
115 fTriggerMultiplicity(0),
116 fTriggerMultiplicityEta(0),
117 fCountMode(kCountAll),
121 fFragPhotonInCalo(kFALSE),
123 fPhotonInCalo(kFALSE),
127 fCheckPHOSeta(kFALSE),
128 fFragPhotonOrPi0MinPt(0),
139 // Default Constructor
142 if (!AliPythiaRndm::GetPythiaRandom())
143 AliPythiaRndm::SetPythiaRandom(GetRandom());
146 AliGenPythia::AliGenPythia(Int_t npart)
157 fInteractionRate(0.),
171 fHadronisation(kTRUE),
173 fReadFromFile(kFALSE),
179 fDecayer(new AliDecayerPythia()),
180 fDebugEventFirst(-1),
187 fPhiMaxJet(2.* TMath::Pi()),
188 fJetReconstruction(kCell),
192 fPhiMaxGamma(2. * TMath::Pi()),
196 fPycellThreshold(0.),
198 fPycellMinEtJet(10.),
199 fPycellMaxRadius(1.),
200 fStackFillOpt(kFlavorSelection),
202 fFragmentation(kTRUE),
209 fTriggerMultiplicity(0),
210 fTriggerMultiplicityEta(0),
211 fCountMode(kCountAll),
215 fFragPhotonInCalo(kFALSE),
217 fPhotonInCalo(kFALSE),
221 fCheckPHOSeta(kFALSE),
222 fFragPhotonOrPi0MinPt(0),
232 // default charm production at 5. 5 TeV
234 // structure function GRVHO
238 fTitle= "Particle Generator using PYTHIA";
240 // Set random number generator
241 if (!AliPythiaRndm::GetPythiaRandom())
242 AliPythiaRndm::SetPythiaRandom(GetRandom());
246 AliGenPythia::~AliGenPythia()
249 if(fEventsTime) delete fEventsTime;
252 void AliGenPythia::SetInteractionRate(Float_t rate,Float_t timewindow)
254 // Generate pileup using user specified rate
255 fInteractionRate = rate;
256 fTimeWindow = timewindow;
260 void AliGenPythia::GeneratePileup()
262 // Generate sub events time for pileup
264 if(fInteractionRate == 0.) {
265 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
269 Int_t npart = NumberParticles();
271 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
275 if(fEventsTime) delete fEventsTime;
276 fEventsTime = new TArrayF(npart);
277 TArrayF &array = *fEventsTime;
278 for(Int_t ipart = 0; ipart < npart; ipart++)
281 Float_t eventtime = 0.;
284 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
285 if(eventtime > fTimeWindow) break;
286 array.Set(array.GetSize()+1);
287 array[array.GetSize()-1] = eventtime;
293 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
294 if(TMath::Abs(eventtime) > fTimeWindow) break;
295 array.Set(array.GetSize()+1);
296 array[array.GetSize()-1] = eventtime;
299 SetNumberParticles(fEventsTime->GetSize());
302 void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
303 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
305 // Set pycell parameters
306 fPycellEtaMax = etamax;
309 fPycellThreshold = thresh;
310 fPycellEtSeed = etseed;
311 fPycellMinEtJet = minet;
312 fPycellMaxRadius = r;
317 void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast)
319 // Set a range of event numbers, for which a table
320 // of generated particle will be printed
321 fDebugEventFirst = eventFirst;
322 fDebugEventLast = eventLast;
323 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
326 void AliGenPythia::Init()
330 SetMC(AliPythia::Instance());
331 fPythia=(AliPythia*) fMCEvGen;
334 fParentWeight=1./Float_t(fNpart);
338 fPythia->SetCKIN(3,fPtHardMin);
339 fPythia->SetCKIN(4,fPtHardMax);
340 fPythia->SetCKIN(7,fYHardMin);
341 fPythia->SetCKIN(8,fYHardMax);
343 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget, fNucPdf);
345 if (fFragmentation) {
346 fPythia->SetMSTP(111,1);
348 fPythia->SetMSTP(111,0);
352 // initial state radiation
353 fPythia->SetMSTP(61,fGinit);
354 // final state radiation
355 fPythia->SetMSTP(71,fGfinal);
358 fPythia->SetMSTP(91,1);
359 fPythia->SetPARP(91,fPtKick);
360 fPythia->SetPARP(93, 4. * fPtKick);
362 fPythia->SetMSTP(91,0);
367 fRL = AliRunLoader::Open(fFileName, "Partons");
368 fRL->LoadKinematics();
374 fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
375 // Forward Paramters to the AliPythia object
376 fDecayer->SetForceDecay(fForceDecay);
377 // Switch off Heavy Flavors on request
379 // Maximum number of quark flavours used in pdf
380 fPythia->SetMSTP(58, 3);
381 // Maximum number of flavors that can be used in showers
382 fPythia->SetMSTJ(45, 3);
383 // Switch off g->QQbar splitting in decay table
384 ((AliDecayerPythia*) fDecayer)->HeavyFlavourOff();
390 // Parent and Children Selection
393 case kPyOldUEQ2ordered:
394 case kPyOldUEQ2ordered2:
398 case kPyCharmUnforced:
399 case kPyCharmPbPbMNR:
402 case kPyCharmppMNRwmi:
403 fParentSelect[0] = 411;
404 fParentSelect[1] = 421;
405 fParentSelect[2] = 431;
406 fParentSelect[3] = 4122;
407 fParentSelect[4] = 4232;
408 fParentSelect[5] = 4132;
409 fParentSelect[6] = 4332;
415 fParentSelect[0] = 421;
418 case kPyDPlusPbPbMNR:
421 fParentSelect[0] = 411;
424 case kPyDPlusStrangePbPbMNR:
425 case kPyDPlusStrangepPbMNR:
426 case kPyDPlusStrangeppMNR:
427 fParentSelect[0] = 431;
432 case kPyBeautyPbPbMNR:
433 case kPyBeautypPbMNR:
435 case kPyBeautyppMNRwmi:
436 fParentSelect[0]= 511;
437 fParentSelect[1]= 521;
438 fParentSelect[2]= 531;
439 fParentSelect[3]= 5122;
440 fParentSelect[4]= 5132;
441 fParentSelect[5]= 5232;
442 fParentSelect[6]= 5332;
445 case kPyBeautyUnforced:
446 fParentSelect[0] = 511;
447 fParentSelect[1] = 521;
448 fParentSelect[2] = 531;
449 fParentSelect[3] = 5122;
450 fParentSelect[4] = 5132;
451 fParentSelect[5] = 5232;
452 fParentSelect[6] = 5332;
457 fParentSelect[0] = 443;
461 case kPyMbWithDirectPhoton:
474 // JetFinder for Trigger
476 // Configure detector (EMCAL like)
478 fPythia->SetPARU(51, fPycellEtaMax);
479 fPythia->SetMSTU(51, fPycellNEta);
480 fPythia->SetMSTU(52, fPycellNPhi);
482 // Configure Jet Finder
484 fPythia->SetPARU(58, fPycellThreshold);
485 fPythia->SetPARU(52, fPycellEtSeed);
486 fPythia->SetPARU(53, fPycellMinEtJet);
487 fPythia->SetPARU(54, fPycellMaxRadius);
488 fPythia->SetMSTU(54, 2);
490 // This counts the total number of calls to Pyevnt() per run.
505 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
508 fPythia->SetPARJ(200, 0.0);
509 fPythia->SetPARJ(199, 0.0);
510 fPythia->SetPARJ(198, 0.0);
511 fPythia->SetPARJ(197, 0.0);
514 fPythia->InitQuenching(0., 0.1, 0.6e6, 0);
518 // Nestor's change of the splittings
519 fPythia->SetPARJ(200, 0.8);
520 fPythia->SetMSTJ(41, 1); // QCD radiation only
521 fPythia->SetMSTJ(42, 2); // angular ordering
522 fPythia->SetMSTJ(44, 2); // option to run alpha_s
523 fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
524 fPythia->SetMSTJ(50, 0); // No coherence in first branching
525 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
526 } else if (fQuench == 4) {
527 // Armesto-Cunqueiro-Salgado change of the splittings.
528 AliFastGlauber* glauber = AliFastGlauber::Instance();
530 //read and store transverse almonds corresponding to differnt
532 glauber->SetCentralityClass(0.,0.1);
533 fPythia->SetPARJ(200, 1.);
534 fPythia->SetPARJ(198, fQhat);
535 fPythia->SetPARJ(199, fLength);
537 fPythia->SetMSTJ(41, 1); // QCD radiation only
538 fPythia->SetMSTJ(42, 2); // angular ordering
539 fPythia->SetMSTJ(44, 2); // option to run alpha_s
540 //fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
541 //fPythia->SetMSTJ(50, 0); // No coherence in first branching
542 fPythia->SetPARJ(82, 1.); // Cut off for parton showers
543 // MSTJ(41) must NOT be 11 or 12, as then FSR may go through PYPTFS
544 // (kt-ordered cascade) in which medium effects have not been introduced.
548 void AliGenPythia::Generate()
550 // Generate one event
551 if (!fPythia) fPythia=(AliPythia*) fMCEvGen;
552 fDecayer->ForceDecay();
554 Float_t polar[3] = {0,0,0};
555 Float_t origin[3] = {0,0,0};
557 // converts from mm/c to s
558 const Float_t kconv=0.001/2.999792458e8;
568 // Set collision vertex position
569 if (fVertexSmear == kPerEvent) Vertex();
578 // Switch hadronisation off
580 fPythia->SetMSTJ(1, 0);
584 // Quenching comes through medium-modified splitting functions.
585 AliFastGlauber::Instance()->GetRandomBHard(bimp);
586 fPythia->SetPARJ(197,bimp);
589 // Either produce new event or read partons from file
591 if (!fReadFromFile) {
597 fNpartons = fPythia->GetN();
599 printf("Loading Event %d\n",AliRunLoader::Instance()->GetEventNumber());
600 fRL->GetEvent(AliRunLoader::Instance()->GetEventNumber());
602 LoadEvent(fRL->Stack(), 0 , 1);
607 // Run quenching routine
611 } else if (fQuench == 2){
612 fPythia->Pyquen(208., 0, 0.);
613 } else if (fQuench == 3) {
614 // Quenching is via multiplicative correction of the splittings
618 // Switch hadronisation on
620 if (fHadronisation) {
621 fPythia->SetMSTJ(1, 1);
623 // .. and perform hadronisation
624 // printf("Calling hadronisation %d\n", fPythia->GetN());
628 fPythia->ImportParticles(&fParticles,"All");
636 Int_t np = fParticles.GetEntriesFast();
638 if (np == 0) continue;
642 Int_t* pParent = new Int_t[np];
643 Int_t* pSelected = new Int_t[np];
644 Int_t* trackIt = new Int_t[np];
645 for (i = 0; i < np; i++) {
651 Int_t nc = 0; // Total n. of selected particles
652 Int_t nParents = 0; // Selected parents
653 Int_t nTkbles = 0; // Trackable particles
654 if (fProcess != kPyMbDefault &&
656 fProcess != kPyMbWithDirectPhoton &&
657 fProcess != kPyJets &&
658 fProcess != kPyDirectGamma &&
659 fProcess != kPyMbNonDiffr &&
660 fProcess != kPyMbMSEL1 &&
663 fProcess != kPyCharmppMNRwmi &&
664 fProcess != kPyBeautyppMNRwmi &&
665 fProcess != kPyBeautyJets) {
667 for (i = 0; i < np; i++) {
668 TParticle* iparticle = (TParticle *) fParticles.At(i);
669 Int_t ks = iparticle->GetStatusCode();
670 kf = CheckPDGCode(iparticle->GetPdgCode());
671 // No initial state partons
672 if (ks==21) continue;
674 // Heavy Flavor Selection
681 if (kfl > 100000) kfl %= 100000;
682 if (kfl > 10000) kfl %= 10000;
684 if (kfl > 10) kfl/=100;
686 if (kfl > 10) kfl/=10;
687 Int_t ipa = iparticle->GetFirstMother()-1;
690 // Establish mother daughter relation between heavy quarks and mesons
692 if (kf >= fFlavorSelect && kf <= 6) {
693 Int_t idau = iparticle->GetFirstDaughter() - 1;
695 TParticle* daughter = (TParticle *) fParticles.At(idau);
696 Int_t pdgD = daughter->GetPdgCode();
697 if (pdgD == 91 || pdgD == 92) {
698 Int_t jmin = daughter->GetFirstDaughter() - 1;
699 Int_t jmax = daughter->GetLastDaughter() - 1;
700 for (Int_t jp = jmin; jp <= jmax; jp++)
701 ((TParticle *) fParticles.At(jp))->SetFirstMother(i+1);
702 } // is string or cluster
708 TParticle * mother = (TParticle *) fParticles.At(ipa);
709 kfMo = TMath::Abs(mother->GetPdgCode());
712 // What to keep in Stack?
713 Bool_t flavorOK = kFALSE;
714 Bool_t selectOK = kFALSE;
716 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
718 if (kfl > fFlavorSelect) {
722 if (kfl == fFlavorSelect) flavorOK = kTRUE;
724 switch (fStackFillOpt) {
725 case kFlavorSelection:
728 case kParentSelection:
729 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
732 if (flavorOK && selectOK) {
734 // Heavy flavor hadron or quark
736 // Kinematic seletion on final state heavy flavor mesons
737 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
742 if (ParentSelected(kf)) ++nParents; // Update parent count
743 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
745 // Kinematic seletion on decay products
746 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
747 && !KinematicSelection(iparticle, 1))
753 // Select if mother was selected and is not tracked
755 if (pSelected[ipa] &&
756 !trackIt[ipa] && // mother will be tracked ?
757 kfMo != 5 && // mother is b-quark, don't store fragments
758 kfMo != 4 && // mother is c-quark, don't store fragments
759 kf != 92) // don't store string
762 // Semi-stable or de-selected: diselect decay products:
765 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
767 Int_t ipF = iparticle->GetFirstDaughter();
768 Int_t ipL = iparticle->GetLastDaughter();
769 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
771 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
772 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
775 if (pSelected[i] == -1) pSelected[i] = 0;
776 if (!pSelected[i]) continue;
777 // Count quarks only if you did not include fragmentation
778 if (fFragmentation && kf <= 10) continue;
781 // Decision on tracking
784 // Track final state particle
785 if (ks == 1) trackIt[i] = 1;
786 // Track semi-stable particles
787 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
788 // Track particles selected by process if undecayed.
789 if (fForceDecay == kNoDecay) {
790 if (ParentSelected(kf)) trackIt[i] = 1;
792 if (ParentSelected(kf)) trackIt[i] = 0;
794 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
798 } // particle selection loop
800 for (i = 0; i<np; i++) {
801 if (!pSelected[i]) continue;
802 TParticle * iparticle = (TParticle *) fParticles.At(i);
803 kf = CheckPDGCode(iparticle->GetPdgCode());
804 Int_t ks = iparticle->GetStatusCode();
805 p[0] = iparticle->Px();
806 p[1] = iparticle->Py();
807 p[2] = iparticle->Pz();
808 p[3] = iparticle->Energy();
810 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
811 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
812 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
814 Float_t tof = kconv*iparticle->T();
815 Int_t ipa = iparticle->GetFirstMother()-1;
816 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
818 PushTrack(fTrackIt*trackIt[i], iparent, kf,
819 p[0], p[1], p[2], p[3],
820 origin[0], origin[1], origin[2], tof,
821 polar[0], polar[1], polar[2],
822 kPPrimary, nt, 1., ks);
839 switch (fCountMode) {
841 // printf(" Count all \n");
845 // printf(" Count parents \n");
848 case kCountTrackables:
849 // printf(" Count trackable \n");
853 if (jev >= fNpart || fNpart == -1) {
854 fKineBias=Float_t(fNpart)/Float_t(fTrials);
856 fQ += fPythia->GetVINT(51);
857 fX1 += fPythia->GetVINT(41);
858 fX2 += fPythia->GetVINT(42);
859 fTrialsRun += fTrials;
866 SetHighWaterMark(nt);
867 // adjust weight due to kinematic selection
870 fXsection=fPythia->GetPARI(1);
873 Int_t AliGenPythia::GenerateMB()
876 // Min Bias selection and other global selections
878 Int_t i, kf, nt, iparent;
881 Float_t polar[3] = {0,0,0};
882 Float_t origin[3] = {0,0,0};
883 // converts from mm/c to s
884 const Float_t kconv=0.001/2.999792458e8;
888 Int_t np = (fHadronisation) ? fParticles.GetEntriesFast() : fNpartons;
892 Int_t* pParent = new Int_t[np];
893 for (i=0; i< np; i++) pParent[i] = -1;
895 //TO BE CHECKED: Should we require this for Beauty Jets?
897 if (fProcess == kPyJets || fProcess == kPyDirectGamma || fProcess == kPyBeautyJets) {
898 TParticle* jet1 = (TParticle *) fParticles.At(6);
899 TParticle* jet2 = (TParticle *) fParticles.At(7);
900 if (!CheckTrigger(jet1, jet2)) {
906 // Select jets with fragmentation photon or pi0 going to PHOS or EMCAL
907 if (fProcess == kPyJets && (fFragPhotonInCalo || fPi0InCalo) ) {
912 if (fFragPhotonInCalo) pdg = 22 ; // Photon
913 else if (fPi0InCalo) pdg = 111 ; // Pi0
915 for (i=0; i< np; i++) {
916 TParticle* iparticle = (TParticle *) fParticles.At(i);
917 if(iparticle->GetStatusCode()==1 && iparticle->GetPdgCode()==pdg &&
918 iparticle->Pt() > fFragPhotonOrPi0MinPt){
919 Int_t imother = iparticle->GetFirstMother() - 1;
920 TParticle* pmother = (TParticle *) fParticles.At(imother);
922 (pdg == 22 && pmother->GetStatusCode() != 11)) //No photon from hadron decay
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((fCheckEMCAL && IsInEMCAL(phi,eta)) ||
927 (fCheckPHOS && IsInPHOS(phi,eta)) )
936 // Select beauty jets with electron in EMCAL
937 if (fProcess == kPyBeautyJets && fEleInEMCAL) {
941 Int_t pdg = 11; //electron
943 Float_t pt, eta, phi;
944 for (i=0; i< np; i++) {
945 TParticle* iparticle = (TParticle *) fParticles.At(i);
946 if(iparticle->GetStatusCode()==1 && TMath::Abs(iparticle->GetPdgCode())==pdg &&
947 iparticle->Pt() > fElectronMinPt){
948 pt = iparticle->Pt();
949 phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
950 eta =TMath::Abs(iparticle->Eta()); //in calos etamin=-etamax
951 if(IsInEMCAL(phi,eta))
957 AliDebug(5,Form("Found an electron jet (pt,eta,phi) = (%f,%f,%f)",pt,eta,phi));
960 // Check for minimum multiplicity
961 if (fTriggerMultiplicity > 0) {
962 Int_t multiplicity = 0;
963 for (i = 0; i < np; i++) {
964 TParticle * iparticle = (TParticle *) fParticles.At(i);
966 Int_t statusCode = iparticle->GetStatusCode();
968 // Initial state particle
972 // skip quarks and gluons
973 Int_t pdgCode = TMath::Abs(iparticle->GetPdgCode());
974 if (pdgCode <= 10 || pdgCode == 21)
977 if (fTriggerMultiplicityEta > 0 && TMath::Abs(iparticle->Eta()) > fTriggerMultiplicityEta)
980 TParticlePDG* pdgPart = iparticle->GetPDG();
981 if (pdgPart && pdgPart->Charge() == 0)
987 if (multiplicity < fTriggerMultiplicity) {
992 Printf("Triggered on event with multiplicity of %d > %d", multiplicity, fTriggerMultiplicity);
995 // Select events with a photon pt > min pt going to PHOS eta acceptance or exactly PHOS eta phi
996 if ((fProcess == kPyJets || fProcess == kPyDirectGamma) && fPhotonInCalo && (fCheckPHOSeta || fCheckPHOS)){
1002 for (i=0; i< np; i++) {
1003 TParticle* iparticle = (TParticle *) fParticles.At(i);
1004 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
1005 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
1007 if(iparticle->GetStatusCode() == 1
1008 && iparticle->GetPdgCode() == pdg
1009 && iparticle->Pt() > fPhotonMinPt
1012 // first check if the photon is in PHOS phi
1013 if(IsInPHOS(phi,eta)){
1017 if(fCheckPHOSeta) iphcand = i; // candiate photon to rotate in phi
1022 if(!okd && iphcand != -1) // execute rotation in phi
1023 RotatePhi(iphcand,okd);
1029 if (fTriggerParticle) {
1030 Bool_t triggered = kFALSE;
1031 for (i = 0; i < np; i++) {
1032 TParticle * iparticle = (TParticle *) fParticles.At(i);
1033 kf = CheckPDGCode(iparticle->GetPdgCode());
1034 if (kf != fTriggerParticle) continue;
1035 if (iparticle->Pt() == 0.) continue;
1036 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
1047 // Check if there is a ccbar or bbbar pair with at least one of the two
1048 // in fYMin < y < fYMax
1050 // TO BE CHECKED: Should we require this for beauty jets?
1052 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi || fProcess == kPyBeautyJets) {
1053 TParticle *partCheck;
1055 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
1056 Bool_t theChild=kFALSE;
1058 Int_t pdg,mpdg,mpdgUpperFamily;
1059 for(i=0; i<np; i++) {
1060 partCheck = (TParticle*)fParticles.At(i);
1061 pdg = partCheck->GetPdgCode();
1062 if(TMath::Abs(pdg) == fFlavorSelect) { // quark
1063 if(pdg>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
1064 y = 0.5*TMath::Log((partCheck->Energy()+partCheck->Pz()+1.e-13)/
1065 (partCheck->Energy()-partCheck->Pz()+1.e-13));
1066 if(y>fYMin && y<fYMax) inYcut=kTRUE;
1068 if(fCutOnChild && TMath::Abs(pdg) == fPdgCodeParticleforAcceptanceCut) {
1069 Int_t mi = partCheck->GetFirstMother() - 1;
1071 mother = (TParticle*)fParticles.At(mi);
1072 mpdg=TMath::Abs(mother->GetPdgCode());
1073 mpdgUpperFamily=(mpdg>1000 ? mpdg+1000 : mpdg+100); // keep e from c from b
1074 if ( ParentSelected(mpdg) ||
1075 (fFlavorSelect==5 && ParentSelected(mpdgUpperFamily))) {
1076 if (KinematicSelection(partCheck,1)) {
1082 if (!theQ || !theQbar || !inYcut) { // one of the c/b conditions not satisfied
1086 if (fCutOnChild && !theChild) { // one of the child conditions not satisfied
1093 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
1094 if ( (fProcess == kPyW ||
1096 fProcess == kPyMbDefault ||
1097 fProcess == kPyMb ||
1098 fProcess == kPyMbWithDirectPhoton ||
1099 fProcess == kPyMbNonDiffr)
1100 && (fCutOnChild == 1) ) {
1101 if ( !CheckKinematicsOnChild() ) {
1108 for (i = 0; i < np; i++) {
1110 TParticle * iparticle = (TParticle *) fParticles.At(i);
1111 kf = CheckPDGCode(iparticle->GetPdgCode());
1112 Int_t ks = iparticle->GetStatusCode();
1113 Int_t km = iparticle->GetFirstMother();
1114 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
1117 //TO BE CHECKED: Should we require this for beauty jets?
1119 ((fProcess == kPyJets || fProcess == kPyBeautyJets) && ks == 21 && km == 0 && i>1)) {
1121 if (ks == 1) trackIt = 1;
1122 Int_t ipa = iparticle->GetFirstMother()-1;
1124 iparent = (ipa > -1) ? pParent[ipa] : -1;
1127 // store track information
1128 p[0] = iparticle->Px();
1129 p[1] = iparticle->Py();
1130 p[2] = iparticle->Pz();
1131 p[3] = iparticle->Energy();
1134 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
1135 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
1136 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
1138 Float_t tof = fEventTime + kconv * iparticle->T();
1140 PushTrack(fTrackIt*trackIt, iparent, kf,
1141 p[0], p[1], p[2], p[3],
1142 origin[0], origin[1], origin[2], tof,
1143 polar[0], polar[1], polar[2],
1144 kPPrimary, nt, 1., ks);
1148 SetHighWaterMark(nt);
1150 } // select particle
1159 void AliGenPythia::FinishRun()
1161 // Print x-section summary
1170 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
1171 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
1174 void AliGenPythia::AdjustWeights() const
1176 // Adjust the weights after generation of all events
1180 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1181 for (Int_t i=0; i<ntrack; i++) {
1182 part= gAlice->GetMCApp()->Particle(i);
1183 part->SetWeight(part->GetWeight()*fKineBias);
1188 void AliGenPythia::SetNuclei(Int_t a1, Int_t a2, Int_t pdfset)
1190 // Treat protons as inside nuclei with mass numbers a1 and a2
1194 fNucPdf = pdfset; // 0 EKS98 1 EPS08
1199 void AliGenPythia::MakeHeader()
1202 // Make header for the simulated event
1205 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1206 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(2);
1209 // Builds the event header, to be called after each event
1210 if (fHeader) delete fHeader;
1211 fHeader = new AliGenPythiaEventHeader("Pythia");
1214 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1));
1217 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1220 fHeader->SetPrimaryVertex(fVertex);
1223 // Number of primaries
1224 fHeader->SetNProduced(fNprimaries);
1226 // Jets that have triggered
1228 //Need to store jets for b-jet studies too!
1229 if (fProcess == kPyJets || fProcess == kPyDirectGamma || fProcess == kPyBeautyJets)
1232 Float_t jets[4][10];
1233 GetJets(njet, ntrig, jets);
1236 for (Int_t i = 0; i < ntrig; i++) {
1237 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1242 // Copy relevant information from external header, if present.
1247 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1248 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1250 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1253 exHeader->TriggerJet(i, uqJet);
1254 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1258 // Store quenching parameters
1265 fPythia->GetQuenchingParameters(xp, yp, z);
1266 } else if (fQuench == 2){
1268 Double_t r1 = PARIMP.rb1;
1269 Double_t r2 = PARIMP.rb2;
1270 Double_t b = PARIMP.b1;
1271 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1272 Double_t phi = PARIMP.psib1;
1273 xp = r * TMath::Cos(phi);
1274 yp = r * TMath::Sin(phi);
1276 } else if (fQuench == 4) {
1280 AliFastGlauber::Instance()->GetSavedXY(xy);
1281 AliFastGlauber::Instance()->GetSavedI0I1(i0i1);
1284 ((AliGenPythiaEventHeader*) fHeader)->SetInMediumLength(2. * i0i1[1] / i0i1[0]);
1287 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1288 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1292 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetVINT(47));
1300 Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2)
1302 // Check the kinematic trigger condition
1305 eta[0] = jet1->Eta();
1306 eta[1] = jet2->Eta();
1308 phi[0] = jet1->Phi();
1309 phi[1] = jet2->Phi();
1311 pdg[0] = jet1->GetPdgCode();
1312 pdg[1] = jet2->GetPdgCode();
1313 Bool_t triggered = kFALSE;
1316 //TO BE CHECKED: If we call this method for kPyBeautyJets, we need it here
1318 if (fProcess == kPyJets || fProcess == kPyBeautyJets) {
1321 Float_t jets[4][10];
1323 // Use Pythia clustering on parton level to determine jet axis
1325 GetJets(njets, ntrig, jets);
1327 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1332 if (pdg[0] == kGamma) {
1336 //Check eta range first...
1337 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1338 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1340 //Eta is okay, now check phi range
1341 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1342 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1353 Bool_t AliGenPythia::CheckKinematicsOnChild(){
1355 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1357 Bool_t checking = kFALSE;
1358 Int_t j, kcode, ks, km;
1359 Int_t nPartAcc = 0; //number of particles in the acceptance range
1360 Int_t numberOfAcceptedParticles = 1;
1361 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1362 Int_t npart = fParticles.GetEntriesFast();
1364 for (j = 0; j<npart; j++) {
1365 TParticle * jparticle = (TParticle *) fParticles.At(j);
1366 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1367 ks = jparticle->GetStatusCode();
1368 km = jparticle->GetFirstMother();
1370 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1373 if( numberOfAcceptedParticles <= nPartAcc){
1382 void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr)
1385 // Load event into Pythia Common Block
1388 Int_t npart = stack -> GetNprimary();
1392 (fPythia->GetPyjets())->N = npart;
1394 n0 = (fPythia->GetPyjets())->N;
1395 (fPythia->GetPyjets())->N = n0 + npart;
1399 for (Int_t part = 0; part < npart; part++) {
1400 TParticle *mPart = stack->Particle(part);
1402 Int_t kf = mPart->GetPdgCode();
1403 Int_t ks = mPart->GetStatusCode();
1404 Int_t idf = mPart->GetFirstDaughter();
1405 Int_t idl = mPart->GetLastDaughter();
1408 if (ks == 11 || ks == 12) {
1415 Float_t px = mPart->Px();
1416 Float_t py = mPart->Py();
1417 Float_t pz = mPart->Pz();
1418 Float_t e = mPart->Energy();
1419 Float_t m = mPart->GetCalcMass();
1422 (fPythia->GetPyjets())->P[0][part+n0] = px;
1423 (fPythia->GetPyjets())->P[1][part+n0] = py;
1424 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1425 (fPythia->GetPyjets())->P[3][part+n0] = e;
1426 (fPythia->GetPyjets())->P[4][part+n0] = m;
1428 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1429 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1430 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1431 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1432 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1436 void AliGenPythia::LoadEvent(TObjArray* stack, Int_t flag, Int_t reHadr)
1439 // Load event into Pythia Common Block
1442 Int_t npart = stack -> GetEntries();
1446 (fPythia->GetPyjets())->N = npart;
1448 n0 = (fPythia->GetPyjets())->N;
1449 (fPythia->GetPyjets())->N = n0 + npart;
1453 for (Int_t part = 0; part < npart; part++) {
1454 TParticle *mPart = dynamic_cast<TParticle *>(stack->At(part));
1455 Int_t kf = mPart->GetPdgCode();
1456 Int_t ks = mPart->GetStatusCode();
1457 Int_t idf = mPart->GetFirstDaughter();
1458 Int_t idl = mPart->GetLastDaughter();
1461 if (ks == 11 || ks == 12) {
1468 Float_t px = mPart->Px();
1469 Float_t py = mPart->Py();
1470 Float_t pz = mPart->Pz();
1471 Float_t e = mPart->Energy();
1472 Float_t m = mPart->GetCalcMass();
1475 (fPythia->GetPyjets())->P[0][part+n0] = px;
1476 (fPythia->GetPyjets())->P[1][part+n0] = py;
1477 (fPythia->GetPyjets())->P[2][part+n0] = pz;
1478 (fPythia->GetPyjets())->P[3][part+n0] = e;
1479 (fPythia->GetPyjets())->P[4][part+n0] = m;
1481 (fPythia->GetPyjets())->K[1][part+n0] = kf;
1482 (fPythia->GetPyjets())->K[0][part+n0] = ks;
1483 (fPythia->GetPyjets())->K[3][part+n0] = idf + 1;
1484 (fPythia->GetPyjets())->K[4][part+n0] = idl + 1;
1485 (fPythia->GetPyjets())->K[2][part+n0] = mPart->GetFirstMother() + 1;
1490 void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1493 // Calls the Pythia jet finding algorithm to find jets in the current event
1498 Int_t n = fPythia->GetN();
1502 fPythia->Pycell(njets);
1504 for (i = 0; i < njets; i++) {
1505 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1506 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1507 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1508 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1519 void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1522 // Calls the Pythia clustering algorithm to find jets in the current event
1524 Int_t n = fPythia->GetN();
1527 if (fJetReconstruction == kCluster) {
1529 // Configure cluster algorithm
1531 fPythia->SetPARU(43, 2.);
1532 fPythia->SetMSTU(41, 1);
1534 // Call cluster algorithm
1536 fPythia->Pyclus(nJets);
1538 // Loading jets from common block
1544 fPythia->Pycell(nJets);
1548 for (i = 0; i < nJets; i++) {
1549 Float_t px = (fPythia->GetPyjets())->P[0][n+i];
1550 Float_t py = (fPythia->GetPyjets())->P[1][n+i];
1551 Float_t pz = (fPythia->GetPyjets())->P[2][n+i];
1552 Float_t e = (fPythia->GetPyjets())->P[3][n+i];
1553 Float_t pt = TMath::Sqrt(px * px + py * py);
1554 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1555 Float_t theta = TMath::ATan2(pt,pz);
1556 Float_t et = e * TMath::Sin(theta);
1557 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1559 eta > fEtaMinJet && eta < fEtaMaxJet &&
1560 phi > fPhiMinJet && phi < fPhiMaxJet &&
1561 et > fEtMinJet && et < fEtMaxJet
1564 jets[0][nJetsTrig] = px;
1565 jets[1][nJetsTrig] = py;
1566 jets[2][nJetsTrig] = pz;
1567 jets[3][nJetsTrig] = e;
1569 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1571 // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg);
1576 void AliGenPythia::GetSubEventTime()
1578 // Calculates time of the next subevent
1581 TArrayF &array = *fEventsTime;
1582 fEventTime = array[fCurSubEvent++];
1584 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1588 Bool_t AliGenPythia::IsInEMCAL(Float_t phi, Float_t eta)
1590 // Is particle in EMCAL acceptance?
1591 // phi in degrees, etamin=-etamax
1592 if(phi > fEMCALMinPhi && phi < fEMCALMaxPhi &&
1599 Bool_t AliGenPythia::IsInPHOS(Float_t phi, Float_t eta)
1601 // Is particle in PHOS acceptance?
1602 // Acceptance slightly larger considered.
1603 // phi in degrees, etamin=-etamax
1604 if(phi > fPHOSMinPhi && phi < fPHOSMaxPhi &&
1611 void AliGenPythia::RotatePhi(Int_t iphcand, Bool_t& okdd)
1613 //calculate the new position random between fPHOSMinPhi and fPHOSMaxPhi
1614 Double_t phiPHOSmin = TMath::Pi()*fPHOSMinPhi/180;
1615 Double_t phiPHOSmax = TMath::Pi()*fPHOSMaxPhi/180;
1616 Double_t phiPHOS = gRandom->Uniform(phiPHOSmin,phiPHOSmax);
1618 //calculate deltaphi
1619 TParticle* ph = (TParticle *) fParticles.At(iphcand);
1620 Double_t phphi = ph->Phi();
1621 Double_t deltaphi = phiPHOS - phphi;
1625 //loop for all particles and produce the phi rotation
1626 Int_t np = (fHadronisation) ? fParticles.GetEntriesFast() : fNpartons;
1627 Double_t oldphi, newphi;
1628 Double_t newVx, newVy, R, Vz, time;
1629 Double_t newPx, newPy, pt, Pz, e;
1630 for(Int_t i=0; i< np; i++) {
1631 TParticle* iparticle = (TParticle *) fParticles.At(i);
1632 oldphi = iparticle->Phi();
1633 newphi = oldphi + deltaphi;
1634 if(newphi < 0) newphi = 2*TMath::Pi() + newphi; // correct angle
1635 if(newphi > 2*TMath::Pi()) newphi = newphi - 2*TMath::Pi(); // correct angle
1638 newVx = R*TMath::Cos(newphi);
1639 newVy = R*TMath::Sin(newphi);
1640 Vz = iparticle->Vz(); // don't transform
1641 time = iparticle->T(); // don't transform
1643 pt = iparticle->Pt();
1644 newPx = pt*TMath::Cos(newphi);
1645 newPy = pt*TMath::Sin(newphi);
1646 Pz = iparticle->Pz(); // don't transform
1647 e = iparticle->Energy(); // don't transform
1650 iparticle->SetProductionVertex(newVx, newVy, Vz, time);
1651 iparticle->SetMomentum(newPx, newPy, Pz, e);
1653 } //end particle loop
1655 // now let's check that we put correctly the candidate photon in PHOS
1656 Float_t phi = ph->Phi()*180./TMath::Pi(); //Convert to degrees
1657 Float_t eta =TMath::Abs(ph->Eta());//in calos etamin=-etamax
1658 if(IsInPHOS(phi,eta))
1664 void AliGenPythia::Streamer(TBuffer &R__b)
1666 // Stream an object of class AliGenPythia.
1668 if (R__b.IsReading()) {
1669 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1670 AliGenerator::Streamer(R__b);
1671 R__b >> (Int_t&)fProcess;
1672 R__b >> (Int_t&)fStrucFunc;
1673 R__b >> (Int_t&)fForceDecay;
1677 fParentSelect.Streamer(R__b);
1678 fChildSelect.Streamer(R__b);
1680 // (AliPythia::Instance())->Streamer(R__b);
1683 // if (fDecayer) fDecayer->Streamer(R__b);
1685 R__b.WriteVersion(AliGenPythia::IsA());
1686 AliGenerator::Streamer(R__b);
1687 R__b << (Int_t)fProcess;
1688 R__b << (Int_t)fStrucFunc;
1689 R__b << (Int_t)fForceDecay;
1693 fParentSelect.Streamer(R__b);
1694 fChildSelect.Streamer(R__b);
1699 // fDecayer->Streamer(R__b);