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 **************************************************************************/
18 // Generator using AMPT as an external generator
20 #include "AliGenAmpt.h"
22 #include <TClonesArray.h>
25 #include <TLorentzVector.h>
27 #include <TParticle.h>
28 #include <TVirtualMC.h>
29 #include <TParticlePDG.h>
30 #include "AliGenHijingEventHeader.h"
31 #define AliGenAmptEventHeader AliGenHijingEventHeader
32 #include "AliAmptRndm.h"
35 #include "AliDecayer.h"
39 AliGenAmpt::AliGenAmpt()
66 fPhiMaxJet(TMath::TwoPi()),
76 fNoHeavyQuarks(kFALSE),
85 fHeader(new AliGenAmptEventHeader("Ampt")),
91 AliAmptRndm::SetAmptRandom(GetRandom());
94 AliGenAmpt::AliGenAmpt(Int_t npart)
121 fPhiMaxJet(2. * TMath::Pi()),
131 fNoHeavyQuarks(kFALSE),
140 fHeader(new AliGenAmptEventHeader("Ampt")),
144 // Default PbPb collisions at 2.76 TeV
148 fTitle= "Particle Generator using AMPT";
149 AliAmptRndm::SetAmptRandom(GetRandom());
152 AliGenAmpt::~AliGenAmpt()
155 if ( fDsigmaDb) delete fDsigmaDb;
156 if ( fDnDb) delete fDnDb;
157 if ( fHeader) delete fHeader;
160 void AliGenAmpt::Init()
166 fProjectile.Resize(8);
168 fAmpt = new TAmpt(fEnergyCMS, fFrame, fProjectile, fTarget,
169 fAProjectile, fZProjectile, fATarget, fZTarget,
170 fMinImpactParam, fMaxImpactParam);
173 fAmpt->SetIHPR2(2, fRadiation);
174 fAmpt->SetIHPR2(3, fTrigger);
175 fAmpt->SetIHPR2(6, fShadowing);
176 fAmpt->SetIHPR2(12, fDecaysOff);
177 fAmpt->SetIHPR2(21, fKeep);
178 fAmpt->SetHIPR1(8, fPtHardMin);
179 fAmpt->SetHIPR1(9, fPtHardMax);
180 fAmpt->SetHIPR1(10, fPtMinJet);
181 fAmpt->SetHIPR1(50, fSimpleJet);
184 // fQuench = 0: no quenching
185 // fQuench = 1: Hijing default
186 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
187 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
188 // fQuench = 4: new LHC parameters with log(e) dependence
189 // fQuench = 5: new RHIC parameters with log(e) dependence
190 fAmpt->SetIHPR2(50, 0);
192 fAmpt->SetIHPR2(4, 1);
194 fAmpt->SetIHPR2(4, 0);
197 fAmpt->SetHIPR1(14, 1.1);
198 fAmpt->SetHIPR1(11, 3.7);
199 } else if (fQuench == 3) {
200 fAmpt->SetHIPR1(14, 0.20);
201 fAmpt->SetHIPR1(11, 2.5);
202 } else if (fQuench == 4) {
203 fAmpt->SetIHPR2(50, 1);
204 fAmpt->SetHIPR1(14, 4.*0.34);
205 fAmpt->SetHIPR1(11, 3.7);
206 } else if (fQuench == 5) {
207 fAmpt->SetIHPR2(50, 1);
208 fAmpt->SetHIPR1(14, 0.34);
209 fAmpt->SetHIPR1(11, 2.5);
213 if (fNoHeavyQuarks) {
214 fAmpt->SetIHPR2(49, 1);
216 fAmpt->SetIHPR2(49, 0);
220 fAmpt->SetIsoft(fIsoft);
221 fAmpt->SetNtMax(fNtMax);
222 fAmpt->SetIpop(fIpop);
224 fAmpt->SetAlpha(fAlpha);
225 fAmpt->SetStringFrag(fStringA, fStringB);
232 EvaluateCrossSections();
234 fAmpt->SetReactionPlaneAngle(0.0);
238 void AliGenAmpt::Generate()
240 // Generate one event
242 Float_t polar[3] = {0,0,0};
243 Float_t origin[3] = {0,0,0};
244 Float_t origin0[3] = {0,0,0};
251 Int_t j, kf, ks, ksp, imo;
255 for (j = 0;j < 3; j++)
256 origin0[j] = fOrigin[j];
257 //time0 = fTimeOrigin;
259 if(fVertexSmear == kPerEvent) {
261 for (j=0; j < 3; j++)
262 origin0[j] = fVertex[j];
266 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
270 // Generate random reaction plane angle if requested
272 TRandom *r=AliAmptRndm::GetAmptRandom();
273 fAmpt->SetReactionPlaneAngle(TMath::TwoPi()*r->Rndm());
276 // Generate one event
277 Int_t fpemask = gSystem->GetFPEMask();
278 gSystem->SetFPEMask(0);
279 fAmpt->GenerateEvent();
280 gSystem->SetFPEMask(fpemask);
285 fAmpt->ImportParticles(&fParticles,"All");
286 Int_t np = fParticles.GetEntriesFast();
290 //RS>>: Decayers now returns cm and sec. Since TAmpt returns mm and mm/c, convert its result to cm and sec here
291 const Float_t kconvT=0.001/2.999792458e8; // mm/c to seconds conversion
292 const Float_t kconvL=1./10; // mm to cm conversion
293 for (int ip=np;ip--;) {
294 TParticle* part = (TParticle*)fParticles[ip];
296 part->SetProductionVertex(part->Vx()*kconvL,part->Vy()*kconvL,part->Vz()*kconvL,kconvT*part->T());
300 if (fTrigger != kNoTrigger) {
305 AliDecayer *decayer = 0;
307 // decayer = gMC->GetDecayer();
308 decayer = fDecayer; //AMPT does not do the strong decays per dafault
310 if (decayer&&fDecay) {
311 TClonesArray arr("TParticle",100);
312 for( Int_t nLoop=0; nLoop!=2; ++nLoop) { // In order to produce more than one generation of decays: NumberOfNestedLoops set to 2
314 for (Int_t i = 0; i < np; i++) {
315 TParticle *iparticle = (TParticle *)fParticles.At(i);
316 if (!Stable(iparticle)) // true if particle has daughters already
318 kf = TMath::Abs(iparticle->GetPdgCode());
321 if( !IsThisAKnownParticle(iparticle) ) continue; // skip undesired particles
323 if (0) { // this turned out to be too cumbersome!
324 if (kf!=331&&kf!=3114&&kf!=3114&&kf!=411&&kf!=-4122&&kf!=-3324&&kf!=-3312&&kf!=-3114&&
325 kf!=-311&&kf!=3214&&kf!=-3214&&kf!=-433&&kf!=413&&kf!=3122&&kf!=-3122&&kf!=-413&&
326 kf!=-421&&kf!=-423&&kf!=3324&&kf!=-313&&kf!=213&&kf!=-213&&kf!=3314&&kf!=3222&&
327 kf!=-3222&&kf!=3224&&kf!=-3224&&kf!=-4212&&kf!=4212&&kf!=433&&kf!=423&&kf!=-3322&&
329 continue; //decay eta',Sigma*+,Sigma*-,D+,Lambda_c-,Xi*0_bar,Xi-_bar,Sigma*-,
330 // K0_bar,Sigma*0,Sigma*0_bar,D*_s-,D*+,Lambda0,Lambda0_bar,D*-
331 // D0_bar,D*0_bar,Xi*0,K*0_bar,rho+,rho-,Xi*-,Sigma-,
332 // Sigma+,Sigma*+,Sigma*-,Sigma_c-,Sigma_c+,D*_s+,D*0,Xi0_bar
334 //} else { // really only decay particles if there are not known to Geant3
335 // if (gMC->IdFromPDG(kf)>0)
338 if (0) { // defining the particle for Geant3 leads to a floating point exception.
339 TParticlePDG *pdg = iparticle->GetPDG(1);
340 //pdg->Print(); printf("%s\n",pdg->ParticleClass());
341 TString ptype(pdg->ParticleClass());
342 TMCParticleType mctype(kPTUndefined);
343 if (ptype=="Baryon" || ptype=="Meson")
345 gMC->DefineParticle(pdg->PdgCode(), pdg->GetName(), mctype, pdg->Mass(), pdg->Charge(), pdg->Lifetime(),
346 ptype,pdg->Width(), (Int_t)pdg->Spin(), (Int_t)pdg->Parity(), 0,
347 (Int_t)pdg->Isospin(), 0, 0, 0, 0, pdg->Stable());
348 gMC->SetUserDecay(pdg->PdgCode());
352 TLorentzVector pmom(iparticle->Px(),iparticle->Py(),iparticle->Pz(),iparticle->Energy());
353 decayer->Decay(kf,&pmom);
354 decayer->ImportParticles(&arr);
355 Int_t ndecayed = arr.GetEntries();
357 if (np2+ndecayed>fParticles.GetSize())
358 fParticles.Expand(2*fParticles.GetSize());
360 // iparticle->SetStatusCode(2); to be compatible with Hijing
361 iparticle->SetFirstDaughter(np2);
362 for (Int_t jj = 1; jj < ndecayed; jj++) {
363 TParticle *jp = (TParticle *)arr.At(jj);
364 if (jp->GetFirstMother()!=1)
367 TParticle *newp = new(fParticles[np2]) TParticle(jp->GetPdgCode(),
368 0, //1, //to be compatible with Hijing
373 jp->Px(),jp->Py(),jp->Pz(),jp->Energy(),
374 jp->Vx(),jp->Vy(),jp->Vz(),jp->T());
375 //take care of the phi
376 //if((kf == 333)||(kf == 313)) {
377 if(IsThisAKnownParticle(iparticle)) {
378 //Printf("=============PANOS===================");
379 //Printf("Phi detected - daughet is: %d",jp->GetPdgCode());
380 newp->SetUniqueID(4);
382 else newp->SetUniqueID( jp->GetStatusCode() );
384 } // end of jj->nDecayedParticles
385 iparticle->SetLastDaughter(np2-1);
386 } // end of nDecayedPrticles>1
388 np = fParticles.GetEntries();
390 AliError(Form("Something is fishy: %d %d\n", np,np2));
392 } // end of nLoop->NumberOfNestedLoops
395 AliError("No decayer found, but fDecay==kTRUE!");
402 Int_t* newPos = new Int_t[np];
403 Int_t* pSelected = new Int_t[np];
405 for (Int_t i = 0; i < np; i++) {
411 //TParticle * iparticle = (TParticle *) fParticles.At(0);
412 fVertex[0] = origin0[0];
413 fVertex[1] = origin0[1];
414 fVertex[2] = origin0[2];
417 // First select parent particles
418 for (Int_t i = 0; i < np; i++) {
419 TParticle *iparticle = (TParticle *) fParticles.At(i);
421 // Is this a parent particle ?
422 if (Stable(iparticle)) continue; // quit if particle has no daughters
423 Bool_t selected = kTRUE;
424 Bool_t hasSelectedDaughters = kFALSE;
425 kf = iparticle->GetPdgCode();
426 ks = iparticle->GetStatusCode();
431 selected = KinematicSelection(iparticle, 0) && SelectFlavor(kf);
432 hasSelectedDaughters = DaughtersSelection(iparticle);
434 // Put particle on the stack if it is either selected or
435 // it is the mother of at least one seleted particle
436 if (selected || hasSelectedDaughters) {
440 } // particle loop parents
442 // Now select the final state particles
443 fProjectileSpecn = 0;
444 fProjectileSpecp = 0;
447 for (Int_t i = 0; i<np; i++) {
448 TParticle *iparticle = (TParticle *) fParticles.At(i);
449 // Is this a final state particle ?
450 if (!Stable(iparticle)) continue; // quit if particle has daughters
451 Bool_t selected = kTRUE;
452 kf = iparticle->GetPdgCode();
455 ks = iparticle->GetStatusCode();
456 ksp = iparticle->GetUniqueID();
458 // --------------------------------------------------------------------------
459 // Count spectator neutrons and protons
460 if(ksp == 0 || ksp == 1) {
461 if(kf == kNeutron) fProjectileSpecn += 1;
462 if(kf == kProton) fProjectileSpecp += 1;
463 } else if(ksp == 10 || ksp == 11) {
464 if(kf == kNeutron) fTargetSpecn += 1;
465 if(kf == kProton) fTargetSpecp += 1;
467 // --------------------------------------------------------------------------
469 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
470 if (!fSpectators && selected)
471 selected = (ksp != 0 && ksp != 1 && ksp != 10 && ksp != 11);
474 // Put particle on the stack if selected
478 if (0) printf("---> %d %d %d %s\n",i,nc,kf,iparticle->GetName());
480 } // particle loop final state
482 // Write particles to stack
483 for (Int_t i = 0; i<np; i++) {
485 TParticle *iparticle = (TParticle *) fParticles.At(i);
486 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
487 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
488 kf = iparticle->GetPdgCode();
489 ks = iparticle->GetStatusCode();
490 p[0] = iparticle->Px();
491 p[1] = iparticle->Py();
492 p[2] = iparticle->Pz() * sign;
493 origin[0] = origin0[0]+iparticle->Vx();
494 origin[1] = origin0[1]+iparticle->Vy();
495 origin[2] = origin0[2]+iparticle->Vz();
496 tof = time0 + iparticle->T();
499 TParticle* mother = 0;
500 TMCProcess procID = (TMCProcess) iparticle->GetUniqueID();
502 imo = iparticle->GetFirstMother();
503 mother = (TParticle *) fParticles.At(imo);
504 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
505 } else { // if has no mothers then it was created by AMPT
507 procID = kPPrimary; // reseting to ALIROOT convention
509 procID = kPNoProcess; // for expectators
511 Bool_t tFlag = (fTrackIt && !hasDaughter);
512 PushTrack(tFlag,imo,kf,p,origin,polar,tof,procID,nt, 1., ks);
521 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
524 if (jev >= fNpart || fNpart == -1) {
525 fKineBias = Float_t(fNpart)/Float_t(fTrials);
526 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
532 SetHighWaterMark(nt);
535 Bool_t AliGenAmpt::IsThisAKnownParticle(TParticle *thisGuy)
537 // In order to prevent AMPT to introduce weird particles into the decayer and transporter
538 // blame cperez@cern.ch for this method
540 Int_t pdgcode = TMath::Abs( thisGuy->GetPdgCode() );
542 Int_t myFavoriteParticles[ 38] = { 3322, 3314, 3312, 3224, 3222, // Xi0 Xi*+- Xi+- Sigma*-+ Sigma-+
543 3214, 3212, 3122, 3114, 3112, // Sigma*0 Sigma0 Lambda0 Sigma*+- Sigma+-
544 2224, 2214, 2212, 2114, 2112, // Delta--++ Delta-+ proton Delta0 neutron
545 1114, 323, 321, 313, 311, // Delta+- K*-+ K-+ K*0 K0
546 213, 211, 11, 22, 111, // rho-+ pi-+ e+- gamma pi0
547 113, 130, 221, 223, 310, // rho0 K_L0 eta omega K_S0
548 331, 333, 3324, 431, 421, // eta' phi Xi*0 Ds-+ D0
549 411, 413, 13 // D-+ D*-+ mu+-
552 Bool_t found = kFALSE;
553 for(Int_t i=0; i!=38; ++i)
554 if( myFavoriteParticles[i] == pdgcode ) {
562 void AliGenAmpt::EvaluateCrossSections()
564 // Glauber Calculation of geometrical x-section
566 Float_t xTot = 0.; // barn
567 Float_t xTotHard = 0.; // barn
568 Float_t xPart = 0.; // barn
569 Float_t xPartHard = 0.; // barn
570 Float_t sigmaHard = 0.1; // mbarn
572 Float_t bMax = fAmpt->GetHIPR1(34)+fAmpt->GetHIPR1(35);
573 const Float_t kdib = 0.2;
574 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
576 printf("\n Projectile Radius (fm): %f \n",fAmpt->GetHIPR1(34));
577 printf("\n Target Radius (fm): %f \n",fAmpt->GetHIPR1(35));
580 Float_t oldvalue= 0.;
581 Float_t* b = new Float_t[kMax]; memset(b,0,kMax*sizeof(Float_t));
582 Float_t* si1 = new Float_t[kMax]; memset(si1,0,kMax*sizeof(Float_t));
583 Float_t* si2 = new Float_t[kMax]; memset(si2,0,kMax*sizeof(Float_t));
584 for (i = 0; i < kMax; i++) {
585 Float_t xb = bMin+i*kdib;
586 Float_t ov=fAmpt->Profile(xb);
587 Float_t gb = 2.*0.01*fAmpt->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fAmpt->GetHINT1(12)*ov));
588 Float_t gbh = 2.*0.01*fAmpt->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
591 printf("profile %f %f %f\n", xb, ov, fAmpt->GetHINT1(12));
593 if (xb > fMinImpactParam && xb < fMaxImpactParam) {
598 if ((oldvalue) && ((xTot-oldvalue)/oldvalue<0.0001))
601 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
602 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
610 printf("\n Total cross section (barn): %f \n",xTot);
611 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
612 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
613 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
615 // Store result as a graph
620 fDsigmaDb = new TGraph(i, b, si1);
622 fDnDb = new TGraph(i, b, si2);
625 Bool_t AliGenAmpt::DaughtersSelection(TParticle* iparticle)
627 // Looks recursively if one of the daughters has been selected
628 //printf("\n Consider daughters %d:",iparticle->GetPdgCode());
631 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
632 Bool_t selected = kFALSE;
634 imin = iparticle->GetFirstDaughter();
635 imax = iparticle->GetLastDaughter();
636 for (Int_t i = imin; i <= imax; i++){
637 TParticle * jparticle = (TParticle *) fParticles.At(i);
638 Int_t ip = jparticle->GetPdgCode();
639 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
640 selected=kTRUE; break;
642 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
650 Bool_t AliGenAmpt::SelectFlavor(Int_t pid)
652 // Select flavor of particle
654 // 4: charm and beauty
661 Int_t ifl = TMath::Abs(pid/100);
662 if (ifl > 10) ifl/=10;
663 res = (fFlavor == ifl);
666 // This part if gamma writing is inhibited
668 res = res && (pid != kGamma && pid != kPi0);
673 Bool_t AliGenAmpt::Stable(TParticle* particle) const
675 // Return true for a stable particle
679 if (particle->GetFirstDaughter() < 0 )
687 void AliGenAmpt::MakeHeader()
689 // Fills the event header, to be called after each event
691 fHeader->SetNProduced(fNprimaries);
692 fHeader->SetImpactParameter(fAmpt->GetHINT1(19));
693 fHeader->SetTotalEnergy(fAmpt->GetEATT());
694 fHeader->SetHardScatters(fAmpt->GetJATT());
695 fHeader->SetParticipants(fAmpt->GetNP(), fAmpt->GetNT());
696 fHeader->SetCollisions(fAmpt->GetN0(),
700 fHeader->SetSpectators(fProjectileSpecn, fProjectileSpecp,
701 fTargetSpecn,fTargetSpecp);
702 //fHeader->SetReactionPlaneAngle(fAmpt->GetHINT1(20));
703 fHeader->SetReactionPlaneAngle(fAmpt->GetReactionPlaneAngle());
704 //printf("Impact Parameter %13.3f \n", fAmpt->GetHINT1(19));
706 // 4-momentum vectors of the triggered jets.
707 // Before final state gluon radiation.
708 TLorentzVector* jet1 = new TLorentzVector(fAmpt->GetHINT1(21),
711 fAmpt->GetHINT1(24));
713 TLorentzVector* jet2 = new TLorentzVector(fAmpt->GetHINT1(31),
716 fAmpt->GetHINT1(34));
717 // After final state gluon radiation.
718 TLorentzVector* jet3 = new TLorentzVector(fAmpt->GetHINT1(26),
721 fAmpt->GetHINT1(29));
723 TLorentzVector* jet4 = new TLorentzVector(fAmpt->GetHINT1(36),
726 fAmpt->GetHINT1(39));
727 fHeader->SetJets(jet1, jet2, jet3, jet4);
728 // Bookkeeping for kinematic bias
729 fHeader->SetTrials(fTrials);
731 fHeader->SetPrimaryVertex(fVertex);
732 fHeader->SetInteractionTime(fEventTime);
734 fCollisionGeometry = fHeader;
739 Bool_t AliGenAmpt::CheckTrigger()
741 // Check the kinematic trigger condition
743 Bool_t triggered = kFALSE;
747 TLorentzVector* jet1 = new TLorentzVector(fAmpt->GetHINT1(26),
750 fAmpt->GetHINT1(29));
752 TLorentzVector* jet2 = new TLorentzVector(fAmpt->GetHINT1(36),
755 fAmpt->GetHINT1(39));
756 Double_t eta1 = jet1->Eta();
757 Double_t eta2 = jet2->Eta();
758 Double_t phi1 = jet1->Phi();
759 Double_t phi2 = jet2->Phi();
760 //printf("\n Trigger: %f %f %f %f", fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
761 if ( (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
762 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
764 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
765 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
768 } else if (fTrigger == 2) {
770 Int_t np = fParticles.GetEntriesFast();
771 for (Int_t i = 0; i < np; i++) {
772 TParticle* part = (TParticle*) fParticles.At(i);
773 Int_t kf = part->GetPdgCode();
774 Int_t ksp = part->GetUniqueID();
775 if (kf == 22 && ksp == 40) {
776 Float_t phi = part->Phi();
777 Float_t eta = part->Eta();
778 if (eta < fEtaMaxJet &&
784 } // check phi,eta within limits