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 "AliGenPythiaPlus.h"
37 #include "AliHeader.h"
38 #include "AliGenPythiaEventHeader.h"
39 #include "AliPythiaBase.h"
40 #include "AliPythiaRndm.h"
43 #include "AliRunLoader.h"
45 #include "PyquenCommon.h"
47 ClassImp(AliGenPythiaPlus)
50 AliGenPythiaPlus::AliGenPythiaPlus():
81 fDecayer(new AliDecayerPythia()),
89 fPhiMaxJet(2.* TMath::Pi()),
90 fJetReconstruction(kCell),
94 fPhiMaxGamma(2. * TMath::Pi()),
101 fPycellThreshold(0.),
103 fPycellMinEtJet(10.),
104 fPycellMaxRadius(1.),
105 fStackFillOpt(kFlavorSelection),
107 fFragmentation(kTRUE),
113 fCountMode(kCountAll),
117 fFragPhotonInCalo(kFALSE),
119 fPhotonInCalo(kFALSE),
122 fCheckPHOSeta(kFALSE),
123 fFragPhotonOrPi0MinPt(0),
134 // Default Constructor
137 if (!AliPythiaRndm::GetPythiaRandom())
138 AliPythiaRndm::SetPythiaRandom(GetRandom());
141 AliGenPythiaPlus::AliGenPythiaPlus(AliPythiaBase* pythia)
153 fInteractionRate(0.),
166 fHadronisation(kTRUE),
168 fReadFromFile(kFALSE),
172 fDecayer(new AliDecayerPythia()),
173 fDebugEventFirst(-1),
180 fPhiMaxJet(2.* TMath::Pi()),
181 fJetReconstruction(kCell),
185 fPhiMaxGamma(2. * TMath::Pi()),
192 fPycellThreshold(0.),
194 fPycellMinEtJet(10.),
195 fPycellMaxRadius(1.),
196 fStackFillOpt(kFlavorSelection),
198 fFragmentation(kTRUE),
204 fCountMode(kCountAll),
208 fFragPhotonInCalo(kFALSE),
210 fPhotonInCalo(kFALSE),
213 fCheckPHOSeta(kFALSE),
214 fFragPhotonOrPi0MinPt(0),
225 // default charm production at 5. 5 TeV
227 // structure function GRVHO
231 fTitle= "Particle Generator using PYTHIA";
233 // Set random number generator
234 if (!AliPythiaRndm::GetPythiaRandom())
235 AliPythiaRndm::SetPythiaRandom(GetRandom());
239 AliGenPythiaPlus::~AliGenPythiaPlus()
242 if(fEventsTime) delete fEventsTime;
245 void AliGenPythiaPlus::SetInteractionRate(Float_t rate,Float_t timewindow)
247 // Generate pileup using user specified rate
248 fInteractionRate = rate;
249 fTimeWindow = timewindow;
253 void AliGenPythiaPlus::GeneratePileup()
255 // Generate sub events time for pileup
257 if(fInteractionRate == 0.) {
258 Warning("GeneratePileup","Zero interaction specified. Skipping pileup generation.\n");
262 Int_t npart = NumberParticles();
264 Warning("GeneratePileup","Negative number of particles. Skipping pileup generation.\n");
268 if(fEventsTime) delete fEventsTime;
269 fEventsTime = new TArrayF(npart);
270 TArrayF &array = *fEventsTime;
271 for(Int_t ipart = 0; ipart < npart; ipart++)
274 Float_t eventtime = 0.;
277 eventtime += (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
278 if(eventtime > fTimeWindow) break;
279 array.Set(array.GetSize()+1);
280 array[array.GetSize()-1] = eventtime;
286 eventtime -= (AliPythiaRndm::GetPythiaRandom())->Exp(1./fInteractionRate);
287 if(TMath::Abs(eventtime) > fTimeWindow) break;
288 array.Set(array.GetSize()+1);
289 array[array.GetSize()-1] = eventtime;
292 SetNumberParticles(fEventsTime->GetSize());
295 void AliGenPythiaPlus::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi,
296 Float_t thresh, Float_t etseed, Float_t minet, Float_t r)
298 // Set pycell parameters
299 fPycellEtaMax = etamax;
302 fPycellThreshold = thresh;
303 fPycellEtSeed = etseed;
304 fPycellMinEtJet = minet;
305 fPycellMaxRadius = r;
310 void AliGenPythiaPlus::SetEventListRange(Int_t eventFirst, Int_t eventLast)
312 // Set a range of event numbers, for which a table
313 // of generated particle will be printed
314 fDebugEventFirst = eventFirst;
315 fDebugEventLast = eventLast;
316 if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst;
319 void AliGenPythiaPlus::Init()
323 // SetMC(AliPythia::Instance());
324 // fPythia=(AliPythia*) fMCEvGen;
327 fParentWeight=1./Float_t(fNpart);
331 fPythia->SetPtHardRange(fPtHardMin, fPtHardMax);
332 fPythia->SetYHardRange(fYHardMin, fYHardMax);
334 if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget);
336 if (fFragmentation) {
337 fPythia->SetFragmentation(1);
339 fPythia->SetFragmentation(0);
343 // initial state radiation
344 fPythia->SetInitialAndFinalStateRadiation(fGinit, fGfinal);
347 fPythia->SetIntrinsicKt(fPtKick);
350 fRL = AliRunLoader::Open(fFileName, "Partons");
351 fRL->LoadKinematics();
357 fPythia->ProcInit(fProcess, fEnergyCMS, fStrucFunc, fItune);
358 // Forward Paramters to the AliPythia object
359 fDecayer->SetForceDecay(fForceDecay);
360 // Switch off Heavy Flavors on request
362 fPythia->SwitchHFOff();
363 // Switch off g->QQbar splitting in decay table
364 ((AliDecayerPythia*) fDecayer)->HeavyFlavourOff();
370 // Parent and Children Selection
373 case kPyOldUEQ2ordered:
374 case kPyOldUEQ2ordered2:
378 case kPyCharmUnforced:
379 case kPyCharmPbPbMNR:
382 case kPyCharmppMNRwmi:
384 fParentSelect[0] = 411;
385 fParentSelect[1] = 421;
386 fParentSelect[2] = 431;
387 fParentSelect[3] = 4122;
388 fParentSelect[4] = 4232;
389 fParentSelect[5] = 4132;
390 fParentSelect[6] = 4332;
396 fParentSelect[0] = 421;
399 case kPyDPlusPbPbMNR:
402 fParentSelect[0] = 411;
405 case kPyDPlusStrangePbPbMNR:
406 case kPyDPlusStrangepPbMNR:
407 case kPyDPlusStrangeppMNR:
408 fParentSelect[0] = 431;
411 case kPyLambdacppMNR:
412 fParentSelect[0] = 4122;
417 case kPyBeautyPbPbMNR:
418 case kPyBeautypPbMNR:
420 case kPyBeautyppMNRwmi:
422 fParentSelect[0]= 511;
423 fParentSelect[1]= 521;
424 fParentSelect[2]= 531;
425 fParentSelect[3]= 5122;
426 fParentSelect[4]= 5132;
427 fParentSelect[5]= 5232;
428 fParentSelect[6]= 5332;
431 case kPyBeautyUnforced:
432 fParentSelect[0] = 511;
433 fParentSelect[1] = 521;
434 fParentSelect[2] = 531;
435 fParentSelect[3] = 5122;
436 fParentSelect[4] = 5132;
437 fParentSelect[5] = 5232;
438 fParentSelect[6] = 5332;
443 fParentSelect[0] = 443;
445 case kPyMbAtlasTuneMC09:
448 case kPyMbWithDirectPhoton:
460 case kPyMBRSingleDiffraction:
461 case kPyMBRDoubleDiffraction:
462 case kPyMBRCentralDiffraction:
467 // JetFinder for Trigger
469 // Configure detector (EMCAL like)
471 fPythia->SetPycellParameters(fPycellEtaMax,fPycellNEta, fPycellNPhi,
472 fPycellThreshold, fPycellEtSeed,
473 fPycellMinEtJet, fPycellMaxRadius);
475 // This counts the total number of calls to Pyevnt() per run.
490 Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n");
494 fPythia->InitQuenching(0., 0.1, 0.6e6, 0, 0.97, 30);
497 // fPythia->SetPARJ(200, 0.0);
499 // if (fQuench == 3) {
500 // // Nestor's change of the splittings
501 // fPythia->SetPARJ(200, 0.8);
502 // fPythia->SetMSTJ(41, 1); // QCD radiation only
503 // fPythia->SetMSTJ(42, 2); // angular ordering
504 // fPythia->SetMSTJ(44, 2); // option to run alpha_s
505 // fPythia->SetMSTJ(47, 0); // No correction back to hard scattering element
506 // fPythia->SetMSTJ(50, 0); // No coherence in first branching
507 // fPythia->SetPARJ(82, 1.); // Cut off for parton showers
511 void AliGenPythiaPlus::Generate()
513 // Generate one event
515 fDecayer->ForceDecay();
517 Double_t polar[3] = {0,0,0};
518 Double_t origin[3] = {0,0,0};
520 // converts from mm/c to s
521 const Float_t kconv=0.001/2.999792458e8;
531 // Set collision vertex position
532 if (fVertexSmear == kPerEvent) Vertex();
541 // Switch hadronisation off
543 // fPythia->SwitchHadronisationOff();
545 // Either produce new event or read partons from file
547 if (!fReadFromFile) {
549 fPythia->GenerateEvent();
551 fPythia->GenerateMIEvent();
553 fNpartons = fPythia->GetNumberOfParticles();
555 printf("Loading Event %d\n",AliRunLoader::Instance()->GetEventNumber());
556 fRL->GetEvent(AliRunLoader::Instance()->GetEventNumber());
557 fPythia->SetNumberOfParticles(0);
558 fPythia->LoadEvent(fRL->Stack(), 0 , 1);
559 fPythia->EditEventList(21);
563 // Run quenching routine
567 } else if (fQuench == 2){
568 fPythia->Pyquen(208., 0, 0.);
569 } else if (fQuench == 3) {
570 // Quenching is via multiplicative correction of the splittings
574 // Switch hadronisation on
576 // fPythia->SwitchHadronisationOn();
578 // .. and perform hadronisation
579 // printf("Calling hadronisation %d\n", fPythia->GetN());
580 // fPythia->HadronizeEvent();
582 fPythia->GetParticles(&fParticles);
590 Int_t np = fParticles.GetEntriesFast();
592 if (np == 0) continue;
596 Int_t* pParent = new Int_t[np];
597 Int_t* pSelected = new Int_t[np];
598 Int_t* trackIt = new Int_t[np];
599 for (i = 0; i < np; i++) {
605 Int_t nc = 0; // Total n. of selected particles
606 Int_t nParents = 0; // Selected parents
607 Int_t nTkbles = 0; // Trackable particles
608 if (fProcess != kPyMbDefault &&
610 fProcess != kPyMbWithDirectPhoton &&
611 fProcess != kPyJets &&
612 fProcess != kPyDirectGamma &&
613 fProcess != kPyMbNonDiffr &&
614 fProcess != kPyMbMSEL1 &&
617 fProcess != kPyZgamma &&
618 fProcess != kPyCharmppMNRwmi &&
619 fProcess != kPyBeautyppMNRwmi &&
620 fProcess != kPyWPWHG &&
621 fProcess != kPyJetsPWHG &&
622 fProcess != kPyCharmPWHG &&
623 fProcess != kPyBeautyPWHG) {
625 for (i = 0; i < np; i++) {
626 TParticle* iparticle = (TParticle *) fParticles.At(i);
627 Int_t ks = iparticle->GetStatusCode();
628 kf = CheckPDGCode(iparticle->GetPdgCode());
629 // No initial state partons
630 if (ks==21) continue;
632 // Heavy Flavor Selection
639 if (kfl > 100000) kfl %= 100000;
640 if (kfl > 10000) kfl %= 10000;
642 if (kfl > 10) kfl/=100;
644 if (kfl > 10) kfl/=10;
645 Int_t ipa = (fPythia->Version() == 6) ? (iparticle->GetFirstMother() - 1) :(iparticle->GetFirstMother()) ;
648 // Establish mother daughter relation between heavy quarks and mesons
650 if (kf >= fFlavorSelect && kf <= 6) {
651 Int_t idau = (fPythia->Version() == 6) ? (iparticle->GetFirstDaughter() - 1) :(iparticle->GetFirstDaughter());
653 TParticle* daughter = (TParticle *) fParticles.At(idau);
654 Int_t pdgD = daughter->GetPdgCode();
655 if (pdgD == 91 || pdgD == 92) {
656 Int_t jmin = (fPythia->Version() == 6) ? (daughter->GetFirstDaughter() - 1) : (daughter->GetFirstDaughter());
657 Int_t jmax = (fPythia->Version() == 6) ? (daughter->GetLastDaughter() - 1) : (daughter->GetLastDaughter());
659 for (Int_t jp = jmin; jp <= jmax; jp++)
660 ((TParticle *) fParticles.At(jp))->SetFirstMother(i+1);
661 } // is string or cluster
667 TParticle * mother = (TParticle *) fParticles.At(ipa);
668 kfMo = TMath::Abs(mother->GetPdgCode());
671 // What to keep in Stack?
672 Bool_t flavorOK = kFALSE;
673 Bool_t selectOK = kFALSE;
675 if (kfl >= fFlavorSelect) flavorOK = kTRUE;
677 if (kfl > fFlavorSelect) {
681 if (kfl == fFlavorSelect) flavorOK = kTRUE;
683 switch (fStackFillOpt) {
684 case kFlavorSelection:
687 case kParentSelection:
688 if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE;
691 if (flavorOK && selectOK) {
693 // Heavy flavor hadron or quark
695 // Kinematic seletion on final state heavy flavor mesons
696 if (ParentSelected(kf) && !KinematicSelection(iparticle, 0))
701 if (ParentSelected(kf)) ++nParents; // Update parent count
702 // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf);
704 // Kinematic seletion on decay products
705 if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf)
706 && !KinematicSelection(iparticle, 1))
712 // Select if mother was selected and is not tracked
714 if (pSelected[ipa] &&
715 !trackIt[ipa] && // mother will be tracked ?
716 kfMo != 5 && // mother is b-quark, don't store fragments
717 kfMo != 4 && // mother is c-quark, don't store fragments
718 kf != 92) // don't store string
721 // Semi-stable or de-selected: diselect decay products:
724 if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime)
726 Int_t ipF = iparticle->GetFirstDaughter();
727 Int_t ipL = iparticle->GetLastDaughter();
728 if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1;
730 // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf);
731 pSelected[i] = (pSelected[i] == -1) ? 0 : 1;
734 if (pSelected[i] == -1) pSelected[i] = 0;
735 if (!pSelected[i]) continue;
736 // Count quarks only if you did not include fragmentation
737 if (fFragmentation && kf <= 10) continue;
740 // Decision on tracking
743 // Track final state particle
744 if (ks == 1) trackIt[i] = 1;
745 // Track semi-stable particles
746 if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1;
747 // Track particles selected by process if undecayed.
748 if (fForceDecay == kNoDecay) {
749 if (ParentSelected(kf)) trackIt[i] = 1;
751 if (ParentSelected(kf)) trackIt[i] = 0;
753 if (trackIt[i] == 1) ++nTkbles; // Update trackable counter
757 } // particle selection loop
759 for (i = 0; i < np; i++) {
760 if (!pSelected[i]) continue;
761 TParticle * iparticle = (TParticle *) fParticles.At(i);
762 kf = CheckPDGCode(iparticle->GetPdgCode());
763 Int_t ks = iparticle->GetStatusCode();
764 p[0] = iparticle->Px();
765 p[1] = iparticle->Py();
766 p[2] = iparticle->Pz();
767 p[3] = iparticle->Energy();
769 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
770 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
771 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
773 Float_t tof = fTime + kconv*iparticle->T();
774 Int_t ipa = (fPythia->Version() == 6) ? (iparticle->GetFirstMother() - 1) :(iparticle->GetFirstMother()) ;
775 Int_t iparent = (ipa > -1) ? pParent[ipa] : -1;
777 PushTrack(fTrackIt*trackIt[i], iparent, kf,
778 p[0], p[1], p[2], p[3],
779 origin[0], origin[1], origin[2], tof,
780 polar[0], polar[1], polar[2],
781 kPPrimary, nt, 1., ks);
798 switch (fCountMode) {
800 // printf(" Count all \n");
804 // printf(" Count parents \n");
807 case kCountTrackables:
808 // printf(" Count trackable \n");
812 if (jev >= fNpart || fNpart == -1) {
813 fKineBias=Float_t(fNpart)/Float_t(fTrials);
814 if (fInfo) fPythia->GetXandQ(fX1, fX2, fQ);
815 fTrialsRun += fTrials;
822 SetHighWaterMark(nt);
823 // Adjust weight due to kinematic selection
826 fXsection = fPythia->GetXSection();
829 Int_t AliGenPythiaPlus::GenerateMB()
832 // Min Bias selection and other global selections
834 Int_t i, kf, nt, iparent;
837 Float_t polar[3] = {0,0,0};
838 Float_t origin[3] = {0,0,0};
839 // converts from mm/c to s
840 const Float_t kconv = 0.001 / 2.999792458e8;
842 Int_t np = (fHadronisation) ? fParticles.GetEntriesFast() : fNpartons;
844 Int_t* pParent = new Int_t[np];
845 for (i=0; i< np; i++) pParent[i] = -1;
846 if (fProcess == kPyJets || fProcess == kPyDirectGamma || fProcess == kPyJetsPWHG || fProcess == kPyCharmPWHG || fProcess == kPyBeautyPWHG ) {
847 TParticle* jet1 = (TParticle *) fParticles.At(6);
848 TParticle* jet2 = (TParticle *) fParticles.At(7);
849 if (!CheckTrigger(jet1, jet2)) {
855 // Select jets with fragmentation photon or pi0 going to PHOS or EMCAL
856 if ((fProcess == kPyJets || fProcess == kPyJetsPWHG) && (fFragPhotonInCalo || fPi0InCalo) ) {
861 if (fFragPhotonInCalo) pdg = 22 ; // Photon
862 else if (fPi0InCalo) pdg = 111 ; // Pi0
864 for (i=0; i< np; i++) {
865 TParticle* iparticle = (TParticle *) fParticles.At(i);
866 if(iparticle->GetStatusCode()==1 && iparticle->GetPdgCode()==pdg &&
867 iparticle->Pt() > fFragPhotonOrPi0MinPt){
868 Int_t imother = (fPythia->Version() == 6) ? (iparticle->GetFirstMother() - 1) :(iparticle->GetFirstMother()) ;
869 TParticle* pmother = (TParticle *) fParticles.At(imother);
871 (pdg == 22 && pmother->GetStatusCode() != 11))//No photon from hadron decay
873 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
874 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
875 if((fCheckEMCAL && IsInEMCAL(phi,eta)) ||
876 (fCheckPHOS && IsInPHOS(phi,eta)) )
888 // Select events with a photon pt > min pt going to PHOS eta acceptance or exactly PHOS eta phi
889 if ((fProcess == kPyJets || fProcess == kPyJetsPWHG || fProcess == kPyDirectGamma) && fPhotonInCalo && (fCheckPHOSeta || fCheckPHOS)){
895 for (i=0; i< np; i++) {
896 TParticle* iparticle = (TParticle *) fParticles.At(i);
897 Float_t phi = iparticle->Phi()*180./TMath::Pi(); //Convert to degrees
898 Float_t eta =TMath::Abs(iparticle->Eta());//in calos etamin=-etamax
900 if(iparticle->GetStatusCode() == 1
901 && iparticle->GetPdgCode() == pdg
902 && iparticle->Pt() > fPhotonMinPt
905 // first check if the photon is in PHOS phi
906 if(IsInPHOS(phi,eta)){
910 if(fCheckPHOSeta) iphcand = i; // candiate photon to rotate in phi
915 if(!okd && iphcand != -1) // execute rotation in phi
916 RotatePhi(iphcand,okd);
924 if (fTriggerParticle) {
925 Bool_t triggered = kFALSE;
926 for (i = 0; i < np; i++) {
927 TParticle * iparticle = (TParticle *) fParticles.At(i);
928 kf = CheckPDGCode(iparticle->GetPdgCode());
929 if (kf != fTriggerParticle) continue;
930 if (iparticle->Pt() == 0.) continue;
931 if (TMath::Abs(iparticle->Eta()) > fTriggerEta) continue;
942 // Check if there is a ccbar or bbbar pair with at least one of the two
943 // in fYMin < y < fYMax
944 if (fProcess == kPyCharmppMNRwmi || fProcess == kPyBeautyppMNRwmi) {
945 TParticle *partCheck;
947 Bool_t theQ=kFALSE,theQbar=kFALSE,inYcut=kFALSE;
948 Bool_t theChild=kFALSE;
950 Int_t pdg,mpdg,mpdgUpperFamily;
951 for(i=0; i<np; i++) {
952 partCheck = (TParticle*)fParticles.At(i);
953 pdg = partCheck->GetPdgCode();
954 if(TMath::Abs(pdg) == fFlavorSelect) { // quark
955 if(pdg>0) { theQ=kTRUE; } else { theQbar=kTRUE; }
956 y = 0.5*TMath::Log((partCheck->Energy()+partCheck->Pz()+1.e-13)/
957 (partCheck->Energy()-partCheck->Pz()+1.e-13));
958 if(fUseYCutHQ && y>fYMinHQ && y<fYMaxHQ) inYcut=kTRUE;
959 if(!fUseYCutHQ && y>fYMin && y<fYMax) inYcut=kTRUE;
962 if(fCutOnChild && TMath::Abs(pdg) == fPdgCodeParticleforAcceptanceCut) {
963 Int_t mi = partCheck->GetFirstMother() - 1;
965 mother = (TParticle*)fParticles.At(mi);
966 mpdg=TMath::Abs(mother->GetPdgCode());
967 mpdgUpperFamily=(mpdg>1000 ? mpdg+1000 : mpdg+100); // keep e from c from b
968 if ( ParentSelected(mpdg) ||
969 (fFlavorSelect==5 && ParentSelected(mpdgUpperFamily))) {
970 if (KinematicSelection(partCheck,1)) {
976 if (!theQ || !theQbar || !inYcut) { // one of the c/b conditions not satisfied
980 if (fCutOnChild && !theChild) { // one of the child conditions not satisfied
987 //Introducing child cuts in case kPyW, kPyZ, kPyMb, and kPyMbNonDiff
989 fProcess == kPyWPWHG ||
992 fProcess == kPyZgamma ||
993 fProcess == kPyMbDefault ||
995 fProcess == kPyMbWithDirectPhoton ||
996 fProcess == kPyMbNonDiffr)
997 && (fCutOnChild == 1) ) {
998 if ( !CheckKinematicsOnChild() ) {
1005 for (i = 0; i < np; i++) {
1007 TParticle * iparticle = (TParticle *) fParticles.At(i);
1008 kf = CheckPDGCode(iparticle->GetPdgCode());
1009 Int_t ks = iparticle->GetStatusCode();
1010 Int_t km = iparticle->GetFirstMother();
1011 if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) ||
1013 ((fProcess == kPyJets || fProcess == kPyJetsPWHG) && ks == 21 && km == 0 && i>1)) {
1015 if (ks == 1) trackIt = 1;
1017 Int_t ipa = (fPythia->Version() == 6) ? (iparticle->GetFirstMother() - 1) :(iparticle->GetFirstMother()) ;
1018 iparent = (ipa > -1) ? pParent[ipa] : -1;
1019 if (ipa >= np) fPythia->EventListing();
1022 // store track information
1023 p[0] = iparticle->Px();
1024 p[1] = iparticle->Py();
1025 p[2] = iparticle->Pz();
1026 p[3] = iparticle->Energy();
1029 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
1030 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
1031 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
1033 Float_t tof = fTime + fEventTime + kconv * iparticle->T();
1035 PushTrack(fTrackIt*trackIt, iparent, kf,
1036 p[0], p[1], p[2], p[3],
1037 origin[0], origin[1], origin[2], tof,
1038 polar[0], polar[1], polar[2],
1039 kPPrimary, nt, 1., ks);
1044 // Special Treatment to store color-flow
1047 if (ks == 3 || ks == 13 || ks == 14) {
1048 TParticle* particle = 0;
1050 particle = fStack->Particle(nt);
1052 particle = AliRunLoader::Instance()->Stack()->Particle(nt);
1054 particle->SetFirstDaughter(fPythia->GetK(2, i));
1055 particle->SetLastDaughter(fPythia->GetK(3, i));
1060 SetHighWaterMark(nt);
1062 } // select particle
1071 void AliGenPythiaPlus::FinishRun()
1073 // Print x-section summary
1074 fPythia->PrintStatistics();
1082 printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun);
1083 printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2);
1086 void AliGenPythiaPlus::AdjustWeights() const
1088 // Adjust the weights after generation of all events
1092 Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
1093 for (Int_t i=0; i<ntrack; i++) {
1094 part= gAlice->GetMCApp()->Particle(i);
1095 part->SetWeight(part->GetWeight()*fKineBias);
1100 void AliGenPythiaPlus::SetNuclei(Int_t a1, Int_t a2)
1102 // Treat protons as inside nuclei with mass numbers a1 and a2
1110 void AliGenPythiaPlus::MakeHeader()
1113 // Make header for the simulated event
1116 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
1117 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->EventListing();
1120 // Builds the event header, to be called after each event
1121 if (fHeader) delete fHeader;
1122 fHeader = new AliGenPythiaEventHeader("Pythia");
1123 fHeader->SetTitle(GetTitle());
1127 ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->ProcessCode());
1130 ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials);
1133 fHeader->SetPrimaryVertex(fVertex);
1134 fHeader->SetInteractionTime(fTime+fEventTime);
1136 // Number of primaries
1137 fHeader->SetNProduced(fNprimaries);
1139 // Jets that have triggered
1141 if (fProcess == kPyJets || fProcess == kPyJetsPWHG)
1144 Float_t jets[4][10];
1145 GetJets(njet, ntrig, jets);
1148 for (Int_t i = 0; i < ntrig; i++) {
1149 ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i],
1154 // Copy relevant information from external header, if present.
1159 AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader());
1160 for (Int_t i = 0; i < exHeader->NTriggerJets(); i++)
1162 printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets());
1165 exHeader->TriggerJet(i, uqJet);
1166 ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]);
1170 // Store quenching parameters
1173 Double_t z[4] = {0.};
1178 fPythia->GetQuenchingParameters(xp, yp, z);
1181 Double_t r1 = PARIMP.rb1;
1182 Double_t r2 = PARIMP.rb2;
1183 Double_t b = PARIMP.b1;
1184 Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b);
1185 Double_t phi = PARIMP.psib1;
1186 xp = r * TMath::Cos(phi);
1187 yp = r * TMath::Sin(phi);
1190 ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp);
1191 ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z);
1195 ((AliGenPythiaEventHeader*) fHeader)->SetPtHard(fPythia->GetPtHard());
1203 Bool_t AliGenPythiaPlus::CheckTrigger(const TParticle* jet1, const TParticle* jet2)
1205 // Check the kinematic trigger condition
1208 eta[0] = jet1->Eta();
1209 eta[1] = jet2->Eta();
1211 phi[0] = jet1->Phi();
1212 phi[1] = jet2->Phi();
1214 pdg[0] = jet1->GetPdgCode();
1215 pdg[1] = jet2->GetPdgCode();
1216 Bool_t triggered = kFALSE;
1218 if (fProcess == kPyJets || fProcess == kPyJetsPWHG) {
1221 Float_t jets[4][10];
1223 // Use Pythia clustering on parton level to determine jet axis
1225 GetJets(njets, ntrig, jets);
1227 if (ntrig || fEtMinJet == 0.) triggered = kTRUE;
1232 if (pdg[0] == kGamma) {
1236 //Check eta range first...
1237 if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) &&
1238 (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma))
1240 //Eta is okay, now check phi range
1241 if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) &&
1242 (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma))
1253 Bool_t AliGenPythiaPlus::CheckKinematicsOnChild(){
1255 //Checking Kinematics on Child (status code 1, particle code ?, kin cuts
1257 Bool_t checking = kFALSE;
1258 Int_t j, kcode, ks, km;
1259 Int_t nPartAcc = 0; //number of particles in the acceptance range
1260 Int_t numberOfAcceptedParticles = 1;
1261 if (fNumberOfAcceptedParticles != 0) { numberOfAcceptedParticles = fNumberOfAcceptedParticles; }
1262 Int_t npart = fParticles.GetEntriesFast();
1264 for (j = 0; j<npart; j++) {
1265 TParticle * jparticle = (TParticle *) fParticles.At(j);
1266 kcode = TMath::Abs( CheckPDGCode(jparticle->GetPdgCode()) );
1267 ks = jparticle->GetStatusCode();
1268 km = jparticle->GetFirstMother();
1270 if( (ks == 1) && (kcode == fPdgCodeParticleforAcceptanceCut) && (KinematicSelection(jparticle,1)) ){
1273 if( numberOfAcceptedParticles <= nPartAcc){
1282 void AliGenPythiaPlus::RecJetsUA1(Int_t& njets, Float_t jets [4][50])
1285 // Calls the Pythia jet finding algorithm to find jets in the current event
1292 fPythia->Pycell(njets);
1294 for (i = 0; i < njets; i++) {
1295 Float_t px, py, pz, e;
1296 fPythia->GetJet(i, px, py, pz, e);
1305 void AliGenPythiaPlus::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10])
1308 // Calls the Pythia clustering algorithm to find jets in the current event
1312 if (fJetReconstruction == kCluster) {
1314 // Configure cluster algorithm
1316 // fPythia->SetPARU(43, 2.);
1317 // fPythia->SetMSTU(41, 1);
1319 // Call cluster algorithm
1321 fPythia->Pyclus(nJets);
1323 // Loading jets from common block
1329 fPythia->Pycell(nJets);
1333 for (i = 0; i < nJets; i++) {
1334 Float_t px, py, pz, e;
1335 fPythia->GetJet(i, px, py, pz, e);
1336 Float_t pt = TMath::Sqrt(px * px + py * py);
1337 Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px);
1338 Float_t theta = TMath::ATan2(pt,pz);
1339 Float_t et = e * TMath::Sin(theta);
1340 Float_t eta = -TMath::Log(TMath::Tan(theta / 2.));
1342 eta > fEtaMinJet && eta < fEtaMaxJet &&
1343 phi > fPhiMinJet && phi < fPhiMaxJet &&
1344 et > fEtMinJet && et < fEtMaxJet
1347 jets[0][nJetsTrig] = px;
1348 jets[1][nJetsTrig] = py;
1349 jets[2][nJetsTrig] = pz;
1350 jets[3][nJetsTrig] = e;
1357 void AliGenPythiaPlus::GetSubEventTime()
1359 // Calculates time of the next subevent
1362 TArrayF &array = *fEventsTime;
1363 fEventTime = array[fCurSubEvent++];
1365 // printf(" Event time: %d %f %p",fCurSubEvent,fEventTime,fEventsTime);
1372 Bool_t AliGenPythiaPlus::IsInEMCAL(Float_t phi, Float_t eta) const
1374 // Is particle in EMCAL acceptance?
1375 // phi in degrees, etamin=-etamax
1376 if(phi > fEMCALMinPhi && phi < fEMCALMaxPhi &&
1383 Bool_t AliGenPythiaPlus::IsInPHOS(Float_t phi, Float_t eta) const
1385 // Is particle in PHOS acceptance?
1386 // Acceptance slightly larger considered.
1387 // phi in degrees, etamin=-etamax
1388 if(phi > fPHOSMinPhi && phi < fPHOSMaxPhi &&
1395 void AliGenPythiaPlus::RotatePhi(Int_t iphcand, Bool_t& okdd)
1397 //calculate the new position random between fPHOSMinPhi and fPHOSMaxPhi
1398 Double_t phiPHOSmin = TMath::Pi()*fPHOSMinPhi/180;
1399 Double_t phiPHOSmax = TMath::Pi()*fPHOSMaxPhi/180;
1400 Double_t phiPHOS = gRandom->Uniform(phiPHOSmin,phiPHOSmax);
1402 //calculate deltaphi
1403 TParticle* ph = (TParticle *) fParticles.At(iphcand);
1404 Double_t phphi = ph->Phi();
1405 Double_t deltaphi = phiPHOS - phphi;
1409 //loop for all particles and produce the phi rotation
1410 Int_t np = (fHadronisation) ? fParticles.GetEntriesFast() : fNpartons;
1411 Double_t oldphi, newphi;
1412 Double_t newVx, newVy, R, Vz, time;
1413 Double_t newPx, newPy, pt, Pz, e;
1414 for(Int_t i=0; i< np; i++) {
1415 TParticle* iparticle = (TParticle *) fParticles.At(i);
1416 oldphi = iparticle->Phi();
1417 newphi = oldphi + deltaphi;
1418 if(newphi < 0) newphi = 2*TMath::Pi() + newphi; // correct angle
1419 if(newphi > 2*TMath::Pi()) newphi = newphi - 2*TMath::Pi(); // correct angle
1422 newVx = R*TMath::Cos(newphi);
1423 newVy = R*TMath::Sin(newphi);
1424 Vz = iparticle->Vz(); // don't transform
1425 time = iparticle->T(); // don't transform
1427 pt = iparticle->Pt();
1428 newPx = pt*TMath::Cos(newphi);
1429 newPy = pt*TMath::Sin(newphi);
1430 Pz = iparticle->Pz(); // don't transform
1431 e = iparticle->Energy(); // don't transform
1434 iparticle->SetProductionVertex(newVx, newVy, Vz, time);
1435 iparticle->SetMomentum(newPx, newPy, Pz, e);
1437 } //end particle loop
1439 // now let's check that we put correctly the candidate photon in PHOS
1440 Float_t phi = ph->Phi()*180./TMath::Pi(); //Convert to degrees
1441 Float_t eta =TMath::Abs(ph->Eta());//in calos etamin=-etamax
1442 if(IsInPHOS(phi,eta))
1448 void AliGenPythiaPlus::Streamer(TBuffer &R__b)
1450 // Stream an object of class AliGenPythia.
1452 if (R__b.IsReading()) {
1453 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1454 AliGenerator::Streamer(R__b);
1455 R__b >> (Int_t&)fProcess;
1456 R__b >> (Int_t&)fStrucFunc;
1457 R__b >> (Int_t&)fForceDecay;
1461 fParentSelect.Streamer(R__b);
1462 fChildSelect.Streamer(R__b);
1464 // (AliPythia::Instance())->Streamer(R__b);
1467 // if (fDecayer) fDecayer->Streamer(R__b);
1469 R__b.WriteVersion(AliGenPythiaPlus::IsA());
1470 AliGenerator::Streamer(R__b);
1471 R__b << (Int_t)fProcess;
1472 R__b << (Int_t)fStrucFunc;
1473 R__b << (Int_t)fForceDecay;
1477 fParentSelect.Streamer(R__b);
1478 fChildSelect.Streamer(R__b);
1483 // fDecayer->Streamer(R__b);