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>
31 #include "AliRunLoader.h"
32 #include "AliGenDPMjet.h"
33 #include "AliGenDPMjetEventHeader.h"
35 #include "AliDpmJetRndm.h"
36 #include "AliHeader.h"
40 ClassImp(AliGenDPMjet)
42 //______________________________________________________________________________
43 AliGenDPMjet::AliGenDPMjet()
65 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
69 //______________________________________________________________________________
70 AliGenDPMjet::AliGenDPMjet(Int_t npart)
84 fParticles(new TClonesArray("TParticle",10000)),
91 // Default PbPb collisions at 5. 5 TeV
94 fTitle= "Particle Generator using DPMJET";
98 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
101 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
122 // Dummy copy constructor
125 //______________________________________________________________________________
126 AliGenDPMjet::~AliGenDPMjet()
131 //______________________________________________________________________________
132 void AliGenDPMjet::Init()
136 SetMC(new TDPMjet(fProcess, fAProjectile, fZProjectile, fATarget, fZTarget,
137 fBeamEn,fEnergyCMS));
139 fDPMjet=(TDPMjet*) fMCEvGen;
141 // **** Flag to force central production
142 // fICentr=1. central production forced
143 // fICentr<0 && fICentr>-100 -> bmin = fMinImpactParam, bmax = fMaxImpactParam
144 // fICentr<-99 -> fraction of x-sec. = XSFRAC
145 // fICentr=-1. -> evaporation/fzc suppressed
146 // fICentr<-1. -> evaporation/fzc suppressed
147 if (fAProjectile == 1 && fZProjectile == 1) fDPMjet->SetfIdp(1);
149 fDPMjet->SetfFCentr(fICentr);
150 fDPMjet->SetbRange(fMinImpactParam, fMaxImpactParam);
151 fDPMjet->SetPi0Decay(fPi0Decay);
155 fDPMjet->Initialize();
159 //______________________________________________________________________________
160 void AliGenDPMjet::Generate()
162 // Generate one event
164 Float_t polar[3] = {0,0,0};
165 Float_t origin[3] = {0,0,0};
166 Float_t origin0[3] = {0,0,0};
170 // converts from mm/c to s
171 const Float_t kconv = 0.001/2.999792458e8;
177 // Set collision vertex position
178 if (fVertexSmear == kPerEvent) Vertex();
182 // Generate one event
183 // --------------------------------------------------------------------------
186 // --------------------------------------------------------------------------
187 fDPMjet->GenerateEvent();
190 fDPMjet->ImportParticles(fParticles,"All");
194 fGenImpPar = fDPMjet->GetBImpac();
196 Int_t np = fParticles->GetEntriesFast();
197 printf("\n **************************************************%d\n",np);
201 Int_t* newPos = new Int_t[np];
202 Int_t* pSelected = new Int_t[np];
204 for (i = 0; i<np; i++) {
211 fVertex[0] = origin0[0];
212 fVertex[1] = origin0[1];
213 fVertex[2] = origin0[2];
215 // First select parent particles
217 for (i = 0; i<np; i++) {
218 TParticle *iparticle = (TParticle *) fParticles->At(i);
220 // Is this a parent particle ?
222 if (Stable(iparticle)) continue;
224 Bool_t selected = kTRUE;
225 Bool_t hasSelectedDaughters = kFALSE;
227 kf = iparticle->GetPdgCode();
228 if (kf == 92) continue;
229 ks = iparticle->GetStatusCode();
230 // No initial state partons
231 if (ks==21) continue;
233 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
235 hasSelectedDaughters = DaughtersSelection(iparticle);
237 // Put particle on the stack if it is either selected or
238 // it is the mother of at least one seleted particle
240 if (selected || hasSelectedDaughters) {
244 } // particle loop parents
246 // Now select the final state particles
249 for (i=0; i<np; i++) {
250 TParticle *iparticle = (TParticle *) fParticles->At(i);
252 // Is this a final state particle ?
254 if (!Stable(iparticle)) continue;
256 Bool_t selected = kTRUE;
257 kf = iparticle->GetPdgCode();
258 ks = iparticle->GetStatusCode();
260 // --------------------------------------------------------------------------
261 // Count spectator neutrons and protons (ks == 13, 14)
262 if(ks == 13 || ks == 14){
263 if(kf == kNeutron) fSpecn += 1;
264 if(kf == kProton) fSpecp += 1;
266 // --------------------------------------------------------------------------
269 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
270 if (!fSpectators && selected) selected = (ks == 13 || ks == 14);
273 // Put particle on the stack if selected
279 } // particle loop final state
281 // Write particles to stack
283 for (i = 0; i<np; i++) {
284 TParticle * iparticle = (TParticle *) fParticles->At(i);
285 Bool_t hasMother = (iparticle->GetFirstMother()>=0);
288 kf = iparticle->GetPdgCode();
289 ks = iparticle->GetStatusCode();
291 p[0] = iparticle->Px();
292 p[1] = iparticle->Py();
293 p[2] = iparticle->Pz();
294 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
295 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
296 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
298 tof = kconv*iparticle->T();
301 TParticle* mother = 0;
303 imo = iparticle->GetFirstMother();
304 mother = (TParticle *) fParticles->At(imo);
305 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
308 Bool_t tFlag = (fTrackIt && (ks == 1));
310 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
319 if (jev >= fNpart || fNpart == -1) {
325 SetHighWaterMark(nt);
328 //______________________________________________________________________________
329 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
332 // Looks recursively if one of the daughters has been selected
334 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
338 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
339 Bool_t selected = kFALSE;
341 imin = iparticle->GetFirstDaughter();
342 imax = iparticle->GetLastDaughter();
343 for (i = imin; i <= imax; i++){
344 TParticle * jparticle = (TParticle *) fParticles->At(i);
345 Int_t ip = jparticle->GetPdgCode();
346 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
347 selected=kTRUE; break;
349 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
359 //______________________________________________________________________________
360 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
362 // Select flavor of particle
364 // 4: charm and beauty
371 Int_t ifl = TMath::Abs(pid/100);
372 if (ifl > 10) ifl/=10;
373 res = (fFlavor == ifl);
376 // This part if gamma writing is inhibited
378 res = res && (pid != kGamma && pid != kPi0);
383 //______________________________________________________________________________
384 Bool_t AliGenDPMjet::Stable(TParticle* particle)
386 // Return true for a stable particle
389 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
390 if (particle->GetStatusCode() == 1) return kTRUE;
395 //______________________________________________________________________________
396 void AliGenDPMjet::MakeHeader()
398 // Builds the event header, to be called after each event
399 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
400 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
401 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
402 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
403 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
405 ((AliGenDPMjetEventHeader*) header)->SetProcessType(fDPMjet->GetProcessCode());
406 // Bookkeeping for kinematic bias
407 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
409 header->SetPrimaryVertex(fVertex);
410 gAlice->SetGenEventHeader(header);
414 void AliGenDPMjet::AddHeader(AliGenEventHeader* header)
416 // Add header to container or runloader
418 fContainer->AddHeader(header);
420 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
425 //______________________________________________________________________________
426 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
428 // Assignment operator
434 //______________________________________________________________________________