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()
66 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
70 //______________________________________________________________________________
71 AliGenDPMjet::AliGenDPMjet(Int_t npart)
91 // Default PbPb collisions at 5. 5 TeV
95 fTitle= "Particle Generator using DPMJET";
99 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
102 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
122 // Dummy copy constructor
126 //______________________________________________________________________________
127 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 && TMath::Abs(fZProjectile == 1)) fDPMjet->SetfIdp(1);
149 fDPMjet->SetfFCentr(fICentr);
150 fDPMjet->SetbRange(fMinImpactParam, fMaxImpactParam);
151 fDPMjet->SetPi0Decay(fPi0Decay);
152 fDPMjet->SetDecayAll(fDecayAll);
156 fDPMjet->Initialize();
160 //______________________________________________________________________________
161 void AliGenDPMjet::Generate()
163 // Generate one event
165 Float_t polar[3] = {0,0,0};
166 Float_t origin[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();
191 fDPMjet->ImportParticles(&fParticles,"All");
195 fGenImpPar = fDPMjet->GetBImpac();
197 Int_t np = fParticles.GetEntriesFast();
198 printf("\n **************************************************%d\n",np);
202 Int_t* newPos = new Int_t[np];
203 Int_t* pSelected = new Int_t[np];
205 for (i = 0; i<np; i++) {
210 // First select parent particles
212 for (i = 0; i<np; i++) {
213 TParticle *iparticle = (TParticle *) fParticles.At(i);
215 // Is this a parent particle ?
217 if (Stable(iparticle)) continue;
219 Bool_t selected = kTRUE;
220 Bool_t hasSelectedDaughters = kFALSE;
222 kf = iparticle->GetPdgCode();
223 if (kf == 92 || kf == 99999) continue;
224 ks = iparticle->GetStatusCode();
225 // No initial state partons
226 if (ks==21) continue;
228 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
232 hasSelectedDaughters = DaughtersSelection(iparticle);
235 // Put particle on the stack if it is either selected or
236 // it is the mother of at least one seleted particle
238 if (selected || hasSelectedDaughters) {
242 } // particle loop parents
244 // Now select the final state particles
247 for (i=0; i<np; i++) {
248 TParticle *iparticle = (TParticle *) fParticles.At(i);
250 // Is this a final state particle ?
252 if (!Stable(iparticle)) continue;
254 Bool_t selected = kTRUE;
255 kf = iparticle->GetPdgCode();
256 ks = iparticle->GetStatusCode();
258 // --------------------------------------------------------------------------
259 // Count spectator neutrons and protons (ks == 13, 14)
260 if(ks == 13 || ks == 14){
261 if(kf == kNeutron) fSpecn += 1;
262 if(kf == kProton) fSpecp += 1;
264 // --------------------------------------------------------------------------
267 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
268 if (!fSpectators && selected) selected = (ks == 13 || ks == 14);
271 // Put particle on the stack if selected
277 } // particle loop final state
279 // Write particles to stack
281 for (i = 0; i<np; i++) {
282 TParticle * iparticle = (TParticle *) fParticles.At(i);
283 Bool_t hasMother = (iparticle->GetFirstMother()>=0);
286 kf = iparticle->GetPdgCode();
287 ks = iparticle->GetStatusCode();
289 p[0] = iparticle->Px();
290 p[1] = iparticle->Py();
291 p[2] = iparticle->Pz();
292 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
293 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
294 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
296 tof = kconv*iparticle->T();
299 TParticle* mother = 0;
301 imo = iparticle->GetFirstMother();
302 mother = (TParticle *) fParticles.At(imo);
303 imo = (mother->GetPdgCode() != 92 && mother->GetPdgCode() != 99999) ? newPos[imo] : -1;
308 Bool_t tFlag = (fTrackIt && (ks == 1));
309 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
318 if (jev >= fNpart || fNpart == -1) {
324 SetHighWaterMark(nt);
327 //______________________________________________________________________________
328 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
331 // Looks recursively if one of the daughters has been selected
333 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
337 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
338 Bool_t selected = kFALSE;
340 imin = iparticle->GetFirstDaughter();
341 imax = iparticle->GetLastDaughter();
342 for (i = imin; i <= imax; i++){
343 TParticle * jparticle = (TParticle *) fParticles.At(i);
344 Int_t ip = jparticle->GetPdgCode();
345 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
346 selected=kTRUE; break;
348 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
358 //______________________________________________________________________________
359 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
361 // Select flavor of particle
363 // 4: charm and beauty
370 Int_t ifl = TMath::Abs(pid/100);
371 if (ifl > 10) ifl/=10;
372 res = (fFlavor == ifl);
375 // This part if gamma writing is inhibited
377 res = res && (pid != kGamma && pid != kPi0);
382 //______________________________________________________________________________
383 Bool_t AliGenDPMjet::Stable(TParticle* particle)
385 // Return true for a stable particle
388 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
389 if (particle->GetStatusCode() == 1) return kTRUE;
394 //______________________________________________________________________________
395 void AliGenDPMjet::MakeHeader()
397 // Builds the event header, to be called after each event
398 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
399 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
400 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
401 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
402 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
404 ((AliGenDPMjetEventHeader*) header)->SetProcessType(fDPMjet->GetProcessCode());
405 // Bookkeeping for kinematic bias
406 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
408 header->SetPrimaryVertex(fVertex);
409 gAlice->SetGenEventHeader(header);
413 void AliGenDPMjet::AddHeader(AliGenEventHeader* header)
415 // Add header to container or runloader
417 fContainer->AddHeader(header);
419 AliRunLoader::Instance()->GetHeader()->SetGenEventHeader(header);
424 //______________________________________________________________________________
425 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
427 // Assignment operator
432 void AliGenDPMjet::FinishRun()
434 // Print run statistics
435 fDPMjet->Dt_Dtuout();
440 //______________________________________________________________________________