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 <TClonesArray.h>
32 #include "AliRunLoader.h"
33 #include "AliGenDPMjet.h"
34 #include "AliGenDPMjetEventHeader.h"
36 #include "AliDpmJetRndm.h"
37 #include "AliHeader.h"
41 ClassImp(AliGenDPMjet)
43 //______________________________________________________________________________
44 AliGenDPMjet::AliGenDPMjet()
65 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
69 //______________________________________________________________________________
70 AliGenDPMjet::AliGenDPMjet(Int_t npart)
90 // Default PbPb collisions at 5. 5 TeV
93 fTitle= "Particle Generator using DPMJET";
97 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
100 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
120 // Dummy copy constructor
123 //______________________________________________________________________________
124 AliGenDPMjet::~AliGenDPMjet()
128 //______________________________________________________________________________
129 void AliGenDPMjet::Init()
133 SetMC(new TDPMjet(fProcess, fAProjectile, fZProjectile, fATarget, fZTarget,
134 fBeamEn,fEnergyCMS));
136 fDPMjet=(TDPMjet*) fMCEvGen;
138 // **** Flag to force central production
139 // fICentr=1. central production forced
140 // fICentr<0 && fICentr>-100 -> bmin = fMinImpactParam, bmax = fMaxImpactParam
141 // fICentr<-99 -> fraction of x-sec. = XSFRAC
142 // fICentr=-1. -> evaporation/fzc suppressed
143 // fICentr<-1. -> evaporation/fzc suppressed
144 if (fAProjectile == 1 && fZProjectile == 1) fDPMjet->SetfIdp(1);
146 fDPMjet->SetfFCentr(fICentr);
147 fDPMjet->SetbRange(fMinImpactParam, fMaxImpactParam);
148 fDPMjet->SetPi0Decay(fPi0Decay);
152 fDPMjet->Initialize();
156 //______________________________________________________________________________
157 void AliGenDPMjet::Generate()
159 // Generate one event
161 Float_t polar[3] = {0,0,0};
162 Float_t origin[3] = {0,0,0};
163 Float_t origin0[3] = {0,0,0};
167 // converts from mm/c to s
168 const Float_t kconv = 0.001/2.999792458e8;
174 // Set collision vertex position
175 if (fVertexSmear == kPerEvent) Vertex();
179 // Generate one event
180 // --------------------------------------------------------------------------
183 // --------------------------------------------------------------------------
184 fDPMjet->GenerateEvent();
187 fDPMjet->ImportParticles(&fParticles,"All");
191 fGenImpPar = fDPMjet->GetBImpac();
193 Int_t np = fParticles.GetEntriesFast();
194 printf("\n **************************************************%d\n",np);
198 Int_t* newPos = new Int_t[np];
199 Int_t* pSelected = new Int_t[np];
201 for (i = 0; i<np; i++) {
208 fVertex[0] = origin0[0];
209 fVertex[1] = origin0[1];
210 fVertex[2] = origin0[2];
212 // First select parent particles
214 for (i = 0; i<np; i++) {
215 TParticle *iparticle = (TParticle *) fParticles.At(i);
217 // Is this a parent particle ?
219 if (Stable(iparticle)) continue;
221 Bool_t selected = kTRUE;
222 Bool_t hasSelectedDaughters = kFALSE;
224 kf = iparticle->GetPdgCode();
225 if (kf == 92) continue;
226 ks = iparticle->GetStatusCode();
227 // No initial state partons
228 if (ks==21) continue;
230 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
232 hasSelectedDaughters = DaughtersSelection(iparticle);
234 // Put particle on the stack if it is either selected or
235 // it is the mother of at least one seleted particle
237 if (selected || hasSelectedDaughters) {
241 } // particle loop parents
243 // Now select the final state particles
246 for (i=0; i<np; i++) {
247 TParticle *iparticle = (TParticle *) fParticles.At(i);
249 // Is this a final state particle ?
251 if (!Stable(iparticle)) continue;
253 Bool_t selected = kTRUE;
254 kf = iparticle->GetPdgCode();
255 ks = iparticle->GetStatusCode();
257 // --------------------------------------------------------------------------
258 // Count spectator neutrons and protons (ks == 13, 14)
259 if(ks == 13 || ks == 14){
260 if(kf == kNeutron) fSpecn += 1;
261 if(kf == kProton) fSpecp += 1;
263 // --------------------------------------------------------------------------
266 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
267 if (!fSpectators && selected) selected = (ks == 13 || ks == 14);
270 // Put particle on the stack if selected
276 } // particle loop final state
278 // Write particles to stack
280 for (i = 0; i<np; i++) {
281 TParticle * iparticle = (TParticle *) fParticles.At(i);
282 Bool_t hasMother = (iparticle->GetFirstMother()>=0);
285 kf = iparticle->GetPdgCode();
286 ks = iparticle->GetStatusCode();
288 p[0] = iparticle->Px();
289 p[1] = iparticle->Py();
290 p[2] = iparticle->Pz();
291 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
292 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
293 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
295 tof = kconv*iparticle->T();
298 TParticle* mother = 0;
300 imo = iparticle->GetFirstMother();
301 mother = (TParticle *) fParticles.At(imo);
302 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
305 Bool_t tFlag = (fTrackIt && (ks == 1));
307 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
316 if (jev >= fNpart || fNpart == -1) {
322 SetHighWaterMark(nt);
325 //______________________________________________________________________________
326 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
329 // Looks recursively if one of the daughters has been selected
331 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
335 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
336 Bool_t selected = kFALSE;
338 imin = iparticle->GetFirstDaughter();
339 imax = iparticle->GetLastDaughter();
340 for (i = imin; i <= imax; i++){
341 TParticle * jparticle = (TParticle *) fParticles.At(i);
342 Int_t ip = jparticle->GetPdgCode();
343 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
344 selected=kTRUE; break;
346 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
356 //______________________________________________________________________________
357 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
359 // Select flavor of particle
361 // 4: charm and beauty
368 Int_t ifl = TMath::Abs(pid/100);
369 if (ifl > 10) ifl/=10;
370 res = (fFlavor == ifl);
373 // This part if gamma writing is inhibited
375 res = res && (pid != kGamma && pid != kPi0);
380 //______________________________________________________________________________
381 Bool_t AliGenDPMjet::Stable(TParticle* particle)
383 // Return true for a stable particle
386 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
387 if (particle->GetStatusCode() == 1) return kTRUE;
392 //______________________________________________________________________________
393 void AliGenDPMjet::MakeHeader()
395 // Builds the event header, to be called after each event
396 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
397 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
398 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
399 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
400 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
402 ((AliGenDPMjetEventHeader*) header)->SetProcessType(fDPMjet->GetProcessCode());
403 // Bookkeeping for kinematic bias
404 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
406 header->SetPrimaryVertex(fVertex);
407 gAlice->SetGenEventHeader(header);
411 void AliGenDPMjet::AddHeader(AliGenEventHeader* header)
413 // Add header to container or runloader
415 fContainer->AddHeader(header);
417 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
422 //______________________________________________________________________________
423 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
425 // Assignment operator
431 //______________________________________________________________________________