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 **************************************************************************/
20 #include "AliGenHijing.h"
24 #include <TParticle.h>
27 ClassImp(AliGenHijing)
29 AliGenHijing::AliGenHijing()
35 AliGenHijing::AliGenHijing(Int_t npart)
38 // Default PbPb collisions at 5. 5 TeV
41 SetImpactParameterRange();
53 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
59 AliGenHijing::~AliGenHijing()
64 void AliGenHijing::Init()
67 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
68 fAProjectile, fZProjectile, fATarget, fZTarget,
69 fMinImpactParam, fMaxImpactParam));
71 fHijing=(THijing*) fgMCEvGen;
72 fHijing->Initialize();
73 fHijing->SetIHPR2(3, fTrigger);
74 fHijing->SetIHPR2(4, fQuench);
75 fHijing->SetIHPR2(6, fShadowing);
76 fHijing->SetIHPR2(12, fDecaysOff);
77 fHijing->SetIHPR2(21, fKeep);
79 if (fEvaluate) EvaluateCrossSections();
82 void AliGenHijing::Generate()
86 Float_t polar[3] = {0,0,0};
87 Float_t origin[3]= {0,0,0};
88 Float_t origin0[3]= {0,0,0};
89 Float_t p[3], random[6];
92 static TClonesArray *particles;
93 // converts from mm/c to s
94 const Float_t kconv=0.001/2.999792458e8;
100 if(!particles) particles=new TClonesArray("TParticle",10000);
103 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
104 if(fVertexSmear==perEvent) {
107 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
108 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
109 // fHijing->SetMSTP(151,0);
111 } else if (fVertexSmear==perTrack) {
112 // fHijing->SetMSTP(151,0);
114 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
120 fHijing->GenerateEvent();
122 fHijing->ImportParticles(particles,"All");
123 Int_t np = particles->GetEntriesFast();
124 printf("\n **************************************************%d\n",np);
126 if (np == 0 ) continue;
128 Int_t * newPos = new Int_t[np];
129 for (i = 0; i<np-1; i++) *(newPos+i)=i;
131 for (i = 0; i<np-1; i++) {
132 TParticle * iparticle = (TParticle *) particles->At(i);
134 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
135 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
136 Bool_t selected = kTRUE;
137 Bool_t hasSelectedDaughters = kFALSE;
139 if (!fSelectAll) selected = KinematicSelection(iparticle);
140 kf = iparticle->GetPdgCode();
141 // Int_t id1=iparticle->GetFirstDaughter();
142 // Int_t id2=iparticle->GetLastDaughter();
143 // printf("\n particle %d %d %d %d %d %d\n",i, kf, id1, id2, hasDaughter, selected);
145 if (hasDaughter && !selected) hasSelectedDaughters = DaughtersSelection(iparticle, particles);
147 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
150 if (selected || hasSelectedDaughters) {
152 ks = iparticle->GetStatusCode();
153 p[0]=iparticle->Px();
154 p[1]=iparticle->Py();
155 p[2]=iparticle->Pz();
156 origin[0]=origin0[0]+iparticle->Vx()/10;
157 origin[1]=origin0[1]+iparticle->Vy()/10;
158 origin[2]=origin0[2]+iparticle->Vz()/10;
159 tof=kconv*iparticle->T();
162 imo=iparticle->GetFirstMother();
166 // printf("\n selected iparent %d %d %d \n",i, kf, imo);
168 gAlice->SetTrack(0,imo,kf,p,origin,polar,
171 gAlice->SetTrack(fTrackIt,imo,kf,p,origin,polar,
178 printf("\n I've put %i particles on the stack \n",nc);
181 if (jev >= fNpart || fNpart == -1) {
182 fKineBias=Float_t(fNpart)/Float_t(fTrials);
183 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
190 Bool_t AliGenHijing::KinematicSelection(TParticle *particle)
192 // Perform kinematic selection
193 Float_t px=particle->Px();
194 Float_t py=particle->Py();
195 Float_t pz=particle->Pz();
196 Float_t e=particle->Energy();
199 // transverse momentum cut
200 Float_t pt=TMath::Sqrt(px*px+py*py);
201 if (pt > fPtMax || pt < fPtMin)
203 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
208 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
209 if (p > fPMax || p < fPMin)
211 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
217 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz)));
218 if (theta > fThetaMax || theta < fThetaMin)
221 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
227 Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
228 if (y > fYMax || y < fYMin)
230 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
236 Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
237 if (phi > fPhiMax || phi < fPhiMin)
239 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
246 void AliGenHijing::KeepFullEvent()
251 void AliGenHijing::EvaluateCrossSections()
253 // Glauber Calculation of geometrical x-section
255 Float_t xTot=0.; // barn
256 Float_t xTotHard=0.; // barn
257 Float_t xPart=0.; // barn
258 Float_t xPartHard=0.; // barn
259 Float_t sigmaHard=0.1; // mbarn
261 Float_t bMax=fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
262 const Float_t kdib=0.2;
263 Int_t kMax=Int_t((bMax-bMin)/kdib)+1;
266 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
267 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
271 for (i=0; i<kMax; i++)
273 Float_t xb=bMin+i*kdib;
275 ov=fHijing->Profile(xb);
276 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
277 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
280 if (xb > fMinImpactParam && xb < fMaxImpactParam)
286 if ((xTot-oldvalue)/oldvalue<0.0001) break;
288 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
289 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
291 printf("\n Total cross section (barn): %f \n",xTot);
292 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
293 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
294 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
297 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
300 // Looks recursively if one of the daughters has been selected
302 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
306 Bool_t hasDaughters= (iparticle->GetFirstDaughter() >=0);
307 Bool_t selected=kFALSE;
309 imin=iparticle->GetFirstDaughter();
310 imax=iparticle->GetLastDaughter();
311 // printf("\n Has daughters %d %d:", imin, imax);
312 for (i=imin; i<= imax; i++){
313 TParticle * jparticle = (TParticle *) particles->At(i);
314 // Int_t ip=jparticle->GetPdgCode();
315 // printf("\n consider daughter %d %d", i,ip);
317 if (KinematicSelection(jparticle)) {selected=kTRUE; break;}
318 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
329 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
331 // Assignment operator