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 **************************************************************************/
17 // Generator using DPMJET as an external generator
18 // The main DPMJET options are accessable for the user through this interface.
19 // Uses the TDPMjet implementation of TGenerator.
24 #include <TParticle.h>
26 #include <TDatabasePDG.h>
27 #include <TParticlePDG.h>
28 #include <TParticleClassPDG.h>
30 #include <TLorentzVector.h>
32 #include "AliGenDPMjet.h"
33 #include "AliGenDPMjetEventHeader.h"
34 #include "AliPythia.h"
36 #include "AliDpmJetRndm.h"
38 ClassImp(AliGenDPMjet)
41 //______________________________________________________________________________
42 AliGenDPMjet::AliGenDPMjet()
48 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
52 //______________________________________________________________________________
53 AliGenDPMjet::AliGenDPMjet(Int_t npart)
56 // Default PbPb collisions at 5. 5 TeV
59 fTitle= "Particle Generator using DPMJET";
66 SetImpactParameterRange();
77 fParticles = new TClonesArray("TParticle",10000);
79 // Set random number generator
82 AliPythia::Instance();
83 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
86 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
91 //______________________________________________________________________________
92 AliGenDPMjet::~AliGenDPMjet()
99 //______________________________________________________________________________
100 void AliGenDPMjet::Init()
104 SetMC(new TDPMjet(fAProjectile, fZProjectile, fATarget, fZTarget,
105 fBeamEn,fEnergyCMS));
107 fDPMjet=(TDPMjet*) fMCEvGen;
109 // **** Flag to force central production
110 // fICentr=1. central production forced
111 // fICentr<0 && fICentr>-100 -> bmin = fMinImpactParam, bmax = fMaxImpactParam
112 // fICentr<-99 -> fraction of x-sec. = XSFRAC
113 // fICentr=-1. -> evaporation/fzc suppressed
114 // fICentr<-1. -> evaporation/fzc suppressed
115 if (fAProjectile == 1 && fZProjectile == 1) fDPMjet->SetfIdp(1);
117 fDPMjet->SetfFCentr(fICentr);
118 fDPMjet->SetbRange(fMinImpactParam,fMaxImpactParam);
123 fDPMjet->Initialize();
124 //if (fEvaluate) EvaluateCrossSections();
126 // Initialize AliIonPDGCodes to define ion PDG codes
127 /*AliIonPDGCodes *PDGcodes = new AliIonPDGCodes();
128 PDGcodes->AddParticlesToPdgDataBase();
129 PDGcodes->MapPDGGEant3Codes();*/
133 //______________________________________________________________________________
134 void AliGenDPMjet::Generate()
136 // Generate one event
138 Float_t polar[3] = {0,0,0};
139 Float_t origin[3] = {0,0,0};
140 Float_t origin0[3] = {0,0,0};
141 Float_t p[3], random[6];
144 // converts from mm/c to s
145 const Float_t kconv = 0.001/2.999792458e8;
148 Int_t j, kf, ks, imo;
152 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
153 if(fVertexSmear == kPerEvent) {
156 while(TMath::Abs(dv[2])>fCutVertexZ*fOsigma[2]) {
158 for (j=0; j < 3; j++) {
159 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
160 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
163 for (j=0; j < 3; j++) origin0[j] += dv[j];
168 // Generate one event
169 // --------------------------------------------------------------------------
172 // --------------------------------------------------------------------------
173 fDPMjet->GenerateEvent();
176 fDPMjet->ImportParticles(fParticles,"All");
180 fGenImpPar = fDPMjet->GetBImpac();
182 Int_t np = fParticles->GetEntriesFast();
183 printf("\n **************************************************%d\n",np);
187 Int_t* newPos = new Int_t[np];
188 Int_t* pSelected = new Int_t[np];
190 for (i = 0; i<np; i++) {
197 //TParticle *iparticle = (TParticle*) fParticles->At(0);
198 fVertex[0] = origin0[0];
199 fVertex[1] = origin0[1];
200 fVertex[2] = origin0[2];
201 //for(int jj=0; jj<3; jj++) printf(" fEventVertex[%d] = %f\n",jj,fEventVertex[jj]);
203 // First select parent particles
205 for (i = 0; i<np; i++) {
206 TParticle *iparticle = (TParticle *) fParticles->At(i);
207 //if(!iparticle) iparticle->Print("");
209 // Is this a parent particle ?
211 if (Stable(iparticle)) continue;
213 Bool_t selected = kTRUE;
214 Bool_t hasSelectedDaughters = kFALSE;
216 kf = iparticle->GetPdgCode();
217 if (kf == 92) continue;
218 ks = iparticle->GetStatusCode();
219 // No initial state partons
220 if (ks==21) continue;
222 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
224 hasSelectedDaughters = DaughtersSelection(iparticle);
226 // Put particle on the stack if it is either selected or
227 // it is the mother of at least one seleted particle
229 if (selected || hasSelectedDaughters) {
233 } // particle loop parents
235 // Now select the final state particles
238 for (i=0; i<np; i++) {
239 TParticle *iparticle = (TParticle *) fParticles->At(i);
240 //if(!iparticle) printf(" i = %d -> iparticle==0\n",i);
242 // Is this a final state particle ?
244 if (!Stable(iparticle)) continue;
246 Bool_t selected = kTRUE;
247 kf = iparticle->GetPdgCode();
248 ks = iparticle->GetStatusCode();
250 // --------------------------------------------------------------------------
251 // Count spectator neutrons and protons (ks == 13, 14)
252 if(ks == 13 || ks == 14){
253 if(kf == kNeutron) fSpecn += 1;
254 if(kf == kProton) fSpecp += 1;
256 // --------------------------------------------------------------------------
259 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
260 if (!fSpectators && selected) selected = (ks == 13 || ks == 14);
263 // Put particle on the stack if selected
269 } // particle loop final state
271 // Write particles to stack
273 for (i = 0; i<np; i++) {
274 TParticle * iparticle = (TParticle *) fParticles->At(i);
275 Bool_t hasMother = (iparticle->GetFirstMother()>=0);
276 // Bool_t hasDaughter = (iparticle->GetFirstDaughter()>=0);
280 kf = iparticle->GetPdgCode();
281 if(kf==99999) continue;
282 ks = iparticle->GetStatusCode();
284 p[0] = iparticle->Px();
285 p[1] = iparticle->Py();
286 p[2] = iparticle->Pz();
287 origin[0] = origin0[0]+iparticle->Vx()/10;
288 origin[1] = origin0[1]+iparticle->Vy()/10;
289 origin[2] = origin0[2]+iparticle->Vz()/10;
290 tof = kconv*iparticle->T();
293 TParticle* mother = 0;
295 imo = iparticle->GetFirstMother();
296 mother = (TParticle *) fParticles->At(imo);
297 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
300 // --- Nucleons and photons from nucleus evaporation
301 //if(ks==-1 && (kf==2212 || kf==2112 || kf==22)) imo=-1;
303 // --- Offset added to nuclei, alpha particles, deuteron
304 // --- and triton PDG codes (according to TGeant3 PDG codes)
305 //if(ks==1000 || ks==1001) kf += 10000000;
306 if(kf>10000) kf += 10000000;
308 if(kf>10000 || ks==1000 || ks==1001) printf(" kf = %d, ks = %d imo = %d \n", kf,ks,imo);
311 Bool_t tFlag = (fTrackIt && (ks == 1));
313 /* // --- Particle NOT to be tracked:
314 // --- (1) chains from valence quark system (idhkk=99999)
315 // --- (2) quark, diquarks and gluons (idhkk=1->8,...,idhkk=21)
316 if(kf==99999 || kf==1 || kf==2 || kf==3 || kf==4 || kf==5 ||
317 kf==6 || kf==7 || kf==8 || kf==21 ||
318 kf==1103 || kf==2101 || kf==2103 || kf==2203 || kf==3101 ||
319 kf==3103 || kf==3201 || kf==3203 || kf==3303 || kf==4101 ||
320 kf==4103 || kf==4201 || kf==4203 || kf==4301 || kf==4303 ||
321 kf==4403 || kf==5101 || kf==5103 || kf==5201 || kf==5203 ||
322 kf==5301 || kf==5303 || kf==5401 || kf==5403 || kf==5503)
325 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
333 printf("\n I've put %i particles on the stack \n",nc);
336 if (jev >= fNpart || fNpart == -1) {
337 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
340 printf("\n Not breaking ### Trials: %i %i %i\n",fTrials, fNpart, jev);
344 SetHighWaterMark(nt);
348 //______________________________________________________________________________
349 void AliGenDPMjet::KeepFullEvent()
355 //______________________________________________________________________________
356 /*void AliGenDPMjet::EvaluateCrossSections()
358 // Glauber Calculation of geometrical x-section
360 Float_t xTot = 0.; // barn
361 Float_t xTotHard = 0.; // barn
362 Float_t xPart = 0.; // barn
363 Float_t xPartHard = 0.; // barn
364 Float_t sigmaHard = 0.1; // mbarn
366 Float_t bMax = fDPMjet->GetProjRadius()+fDPMjet->GetTargRadius();
367 const Float_t kdib = 0.2;
368 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
371 printf("\n Projectile Radius (fm): %f \n",fDPMjet->GetProjRadius());
372 printf("\n Target Radius (fm): %f \n",fDPMjet->GetTargRadius());
374 Float_t oldvalue= 0.;
376 Float_t* b = new Float_t[kMax];
377 Float_t* si1 = new Float_t[kMax];
378 Float_t* si2 = new Float_t[kMax];
380 for (i = 0; i < kMax; i++)
382 Float_t xb = bMin+i*kdib;
384 ov=fDPMjet->Profile(xb);
385 // ATT!->Manca la x-sec anel. nucleone-nucleone
386 Float_t gb = 2.*0.01*fDPMjet->TMath::Pi()*kdib*xb*(1.-TMath::Exp(-fDPMjet->GetXSFrac()*ov));
387 Float_t gbh = 2.*0.01*fDPMjet->TMath::Pi()*kdib*xb*sigmaHard*ov;
390 if (xb > fMinImpactParam && xb < fMaxImpactParam)
396 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
398 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
399 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
407 printf("\n Total cross section (barn): %f \n",xTot);
408 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
409 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
410 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
412 // Store result as a graph
417 fDsigmaDb = new TGraph(i, b, si1);
418 fDnDb = new TGraph(i, b, si2);
422 //______________________________________________________________________________
423 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
426 // Looks recursively if one of the daughters has been selected
428 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
432 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
433 Bool_t selected = kFALSE;
435 imin = iparticle->GetFirstDaughter();
436 imax = iparticle->GetLastDaughter();
437 for (i = imin; i <= imax; i++){
438 TParticle * jparticle = (TParticle *) fParticles->At(i);
439 Int_t ip = jparticle->GetPdgCode();
440 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
441 selected=kTRUE; break;
443 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
453 //______________________________________________________________________________
454 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
456 // Select flavor of particle
458 // 4: charm and beauty
465 Int_t ifl = TMath::Abs(pid/100);
466 if (ifl > 10) ifl/=10;
467 res = (fFlavor == ifl);
470 // This part if gamma writing is inhibited
472 res = res && (pid != kGamma && pid != kPi0);
477 //______________________________________________________________________________
478 Bool_t AliGenDPMjet::Stable(TParticle* particle)
480 // Return true for a stable particle
483 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
484 if (particle->GetStatusCode() == 1) return kTRUE;
491 //______________________________________________________________________________
492 /*void AliGenDPMjet::Boost(TClonesArray* particles)
495 // Boost cms into LHC lab frame
497 Double_t dy = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
498 (Double_t(fZTarget) * Double_t(fAProjectile)));
499 Double_t beta = TMath::TanH(dy);
500 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
501 Double_t gb = gamma * beta;
503 printf("\n Boosting particles to lab frame %f %f %f", dy, beta, gamma);
506 Int_t np = particles->GetEntriesFast();
507 for (i = 0; i < np; i++)
509 TParticle* iparticle = (TParticle*) fParticles->At(i);
511 Double_t e = iparticle->Energy();
512 Double_t px = iparticle->Px();
513 Double_t py = iparticle->Py();
514 Double_t pz = iparticle->Pz();
516 Double_t eb = gamma * e - gb * pz;
517 Double_t pzb = -gb * e + gamma * pz;
519 iparticle->SetMomentum(px, py, pzb, eb);
525 //______________________________________________________________________________
526 void AliGenDPMjet::MakeHeader()
528 // Builds the event header, to be called after each event
529 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
530 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
531 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
532 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
533 // ((AliGenDPMjetEventHeader*) header)->SetWounded(fDPMjet->GetProjWounded(),
534 // fDPMjet->GetTargWounded());
535 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
537 /*((AliGenDPMjetEventHeader*) header)->SetCollisions(fDPMjet->GetN0(),
540 fDPMjet->GetN11());*/
541 ((AliGenDPMjetEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
543 // Bookkeeping for kinematic bias
544 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
546 header->SetPrimaryVertex(fVertex);
547 gAlice->SetGenEventHeader(header);
552 //______________________________________________________________________________
553 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
555 // Assignment operator
561 //______________________________________________________________________________