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")),
90 AliAmptRndm::SetAmptRandom(GetRandom());
93 AliGenAmpt::AliGenAmpt(Int_t npart)
120 fPhiMaxJet(2. * TMath::Pi()),
130 fNoHeavyQuarks(kFALSE),
139 fHeader(new AliGenAmptEventHeader("Ampt")),
142 // Default PbPb collisions at 2.76 TeV
146 fTitle= "Particle Generator using AMPT";
147 AliAmptRndm::SetAmptRandom(GetRandom());
150 AliGenAmpt::~AliGenAmpt()
153 if ( fDsigmaDb) delete fDsigmaDb;
154 if ( fDnDb) delete fDnDb;
155 if ( fHeader) delete fHeader;
158 void AliGenAmpt::Init()
164 fProjectile.Resize(8);
166 fAmpt = new TAmpt(fEnergyCMS, fFrame, fProjectile, fTarget,
167 fAProjectile, fZProjectile, fATarget, fZTarget,
168 fMinImpactParam, fMaxImpactParam);
171 fAmpt->SetIHPR2(2, fRadiation);
172 fAmpt->SetIHPR2(3, fTrigger);
173 fAmpt->SetIHPR2(6, fShadowing);
174 fAmpt->SetIHPR2(12, fDecaysOff);
175 fAmpt->SetIHPR2(21, fKeep);
176 fAmpt->SetHIPR1(8, fPtHardMin);
177 fAmpt->SetHIPR1(9, fPtHardMax);
178 fAmpt->SetHIPR1(10, fPtMinJet);
179 fAmpt->SetHIPR1(50, fSimpleJet);
182 // fQuench = 0: no quenching
183 // fQuench = 1: Hijing default
184 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
185 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
186 // fQuench = 4: new LHC parameters with log(e) dependence
187 // fQuench = 5: new RHIC parameters with log(e) dependence
188 fAmpt->SetIHPR2(50, 0);
190 fAmpt->SetIHPR2(4, 1);
192 fAmpt->SetIHPR2(4, 0);
195 fAmpt->SetHIPR1(14, 1.1);
196 fAmpt->SetHIPR1(11, 3.7);
197 } else if (fQuench == 3) {
198 fAmpt->SetHIPR1(14, 0.20);
199 fAmpt->SetHIPR1(11, 2.5);
200 } else if (fQuench == 4) {
201 fAmpt->SetIHPR2(50, 1);
202 fAmpt->SetHIPR1(14, 4.*0.34);
203 fAmpt->SetHIPR1(11, 3.7);
204 } else if (fQuench == 5) {
205 fAmpt->SetIHPR2(50, 1);
206 fAmpt->SetHIPR1(14, 0.34);
207 fAmpt->SetHIPR1(11, 2.5);
211 if (fNoHeavyQuarks) {
212 fAmpt->SetIHPR2(49, 1);
214 fAmpt->SetIHPR2(49, 0);
218 fAmpt->SetIsoft(fIsoft);
219 fAmpt->SetNtMax(fNtMax);
220 fAmpt->SetIpop(fIpop);
222 fAmpt->SetAlpha(fAlpha);
223 fAmpt->SetStringFrag(fStringA, fStringB);
230 EvaluateCrossSections();
233 void AliGenAmpt::Generate()
235 // Generate one event
237 Float_t polar[3] = {0,0,0};
238 Float_t origin[3] = {0,0,0};
239 Float_t origin0[3] = {0,0,0};
244 // converts from mm/c to s
245 const Float_t kconv = 0.001/2.99792458e8;
249 Int_t j, kf, ks, ksp, imo;
253 for (j = 0;j < 3; j++)
254 origin0[j] = fOrigin[j];
255 //time0 = fTimeOrigin;
257 if(fVertexSmear == kPerEvent) {
259 for (j=0; j < 3; j++)
260 origin0[j] = fVertex[j];
264 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
267 // Generate one event
268 Int_t fpemask = gSystem->GetFPEMask();
269 gSystem->SetFPEMask(0);
270 fAmpt->GenerateEvent();
271 gSystem->SetFPEMask(fpemask);
274 fAmpt->ImportParticles(&fParticles,"All");
275 Int_t np = fParticles.GetEntriesFast();
279 if (fTrigger != kNoTrigger) {
284 AliDecayer *decayer = 0;
286 // decayer = gMC->GetDecayer();
287 decayer = fDecayer; //AMPT does not do the strong decays per dafault
289 if (decayer&&fDecay) {
290 TClonesArray arr("TParticle",100);
291 for( Int_t nLoop=0; nLoop!=2; ++nLoop) { // In order to produce more than one generation of decays: NumberOfNestedLoops set to 2
293 for (Int_t i = 0; i < np; i++) {
294 TParticle *iparticle = (TParticle *)fParticles.At(i);
295 if (!Stable(iparticle)) // true if particle has daughters already
297 kf = TMath::Abs(iparticle->GetPdgCode());
300 if( !IsThisAKnownParticle(iparticle) ) continue; // skip undesired particles
302 if (0) { // this turned out to be too cumbersome!
303 if (kf!=331&&kf!=3114&&kf!=3114&&kf!=411&&kf!=-4122&&kf!=-3324&&kf!=-3312&&kf!=-3114&&
304 kf!=-311&&kf!=3214&&kf!=-3214&&kf!=-433&&kf!=413&&kf!=3122&&kf!=-3122&&kf!=-413&&
305 kf!=-421&&kf!=-423&&kf!=3324&&kf!=-313&&kf!=213&&kf!=-213&&kf!=3314&&kf!=3222&&
306 kf!=-3222&&kf!=3224&&kf!=-3224&&kf!=-4212&&kf!=4212&&kf!=433&&kf!=423&&kf!=-3322&&
308 continue; //decay eta',Sigma*+,Sigma*-,D+,Lambda_c-,Xi*0_bar,Xi-_bar,Sigma*-,
309 // K0_bar,Sigma*0,Sigma*0_bar,D*_s-,D*+,Lambda0,Lambda0_bar,D*-
310 // D0_bar,D*0_bar,Xi*0,K*0_bar,rho+,rho-,Xi*-,Sigma-,
311 // Sigma+,Sigma*+,Sigma*-,Sigma_c-,Sigma_c+,D*_s+,D*0,Xi0_bar
313 //} else { // really only decay particles if there are not known to Geant3
314 // if (gMC->IdFromPDG(kf)>0)
317 if (0) { // defining the particle for Geant3 leads to a floating point exception.
318 TParticlePDG *pdg = iparticle->GetPDG(1);
319 //pdg->Print(); printf("%s\n",pdg->ParticleClass());
320 TString ptype(pdg->ParticleClass());
321 TMCParticleType mctype(kPTUndefined);
322 if (ptype=="Baryon" || ptype=="Meson")
324 gMC->DefineParticle(pdg->PdgCode(), pdg->GetName(), mctype, pdg->Mass(), pdg->Charge(), pdg->Lifetime(),
325 ptype,pdg->Width(), (Int_t)pdg->Spin(), (Int_t)pdg->Parity(), 0,
326 (Int_t)pdg->Isospin(), 0, 0, 0, 0, pdg->Stable());
327 gMC->SetUserDecay(pdg->PdgCode());
331 TLorentzVector pmom(iparticle->Px(),iparticle->Py(),iparticle->Pz(),iparticle->Energy());
332 decayer->Decay(kf,&pmom);
333 decayer->ImportParticles(&arr);
334 Int_t ndecayed = arr.GetEntries();
336 if (np2+ndecayed>fParticles.GetSize())
337 fParticles.Expand(2*fParticles.GetSize());
339 // iparticle->SetStatusCode(2); to be compatible with Hijing
340 iparticle->SetFirstDaughter(np2);
341 for (Int_t jj = 1; jj < ndecayed; jj++) {
342 TParticle *jp = (TParticle *)arr.At(jj);
343 if (jp->GetFirstMother()!=1)
345 TParticle *newp = new(fParticles[np2]) TParticle(jp->GetPdgCode(),
346 0, //1, //to be compatible with Hijing
351 jp->Px(),jp->Py(),jp->Pz(),jp->Energy(),
352 jp->Vx(),jp->Vy(),jp->Vz(),jp->T());
353 newp->SetUniqueID( jp->GetStatusCode() );
355 } // end of jj->nDecayedParticles
356 iparticle->SetLastDaughter(np2-1);
357 } // end of nDecayedPrticles>1
359 np = fParticles.GetEntries();
361 AliError(Form("Something is fishy: %d %d\n", np,np2));
363 } // end of nLoop->NumberOfNestedLoops
366 AliError("No decayer found, but fDecay==kTRUE!");
373 Int_t* newPos = new Int_t[np];
374 Int_t* pSelected = new Int_t[np];
376 for (Int_t i = 0; i < np; i++) {
382 //TParticle * iparticle = (TParticle *) fParticles.At(0);
383 fVertex[0] = origin0[0];
384 fVertex[1] = origin0[1];
385 fVertex[2] = origin0[2];
388 // First select parent particles
389 for (Int_t i = 0; i < np; i++) {
390 TParticle *iparticle = (TParticle *) fParticles.At(i);
392 // Is this a parent particle ?
393 if (Stable(iparticle)) continue; // quit if particle has no daughters
394 Bool_t selected = kTRUE;
395 Bool_t hasSelectedDaughters = kFALSE;
396 kf = iparticle->GetPdgCode();
397 ks = iparticle->GetStatusCode();
402 selected = KinematicSelection(iparticle, 0) && SelectFlavor(kf);
403 hasSelectedDaughters = DaughtersSelection(iparticle);
405 // Put particle on the stack if it is either selected or
406 // it is the mother of at least one seleted particle
407 if (selected || hasSelectedDaughters) {
411 } // particle loop parents
413 // Now select the final state particles
414 fProjectileSpecn = 0;
415 fProjectileSpecp = 0;
418 for (Int_t i = 0; i<np; i++) {
419 TParticle *iparticle = (TParticle *) fParticles.At(i);
420 // Is this a final state particle ?
421 if (!Stable(iparticle)) continue; // quit if particle has daughters
422 Bool_t selected = kTRUE;
423 kf = iparticle->GetPdgCode();
426 ks = iparticle->GetStatusCode();
427 ksp = iparticle->GetUniqueID();
429 // --------------------------------------------------------------------------
430 // Count spectator neutrons and protons
431 if(ksp == 0 || ksp == 1) {
432 if(kf == kNeutron) fProjectileSpecn += 1;
433 if(kf == kProton) fProjectileSpecp += 1;
434 } else if(ksp == 10 || ksp == 11) {
435 if(kf == kNeutron) fTargetSpecn += 1;
436 if(kf == kProton) fTargetSpecp += 1;
438 // --------------------------------------------------------------------------
440 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
441 if (!fSpectators && selected)
442 selected = (ksp != 0 && ksp != 1 && ksp != 10 && ksp != 11);
445 // Put particle on the stack if selected
449 if (0) printf("---> %d %d %d %s\n",i,nc,kf,iparticle->GetName());
451 } // particle loop final state
453 // Write particles to stack
454 for (Int_t i = 0; i<np; i++) {
456 TParticle *iparticle = (TParticle *) fParticles.At(i);
457 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
458 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
459 kf = iparticle->GetPdgCode();
460 ks = iparticle->GetStatusCode();
461 p[0] = iparticle->Px();
462 p[1] = iparticle->Py();
463 p[2] = iparticle->Pz() * sign;
464 origin[0] = origin0[0]+iparticle->Vx()/10;
465 origin[1] = origin0[1]+iparticle->Vy()/10;
466 origin[2] = origin0[2]+iparticle->Vz()/10;
467 tof = time0+kconv * iparticle->T();
470 TParticle* mother = 0;
471 TMCProcess procID = (TMCProcess) iparticle->GetUniqueID();
473 imo = iparticle->GetFirstMother();
474 mother = (TParticle *) fParticles.At(imo);
475 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
476 } else { // if has no mothers then it was created by AMPT
478 procID = kPPrimary; // reseting to ALIROOT convention
480 procID = kPNoProcess; // for expectators
482 Bool_t tFlag = (fTrackIt && !hasDaughter);
483 PushTrack(tFlag,imo,kf,p,origin,polar,tof,procID,nt, 1., ks);
492 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
495 if (jev >= fNpart || fNpart == -1) {
496 fKineBias = Float_t(fNpart)/Float_t(fTrials);
497 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
503 SetHighWaterMark(nt);
506 Bool_t AliGenAmpt::IsThisAKnownParticle(TParticle *thisGuy)
508 // In order to prevent AMPT to introduce weird particles into the decayer and transporter
509 // blame cperez@cern.ch for this method
511 Int_t pdgcode = TMath::Abs( thisGuy->GetPdgCode() );
513 Int_t myFavoriteParticles[ 38] = { 3322, 3314, 3312, 3224, 3222, // Xi0 Xi*+- Xi+- Sigma*-+ Sigma-+
514 3214, 3212, 3122, 3114, 3112, // Sigma*0 Sigma0 Lambda0 Sigma*+- Sigma+-
515 2224, 2214, 2212, 2114, 2112, // Delta--++ Delta-+ proton Delta0 neutron
516 1114, 323, 321, 313, 311, // Delta+- K*-+ K-+ K*0 K0
517 213, 211, 11, 22, 111, // rho-+ pi-+ e+- gamma pi0
518 113, 130, 221, 223, 310, // rho0 K_L0 eta omega K_S0
519 331, 333, 3324, 431, 421, // eta' phi Xi*0 Ds-+ D0
520 411, 413, 13 // D-+ D*-+ mu+-
523 Bool_t found = kFALSE;
524 for(Int_t i=0; i!=38; ++i)
525 if( myFavoriteParticles[i] == pdgcode ) {
533 void AliGenAmpt::EvaluateCrossSections()
535 // Glauber Calculation of geometrical x-section
537 Float_t xTot = 0.; // barn
538 Float_t xTotHard = 0.; // barn
539 Float_t xPart = 0.; // barn
540 Float_t xPartHard = 0.; // barn
541 Float_t sigmaHard = 0.1; // mbarn
543 Float_t bMax = fAmpt->GetHIPR1(34)+fAmpt->GetHIPR1(35);
544 const Float_t kdib = 0.2;
545 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
547 printf("\n Projectile Radius (fm): %f \n",fAmpt->GetHIPR1(34));
548 printf("\n Target Radius (fm): %f \n",fAmpt->GetHIPR1(35));
551 Float_t oldvalue= 0.;
552 Float_t* b = new Float_t[kMax]; memset(b,0,kMax*sizeof(Float_t));
553 Float_t* si1 = new Float_t[kMax]; memset(si1,0,kMax*sizeof(Float_t));
554 Float_t* si2 = new Float_t[kMax]; memset(si2,0,kMax*sizeof(Float_t));
555 for (i = 0; i < kMax; i++) {
556 Float_t xb = bMin+i*kdib;
557 Float_t ov=fAmpt->Profile(xb);
558 Float_t gb = 2.*0.01*fAmpt->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fAmpt->GetHINT1(12)*ov));
559 Float_t gbh = 2.*0.01*fAmpt->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
562 printf("profile %f %f %f\n", xb, ov, fAmpt->GetHINT1(12));
564 if (xb > fMinImpactParam && xb < fMaxImpactParam) {
569 if ((oldvalue) && ((xTot-oldvalue)/oldvalue<0.0001))
572 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
573 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
581 printf("\n Total cross section (barn): %f \n",xTot);
582 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
583 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
584 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
586 // Store result as a graph
591 fDsigmaDb = new TGraph(i, b, si1);
593 fDnDb = new TGraph(i, b, si2);
596 Bool_t AliGenAmpt::DaughtersSelection(TParticle* iparticle)
598 // Looks recursively if one of the daughters has been selected
599 //printf("\n Consider daughters %d:",iparticle->GetPdgCode());
602 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
603 Bool_t selected = kFALSE;
605 imin = iparticle->GetFirstDaughter();
606 imax = iparticle->GetLastDaughter();
607 for (Int_t i = imin; i <= imax; i++){
608 TParticle * jparticle = (TParticle *) fParticles.At(i);
609 Int_t ip = jparticle->GetPdgCode();
610 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
611 selected=kTRUE; break;
613 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
621 Bool_t AliGenAmpt::SelectFlavor(Int_t pid)
623 // Select flavor of particle
625 // 4: charm and beauty
632 Int_t ifl = TMath::Abs(pid/100);
633 if (ifl > 10) ifl/=10;
634 res = (fFlavor == ifl);
637 // This part if gamma writing is inhibited
639 res = res && (pid != kGamma && pid != kPi0);
644 Bool_t AliGenAmpt::Stable(TParticle* particle) const
646 // Return true for a stable particle
650 if (particle->GetFirstDaughter() < 0 )
658 void AliGenAmpt::MakeHeader()
660 // Fills the event header, to be called after each event
662 fHeader->SetNProduced(fNprimaries);
663 fHeader->SetImpactParameter(fAmpt->GetHINT1(19));
664 fHeader->SetTotalEnergy(fAmpt->GetEATT());
665 fHeader->SetHardScatters(fAmpt->GetJATT());
666 fHeader->SetParticipants(fAmpt->GetNP(), fAmpt->GetNT());
667 fHeader->SetCollisions(fAmpt->GetN0(),
671 fHeader->SetSpectators(fProjectileSpecn, fProjectileSpecp,
672 fTargetSpecn,fTargetSpecp);
673 fHeader->SetReactionPlaneAngle(fAmpt->GetHINT1(20));
674 //printf("Impact Parameter %13.3f \n", fAmpt->GetHINT1(19));
676 // 4-momentum vectors of the triggered jets.
677 // Before final state gluon radiation.
678 TLorentzVector* jet1 = new TLorentzVector(fAmpt->GetHINT1(21),
681 fAmpt->GetHINT1(24));
683 TLorentzVector* jet2 = new TLorentzVector(fAmpt->GetHINT1(31),
686 fAmpt->GetHINT1(34));
687 // After final state gluon radiation.
688 TLorentzVector* jet3 = new TLorentzVector(fAmpt->GetHINT1(26),
691 fAmpt->GetHINT1(29));
693 TLorentzVector* jet4 = new TLorentzVector(fAmpt->GetHINT1(36),
696 fAmpt->GetHINT1(39));
697 fHeader->SetJets(jet1, jet2, jet3, jet4);
698 // Bookkeeping for kinematic bias
699 fHeader->SetTrials(fTrials);
701 fHeader->SetPrimaryVertex(fVertex);
702 fHeader->SetInteractionTime(fEventTime);
704 fCollisionGeometry = fHeader;
709 Bool_t AliGenAmpt::CheckTrigger()
711 // Check the kinematic trigger condition
713 Bool_t triggered = kFALSE;
717 TLorentzVector* jet1 = new TLorentzVector(fAmpt->GetHINT1(26),
720 fAmpt->GetHINT1(29));
722 TLorentzVector* jet2 = new TLorentzVector(fAmpt->GetHINT1(36),
725 fAmpt->GetHINT1(39));
726 Double_t eta1 = jet1->Eta();
727 Double_t eta2 = jet2->Eta();
728 Double_t phi1 = jet1->Phi();
729 Double_t phi2 = jet2->Phi();
730 //printf("\n Trigger: %f %f %f %f", fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
731 if ( (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
732 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
734 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
735 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
738 } else if (fTrigger == 2) {
740 Int_t np = fParticles.GetEntriesFast();
741 for (Int_t i = 0; i < np; i++) {
742 TParticle* part = (TParticle*) fParticles.At(i);
743 Int_t kf = part->GetPdgCode();
744 Int_t ksp = part->GetUniqueID();
745 if (kf == 22 && ksp == 40) {
746 Float_t phi = part->Phi();
747 Float_t eta = part->Eta();
748 if (eta < fEtaMaxJet &&
754 } // check phi,eta within limits