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.20 2001/02/14 15:50:40 hristov
19 The last particle in event marked using SetHighWaterMark
21 Revision 1.19 2000/12/21 16:24:06 morsch
22 Coding convention clean-up
24 Revision 1.18 2000/12/06 17:46:30 morsch
25 Avoid random numbers 1 and 0.
27 Revision 1.17 2000/12/04 11:22:03 morsch
28 Init of sRandom as in 1.15
30 Revision 1.16 2000/12/02 11:41:39 morsch
31 Use SetRandom() to initialize random number generator in constructor.
33 Revision 1.15 2000/11/30 20:29:02 morsch
34 Initialise static variable sRandom in constructor: sRandom = fRandom;
36 Revision 1.14 2000/11/30 07:12:50 alibrary
37 Introducing new Rndm and QA classes
39 Revision 1.13 2000/11/09 17:40:27 morsch
40 Possibility to select/unselect spectator protons and neutrons.
41 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
43 Revision 1.12 2000/10/20 13:38:38 morsch
44 Debug printouts commented.
46 Revision 1.11 2000/10/20 13:22:26 morsch
47 - skip particle type 92 (string)
48 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
51 Revision 1.10 2000/10/17 15:10:20 morsch
52 Write first all the parent particles to the stack and then the final state particles.
54 Revision 1.9 2000/10/17 13:38:59 morsch
55 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
57 Revision 1.8 2000/10/17 12:46:31 morsch
58 Protect EvaluateCrossSections() against division by zero.
60 Revision 1.7 2000/10/02 21:28:06 fca
61 Removal of useless dependecies via forward declarations
63 Revision 1.6 2000/09/11 13:23:37 morsch
64 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
65 luget_hijing and luset_hijing.
67 Revision 1.5 2000/09/07 16:55:40 morsch
68 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
70 Revision 1.4 2000/07/11 18:24:56 fca
71 Coding convention corrections + few minor bug fixes
73 Revision 1.3 2000/06/30 12:08:36 morsch
74 In member data: char* replaced by TString, Init takes care of resizing the strings to
75 8 characters required by Hijing.
77 Revision 1.2 2000/06/15 14:15:05 morsch
78 Add possibility for heavy flavor selection: charm and beauty.
80 Revision 1.1 2000/06/09 20:47:27 morsch
81 AliGenerator interface class to HIJING using THijing (test version)
87 // Generator using HIJING as an external generator
88 // The main HIJING options are accessable for the user through this interface.
89 // Uses the THijing implementation of TGenerator.
91 // andreas.morsch@cern.ch
93 #include "AliGenHijing.h"
94 #include "AliGenHijingEventHeader.h"
98 #include <TParticle.h>
102 ClassImp(AliGenHijing)
104 AliGenHijing::AliGenHijing()
110 AliGenHijing::AliGenHijing(Int_t npart)
113 // Default PbPb collisions at 5. 5 TeV
116 SetImpactParameterRange();
129 // Set random number generator
133 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
139 AliGenHijing::~AliGenHijing()
144 void AliGenHijing::Init()
149 fProjectile.Resize(8);
151 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
152 fAProjectile, fZProjectile, fATarget, fZTarget,
153 fMinImpactParam, fMaxImpactParam));
155 fHijing=(THijing*) fgMCEvGen;
157 fHijing->SetIHPR2(3, fTrigger);
158 fHijing->SetIHPR2(4, fQuench);
159 fHijing->SetIHPR2(6, fShadowing);
160 fHijing->SetIHPR2(12, fDecaysOff);
161 fHijing->SetIHPR2(21, fKeep);
162 fHijing->Rluset(50,0);
163 fHijing->Initialize();
167 if (fEvaluate) EvaluateCrossSections();
170 // Initialize random generator
173 void AliGenHijing::Generate()
175 // Generate one event
177 Float_t polar[3] = {0,0,0};
178 Float_t origin[3]= {0,0,0};
179 Float_t origin0[3]= {0,0,0};
180 Float_t p[3], random[6];
183 static TClonesArray *particles;
184 // converts from mm/c to s
185 const Float_t kconv=0.001/2.999792458e8;
189 Int_t j, kf, ks, imo;
192 if(!particles) particles=new TClonesArray("TParticle",10000);
195 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
196 if(fVertexSmear==kPerEvent) {
199 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
200 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
201 // fHijing->SetMSTP(151,0);
203 } else if (fVertexSmear==kPerTrack) {
204 // fHijing->SetMSTP(151,0);
206 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
212 fHijing->GenerateEvent();
214 fHijing->ImportParticles(particles,"All");
215 Int_t np = particles->GetEntriesFast();
216 printf("\n **************************************************%d\n",np);
218 if (np == 0 ) continue;
220 Int_t * newPos = new Int_t[np];
222 for (i = 0; i<np; i++) *(newPos+i)=i;
224 // First write parent particles
227 for (i = 0; i<np; i++) {
228 TParticle * iparticle = (TParticle *) particles->At(i);
229 // Is this a parent particle ?
230 if (Stable(iparticle)) continue;
232 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
233 Bool_t selected = kTRUE;
234 Bool_t hasSelectedDaughters = kFALSE;
237 kf = iparticle->GetPdgCode();
238 ks = iparticle->GetStatusCode();
239 if (kf == 92) continue;
241 if (!fSelectAll) selected = KinematicSelection(iparticle)&&SelectFlavor(kf);
242 hasSelectedDaughters = DaughtersSelection(iparticle, particles);
244 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
246 if (selected || hasSelectedDaughters) {
248 p[0]=iparticle->Px();
249 p[1]=iparticle->Py();
250 p[2]=iparticle->Pz();
251 origin[0]=origin0[0]+iparticle->Vx()/10;
252 origin[1]=origin0[1]+iparticle->Vy()/10;
253 origin[2]=origin0[2]+iparticle->Vz()/10;
254 tof=kconv*iparticle->T();
257 imo=iparticle->GetFirstMother();
258 TParticle* mother= (TParticle *) particles->At(imo);
259 imo = (mother->GetPdgCode() != 92) ? imo=*(newPos+imo) : -1;
261 // Put particle on the stack ...
262 // printf("\n set track mother: %d %d %d %d %d %d ",i,imo, kf, nt+1, selected, hasSelectedDaughters);
264 gAlice->SetTrack(0,imo,kf,p,origin,polar,
266 // ... and keep it there
267 gAlice->KeepTrack(nt);
271 } // particle loop parents
273 // Now write the final state particles
276 for (i = 0; i<np; i++) {
277 TParticle * iparticle = (TParticle *) particles->At(i);
278 // Is this a final state particle ?
279 if (!Stable(iparticle)) continue;
281 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
282 Bool_t selected = kTRUE;
283 kf = iparticle->GetPdgCode();
284 ks = iparticle->GetStatusCode();
286 selected = KinematicSelection(iparticle)&&SelectFlavor(kf);
287 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
291 // Put particle on the stack if selected
295 p[0]=iparticle->Px();
296 p[1]=iparticle->Py();
297 p[2]=iparticle->Pz();
298 origin[0]=origin0[0]+iparticle->Vx()/10;
299 origin[1]=origin0[1]+iparticle->Vy()/10;
300 origin[2]=origin0[2]+iparticle->Vz()/10;
301 tof=kconv*iparticle->T();
305 imo=iparticle->GetFirstMother();
306 TParticle* mother= (TParticle *) particles->At(imo);
307 imo = (mother->GetPdgCode() != 92) ? imo=*(newPos+imo) : -1;
309 // Put particle on the stack
310 gAlice->SetTrack(fTrackIt,imo,kf,p,origin,polar,
312 // tof,"Secondary",nt);
314 // printf("\n set track final: %d %d %d",imo, kf, nt);
315 gAlice->KeepTrack(nt);
318 } // particle loop final state
322 printf("\n I've put %i particles on the stack \n",nc);
325 if (jev >= fNpart || fNpart == -1) {
326 fKineBias=Float_t(fNpart)/Float_t(fTrials);
327 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
332 fHijing->Rluget(50,-1);
333 gAlice->SetHighWaterMark(nt);
336 Bool_t AliGenHijing::KinematicSelection(TParticle *particle)
338 // Perform kinematic selection
339 Double_t px=particle->Px();
340 Double_t py=particle->Py();
341 Double_t pz=particle->Pz();
342 Double_t e=particle->Energy();
345 // transverse momentum cut
346 Double_t pt=TMath::Sqrt(px*px+py*py);
347 if (pt > fPtMax || pt < fPtMin)
349 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
354 Double_t p=TMath::Sqrt(px*px+py*py+pz*pz);
355 if (p > fPMax || p < fPMin)
357 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
363 Double_t theta = Double_t(TMath::ATan2(Double_t(pt),Double_t(pz)));
364 if (theta > fThetaMax || theta < fThetaMin)
367 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
375 else if (e<=-pz) y = -99;
376 else y = 0.5*TMath::Log((e+pz)/(e-pz));
377 if (y > fYMax || y < fYMin)
379 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
385 Double_t phi=Double_t(TMath::ATan2(Double_t(py),Double_t(px)));
386 if (phi > fPhiMax || phi < fPhiMin)
388 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
395 void AliGenHijing::KeepFullEvent()
400 void AliGenHijing::EvaluateCrossSections()
402 // Glauber Calculation of geometrical x-section
404 Float_t xTot=0.; // barn
405 Float_t xTotHard=0.; // barn
406 Float_t xPart=0.; // barn
407 Float_t xPartHard=0.; // barn
408 Float_t sigmaHard=0.1; // mbarn
410 Float_t bMax=fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
411 const Float_t kdib=0.2;
412 Int_t kMax=Int_t((bMax-bMin)/kdib)+1;
415 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
416 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
420 for (i=0; i<kMax; i++)
422 Float_t xb=bMin+i*kdib;
424 ov=fHijing->Profile(xb);
425 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
426 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
429 if (xb > fMinImpactParam && xb < fMaxImpactParam)
435 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
437 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
438 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
440 printf("\n Total cross section (barn): %f \n",xTot);
441 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
442 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
443 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
446 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
449 // Looks recursively if one of the daughters has been selected
451 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
455 Bool_t hasDaughters= (iparticle->GetFirstDaughter() >=0);
456 Bool_t selected=kFALSE;
458 imin=iparticle->GetFirstDaughter();
459 imax=iparticle->GetLastDaughter();
460 for (i=imin; i<= imax; i++){
461 TParticle * jparticle = (TParticle *) particles->At(i);
462 Int_t ip=jparticle->GetPdgCode();
463 if (KinematicSelection(jparticle)&&SelectFlavor(ip)) {
464 selected=kTRUE; break;
466 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
476 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
478 // Select flavor of particle
480 // 4: charm and beauty
482 if (fFlavor == 0) return kTRUE;
484 Int_t ifl=TMath::Abs(pid/100);
485 if (ifl > 10) ifl/=10;
486 return (fFlavor == ifl);
489 Bool_t AliGenHijing::Stable(TParticle* particle)
491 // Return true for a stable particle
493 Int_t kf = TMath::Abs(particle->GetPdgCode());
495 if ( (particle->GetFirstDaughter() < 0 ) || (kf == 1000*fFlavor+122))
504 void AliGenHijing::MakeHeader()
506 // Builds the event header, to be called after each event
507 AliGenHijingEventHeader* header = new AliGenHijingEventHeader("Hijing");
508 // header->SetDate(date);
509 // header->SetRunNumber(run);
510 // header->SetEventNumber(event);
511 header->SetNProduced(fHijing->GetNATT());
512 header->SetImpactParameter(fHijing->GetHINT1(19));
513 header->SetTotalEnergy(fHijing->GetEATT());
514 header->SetHardScatters(fHijing->GetJATT());
515 header->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
516 header->SetCollisions(fHijing->GetN0(),
522 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
524 // Assignment operator
529 # define rluget_hijing rluget_hijing_
530 # define rluset_hijing rluset_hijing_
531 # define rlu_hijing rlu_hijing_
532 # define type_of_call
534 # define rluget_hijing RLUGET_HIJING
535 # define rluset_hijing RLUSET_HIJING
536 # define rlu_hijing RLU_HIJING
537 # define type_of_call _stdcall
542 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
543 {printf("Dummy version of rluget_hijing reached\n");}
545 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
546 {printf("Dummy version of rluset_hijing reached\n");}
548 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
551 do r=sRandom->Rndm(); while(0 >= r || r >= 1);