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 **************************************************************************/
18 Revision 1.5 2000/09/07 16:55:40 morsch
19 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
21 Revision 1.4 2000/07/11 18:24:56 fca
22 Coding convention corrections + few minor bug fixes
24 Revision 1.3 2000/06/30 12:08:36 morsch
25 In member data: char* replaced by TString, Init takes care of resizing the strings to
26 8 characters required by Hijing.
28 Revision 1.2 2000/06/15 14:15:05 morsch
29 Add possibility for heavy flavor selection: charm and beauty.
31 Revision 1.1 2000/06/09 20:47:27 morsch
32 AliGenerator interface class to HIJING using THijing (test version)
36 #include "AliGenHijing.h"
37 #include "AliGenHijingEventHeader.h"
41 #include <TParticle.h>
44 ClassImp(AliGenHijing)
46 AliGenHijing::AliGenHijing()
52 AliGenHijing::AliGenHijing(Int_t npart)
55 // Default PbPb collisions at 5. 5 TeV
58 SetImpactParameterRange();
71 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
77 AliGenHijing::~AliGenHijing()
82 void AliGenHijing::Init()
87 fProjectile.Resize(8);
89 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
90 fAProjectile, fZProjectile, fATarget, fZTarget,
91 fMinImpactParam, fMaxImpactParam));
93 fHijing=(THijing*) fgMCEvGen;
95 fHijing->SetIHPR2(3, fTrigger);
96 fHijing->SetIHPR2(4, fQuench);
97 fHijing->SetIHPR2(6, fShadowing);
98 fHijing->SetIHPR2(12, fDecaysOff);
99 fHijing->SetIHPR2(21, fKeep);
100 fHijing->Rluset(50,0);
101 fHijing->Initialize();
105 if (fEvaluate) EvaluateCrossSections();
108 void AliGenHijing::Generate()
110 // Generate one event
112 Float_t polar[3] = {0,0,0};
113 Float_t origin[3]= {0,0,0};
114 Float_t origin0[3]= {0,0,0};
115 Float_t p[3], random[6];
118 static TClonesArray *particles;
119 // converts from mm/c to s
120 const Float_t kconv=0.001/2.999792458e8;
124 Int_t j, kf, ks, imo;
127 if(!particles) particles=new TClonesArray("TParticle",10000);
130 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
131 if(fVertexSmear==kPerEvent) {
134 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
135 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
136 // fHijing->SetMSTP(151,0);
138 } else if (fVertexSmear==kPerTrack) {
139 // fHijing->SetMSTP(151,0);
141 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
147 fHijing->GenerateEvent();
149 fHijing->ImportParticles(particles,"All");
150 Int_t np = particles->GetEntriesFast();
151 printf("\n **************************************************%d\n",np);
153 if (np == 0 ) continue;
155 Int_t * newPos = new Int_t[np];
156 for (i = 0; i<np; i++) *(newPos+i)=i;
158 for (i = 0; i<np; i++) {
159 TParticle * iparticle = (TParticle *) particles->At(i);
161 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
162 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
163 Bool_t selected = kTRUE;
164 Bool_t hasSelectedDaughters = kFALSE;
167 kf = iparticle->GetPdgCode();
168 if (!fSelectAll) selected = KinematicSelection(iparticle)&&SelectFlavor(kf);
169 if (hasDaughter && !selected) hasSelectedDaughters = DaughtersSelection(iparticle, particles);
171 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
174 if (selected || hasSelectedDaughters) {
176 ks = iparticle->GetStatusCode();
177 p[0]=iparticle->Px();
178 p[1]=iparticle->Py();
179 p[2]=iparticle->Pz();
180 origin[0]=origin0[0]+iparticle->Vx()/10;
181 origin[1]=origin0[1]+iparticle->Vy()/10;
182 origin[2]=origin0[2]+iparticle->Vz()/10;
183 tof=kconv*iparticle->T();
186 imo=iparticle->GetFirstMother();
190 // printf("\n selected iparent %d %d %d \n",i, kf, imo);
192 gAlice->SetTrack(0,imo,kf,p,origin,polar,
195 gAlice->SetTrack(fTrackIt,imo,kf,p,origin,polar,
202 printf("\n I've put %i particles on the stack \n",nc);
205 if (jev >= fNpart || fNpart == -1) {
206 fKineBias=Float_t(fNpart)/Float_t(fTrials);
207 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
212 fHijing->Rluget(50,-1);
215 Bool_t AliGenHijing::KinematicSelection(TParticle *particle)
217 // Perform kinematic selection
218 Float_t px=particle->Px();
219 Float_t py=particle->Py();
220 Float_t pz=particle->Pz();
221 Float_t e=particle->Energy();
224 // transverse momentum cut
225 Float_t pt=TMath::Sqrt(px*px+py*py);
226 if (pt > fPtMax || pt < fPtMin)
228 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
233 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
234 if (p > fPMax || p < fPMin)
236 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
242 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(pz)));
243 if (theta > fThetaMax || theta < fThetaMin)
246 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
252 Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
253 if (y > fYMax || y < fYMin)
255 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
261 Float_t phi=Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
262 if (phi > fPhiMax || phi < fPhiMin)
264 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
271 void AliGenHijing::KeepFullEvent()
276 void AliGenHijing::EvaluateCrossSections()
278 // Glauber Calculation of geometrical x-section
280 Float_t xTot=0.; // barn
281 Float_t xTotHard=0.; // barn
282 Float_t xPart=0.; // barn
283 Float_t xPartHard=0.; // barn
284 Float_t sigmaHard=0.1; // mbarn
286 Float_t bMax=fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
287 const Float_t kdib=0.2;
288 Int_t kMax=Int_t((bMax-bMin)/kdib)+1;
291 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
292 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
296 for (i=0; i<kMax; i++)
298 Float_t xb=bMin+i*kdib;
300 ov=fHijing->Profile(xb);
301 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
302 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
305 if (xb > fMinImpactParam && xb < fMaxImpactParam)
311 if ((xTot-oldvalue)/oldvalue<0.0001) break;
313 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
314 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
316 printf("\n Total cross section (barn): %f \n",xTot);
317 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
318 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
319 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
322 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
325 // Looks recursively if one of the daughters has been selected
327 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
331 Bool_t hasDaughters= (iparticle->GetFirstDaughter() >=0);
332 Bool_t selected=kFALSE;
334 imin=iparticle->GetFirstDaughter();
335 imax=iparticle->GetLastDaughter();
336 for (i=imin; i<= imax; i++){
337 TParticle * jparticle = (TParticle *) particles->At(i);
338 Int_t ip=jparticle->GetPdgCode();
339 if (KinematicSelection(jparticle)&&SelectFlavor(ip)) {selected=kTRUE; break;}
340 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
350 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
352 // Select flavor of particle
354 // 4: charm and beauty
356 if (fFlavor == 0) return kTRUE;
358 Int_t ifl=TMath::Abs(pid/100);
359 if (ifl > 10) ifl/=10;
360 return ((fFlavor==4 && (ifl==4 || ifl==5)) ||
361 (fFlavor==5 && ifl==5));
365 void AliGenHijing::MakeHeader()
367 // Builds the event header, to be called after each event
368 AliGenHijingEventHeader* header = new AliGenHijingEventHeader("Hijing");
369 // header->SetDate(date);
370 // header->SetRunNumber(run);
371 // header->SetEventNumber(event);
372 header->SetNProduced(fHijing->GetNATT());
373 header->SetImpactParameter(fHijing->GetHINT1(19));
374 header->SetTotalEnergy(fHijing->GetEATT());
375 header->SetHardScatters(fHijing->GetJATT());
376 header->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
377 header->SetCollisions(fHijing->GetN0(),
383 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
385 // Assignment operator