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)
89 // Default PbPb collisions at 5. 5 TeV
93 fTitle= "Particle Generator using DPMJET";
97 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
100 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
119 // 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 && TMath::Abs(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};
166 // converts from mm/c to s
167 const Float_t kconv = 0.001/2.999792458e8;
173 // Set collision vertex position
174 if (fVertexSmear == kPerEvent) Vertex();
178 // Generate one event
179 // --------------------------------------------------------------------------
182 // --------------------------------------------------------------------------
183 fDPMjet->GenerateEvent();
186 fDPMjet->ImportParticles(&fParticles,"All");
190 fGenImpPar = fDPMjet->GetBImpac();
192 Int_t np = fParticles.GetEntriesFast();
193 printf("\n **************************************************%d\n",np);
197 Int_t* newPos = new Int_t[np];
198 Int_t* pSelected = new Int_t[np];
200 for (i = 0; i<np; i++) {
205 // First select parent particles
207 for (i = 0; i<np; i++) {
208 TParticle *iparticle = (TParticle *) fParticles.At(i);
210 // Is this a parent particle ?
212 if (Stable(iparticle)) continue;
214 Bool_t selected = kTRUE;
215 Bool_t hasSelectedDaughters = kFALSE;
217 kf = iparticle->GetPdgCode();
218 if (kf == 92 || kf == 99999) continue;
219 ks = iparticle->GetStatusCode();
220 // No initial state partons
221 if (ks==21) continue;
223 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
225 hasSelectedDaughters = DaughtersSelection(iparticle);
227 // Put particle on the stack if it is either selected or
228 // it is the mother of at least one seleted particle
230 if (selected || hasSelectedDaughters) {
234 } // particle loop parents
236 // Now select the final state particles
239 for (i=0; i<np; i++) {
240 TParticle *iparticle = (TParticle *) fParticles.At(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);
278 kf = iparticle->GetPdgCode();
279 ks = iparticle->GetStatusCode();
281 p[0] = iparticle->Px();
282 p[1] = iparticle->Py();
283 p[2] = iparticle->Pz();
284 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
285 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
286 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
288 tof = kconv*iparticle->T();
291 TParticle* mother = 0;
293 imo = iparticle->GetFirstMother();
294 mother = (TParticle *) fParticles.At(imo);
295 imo = (mother->GetPdgCode() != 92 && mother->GetPdgCode() != 99999) ? newPos[imo] : -1;
298 Bool_t tFlag = (fTrackIt && (ks == 1));
299 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
308 if (jev >= fNpart || fNpart == -1) {
314 SetHighWaterMark(nt);
317 //______________________________________________________________________________
318 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
321 // Looks recursively if one of the daughters has been selected
323 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
327 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
328 Bool_t selected = kFALSE;
330 imin = iparticle->GetFirstDaughter();
331 imax = iparticle->GetLastDaughter();
332 for (i = imin; i <= imax; i++){
333 TParticle * jparticle = (TParticle *) fParticles.At(i);
334 Int_t ip = jparticle->GetPdgCode();
335 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
336 selected=kTRUE; break;
338 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
348 //______________________________________________________________________________
349 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
351 // Select flavor of particle
353 // 4: charm and beauty
360 Int_t ifl = TMath::Abs(pid/100);
361 if (ifl > 10) ifl/=10;
362 res = (fFlavor == ifl);
365 // This part if gamma writing is inhibited
367 res = res && (pid != kGamma && pid != kPi0);
372 //______________________________________________________________________________
373 Bool_t AliGenDPMjet::Stable(TParticle* particle)
375 // Return true for a stable particle
378 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
379 if (particle->GetStatusCode() == 1) return kTRUE;
384 //______________________________________________________________________________
385 void AliGenDPMjet::MakeHeader()
387 // Builds the event header, to be called after each event
388 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
389 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
390 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
391 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
392 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
394 ((AliGenDPMjetEventHeader*) header)->SetProcessType(fDPMjet->GetProcessCode());
395 // Bookkeeping for kinematic bias
396 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
398 header->SetPrimaryVertex(fVertex);
399 gAlice->SetGenEventHeader(header);
403 void AliGenDPMjet::AddHeader(AliGenEventHeader* header)
405 // Add header to container or runloader
407 fContainer->AddHeader(header);
409 AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
414 //______________________________________________________________________________
415 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
417 // Assignment operator
422 void AliGenDPMjet::FinishRun()
424 // Print run statistics
425 fDPMjet->Dt_Dtuout();
430 //______________________________________________________________________________