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.46 2003/01/07 14:12:33 morsch
19 Provides collision geometry.
21 Revision 1.45 2002/12/16 09:44:49 morsch
22 Default for fRadiation is 3.
24 Revision 1.44 2002/10/14 14:55:35 hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
27 Revision 1.42.4.1 2002/08/28 15:06:50 alibrary
30 Revision 1.43 2002/08/09 12:09:52 morsch
31 Direct gamma trigger correctly included.
33 Revision 1.42 2002/03/12 11:07:08 morsch
34 Add status code of particle to SetTrack call.
36 Revision 1.41 2002/03/05 11:25:33 morsch
37 - New quenching options
38 - Correction in CheckTrigger()
40 Revision 1.40 2002/02/12 11:05:53 morsch
41 Get daughter indices right.
43 Revision 1.39 2002/02/12 09:16:39 morsch
44 Correction in SelectFlavor()
46 Revision 1.38 2002/02/12 08:53:21 morsch
47 SetNoGammas can be used to inhibit writing of gammas and pi0.
49 Revision 1.37 2002/02/08 16:50:50 morsch
50 Add name and title in constructor.
52 Revision 1.36 2002/01/31 20:17:55 morsch
53 Allow for triggered jets with simplified topology: Exact pT, back-to-back
55 Revision 1.35 2001/12/13 07:56:25 hristov
56 Set pointers to zero in the default constructor
58 Revision 1.34 2001/12/11 16:55:42 morsch
59 Correct initialization for jet phi-range.
61 Revision 1.33 2001/12/05 10:18:51 morsch
62 Possibility of kinematic biasing of jet phi range. (J. Klay)
64 Revision 1.32 2001/11/28 13:51:11 morsch
65 Introduce kinematic biasing (etamin, etamax) of jet trigger. Bookkeeping
66 (number of trials) done in AliGenHijingEventHeader.
68 Revision 1.31 2001/11/06 12:30:34 morsch
69 Add Boost() method to boost all particles to LHC lab frame. Needed for asymmetric collision systems.
71 Revision 1.30 2001/10/21 18:35:56 hristov
72 Several pointers were set to zero in the default constructors to avoid memory management problems
74 Revision 1.29 2001/10/15 08:12:24 morsch
75 - Vertex smearing with truncated gaussian.
76 - Store triggered jet info before and after final state radiation into mc-heade
78 Revision 1.28 2001/10/08 11:55:25 morsch
79 Store 4-momenta of trigegred jets in event header.
80 Possibility to switch of initial and final state radiation.
82 Revision 1.27 2001/10/08 07:13:14 morsch
83 Add setter for minimum transverse momentum of triggered jet.
85 Revision 1.26 2001/10/04 08:12:24 morsch
86 Redefinition of stable condition.
88 Revision 1.25 2001/07/27 17:09:36 morsch
89 Use local SetTrack, KeepTrack and SetHighWaterMark methods
90 to delegate either to local stack or to stack owned by AliRun.
91 (Piotr Skowronski, A.M.)
93 Revision 1.24 2001/07/20 09:34:56 morsch
94 Count the number of spectator neutrons and protons and add information
95 to the event header. (Chiara Oppedisano)
97 Revision 1.23 2001/07/13 17:30:22 morsch
100 Revision 1.22 2001/06/11 13:09:23 morsch
101 - Store cross-Section and number of binary collisions as a function of impact parameter
102 - Pass AliGenHijingEventHeader to gAlice.
104 Revision 1.21 2001/02/28 17:35:24 morsch
105 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
107 Revision 1.20 2001/02/14 15:50:40 hristov
108 The last particle in event marked using SetHighWaterMark
110 Revision 1.19 2000/12/21 16:24:06 morsch
111 Coding convention clean-up
113 Revision 1.18 2000/12/06 17:46:30 morsch
114 Avoid random numbers 1 and 0.
116 Revision 1.17 2000/12/04 11:22:03 morsch
117 Init of sRandom as in 1.15
119 Revision 1.16 2000/12/02 11:41:39 morsch
120 Use SetRandom() to initialize random number generator in constructor.
122 Revision 1.15 2000/11/30 20:29:02 morsch
123 Initialise static variable sRandom in constructor: sRandom = fRandom;
125 Revision 1.14 2000/11/30 07:12:50 alibrary
126 Introducing new Rndm and QA classes
128 Revision 1.13 2000/11/09 17:40:27 morsch
129 Possibility to select/unselect spectator protons and neutrons.
130 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
132 Revision 1.12 2000/10/20 13:38:38 morsch
133 Debug printouts commented.
135 Revision 1.11 2000/10/20 13:22:26 morsch
136 - skip particle type 92 (string)
137 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
140 Revision 1.10 2000/10/17 15:10:20 morsch
141 Write first all the parent particles to the stack and then the final state particles.
143 Revision 1.9 2000/10/17 13:38:59 morsch
144 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
146 Revision 1.8 2000/10/17 12:46:31 morsch
147 Protect EvaluateCrossSections() against division by zero.
149 Revision 1.7 2000/10/02 21:28:06 fca
150 Removal of useless dependecies via forward declarations
152 Revision 1.6 2000/09/11 13:23:37 morsch
153 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
154 luget_hijing and luset_hijing.
156 Revision 1.5 2000/09/07 16:55:40 morsch
157 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
159 Revision 1.4 2000/07/11 18:24:56 fca
160 Coding convention corrections + few minor bug fixes
162 Revision 1.3 2000/06/30 12:08:36 morsch
163 In member data: char* replaced by TString, Init takes care of resizing the strings to
164 8 characters required by Hijing.
166 Revision 1.2 2000/06/15 14:15:05 morsch
167 Add possibility for heavy flavor selection: charm and beauty.
169 Revision 1.1 2000/06/09 20:47:27 morsch
170 AliGenerator interface class to HIJING using THijing (test version)
176 // Generator using HIJING as an external generator
177 // The main HIJING options are accessable for the user through this interface.
178 // Uses the THijing implementation of TGenerator.
180 // andreas.morsch@cern.ch
185 #include <TLorentzVector.h>
186 #include <TPDGCode.h>
187 #include <TParticle.h>
189 #include "AliGenHijing.h"
190 #include "AliGenHijingEventHeader.h"
194 ClassImp(AliGenHijing)
196 AliGenHijing::AliGenHijing()
206 AliGenHijing::AliGenHijing(Int_t npart)
209 // Default PbPb collisions at 5. 5 TeV
212 fTitle= "Particle Generator using HIJING";
215 SetImpactParameterRange();
240 fParticles = new TClonesArray("TParticle",10000);
242 // Set random number generator
248 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
254 AliGenHijing::~AliGenHijing()
257 if ( fDsigmaDb) delete fDsigmaDb;
258 if ( fDnDb) delete fDnDb;
262 void AliGenHijing::Init()
267 fProjectile.Resize(8);
269 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
270 fAProjectile, fZProjectile, fATarget, fZTarget,
271 fMinImpactParam, fMaxImpactParam));
273 fHijing=(THijing*) fgMCEvGen;
274 fHijing->SetIHPR2(2, fRadiation);
275 fHijing->SetIHPR2(3, fTrigger);
276 fHijing->SetIHPR2(6, fShadowing);
277 fHijing->SetIHPR2(12, fDecaysOff);
278 fHijing->SetIHPR2(21, fKeep);
279 fHijing->SetHIPR1(10, fPtMinJet);
280 fHijing->SetHIPR1(50, fSimpleJet);
285 // fQuench = 0: no quenching
286 // fQuench = 1: hijing default
287 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
288 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
289 // fQuench = 4: new LHC parameters with log(e) dependence
290 // fQuench = 5: new RHIC parameters with log(e) dependence
291 fHijing->SetIHPR2(50, 0);
293 fHijing->SetIHPR2(4, 1);
295 fHijing->SetIHPR2(4, 0);
296 // New LHC parameters from Xin-Nian Wang
298 fHijing->SetHIPR1(14, 1.1);
299 fHijing->SetHIPR1(11, 3.7);
300 } else if (fQuench == 3) {
301 fHijing->SetHIPR1(14, 0.20);
302 fHijing->SetHIPR1(11, 2.5);
303 } else if (fQuench == 4) {
304 fHijing->SetIHPR2(50, 1);
305 fHijing->SetHIPR1(14, 4.*0.34);
306 fHijing->SetHIPR1(11, 3.7);
307 } else if (fQuench == 5) {
308 fHijing->SetIHPR2(50, 1);
309 fHijing->SetHIPR1(14, 0.34);
310 fHijing->SetHIPR1(11, 2.5);
318 fHijing->Initialize();
320 if (fEvaluate) EvaluateCrossSections();
324 void AliGenHijing::Generate()
326 // Generate one event
328 Float_t polar[3] = {0,0,0};
329 Float_t origin[3] = {0,0,0};
330 Float_t origin0[3] = {0,0,0};
331 Float_t p[3], random[6];
334 // converts from mm/c to s
335 const Float_t kconv = 0.001/2.999792458e8;
339 Int_t j, kf, ks, imo;
345 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
346 if(fVertexSmear == kPerEvent) {
349 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
351 for (j=0; j < 3; j++) {
352 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
353 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
356 for (j=0; j < 3; j++) origin0[j] += dv[j];
357 } else if (fVertexSmear == kPerTrack) {
358 // fHijing->SetMSTP(151,0);
359 for (j = 0; j < 3; j++) {
360 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
365 // Generate one event
366 // --------------------------------------------------------------------------
369 // --------------------------------------------------------------------------
370 fHijing->GenerateEvent();
372 fHijing->ImportParticles(fParticles,"All");
373 if (fTrigger != kNoTrigger) {
374 if (!CheckTrigger()) continue;
379 Int_t np = fParticles->GetEntriesFast();
380 printf("\n **************************************************%d\n",np);
382 if (np == 0 ) continue;
384 Int_t* newPos = new Int_t[np];
385 Int_t* pSelected = new Int_t[np];
387 for (i = 0; i < np; i++) {
394 TParticle * iparticle = (TParticle *) fParticles->At(0);
395 fEventVertex[0] = origin0[0];
396 fEventVertex[1] = origin0[1];
397 fEventVertex[2] = origin0[2];
400 // First select parent particles
403 for (i = 0; i < np; i++) {
404 iparticle = (TParticle *) fParticles->At(i);
406 // Is this a parent particle ?
407 if (Stable(iparticle)) continue;
409 Bool_t selected = kTRUE;
410 Bool_t hasSelectedDaughters = kFALSE;
413 kf = iparticle->GetPdgCode();
414 ks = iparticle->GetStatusCode();
415 if (kf == 92) continue;
417 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
419 hasSelectedDaughters = DaughtersSelection(iparticle);
421 // Put particle on the stack if it is either selected or
422 // it is the mother of at least one seleted particle
424 if (selected || hasSelectedDaughters) {
428 } // particle loop parents
430 // Now select the final state particles
433 for (i = 0; i<np; i++) {
434 TParticle * iparticle = (TParticle *) fParticles->At(i);
435 // Is this a final state particle ?
436 if (!Stable(iparticle)) continue;
438 Bool_t selected = kTRUE;
439 kf = iparticle->GetPdgCode();
440 ks = iparticle->GetStatusCode();
442 // --------------------------------------------------------------------------
443 // Count spectator neutrons and protons
444 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
445 if(kf == kNeutron) fSpecn += 1;
446 if(kf == kProton) fSpecp += 1;
448 // --------------------------------------------------------------------------
451 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
452 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
456 // Put particle on the stack if selected
462 } // particle loop final state
464 // Write particles to stack
466 for (i = 0; i<np; i++) {
467 TParticle * iparticle = (TParticle *) fParticles->At(i);
468 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
469 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
472 kf = iparticle->GetPdgCode();
473 ks = iparticle->GetStatusCode();
474 p[0] = iparticle->Px();
475 p[1] = iparticle->Py();
476 p[2] = iparticle->Pz();
477 origin[0] = origin0[0]+iparticle->Vx()/10;
478 origin[1] = origin0[1]+iparticle->Vy()/10;
479 origin[2] = origin0[2]+iparticle->Vz()/10;
480 tof = kconv*iparticle->T();
482 TParticle* mother = 0;
484 imo = iparticle->GetFirstMother();
485 mother = (TParticle *) fParticles->At(imo);
486 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
488 Bool_t tFlag = (fTrackIt && !hasDaughter);
489 SetTrack(tFlag,imo,kf,p,origin,polar,
490 tof,kPNoProcess,nt, 1., ks);
498 printf("\n I've put %i particles on the stack \n",nc);
501 if (jev >= fNpart || fNpart == -1) {
502 fKineBias = Float_t(fNpart)/Float_t(fTrials);
503 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
509 SetHighWaterMark(nt);
512 void AliGenHijing::KeepFullEvent()
517 void AliGenHijing::EvaluateCrossSections()
519 // Glauber Calculation of geometrical x-section
521 Float_t xTot = 0.; // barn
522 Float_t xTotHard = 0.; // barn
523 Float_t xPart = 0.; // barn
524 Float_t xPartHard = 0.; // barn
525 Float_t sigmaHard = 0.1; // mbarn
527 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
528 const Float_t kdib = 0.2;
529 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
532 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
533 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
535 Float_t oldvalue= 0.;
537 Float_t* b = new Float_t[kMax];
538 Float_t* si1 = new Float_t[kMax];
539 Float_t* si2 = new Float_t[kMax];
541 for (i = 0; i < kMax; i++)
543 Float_t xb = bMin+i*kdib;
545 ov=fHijing->Profile(xb);
546 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
547 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
550 if (xb > fMinImpactParam && xb < fMaxImpactParam)
556 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
558 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
559 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
567 printf("\n Total cross section (barn): %f \n",xTot);
568 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
569 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
570 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
572 // Store result as a graph
577 fDsigmaDb = new TGraph(i, b, si1);
578 fDnDb = new TGraph(i, b, si2);
581 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
584 // Looks recursively if one of the daughters has been selected
586 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
590 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
591 Bool_t selected = kFALSE;
593 imin = iparticle->GetFirstDaughter();
594 imax = iparticle->GetLastDaughter();
595 for (i = imin; i <= imax; i++){
596 TParticle * jparticle = (TParticle *) fParticles->At(i);
597 Int_t ip = jparticle->GetPdgCode();
598 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
599 selected=kTRUE; break;
601 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
610 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
612 // Select flavor of particle
614 // 4: charm and beauty
621 Int_t ifl = TMath::Abs(pid/100);
622 if (ifl > 10) ifl/=10;
623 res = (fFlavor == ifl);
626 // This part if gamma writing is inhibited
628 res = res && (pid != kGamma && pid != kPi0);
633 Bool_t AliGenHijing::Stable(TParticle* particle)
635 // Return true for a stable particle
638 if (particle->GetFirstDaughter() < 0 )
647 void AliGenHijing::Boost()
650 // Boost cms into LHC lab frame
652 Double_t dy = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
653 (Double_t(fZTarget) * Double_t(fAProjectile)));
654 Double_t beta = TMath::TanH(dy);
655 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
656 Double_t gb = gamma * beta;
658 printf("\n Boosting particles to lab frame %f %f %f", dy, beta, gamma);
661 Int_t np = fParticles->GetEntriesFast();
662 for (i = 0; i < np; i++)
664 TParticle* iparticle = (TParticle*) fParticles->At(i);
666 Double_t e = iparticle->Energy();
667 Double_t px = iparticle->Px();
668 Double_t py = iparticle->Py();
669 Double_t pz = iparticle->Pz();
671 Double_t eb = gamma * e - gb * pz;
672 Double_t pzb = -gb * e + gamma * pz;
674 iparticle->SetMomentum(px, py, pzb, eb);
679 void AliGenHijing::MakeHeader()
681 // Builds the event header, to be called after each event
682 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
683 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
684 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
685 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
686 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
687 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
688 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
692 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
694 // 4-momentum vectors of the triggered jets.
696 // Before final state gluon radiation.
697 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
698 fHijing->GetHINT1(22),
699 fHijing->GetHINT1(23),
700 fHijing->GetHINT1(24));
702 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
703 fHijing->GetHINT1(32),
704 fHijing->GetHINT1(33),
705 fHijing->GetHINT1(34));
706 // After final state gluon radiation.
707 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
708 fHijing->GetHINT1(27),
709 fHijing->GetHINT1(28),
710 fHijing->GetHINT1(29));
712 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
713 fHijing->GetHINT1(37),
714 fHijing->GetHINT1(38),
715 fHijing->GetHINT1(39));
716 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
717 // Bookkeeping for kinematic bias
718 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
720 header->SetPrimaryVertex(fEventVertex);
721 gAlice->SetGenEventHeader(header);
722 fCollisionGeometry = (AliGenHijingEventHeader*) header;
725 Bool_t AliGenHijing::CheckTrigger()
727 // Check the kinematic trigger condition
729 Bool_t triggered = kFALSE;
735 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
736 fHijing->GetHINT1(27),
737 fHijing->GetHINT1(28),
738 fHijing->GetHINT1(29));
740 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
741 fHijing->GetHINT1(37),
742 fHijing->GetHINT1(38),
743 fHijing->GetHINT1(39));
744 Double_t eta1 = jet1->Eta();
745 Double_t eta2 = jet2->Eta();
746 Double_t phi1 = jet1->Phi();
747 Double_t phi2 = jet2->Phi();
748 // printf("\n Trigger: %f %f %f %f",
749 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
751 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
752 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
754 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
755 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
758 } else if (fTrigger == 2) {
761 Int_t np = fParticles->GetEntriesFast();
762 for (Int_t i = 0; i < np; i++) {
763 TParticle* part = (TParticle*) fParticles->At(i);
764 Int_t kf = part->GetPdgCode();
765 Int_t ks = part->GetStatusCode();
766 if (kf == 22 && ks == 40) {
767 Float_t phi = part->Phi();
768 Float_t eta = part->Eta();
769 if (eta < fEtaMaxJet &&
775 } // check phi,eta within limits
785 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
787 // Assignment operator
792 # define rluget_hijing rluget_hijing_
793 # define rluset_hijing rluset_hijing_
794 # define rlu_hijing rlu_hijing_
795 # define type_of_call
797 # define rluget_hijing RLUGET_HIJING
798 # define rluset_hijing RLUSET_HIJING
799 # define rlu_hijing RLU_HIJING
800 # define type_of_call _stdcall
805 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
806 {printf("Dummy version of rluget_hijing reached\n");}
808 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
809 {printf("Dummy version of rluset_hijing reached\n");}
811 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
814 do r=sRandom->Rndm(); while(0 >= r || r >= 1);