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.24 2001/07/20 09:34:56 morsch
19 Count the number of spectator neutrons and protons and add information
20 to the event header. (Chiara Oppedisano)
22 Revision 1.23 2001/07/13 17:30:22 morsch
25 Revision 1.22 2001/06/11 13:09:23 morsch
26 - Store cross-Section and number of binary collisions as a function of impact parameter
27 - Pass AliGenHijingEventHeader to gAlice.
29 Revision 1.21 2001/02/28 17:35:24 morsch
30 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
32 Revision 1.20 2001/02/14 15:50:40 hristov
33 The last particle in event marked using SetHighWaterMark
35 Revision 1.19 2000/12/21 16:24:06 morsch
36 Coding convention clean-up
38 Revision 1.18 2000/12/06 17:46:30 morsch
39 Avoid random numbers 1 and 0.
41 Revision 1.17 2000/12/04 11:22:03 morsch
42 Init of sRandom as in 1.15
44 Revision 1.16 2000/12/02 11:41:39 morsch
45 Use SetRandom() to initialize random number generator in constructor.
47 Revision 1.15 2000/11/30 20:29:02 morsch
48 Initialise static variable sRandom in constructor: sRandom = fRandom;
50 Revision 1.14 2000/11/30 07:12:50 alibrary
51 Introducing new Rndm and QA classes
53 Revision 1.13 2000/11/09 17:40:27 morsch
54 Possibility to select/unselect spectator protons and neutrons.
55 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
57 Revision 1.12 2000/10/20 13:38:38 morsch
58 Debug printouts commented.
60 Revision 1.11 2000/10/20 13:22:26 morsch
61 - skip particle type 92 (string)
62 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
65 Revision 1.10 2000/10/17 15:10:20 morsch
66 Write first all the parent particles to the stack and then the final state particles.
68 Revision 1.9 2000/10/17 13:38:59 morsch
69 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
71 Revision 1.8 2000/10/17 12:46:31 morsch
72 Protect EvaluateCrossSections() against division by zero.
74 Revision 1.7 2000/10/02 21:28:06 fca
75 Removal of useless dependecies via forward declarations
77 Revision 1.6 2000/09/11 13:23:37 morsch
78 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
79 luget_hijing and luset_hijing.
81 Revision 1.5 2000/09/07 16:55:40 morsch
82 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
84 Revision 1.4 2000/07/11 18:24:56 fca
85 Coding convention corrections + few minor bug fixes
87 Revision 1.3 2000/06/30 12:08:36 morsch
88 In member data: char* replaced by TString, Init takes care of resizing the strings to
89 8 characters required by Hijing.
91 Revision 1.2 2000/06/15 14:15:05 morsch
92 Add possibility for heavy flavor selection: charm and beauty.
94 Revision 1.1 2000/06/09 20:47:27 morsch
95 AliGenerator interface class to HIJING using THijing (test version)
101 // Generator using HIJING as an external generator
102 // The main HIJING options are accessable for the user through this interface.
103 // Uses the THijing implementation of TGenerator.
105 // andreas.morsch@cern.ch
107 #include "AliGenHijing.h"
108 #include "AliGenHijingEventHeader.h"
113 #include <TParticle.h>
118 ClassImp(AliGenHijing)
120 AliGenHijing::AliGenHijing()
126 AliGenHijing::AliGenHijing(Int_t npart)
129 // Default PbPb collisions at 5. 5 TeV
132 SetImpactParameterRange();
147 // Set random number generator
151 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
157 AliGenHijing::~AliGenHijing()
160 if ( fDsigmaDb) delete fDsigmaDb;
161 if ( fDnDb) delete fDnDb;
164 void AliGenHijing::Init()
169 fProjectile.Resize(8);
171 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
172 fAProjectile, fZProjectile, fATarget, fZTarget,
173 fMinImpactParam, fMaxImpactParam));
175 fHijing=(THijing*) fgMCEvGen;
177 fHijing->SetIHPR2(3, fTrigger);
178 fHijing->SetIHPR2(4, fQuench);
179 fHijing->SetIHPR2(6, fShadowing);
180 fHijing->SetIHPR2(12, fDecaysOff);
181 fHijing->SetIHPR2(21, fKeep);
182 fHijing->Initialize();
186 if (fEvaluate) EvaluateCrossSections();
189 // Initialize random generator
192 void AliGenHijing::Generate()
194 // Generate one event
196 Float_t polar[3] = {0,0,0};
197 Float_t origin[3] = {0,0,0};
198 Float_t origin0[3] = {0,0,0};
199 Float_t p[3], random[6];
202 static TClonesArray *particles;
203 // converts from mm/c to s
204 const Float_t kconv = 0.001/2.999792458e8;
208 Int_t j, kf, ks, imo;
211 if(!particles) particles = new TClonesArray("TParticle",10000);
214 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
215 if(fVertexSmear == kPerEvent) {
217 for (j=0; j < 3; j++) {
218 origin0[j] += fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
219 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
221 } else if (fVertexSmear == kPerTrack) {
222 // fHijing->SetMSTP(151,0);
223 for (j = 0; j < 3; j++) {
224 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
229 // Generate one event
230 // --------------------------------------------------------------------------
233 // --------------------------------------------------------------------------
234 fHijing->GenerateEvent();
236 fHijing->ImportParticles(particles,"All");
237 Int_t np = particles->GetEntriesFast();
238 printf("\n **************************************************%d\n",np);
240 if (np == 0 ) continue;
242 Int_t * newPos = new Int_t[np];
244 for (i = 0; i < np; i++) *(newPos+i) = i;
246 // First write parent particles
249 for (i = 0; i < np; i++) {
250 TParticle * iparticle = (TParticle *) particles->At(i);
251 // Is this a parent particle ?
252 if (Stable(iparticle)) continue;
254 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
255 Bool_t selected = kTRUE;
256 Bool_t hasSelectedDaughters = kFALSE;
259 kf = iparticle->GetPdgCode();
260 ks = iparticle->GetStatusCode();
261 if (kf == 92) continue;
263 if (!fSelectAll) selected = KinematicSelection(iparticle, 0)&&SelectFlavor(kf);
264 hasSelectedDaughters = DaughtersSelection(iparticle, particles);
266 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
268 if (selected || hasSelectedDaughters) {
270 p[0] = iparticle->Px();
271 p[1] = iparticle->Py();
272 p[2] = iparticle->Pz();
273 origin[0] = origin0[0]+iparticle->Vx()/10;
274 origin[1] = origin0[1]+iparticle->Vy()/10;
275 origin[2] = origin0[2]+iparticle->Vz()/10;
276 tof = kconv*iparticle->T();
279 imo = iparticle->GetFirstMother();
280 TParticle* mother = (TParticle *) particles->At(imo);
281 imo = (mother->GetPdgCode() != 92) ? imo =* (newPos+imo) : -1;
283 // Put particle on the stack ...
284 // printf("\n set track mother: %d %d %d %d %d %d ",i,imo, kf, nt+1, selected, hasSelectedDaughters);
286 SetTrack(0,imo,kf,p,origin,polar, tof,kPPrimary,nt);
287 // ... and keep it there
292 } // particle loop parents
294 // Now write the final state particles
297 for (i = 0; i<np; i++) {
298 TParticle * iparticle = (TParticle *) particles->At(i);
299 // Is this a final state particle ?
300 if (!Stable(iparticle)) continue;
302 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
303 Bool_t selected = kTRUE;
304 kf = iparticle->GetPdgCode();
305 ks = iparticle->GetStatusCode();
306 // --------------------------------------------------------------------------
307 // Count spectator neutrons and protons
308 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
309 if(kf == kNeutron) fSpecn += 1;
310 if(kf == kProton) fSpecp += 1;
312 // --------------------------------------------------------------------------
315 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
316 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
320 // Put particle on the stack if selected
324 p[0] = iparticle->Px();
325 p[1] = iparticle->Py();
326 p[2] = iparticle->Pz();
327 origin[0] = origin0[0]+iparticle->Vx()/10;
328 origin[1] = origin0[1]+iparticle->Vy()/10;
329 origin[2] = origin0[2]+iparticle->Vz()/10;
330 tof = kconv*iparticle->T();
334 imo = iparticle->GetFirstMother();
335 TParticle* mother = (TParticle *) particles->At(imo);
336 imo = (mother->GetPdgCode() != 92) ? imo=*(newPos+imo) : -1;
338 // Put particle on the stack
339 SetTrack(fTrackIt,imo,kf,p,origin,polar,
344 } // particle loop final state
348 printf("\n I've put %i particles on the stack \n",nc);
351 if (jev >= fNpart || fNpart == -1) {
352 fKineBias = Float_t(fNpart)/Float_t(fTrials);
353 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
360 SetHighWaterMark(nt);
363 void AliGenHijing::KeepFullEvent()
368 void AliGenHijing::EvaluateCrossSections()
370 // Glauber Calculation of geometrical x-section
372 Float_t xTot = 0.; // barn
373 Float_t xTotHard = 0.; // barn
374 Float_t xPart = 0.; // barn
375 Float_t xPartHard = 0.; // barn
376 Float_t sigmaHard = 0.1; // mbarn
378 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
379 const Float_t kdib = 0.2;
380 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
383 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
384 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
386 Float_t oldvalue= 0.;
388 Float_t* b = new Float_t[kMax];
389 Float_t* si1 = new Float_t[kMax];
390 Float_t* si2 = new Float_t[kMax];
392 for (i = 0; i < kMax; i++)
394 Float_t xb = bMin+i*kdib;
396 ov=fHijing->Profile(xb);
397 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
398 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
401 if (xb > fMinImpactParam && xb < fMaxImpactParam)
407 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
409 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
410 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
418 printf("\n Total cross section (barn): %f \n",xTot);
419 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
420 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
421 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
423 // Store result as a graph
428 fDsigmaDb = new TGraph(i, b, si1);
429 fDnDb = new TGraph(i, b, si2);
432 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
435 // Looks recursively if one of the daughters has been selected
437 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
441 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
442 Bool_t selected = kFALSE;
444 imin = iparticle->GetFirstDaughter();
445 imax = iparticle->GetLastDaughter();
446 for (i = imin; i <= imax; i++){
447 TParticle * jparticle = (TParticle *) particles->At(i);
448 Int_t ip = jparticle->GetPdgCode();
449 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
450 selected=kTRUE; break;
452 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
461 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
463 // Select flavor of particle
465 // 4: charm and beauty
467 if (fFlavor == 0) return kTRUE;
469 Int_t ifl = TMath::Abs(pid/100);
470 if (ifl > 10) ifl/=10;
471 return (fFlavor == ifl);
474 Bool_t AliGenHijing::Stable(TParticle* particle)
476 // Return true for a stable particle
478 Int_t kf = TMath::Abs(particle->GetPdgCode());
480 if ( (particle->GetFirstDaughter() < 0 ) || (kf == 1000*fFlavor+122))
488 void AliGenHijing::MakeHeader()
490 // Builds the event header, to be called after each event
491 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
492 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
493 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
494 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
495 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
496 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
497 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
501 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
502 gAlice->SetGenEventHeader(header);
506 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
508 // Assignment operator
513 # define rluget_hijing rluget_hijing_
514 # define rluset_hijing rluset_hijing_
515 # define rlu_hijing rlu_hijing_
516 # define type_of_call
518 # define rluget_hijing RLUGET_HIJING
519 # define rluset_hijing RLUSET_HIJING
520 # define rlu_hijing RLU_HIJING
521 # define type_of_call _stdcall
526 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
527 {printf("Dummy version of rluget_hijing reached\n");}
529 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
530 {printf("Dummy version of rluset_hijing reached\n");}
532 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
535 do r=sRandom->Rndm(); while(0 >= r || r >= 1);