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.39 2002/02/12 09:16:39 morsch
19 Correction in SelectFlavor()
21 Revision 1.38 2002/02/12 08:53:21 morsch
22 SetNoGammas can be used to inhibit writing of gammas and pi0.
24 Revision 1.37 2002/02/08 16:50:50 morsch
25 Add name and title in constructor.
27 Revision 1.36 2002/01/31 20:17:55 morsch
28 Allow for triggered jets with simplified topology: Exact pT, back-to-back
30 Revision 1.35 2001/12/13 07:56:25 hristov
31 Set pointers to zero in the default constructor
33 Revision 1.34 2001/12/11 16:55:42 morsch
34 Correct initialization for jet phi-range.
36 Revision 1.33 2001/12/05 10:18:51 morsch
37 Possibility of kinematic biasing of jet phi range. (J. Klay)
39 Revision 1.32 2001/11/28 13:51:11 morsch
40 Introduce kinematic biasing (etamin, etamax) of jet trigger. Bookkeeping
41 (number of trials) done in AliGenHijingEventHeader.
43 Revision 1.31 2001/11/06 12:30:34 morsch
44 Add Boost() method to boost all particles to LHC lab frame. Needed for asymmetric collision systems.
46 Revision 1.30 2001/10/21 18:35:56 hristov
47 Several pointers were set to zero in the default constructors to avoid memory management problems
49 Revision 1.29 2001/10/15 08:12:24 morsch
50 - Vertex smearing with truncated gaussian.
51 - Store triggered jet info before and after final state radiation into mc-heade
53 Revision 1.28 2001/10/08 11:55:25 morsch
54 Store 4-momenta of trigegred jets in event header.
55 Possibility to switch of initial and final state radiation.
57 Revision 1.27 2001/10/08 07:13:14 morsch
58 Add setter for minimum transverse momentum of triggered jet.
60 Revision 1.26 2001/10/04 08:12:24 morsch
61 Redefinition of stable condition.
63 Revision 1.25 2001/07/27 17:09:36 morsch
64 Use local SetTrack, KeepTrack and SetHighWaterMark methods
65 to delegate either to local stack or to stack owned by AliRun.
66 (Piotr Skowronski, A.M.)
68 Revision 1.24 2001/07/20 09:34:56 morsch
69 Count the number of spectator neutrons and protons and add information
70 to the event header. (Chiara Oppedisano)
72 Revision 1.23 2001/07/13 17:30:22 morsch
75 Revision 1.22 2001/06/11 13:09:23 morsch
76 - Store cross-Section and number of binary collisions as a function of impact parameter
77 - Pass AliGenHijingEventHeader to gAlice.
79 Revision 1.21 2001/02/28 17:35:24 morsch
80 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
82 Revision 1.20 2001/02/14 15:50:40 hristov
83 The last particle in event marked using SetHighWaterMark
85 Revision 1.19 2000/12/21 16:24:06 morsch
86 Coding convention clean-up
88 Revision 1.18 2000/12/06 17:46:30 morsch
89 Avoid random numbers 1 and 0.
91 Revision 1.17 2000/12/04 11:22:03 morsch
92 Init of sRandom as in 1.15
94 Revision 1.16 2000/12/02 11:41:39 morsch
95 Use SetRandom() to initialize random number generator in constructor.
97 Revision 1.15 2000/11/30 20:29:02 morsch
98 Initialise static variable sRandom in constructor: sRandom = fRandom;
100 Revision 1.14 2000/11/30 07:12:50 alibrary
101 Introducing new Rndm and QA classes
103 Revision 1.13 2000/11/09 17:40:27 morsch
104 Possibility to select/unselect spectator protons and neutrons.
105 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
107 Revision 1.12 2000/10/20 13:38:38 morsch
108 Debug printouts commented.
110 Revision 1.11 2000/10/20 13:22:26 morsch
111 - skip particle type 92 (string)
112 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
115 Revision 1.10 2000/10/17 15:10:20 morsch
116 Write first all the parent particles to the stack and then the final state particles.
118 Revision 1.9 2000/10/17 13:38:59 morsch
119 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
121 Revision 1.8 2000/10/17 12:46:31 morsch
122 Protect EvaluateCrossSections() against division by zero.
124 Revision 1.7 2000/10/02 21:28:06 fca
125 Removal of useless dependecies via forward declarations
127 Revision 1.6 2000/09/11 13:23:37 morsch
128 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
129 luget_hijing and luset_hijing.
131 Revision 1.5 2000/09/07 16:55:40 morsch
132 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
134 Revision 1.4 2000/07/11 18:24:56 fca
135 Coding convention corrections + few minor bug fixes
137 Revision 1.3 2000/06/30 12:08:36 morsch
138 In member data: char* replaced by TString, Init takes care of resizing the strings to
139 8 characters required by Hijing.
141 Revision 1.2 2000/06/15 14:15:05 morsch
142 Add possibility for heavy flavor selection: charm and beauty.
144 Revision 1.1 2000/06/09 20:47:27 morsch
145 AliGenerator interface class to HIJING using THijing (test version)
151 // Generator using HIJING as an external generator
152 // The main HIJING options are accessable for the user through this interface.
153 // Uses the THijing implementation of TGenerator.
155 // andreas.morsch@cern.ch
157 #include "AliGenHijing.h"
158 #include "AliGenHijingEventHeader.h"
163 #include <TParticle.h>
166 #include <TLorentzVector.h>
169 ClassImp(AliGenHijing)
171 AliGenHijing::AliGenHijing()
180 AliGenHijing::AliGenHijing(Int_t npart)
183 // Default PbPb collisions at 5. 5 TeV
186 fTitle= "Particle Generator using HIJING";
189 SetImpactParameterRange();
215 // Set random number generator
221 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
227 AliGenHijing::~AliGenHijing()
230 if ( fDsigmaDb) delete fDsigmaDb;
231 if ( fDnDb) delete fDnDb;
234 void AliGenHijing::Init()
239 fProjectile.Resize(8);
241 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
242 fAProjectile, fZProjectile, fATarget, fZTarget,
243 fMinImpactParam, fMaxImpactParam));
245 fHijing=(THijing*) fgMCEvGen;
246 fHijing->SetIHPR2(2, fRadiation);
247 fHijing->SetIHPR2(3, fTrigger);
248 fHijing->SetIHPR2(4, fQuench);
249 fHijing->SetIHPR2(6, fShadowing);
250 fHijing->SetIHPR2(12, fDecaysOff);
251 fHijing->SetIHPR2(21, fKeep);
252 fHijing->SetHIPR1(10, fPtMinJet);
253 fHijing->SetHIPR1(50, fSimpleJet);
254 fHijing->Initialize();
256 if (fEvaluate) EvaluateCrossSections();
259 // Initialize random generator
262 void AliGenHijing::Generate()
264 // Generate one event
266 Float_t polar[3] = {0,0,0};
267 Float_t origin[3] = {0,0,0};
268 Float_t origin0[3] = {0,0,0};
269 Float_t p[3], random[6];
272 static TClonesArray *particles;
273 // converts from mm/c to s
274 const Float_t kconv = 0.001/2.999792458e8;
278 Int_t j, kf, ks, imo;
281 if(!particles) particles = new TClonesArray("TParticle",10000);
284 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
285 if(fVertexSmear == kPerEvent) {
288 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
290 for (j=0; j < 3; j++) {
291 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
292 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
295 for (j=0; j < 3; j++) origin0[j] += dv[j];
296 } else if (fVertexSmear == kPerTrack) {
297 // fHijing->SetMSTP(151,0);
298 for (j = 0; j < 3; j++) {
299 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
304 // Generate one event
305 // --------------------------------------------------------------------------
308 // --------------------------------------------------------------------------
309 fHijing->GenerateEvent();
311 if (fTrigger != kNoTrigger) {
312 if (!CheckTrigger()) continue;
315 fHijing->ImportParticles(particles,"All");
316 if (fLHC) Boost(particles);
319 Int_t np = particles->GetEntriesFast();
320 printf("\n **************************************************%d\n",np);
322 if (np == 0 ) continue;
324 Int_t* newPos = new Int_t[np];
325 Int_t* pSelected = new Int_t[np];
327 for (i = 0; i < np; i++) {
334 TParticle * iparticle = (TParticle *) particles->At(0);
335 fEventVertex[0] = origin0[0];
336 fEventVertex[1] = origin0[1];
337 fEventVertex[2] = origin0[2];
340 // First select parent particles
343 for (i = 0; i < np; i++) {
344 iparticle = (TParticle *) particles->At(i);
345 // Is this a parent particle ?
346 if (Stable(iparticle)) continue;
348 Bool_t selected = kTRUE;
349 Bool_t hasSelectedDaughters = kFALSE;
352 kf = iparticle->GetPdgCode();
353 ks = iparticle->GetStatusCode();
354 if (kf == 92) continue;
356 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
358 hasSelectedDaughters = DaughtersSelection(iparticle, particles);
360 // Put particle on the stack if it is either selected or
361 // it is the mother of at least one seleted particle
363 if (selected || hasSelectedDaughters) {
367 } // particle loop parents
369 // Now select the final state particles
372 for (i = 0; i<np; i++) {
373 TParticle * iparticle = (TParticle *) particles->At(i);
374 // Is this a final state particle ?
375 if (!Stable(iparticle)) continue;
377 Bool_t selected = kTRUE;
378 kf = iparticle->GetPdgCode();
379 ks = iparticle->GetStatusCode();
380 // --------------------------------------------------------------------------
381 // Count spectator neutrons and protons
382 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
383 if(kf == kNeutron) fSpecn += 1;
384 if(kf == kProton) fSpecp += 1;
386 // --------------------------------------------------------------------------
389 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
390 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
394 // Put particle on the stack if selected
400 } // particle loop final state
402 // Write particles to stack
404 for (i = 0; i<np; i++) {
405 TParticle * iparticle = (TParticle *) particles->At(i);
406 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
407 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
410 kf = iparticle->GetPdgCode();
411 p[0] = iparticle->Px();
412 p[1] = iparticle->Py();
413 p[2] = iparticle->Pz();
414 origin[0] = origin0[0]+iparticle->Vx()/10;
415 origin[1] = origin0[1]+iparticle->Vy()/10;
416 origin[2] = origin0[2]+iparticle->Vz()/10;
417 tof = kconv*iparticle->T();
419 TParticle* mother = 0;
421 imo = iparticle->GetFirstMother();
422 mother = (TParticle *) particles->At(imo);
423 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
425 Bool_t tFlag = (fTrackIt && !hasDaughter);
426 SetTrack(tFlag,imo,kf,p,origin,polar,
435 printf("\n I've put %i particles on the stack \n",nc);
438 if (jev >= fNpart || fNpart == -1) {
439 fKineBias = Float_t(fNpart)/Float_t(fTrials);
440 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
446 SetHighWaterMark(nt);
449 void AliGenHijing::KeepFullEvent()
454 void AliGenHijing::EvaluateCrossSections()
456 // Glauber Calculation of geometrical x-section
458 Float_t xTot = 0.; // barn
459 Float_t xTotHard = 0.; // barn
460 Float_t xPart = 0.; // barn
461 Float_t xPartHard = 0.; // barn
462 Float_t sigmaHard = 0.1; // mbarn
464 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
465 const Float_t kdib = 0.2;
466 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
469 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
470 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
472 Float_t oldvalue= 0.;
474 Float_t* b = new Float_t[kMax];
475 Float_t* si1 = new Float_t[kMax];
476 Float_t* si2 = new Float_t[kMax];
478 for (i = 0; i < kMax; i++)
480 Float_t xb = bMin+i*kdib;
482 ov=fHijing->Profile(xb);
483 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
484 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
487 if (xb > fMinImpactParam && xb < fMaxImpactParam)
493 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
495 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
496 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
504 printf("\n Total cross section (barn): %f \n",xTot);
505 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
506 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
507 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
509 // Store result as a graph
514 fDsigmaDb = new TGraph(i, b, si1);
515 fDnDb = new TGraph(i, b, si2);
518 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
521 // Looks recursively if one of the daughters has been selected
523 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
527 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
528 Bool_t selected = kFALSE;
530 imin = iparticle->GetFirstDaughter();
531 imax = iparticle->GetLastDaughter();
532 for (i = imin; i <= imax; i++){
533 TParticle * jparticle = (TParticle *) particles->At(i);
534 Int_t ip = jparticle->GetPdgCode();
535 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
536 selected=kTRUE; break;
538 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
547 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
549 // Select flavor of particle
551 // 4: charm and beauty
558 Int_t ifl = TMath::Abs(pid/100);
559 if (ifl > 10) ifl/=10;
560 res = (fFlavor == ifl);
563 // This part if gamma writing is inhibited
565 res = res && (pid != kGamma && pid != kPi0);
570 Bool_t AliGenHijing::Stable(TParticle* particle)
572 // Return true for a stable particle
575 if (particle->GetFirstDaughter() < 0 )
584 void AliGenHijing::Boost(TClonesArray* particles)
587 // Boost cms into LHC lab frame
589 Double_t dy = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
590 (Double_t(fZTarget) * Double_t(fAProjectile)));
591 Double_t beta = TMath::TanH(dy);
592 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
593 Double_t gb = gamma * beta;
595 printf("\n Boosting particles to lab frame %f %f %f", dy, beta, gamma);
598 Int_t np = particles->GetEntriesFast();
599 for (i = 0; i < np; i++)
601 TParticle* iparticle = (TParticle*) particles->At(i);
603 Double_t e = iparticle->Energy();
604 Double_t px = iparticle->Px();
605 Double_t py = iparticle->Py();
606 Double_t pz = iparticle->Pz();
608 Double_t eb = gamma * e - gb * pz;
609 Double_t pzb = -gb * e + gamma * pz;
611 iparticle->SetMomentum(px, py, pzb, eb);
616 void AliGenHijing::MakeHeader()
618 // Builds the event header, to be called after each event
619 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
620 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
621 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
622 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
623 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
624 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
625 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
629 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
631 // 4-momentum vectors of the triggered jets.
633 // Before final state gluon radiation.
634 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
635 fHijing->GetHINT1(22),
636 fHijing->GetHINT1(23),
637 fHijing->GetHINT1(24));
639 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
640 fHijing->GetHINT1(32),
641 fHijing->GetHINT1(33),
642 fHijing->GetHINT1(34));
643 // After final state gluon radiation.
644 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
645 fHijing->GetHINT1(27),
646 fHijing->GetHINT1(28),
647 fHijing->GetHINT1(29));
649 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
650 fHijing->GetHINT1(37),
651 fHijing->GetHINT1(38),
652 fHijing->GetHINT1(39));
653 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
654 // Bookkeeping for kinematic bias
655 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
657 header->SetPrimaryVertex(fEventVertex);
658 gAlice->SetGenEventHeader(header);
661 Bool_t AliGenHijing::CheckTrigger()
663 // Check the kinematic trigger condition
665 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
666 fHijing->GetHINT1(27),
667 fHijing->GetHINT1(28),
668 fHijing->GetHINT1(29));
670 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
671 fHijing->GetHINT1(37),
672 fHijing->GetHINT1(38),
673 fHijing->GetHINT1(39));
674 Double_t eta1 = jet1->Eta();
675 Double_t eta2 = jet2->Eta();
676 Double_t phi1 = jet1->Phi();
677 Double_t phi2 = jet2->Phi();
678 Bool_t triggered = kFALSE;
679 //Check eta range first...
680 if ((eta1 < fEtaMaxJet && eta1 > fEtaMinJet) ||
681 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet))
683 //Eta is okay, now check phi range
684 if ((phi1 < fPhiMaxJet && phi1 > fPhiMinJet) ||
685 (phi2 < fPhiMaxJet && phi2 > fPhiMinJet))
696 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
698 // Assignment operator
703 # define rluget_hijing rluget_hijing_
704 # define rluset_hijing rluset_hijing_
705 # define rlu_hijing rlu_hijing_
706 # define type_of_call
708 # define rluget_hijing RLUGET_HIJING
709 # define rluset_hijing RLUSET_HIJING
710 # define rlu_hijing RLU_HIJING
711 # define type_of_call _stdcall
716 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
717 {printf("Dummy version of rluget_hijing reached\n");}
719 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
720 {printf("Dummy version of rluset_hijing reached\n");}
722 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
725 do r=sRandom->Rndm(); while(0 >= r || r >= 1);