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";
65 SetImpactParameterRange();
76 fParticles = new TClonesArray("TParticle",10000);
78 // Set random number generator
81 AliPythia::Instance();
82 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
85 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
90 //______________________________________________________________________________
91 AliGenDPMjet::~AliGenDPMjet()
98 //______________________________________________________________________________
99 void AliGenDPMjet::Init()
103 SetMC(new TDPMjet(fProcess, fAProjectile, fZProjectile, fATarget, fZTarget,
104 fBeamEn,fEnergyCMS));
106 fDPMjet=(TDPMjet*) fMCEvGen;
108 // **** Flag to force central production
109 // fICentr=1. central production forced
110 // fICentr<0 && fICentr>-100 -> bmin = fMinImpactParam, bmax = fMaxImpactParam
111 // fICentr<-99 -> fraction of x-sec. = XSFRAC
112 // fICentr=-1. -> evaporation/fzc suppressed
113 // fICentr<-1. -> evaporation/fzc suppressed
114 if (fAProjectile == 1 && fZProjectile == 1) fDPMjet->SetfIdp(1);
116 fDPMjet->SetfFCentr(fICentr);
117 fDPMjet->SetbRange(fMinImpactParam, fMaxImpactParam);
122 fDPMjet->Initialize();
126 //______________________________________________________________________________
127 void AliGenDPMjet::Generate()
129 // Generate one event
131 Float_t polar[3] = {0,0,0};
132 Float_t origin[3] = {0,0,0};
133 Float_t origin0[3] = {0,0,0};
137 // converts from mm/c to s
138 const Float_t kconv = 0.001/2.999792458e8;
144 // Set collision vertex position
145 if (fVertexSmear == kPerEvent) Vertex();
149 // Generate one event
150 // --------------------------------------------------------------------------
153 // --------------------------------------------------------------------------
154 fDPMjet->GenerateEvent();
157 fDPMjet->ImportParticles(fParticles,"All");
161 fGenImpPar = fDPMjet->GetBImpac();
163 Int_t np = fParticles->GetEntriesFast();
164 printf("\n **************************************************%d\n",np);
168 Int_t* newPos = new Int_t[np];
169 Int_t* pSelected = new Int_t[np];
171 for (i = 0; i<np; i++) {
178 fVertex[0] = origin0[0];
179 fVertex[1] = origin0[1];
180 fVertex[2] = origin0[2];
182 // First select parent particles
184 for (i = 0; i<np; i++) {
185 TParticle *iparticle = (TParticle *) fParticles->At(i);
187 // Is this a parent particle ?
189 if (Stable(iparticle)) continue;
191 Bool_t selected = kTRUE;
192 Bool_t hasSelectedDaughters = kFALSE;
194 kf = iparticle->GetPdgCode();
195 if (kf == 92) continue;
196 ks = iparticle->GetStatusCode();
197 // No initial state partons
198 if (ks==21) continue;
200 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
202 hasSelectedDaughters = DaughtersSelection(iparticle);
204 // Put particle on the stack if it is either selected or
205 // it is the mother of at least one seleted particle
207 if (selected || hasSelectedDaughters) {
211 } // particle loop parents
213 // Now select the final state particles
216 for (i=0; i<np; i++) {
217 TParticle *iparticle = (TParticle *) fParticles->At(i);
219 // Is this a final state particle ?
221 if (!Stable(iparticle)) continue;
223 Bool_t selected = kTRUE;
224 kf = iparticle->GetPdgCode();
225 ks = iparticle->GetStatusCode();
227 // --------------------------------------------------------------------------
228 // Count spectator neutrons and protons (ks == 13, 14)
229 if(ks == 13 || ks == 14){
230 if(kf == kNeutron) fSpecn += 1;
231 if(kf == kProton) fSpecp += 1;
233 // --------------------------------------------------------------------------
236 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
237 if (!fSpectators && selected) selected = (ks == 13 || ks == 14);
240 // Put particle on the stack if selected
246 } // particle loop final state
248 // Write particles to stack
250 for (i = 0; i<np; i++) {
251 TParticle * iparticle = (TParticle *) fParticles->At(i);
252 Bool_t hasMother = (iparticle->GetFirstMother()>=0);
255 kf = iparticle->GetPdgCode();
256 ks = iparticle->GetStatusCode();
258 p[0] = iparticle->Px();
259 p[1] = iparticle->Py();
260 p[2] = iparticle->Pz();
261 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
262 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
263 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
265 tof = kconv*iparticle->T();
268 TParticle* mother = 0;
270 imo = iparticle->GetFirstMother();
271 mother = (TParticle *) fParticles->At(imo);
272 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
275 Bool_t tFlag = (fTrackIt && (ks == 1));
277 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
286 if (jev >= fNpart || fNpart == -1) {
292 SetHighWaterMark(nt);
296 //______________________________________________________________________________
297 void AliGenDPMjet::KeepFullEvent()
303 //______________________________________________________________________________
304 /*void AliGenDPMjet::EvaluateCrossSections()
306 // Glauber Calculation of geometrical x-section
308 Float_t xTot = 0.; // barn
309 Float_t xTotHard = 0.; // barn
310 Float_t xPart = 0.; // barn
311 Float_t xPartHard = 0.; // barn
312 Float_t sigmaHard = 0.1; // mbarn
314 Float_t bMax = fDPMjet->GetProjRadius()+fDPMjet->GetTargRadius();
315 const Float_t kdib = 0.2;
316 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
319 printf("\n Projectile Radius (fm): %f \n",fDPMjet->GetProjRadius());
320 printf("\n Target Radius (fm): %f \n",fDPMjet->GetTargRadius());
322 Float_t oldvalue= 0.;
324 Float_t* b = new Float_t[kMax];
325 Float_t* si1 = new Float_t[kMax];
326 Float_t* si2 = new Float_t[kMax];
328 for (i = 0; i < kMax; i++)
330 Float_t xb = bMin+i*kdib;
332 ov=fDPMjet->Profile(xb);
333 // ATT!->Manca la x-sec anel. nucleone-nucleone
334 Float_t gb = 2.*0.01*fDPMjet->TMath::Pi()*kdib*xb*(1.-TMath::Exp(-fDPMjet->GetXSFrac()*ov));
335 Float_t gbh = 2.*0.01*fDPMjet->TMath::Pi()*kdib*xb*sigmaHard*ov;
338 if (xb > fMinImpactParam && xb < fMaxImpactParam)
344 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
346 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
347 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
355 printf("\n Total cross section (barn): %f \n",xTot);
356 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
357 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
358 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
360 // Store result as a graph
365 fDsigmaDb = new TGraph(i, b, si1);
366 fDnDb = new TGraph(i, b, si2);
370 //______________________________________________________________________________
371 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
374 // Looks recursively if one of the daughters has been selected
376 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
380 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
381 Bool_t selected = kFALSE;
383 imin = iparticle->GetFirstDaughter();
384 imax = iparticle->GetLastDaughter();
385 for (i = imin; i <= imax; i++){
386 TParticle * jparticle = (TParticle *) fParticles->At(i);
387 Int_t ip = jparticle->GetPdgCode();
388 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
389 selected=kTRUE; break;
391 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
401 //______________________________________________________________________________
402 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
404 // Select flavor of particle
406 // 4: charm and beauty
413 Int_t ifl = TMath::Abs(pid/100);
414 if (ifl > 10) ifl/=10;
415 res = (fFlavor == ifl);
418 // This part if gamma writing is inhibited
420 res = res && (pid != kGamma && pid != kPi0);
425 //______________________________________________________________________________
426 Bool_t AliGenDPMjet::Stable(TParticle* particle)
428 // Return true for a stable particle
431 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
432 if (particle->GetStatusCode() == 1) return kTRUE;
437 //______________________________________________________________________________
438 void AliGenDPMjet::MakeHeader()
440 // Builds the event header, to be called after each event
441 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
442 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
443 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
444 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
445 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
448 // Bookkeeping for kinematic bias
449 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
451 header->SetPrimaryVertex(fVertex);
452 gAlice->SetGenEventHeader(header);
457 //______________________________________________________________________________
458 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
460 // Assignment operator
466 //______________________________________________________________________________