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()
63 fTriggerMultiplicity(0),
64 fTriggerMultiplicityEta(0),
65 fTriggerMultiplicityPtMin(0)
69 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
73 //______________________________________________________________________________
74 AliGenDPMjet::AliGenDPMjet(Int_t npart)
93 fTriggerMultiplicity(0),
94 fTriggerMultiplicityEta(0),
95 fTriggerMultiplicityPtMin(0)
97 // Default PbPb collisions at 5. 5 TeV
101 fTitle= "Particle Generator using DPMJET";
105 AliDpmJetRndm::SetDpmJetRandom(GetRandom());
108 AliGenDPMjet::AliGenDPMjet(const AliGenDPMjet &/*Dpmjet*/)
127 fTriggerMultiplicity(0),
128 fTriggerMultiplicityEta(0),
129 fTriggerMultiplicityPtMin(0)
131 // Dummy copy constructor
135 //______________________________________________________________________________
136 AliGenDPMjet::~AliGenDPMjet()
140 //______________________________________________________________________________
141 void AliGenDPMjet::Init()
145 SetMC(new TDPMjet(fProcess, fAProjectile, fZProjectile, fATarget, fZTarget,
146 fBeamEn,fEnergyCMS));
148 fDPMjet=(TDPMjet*) fMCEvGen;
150 // **** Flag to force central production
151 // fICentr=1. central production forced
152 // fICentr<0 && fICentr>-100 -> bmin = fMinImpactParam, bmax = fMaxImpactParam
153 // fICentr<-99 -> fraction of x-sec. = XSFRAC
154 // fICentr=-1. -> evaporation/fzc suppressed
155 // fICentr<-1. -> evaporation/fzc suppressed
156 if (fAProjectile == 1 && TMath::Abs(fZProjectile == 1)) fDPMjet->SetfIdp(1);
158 fDPMjet->SetfFCentr(fICentr);
159 fDPMjet->SetbRange(fMinImpactParam, fMaxImpactParam);
160 fDPMjet->SetPi0Decay(fPi0Decay);
161 fDPMjet->SetDecayAll(fDecayAll);
165 fDPMjet->Initialize();
169 //______________________________________________________________________________
170 void AliGenDPMjet::Generate()
172 // Generate one event
174 Float_t polar[3] = {0,0,0};
175 Float_t origin[3] = {0,0,0};
179 // converts from mm/c to s
180 const Float_t kconv = 0.001/2.999792458e8;
186 // Set collision vertex position
187 if (fVertexSmear == kPerEvent) Vertex();
191 // Generate one event
192 // --------------------------------------------------------------------------
195 // --------------------------------------------------------------------------
196 fDPMjet->GenerateEvent();
200 fDPMjet->ImportParticles(&fParticles,"All");
204 fGenImpPar = fDPMjet->GetBImpac();
206 Int_t np = fParticles.GetEntriesFast();
208 // Multiplicity Trigger
209 if (fTriggerMultiplicity > 0) {
210 Int_t multiplicity = 0;
211 for (Int_t i = 0; i < np; i++) {
212 TParticle * iparticle = (TParticle *) fParticles.At(i);
214 Int_t statusCode = iparticle->GetStatusCode();
216 // Initial state particle
220 if (fTriggerMultiplicityEta > 0 && TMath::Abs(iparticle->Eta()) > fTriggerMultiplicityEta)
223 if (iparticle->Pt() < fTriggerMultiplicityPtMin)
226 TParticlePDG* pdgPart = iparticle->GetPDG();
227 if (pdgPart && pdgPart->Charge() == 0)
233 if (multiplicity < fTriggerMultiplicity) continue;
234 Printf("Triggered on event with multiplicity of %d >= %d", multiplicity, fTriggerMultiplicity);
238 if (np == 0) continue;
241 Int_t* newPos = new Int_t[np];
242 Int_t* pSelected = new Int_t[np];
244 for (i = 0; i<np; i++) {
249 // First select parent particles
251 for (i = 0; i<np; i++) {
252 TParticle *iparticle = (TParticle *) fParticles.At(i);
254 // Is this a parent particle ?
256 if (Stable(iparticle)) continue;
258 Bool_t selected = kTRUE;
259 Bool_t hasSelectedDaughters = kFALSE;
261 kf = iparticle->GetPdgCode();
262 if (kf == 92 || kf == 99999) continue;
263 ks = iparticle->GetStatusCode();
264 // No initial state partons
265 if (ks==21) continue;
267 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
271 hasSelectedDaughters = DaughtersSelection(iparticle);
274 // Put particle on the stack if it is either selected or
275 // it is the mother of at least one seleted particle
277 if (selected || hasSelectedDaughters) {
281 } // particle loop parents
283 // Now select the final state particles
286 for (i=0; i<np; i++) {
287 TParticle *iparticle = (TParticle *) fParticles.At(i);
289 // Is this a final state particle ?
291 if (!Stable(iparticle)) continue;
293 Bool_t selected = kTRUE;
294 kf = iparticle->GetPdgCode();
295 ks = iparticle->GetStatusCode();
297 // --------------------------------------------------------------------------
298 // Count spectator neutrons and protons (ks == 13, 14)
299 if(ks == 13 || ks == 14){
300 if(kf == kNeutron) fSpecn += 1;
301 if(kf == kProton) fSpecp += 1;
303 // --------------------------------------------------------------------------
306 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
307 if (!fSpectators && selected) selected = (ks == 13 || ks == 14);
310 // Put particle on the stack if selected
316 } // particle loop final state
318 // Write particles to stack
320 for (i = 0; i<np; i++) {
321 TParticle * iparticle = (TParticle *) fParticles.At(i);
322 Bool_t hasMother = (iparticle->GetFirstMother()>=0);
325 kf = iparticle->GetPdgCode();
326 ks = iparticle->GetStatusCode();
328 p[0] = iparticle->Px();
329 p[1] = iparticle->Py();
330 p[2] = iparticle->Pz();
331 origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm]
332 origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm]
333 origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm]
335 tof = kconv*iparticle->T();
338 TParticle* mother = 0;
340 imo = iparticle->GetFirstMother();
341 mother = (TParticle *) fParticles.At(imo);
342 imo = (mother->GetPdgCode() != 92 && mother->GetPdgCode() != 99999) ? newPos[imo] : -1;
347 Bool_t tFlag = (fTrackIt && (ks == 1));
348 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
357 if (jev >= fNpart || fNpart == -1) {
363 SetHighWaterMark(nt);
366 //______________________________________________________________________________
367 Bool_t AliGenDPMjet::DaughtersSelection(TParticle* iparticle)
370 // Looks recursively if one of the daughters has been selected
372 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
376 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
377 Bool_t selected = kFALSE;
379 imin = iparticle->GetFirstDaughter();
380 imax = iparticle->GetLastDaughter();
381 for (i = imin; i <= imax; i++){
382 TParticle * jparticle = (TParticle *) fParticles.At(i);
383 Int_t ip = jparticle->GetPdgCode();
384 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
385 selected=kTRUE; break;
387 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
397 //______________________________________________________________________________
398 Bool_t AliGenDPMjet::SelectFlavor(Int_t pid)
400 // Select flavor of particle
402 // 4: charm and beauty
409 Int_t ifl = TMath::Abs(pid/100);
410 if (ifl > 10) ifl/=10;
411 res = (fFlavor == ifl);
414 // This part if gamma writing is inhibited
416 res = res && (pid != kGamma && pid != kPi0);
421 //______________________________________________________________________________
422 Bool_t AliGenDPMjet::Stable(TParticle* particle)
424 // Return true for a stable particle
427 // if (particle->GetFirstDaughter() < 0 ) return kTRUE;
428 if (particle->GetStatusCode() == 1) return kTRUE;
433 //______________________________________________________________________________
434 void AliGenDPMjet::MakeHeader()
436 // Builds the event header, to be called after each event
437 AliGenEventHeader* header = new AliGenDPMjetEventHeader("DPMJET");
438 ((AliGenDPMjetEventHeader*) header)->SetNProduced(fDPMjet->GetNumStablePc());
439 ((AliGenDPMjetEventHeader*) header)->SetImpactParameter(fDPMjet->GetBImpac());
440 ((AliGenDPMjetEventHeader*) header)->SetTotalEnergy(fDPMjet->GetTotEnergy());
441 ((AliGenDPMjetEventHeader*) header)->SetParticipants(fDPMjet->GetfIp(),
443 ((AliGenDPMjetEventHeader*) header)->SetProcessType(fDPMjet->GetProcessCode());
444 // Bookkeeping for kinematic bias
445 ((AliGenDPMjetEventHeader*) header)->SetTrials(fTrials);
447 header->SetPrimaryVertex(fVertex);
448 gAlice->SetGenEventHeader(header);
452 void AliGenDPMjet::AddHeader(AliGenEventHeader* header)
454 // Add header to container or runloader
456 fContainer->AddHeader(header);
458 AliRunLoader::Instance()->GetHeader()->SetGenEventHeader(header);
463 //______________________________________________________________________________
464 AliGenDPMjet& AliGenDPMjet::operator=(const AliGenDPMjet& /*rhs*/)
466 // Assignment operator
471 void AliGenDPMjet::FinishRun()
473 // Print run statistics
474 fDPMjet->Dt_Dtuout();
479 //______________________________________________________________________________