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.27 2001/10/08 07:13:14 morsch
19 Add setter for minimum transverse momentum of triggered jet.
21 Revision 1.26 2001/10/04 08:12:24 morsch
22 Redefinition of stable condition.
24 Revision 1.25 2001/07/27 17:09:36 morsch
25 Use local SetTrack, KeepTrack and SetHighWaterMark methods
26 to delegate either to local stack or to stack owned by AliRun.
27 (Piotr Skowronski, A.M.)
29 Revision 1.24 2001/07/20 09:34:56 morsch
30 Count the number of spectator neutrons and protons and add information
31 to the event header. (Chiara Oppedisano)
33 Revision 1.23 2001/07/13 17:30:22 morsch
36 Revision 1.22 2001/06/11 13:09:23 morsch
37 - Store cross-Section and number of binary collisions as a function of impact parameter
38 - Pass AliGenHijingEventHeader to gAlice.
40 Revision 1.21 2001/02/28 17:35:24 morsch
41 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
43 Revision 1.20 2001/02/14 15:50:40 hristov
44 The last particle in event marked using SetHighWaterMark
46 Revision 1.19 2000/12/21 16:24:06 morsch
47 Coding convention clean-up
49 Revision 1.18 2000/12/06 17:46:30 morsch
50 Avoid random numbers 1 and 0.
52 Revision 1.17 2000/12/04 11:22:03 morsch
53 Init of sRandom as in 1.15
55 Revision 1.16 2000/12/02 11:41:39 morsch
56 Use SetRandom() to initialize random number generator in constructor.
58 Revision 1.15 2000/11/30 20:29:02 morsch
59 Initialise static variable sRandom in constructor: sRandom = fRandom;
61 Revision 1.14 2000/11/30 07:12:50 alibrary
62 Introducing new Rndm and QA classes
64 Revision 1.13 2000/11/09 17:40:27 morsch
65 Possibility to select/unselect spectator protons and neutrons.
66 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
68 Revision 1.12 2000/10/20 13:38:38 morsch
69 Debug printouts commented.
71 Revision 1.11 2000/10/20 13:22:26 morsch
72 - skip particle type 92 (string)
73 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
76 Revision 1.10 2000/10/17 15:10:20 morsch
77 Write first all the parent particles to the stack and then the final state particles.
79 Revision 1.9 2000/10/17 13:38:59 morsch
80 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
82 Revision 1.8 2000/10/17 12:46:31 morsch
83 Protect EvaluateCrossSections() against division by zero.
85 Revision 1.7 2000/10/02 21:28:06 fca
86 Removal of useless dependecies via forward declarations
88 Revision 1.6 2000/09/11 13:23:37 morsch
89 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
90 luget_hijing and luset_hijing.
92 Revision 1.5 2000/09/07 16:55:40 morsch
93 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
95 Revision 1.4 2000/07/11 18:24:56 fca
96 Coding convention corrections + few minor bug fixes
98 Revision 1.3 2000/06/30 12:08:36 morsch
99 In member data: char* replaced by TString, Init takes care of resizing the strings to
100 8 characters required by Hijing.
102 Revision 1.2 2000/06/15 14:15:05 morsch
103 Add possibility for heavy flavor selection: charm and beauty.
105 Revision 1.1 2000/06/09 20:47:27 morsch
106 AliGenerator interface class to HIJING using THijing (test version)
112 // Generator using HIJING as an external generator
113 // The main HIJING options are accessable for the user through this interface.
114 // Uses the THijing implementation of TGenerator.
116 // andreas.morsch@cern.ch
118 #include "AliGenHijing.h"
119 #include "AliGenHijingEventHeader.h"
124 #include <TParticle.h>
127 #include <TLorentzVector.h>
130 ClassImp(AliGenHijing)
132 AliGenHijing::AliGenHijing()
138 AliGenHijing::AliGenHijing(Int_t npart)
141 // Default PbPb collisions at 5. 5 TeV
144 SetImpactParameterRange();
161 // Set random number generator
165 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
171 AliGenHijing::~AliGenHijing()
174 if ( fDsigmaDb) delete fDsigmaDb;
175 if ( fDnDb) delete fDnDb;
178 void AliGenHijing::Init()
183 fProjectile.Resize(8);
185 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
186 fAProjectile, fZProjectile, fATarget, fZTarget,
187 fMinImpactParam, fMaxImpactParam));
189 fHijing=(THijing*) fgMCEvGen;
190 fHijing->SetIHPR2(2, fRadiation);
191 fHijing->SetIHPR2(3, fTrigger);
192 fHijing->SetIHPR2(4, fQuench);
193 fHijing->SetIHPR2(6, fShadowing);
194 fHijing->SetIHPR2(12, fDecaysOff);
195 fHijing->SetIHPR2(21, fKeep);
196 fHijing->SetHIPR1(10, fPtMinJet);
197 fHijing->Initialize();
201 if (fEvaluate) EvaluateCrossSections();
204 // Initialize random generator
207 void AliGenHijing::Generate()
209 // Generate one event
211 Float_t polar[3] = {0,0,0};
212 Float_t origin[3] = {0,0,0};
213 Float_t origin0[3] = {0,0,0};
214 Float_t p[3], random[6];
217 static TClonesArray *particles;
218 // converts from mm/c to s
219 const Float_t kconv = 0.001/2.999792458e8;
223 Int_t j, kf, ks, imo;
226 if(!particles) particles = new TClonesArray("TParticle",10000);
229 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
230 if(fVertexSmear == kPerEvent) {
232 for (j=0; j < 3; j++) {
233 origin0[j] += fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
234 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
236 } else if (fVertexSmear == kPerTrack) {
237 // fHijing->SetMSTP(151,0);
238 for (j = 0; j < 3; j++) {
239 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
244 // Generate one event
245 // --------------------------------------------------------------------------
248 // --------------------------------------------------------------------------
249 fHijing->GenerateEvent();
251 fHijing->ImportParticles(particles,"All");
252 Int_t np = particles->GetEntriesFast();
253 printf("\n **************************************************%d\n",np);
255 if (np == 0 ) continue;
257 Int_t * newPos = new Int_t[np];
259 for (i = 0; i < np; i++) *(newPos+i) = i;
261 // First write parent particles
264 for (i = 0; i < np; i++) {
265 TParticle * iparticle = (TParticle *) particles->At(i);
266 // Is this a parent particle ?
267 if (Stable(iparticle)) continue;
269 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
270 Bool_t selected = kTRUE;
271 Bool_t hasSelectedDaughters = kFALSE;
274 kf = iparticle->GetPdgCode();
275 ks = iparticle->GetStatusCode();
276 if (kf == 92) continue;
278 if (!fSelectAll) selected = KinematicSelection(iparticle, 0)&&SelectFlavor(kf);
279 hasSelectedDaughters = DaughtersSelection(iparticle, particles);
281 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
283 if (selected || hasSelectedDaughters) {
285 p[0] = iparticle->Px();
286 p[1] = iparticle->Py();
287 p[2] = iparticle->Pz();
288 origin[0] = origin0[0]+iparticle->Vx()/10;
289 origin[1] = origin0[1]+iparticle->Vy()/10;
290 origin[2] = origin0[2]+iparticle->Vz()/10;
291 tof = kconv*iparticle->T();
293 TParticle* mother = 0;
295 imo = iparticle->GetFirstMother();
296 mother = (TParticle *) particles->At(imo);
297 imo = (mother->GetPdgCode() != 92) ? imo =* (newPos+imo) : -1;
300 // Put particle on the stack ...
301 // printf("\n set track mother: %d %d %d %d %d %d ",i,imo, kf, nt+1, selected, hasSelectedDaughters);
303 SetTrack(0,imo,kf,p,origin,polar, tof,kPPrimary,nt);
304 // ... and keep it there
309 } // particle loop parents
311 // Now write the final state particles
314 for (i = 0; i<np; i++) {
315 TParticle * iparticle = (TParticle *) particles->At(i);
316 // Is this a final state particle ?
317 if (!Stable(iparticle)) continue;
319 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
320 Bool_t selected = kTRUE;
321 kf = iparticle->GetPdgCode();
322 ks = iparticle->GetStatusCode();
323 // --------------------------------------------------------------------------
324 // Count spectator neutrons and protons
325 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
326 if(kf == kNeutron) fSpecn += 1;
327 if(kf == kProton) fSpecp += 1;
329 // --------------------------------------------------------------------------
332 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
333 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
337 // Put particle on the stack if selected
341 p[0] = iparticle->Px();
342 p[1] = iparticle->Py();
343 p[2] = iparticle->Pz();
344 origin[0] = origin0[0]+iparticle->Vx()/10;
345 origin[1] = origin0[1]+iparticle->Vy()/10;
346 origin[2] = origin0[2]+iparticle->Vz()/10;
347 tof = kconv*iparticle->T();
349 TParticle* mother = 0;
351 imo = iparticle->GetFirstMother();
352 mother = (TParticle *) particles->At(imo);
353 imo = (mother->GetPdgCode() != 92) ? imo=*(newPos+imo) : -1;
355 // Put particle on the stack
356 SetTrack(fTrackIt,imo,kf,p,origin,polar,
361 } // particle loop final state
365 printf("\n I've put %i particles on the stack \n",nc);
368 if (jev >= fNpart || fNpart == -1) {
369 fKineBias = Float_t(fNpart)/Float_t(fTrials);
370 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
377 SetHighWaterMark(nt);
380 void AliGenHijing::KeepFullEvent()
385 void AliGenHijing::EvaluateCrossSections()
387 // Glauber Calculation of geometrical x-section
389 Float_t xTot = 0.; // barn
390 Float_t xTotHard = 0.; // barn
391 Float_t xPart = 0.; // barn
392 Float_t xPartHard = 0.; // barn
393 Float_t sigmaHard = 0.1; // mbarn
395 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
396 const Float_t kdib = 0.2;
397 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
400 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
401 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
403 Float_t oldvalue= 0.;
405 Float_t* b = new Float_t[kMax];
406 Float_t* si1 = new Float_t[kMax];
407 Float_t* si2 = new Float_t[kMax];
409 for (i = 0; i < kMax; i++)
411 Float_t xb = bMin+i*kdib;
413 ov=fHijing->Profile(xb);
414 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
415 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
418 if (xb > fMinImpactParam && xb < fMaxImpactParam)
424 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
426 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
427 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
435 printf("\n Total cross section (barn): %f \n",xTot);
436 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
437 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
438 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
440 // Store result as a graph
445 fDsigmaDb = new TGraph(i, b, si1);
446 fDnDb = new TGraph(i, b, si2);
449 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
452 // Looks recursively if one of the daughters has been selected
454 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
458 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
459 Bool_t selected = kFALSE;
461 imin = iparticle->GetFirstDaughter();
462 imax = iparticle->GetLastDaughter();
463 for (i = imin; i <= imax; i++){
464 TParticle * jparticle = (TParticle *) particles->At(i);
465 Int_t ip = jparticle->GetPdgCode();
466 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
467 selected=kTRUE; break;
469 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
478 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
480 // Select flavor of particle
482 // 4: charm and beauty
484 if (fFlavor == 0) return kTRUE;
486 Int_t ifl = TMath::Abs(pid/100);
487 if (ifl > 10) ifl/=10;
488 return (fFlavor == ifl);
491 Bool_t AliGenHijing::Stable(TParticle* particle)
493 // Return true for a stable particle
495 if (particle->GetFirstDaughter() < 0 )
503 void AliGenHijing::MakeHeader()
505 // Builds the event header, to be called after each event
506 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
507 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
508 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
509 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
510 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
511 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
512 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
516 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
518 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
519 fHijing->GetHINT1(22),
520 fHijing->GetHINT1(23),
521 fHijing->GetHINT1(24));
523 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
524 fHijing->GetHINT1(32),
525 fHijing->GetHINT1(33),
526 fHijing->GetHINT1(34));
528 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2);
529 gAlice->SetGenEventHeader(header);
532 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
534 // Assignment operator
539 # define rluget_hijing rluget_hijing_
540 # define rluset_hijing rluset_hijing_
541 # define rlu_hijing rlu_hijing_
542 # define type_of_call
544 # define rluget_hijing RLUGET_HIJING
545 # define rluset_hijing RLUSET_HIJING
546 # define rlu_hijing RLU_HIJING
547 # define type_of_call _stdcall
552 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
553 {printf("Dummy version of rluget_hijing reached\n");}
555 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
556 {printf("Dummy version of rluset_hijing reached\n");}
558 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
561 do r=sRandom->Rndm(); while(0 >= r || r >= 1);