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.28 2001/10/08 11:55:25 morsch
19 Store 4-momenta of trigegred jets in event header.
20 Possibility to switch of initial and final state radiation.
22 Revision 1.27 2001/10/08 07:13:14 morsch
23 Add setter for minimum transverse momentum of triggered jet.
25 Revision 1.26 2001/10/04 08:12:24 morsch
26 Redefinition of stable condition.
28 Revision 1.25 2001/07/27 17:09:36 morsch
29 Use local SetTrack, KeepTrack and SetHighWaterMark methods
30 to delegate either to local stack or to stack owned by AliRun.
31 (Piotr Skowronski, A.M.)
33 Revision 1.24 2001/07/20 09:34:56 morsch
34 Count the number of spectator neutrons and protons and add information
35 to the event header. (Chiara Oppedisano)
37 Revision 1.23 2001/07/13 17:30:22 morsch
40 Revision 1.22 2001/06/11 13:09:23 morsch
41 - Store cross-Section and number of binary collisions as a function of impact parameter
42 - Pass AliGenHijingEventHeader to gAlice.
44 Revision 1.21 2001/02/28 17:35:24 morsch
45 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
47 Revision 1.20 2001/02/14 15:50:40 hristov
48 The last particle in event marked using SetHighWaterMark
50 Revision 1.19 2000/12/21 16:24:06 morsch
51 Coding convention clean-up
53 Revision 1.18 2000/12/06 17:46:30 morsch
54 Avoid random numbers 1 and 0.
56 Revision 1.17 2000/12/04 11:22:03 morsch
57 Init of sRandom as in 1.15
59 Revision 1.16 2000/12/02 11:41:39 morsch
60 Use SetRandom() to initialize random number generator in constructor.
62 Revision 1.15 2000/11/30 20:29:02 morsch
63 Initialise static variable sRandom in constructor: sRandom = fRandom;
65 Revision 1.14 2000/11/30 07:12:50 alibrary
66 Introducing new Rndm and QA classes
68 Revision 1.13 2000/11/09 17:40:27 morsch
69 Possibility to select/unselect spectator protons and neutrons.
70 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
72 Revision 1.12 2000/10/20 13:38:38 morsch
73 Debug printouts commented.
75 Revision 1.11 2000/10/20 13:22:26 morsch
76 - skip particle type 92 (string)
77 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
80 Revision 1.10 2000/10/17 15:10:20 morsch
81 Write first all the parent particles to the stack and then the final state particles.
83 Revision 1.9 2000/10/17 13:38:59 morsch
84 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
86 Revision 1.8 2000/10/17 12:46:31 morsch
87 Protect EvaluateCrossSections() against division by zero.
89 Revision 1.7 2000/10/02 21:28:06 fca
90 Removal of useless dependecies via forward declarations
92 Revision 1.6 2000/09/11 13:23:37 morsch
93 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
94 luget_hijing and luset_hijing.
96 Revision 1.5 2000/09/07 16:55:40 morsch
97 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
99 Revision 1.4 2000/07/11 18:24:56 fca
100 Coding convention corrections + few minor bug fixes
102 Revision 1.3 2000/06/30 12:08:36 morsch
103 In member data: char* replaced by TString, Init takes care of resizing the strings to
104 8 characters required by Hijing.
106 Revision 1.2 2000/06/15 14:15:05 morsch
107 Add possibility for heavy flavor selection: charm and beauty.
109 Revision 1.1 2000/06/09 20:47:27 morsch
110 AliGenerator interface class to HIJING using THijing (test version)
116 // Generator using HIJING as an external generator
117 // The main HIJING options are accessable for the user through this interface.
118 // Uses the THijing implementation of TGenerator.
120 // andreas.morsch@cern.ch
122 #include "AliGenHijing.h"
123 #include "AliGenHijingEventHeader.h"
128 #include <TParticle.h>
131 #include <TLorentzVector.h>
134 ClassImp(AliGenHijing)
136 AliGenHijing::AliGenHijing()
142 AliGenHijing::AliGenHijing(Int_t npart)
145 // Default PbPb collisions at 5. 5 TeV
148 SetImpactParameterRange();
166 // Set random number generator
170 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
176 AliGenHijing::~AliGenHijing()
179 if ( fDsigmaDb) delete fDsigmaDb;
180 if ( fDnDb) delete fDnDb;
183 void AliGenHijing::Init()
188 fProjectile.Resize(8);
190 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
191 fAProjectile, fZProjectile, fATarget, fZTarget,
192 fMinImpactParam, fMaxImpactParam));
194 fHijing=(THijing*) fgMCEvGen;
195 fHijing->SetIHPR2(2, fRadiation);
196 fHijing->SetIHPR2(3, fTrigger);
197 fHijing->SetIHPR2(4, fQuench);
198 fHijing->SetIHPR2(6, fShadowing);
199 fHijing->SetIHPR2(12, fDecaysOff);
200 fHijing->SetIHPR2(21, fKeep);
201 fHijing->SetHIPR1(10, fPtMinJet);
202 fHijing->Initialize();
206 if (fEvaluate) EvaluateCrossSections();
209 // Initialize random generator
212 void AliGenHijing::Generate()
214 // Generate one event
216 Float_t polar[3] = {0,0,0};
217 Float_t origin[3] = {0,0,0};
218 Float_t origin0[3] = {0,0,0};
219 Float_t p[3], random[6];
222 static TClonesArray *particles;
223 // converts from mm/c to s
224 const Float_t kconv = 0.001/2.999792458e8;
228 Int_t j, kf, ks, imo;
231 if(!particles) particles = new TClonesArray("TParticle",10000);
234 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
235 if(fVertexSmear == kPerEvent) {
238 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
240 for (j=0; j < 3; j++) {
241 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
242 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
245 for (j=0; j < 3; j++) origin0[j] += dv[j];
246 } else if (fVertexSmear == kPerTrack) {
247 // fHijing->SetMSTP(151,0);
248 for (j = 0; j < 3; j++) {
249 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
254 // Generate one event
255 // --------------------------------------------------------------------------
258 // --------------------------------------------------------------------------
259 fHijing->GenerateEvent();
261 fHijing->ImportParticles(particles,"All");
262 Int_t np = particles->GetEntriesFast();
263 printf("\n **************************************************%d\n",np);
265 if (np == 0 ) continue;
267 Int_t * newPos = new Int_t[np];
269 for (i = 0; i < np; i++) *(newPos+i) = i;
272 TParticle * iparticle = (TParticle *) particles->At(0);
273 fEventVertex[0] = origin0[0];
274 fEventVertex[1] = origin0[1];
275 fEventVertex[2] = origin0[2];
278 // First write parent particles
281 for (i = 0; i < np; i++) {
282 iparticle = (TParticle *) particles->At(i);
283 // Is this a parent particle ?
284 if (Stable(iparticle)) continue;
286 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
287 Bool_t selected = kTRUE;
288 Bool_t hasSelectedDaughters = kFALSE;
291 kf = iparticle->GetPdgCode();
292 ks = iparticle->GetStatusCode();
293 if (kf == 92) continue;
295 if (!fSelectAll) selected = KinematicSelection(iparticle, 0)&&SelectFlavor(kf);
296 hasSelectedDaughters = DaughtersSelection(iparticle, particles);
298 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
300 if (selected || hasSelectedDaughters) {
302 p[0] = iparticle->Px();
303 p[1] = iparticle->Py();
304 p[2] = iparticle->Pz();
305 origin[0] = origin0[0]+iparticle->Vx()/10;
306 origin[1] = origin0[1]+iparticle->Vy()/10;
307 origin[2] = origin0[2]+iparticle->Vz()/10;
308 tof = kconv*iparticle->T();
310 TParticle* mother = 0;
312 imo = iparticle->GetFirstMother();
313 mother = (TParticle *) particles->At(imo);
314 imo = (mother->GetPdgCode() != 92) ? imo =* (newPos+imo) : -1;
317 // Put particle on the stack ...
318 // printf("\n set track mother: %d %d %d %d %d %d ",i,imo, kf, nt+1, selected, hasSelectedDaughters);
320 SetTrack(0,imo,kf,p,origin,polar, tof,kPPrimary,nt);
321 // ... and keep it there
326 } // particle loop parents
328 // Now write the final state particles
331 for (i = 0; i<np; i++) {
332 TParticle * iparticle = (TParticle *) particles->At(i);
333 // Is this a final state particle ?
334 if (!Stable(iparticle)) continue;
336 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
337 Bool_t selected = kTRUE;
338 kf = iparticle->GetPdgCode();
339 ks = iparticle->GetStatusCode();
340 // --------------------------------------------------------------------------
341 // Count spectator neutrons and protons
342 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
343 if(kf == kNeutron) fSpecn += 1;
344 if(kf == kProton) fSpecp += 1;
346 // --------------------------------------------------------------------------
349 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
350 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
354 // Put particle on the stack if selected
358 p[0] = iparticle->Px();
359 p[1] = iparticle->Py();
360 p[2] = iparticle->Pz();
361 origin[0] = origin0[0]+iparticle->Vx()/10;
362 origin[1] = origin0[1]+iparticle->Vy()/10;
363 origin[2] = origin0[2]+iparticle->Vz()/10;
364 tof = kconv*iparticle->T();
366 TParticle* mother = 0;
368 imo = iparticle->GetFirstMother();
369 mother = (TParticle *) particles->At(imo);
370 imo = (mother->GetPdgCode() != 92) ? imo=*(newPos+imo) : -1;
372 // Put particle on the stack
373 SetTrack(fTrackIt,imo,kf,p,origin,polar,
378 } // particle loop final state
382 printf("\n I've put %i particles on the stack \n",nc);
385 if (jev >= fNpart || fNpart == -1) {
386 fKineBias = Float_t(fNpart)/Float_t(fTrials);
387 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
394 SetHighWaterMark(nt);
397 void AliGenHijing::KeepFullEvent()
402 void AliGenHijing::EvaluateCrossSections()
404 // Glauber Calculation of geometrical x-section
406 Float_t xTot = 0.; // barn
407 Float_t xTotHard = 0.; // barn
408 Float_t xPart = 0.; // barn
409 Float_t xPartHard = 0.; // barn
410 Float_t sigmaHard = 0.1; // mbarn
412 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
413 const Float_t kdib = 0.2;
414 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
417 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
418 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
420 Float_t oldvalue= 0.;
422 Float_t* b = new Float_t[kMax];
423 Float_t* si1 = new Float_t[kMax];
424 Float_t* si2 = new Float_t[kMax];
426 for (i = 0; i < kMax; i++)
428 Float_t xb = bMin+i*kdib;
430 ov=fHijing->Profile(xb);
431 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
432 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
435 if (xb > fMinImpactParam && xb < fMaxImpactParam)
441 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
443 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
444 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
452 printf("\n Total cross section (barn): %f \n",xTot);
453 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
454 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
455 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
457 // Store result as a graph
462 fDsigmaDb = new TGraph(i, b, si1);
463 fDnDb = new TGraph(i, b, si2);
466 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
469 // Looks recursively if one of the daughters has been selected
471 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
475 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
476 Bool_t selected = kFALSE;
478 imin = iparticle->GetFirstDaughter();
479 imax = iparticle->GetLastDaughter();
480 for (i = imin; i <= imax; i++){
481 TParticle * jparticle = (TParticle *) particles->At(i);
482 Int_t ip = jparticle->GetPdgCode();
483 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
484 selected=kTRUE; break;
486 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
495 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
497 // Select flavor of particle
499 // 4: charm and beauty
501 if (fFlavor == 0) return kTRUE;
503 Int_t ifl = TMath::Abs(pid/100);
504 if (ifl > 10) ifl/=10;
505 return (fFlavor == ifl);
508 Bool_t AliGenHijing::Stable(TParticle* particle)
510 // Return true for a stable particle
512 if (particle->GetFirstDaughter() < 0 )
520 void AliGenHijing::MakeHeader()
522 // Builds the event header, to be called after each event
523 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
524 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
525 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
526 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
527 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
528 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
529 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
533 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
535 // 4-momentum vectors of the triggered jets.
537 // Before final state gluon radiation.
538 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
539 fHijing->GetHINT1(22),
540 fHijing->GetHINT1(23),
541 fHijing->GetHINT1(24));
543 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
544 fHijing->GetHINT1(32),
545 fHijing->GetHINT1(33),
546 fHijing->GetHINT1(34));
547 // After final state gluon radiation.
548 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
549 fHijing->GetHINT1(27),
550 fHijing->GetHINT1(28),
551 fHijing->GetHINT1(29));
553 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
554 fHijing->GetHINT1(37),
555 fHijing->GetHINT1(38),
556 fHijing->GetHINT1(39));
557 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
559 header->SetPrimaryVertex(fEventVertex);
560 gAlice->SetGenEventHeader(header);
563 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
565 // Assignment operator
570 # define rluget_hijing rluget_hijing_
571 # define rluset_hijing rluset_hijing_
572 # define rlu_hijing rlu_hijing_
573 # define type_of_call
575 # define rluget_hijing RLUGET_HIJING
576 # define rluset_hijing RLUSET_HIJING
577 # define rlu_hijing RLU_HIJING
578 # define type_of_call _stdcall
583 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
584 {printf("Dummy version of rluget_hijing reached\n");}
586 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
587 {printf("Dummy version of rluset_hijing reached\n");}
589 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
592 do r=sRandom->Rndm(); while(0 >= r || r >= 1);