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.44 2002/10/14 14:55:35 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.42.4.1 2002/08/28 15:06:50 alibrary
24 Revision 1.43 2002/08/09 12:09:52 morsch
25 Direct gamma trigger correctly included.
27 Revision 1.42 2002/03/12 11:07:08 morsch
28 Add status code of particle to SetTrack call.
30 Revision 1.41 2002/03/05 11:25:33 morsch
31 - New quenching options
32 - Correction in CheckTrigger()
34 Revision 1.40 2002/02/12 11:05:53 morsch
35 Get daughter indices right.
37 Revision 1.39 2002/02/12 09:16:39 morsch
38 Correction in SelectFlavor()
40 Revision 1.38 2002/02/12 08:53:21 morsch
41 SetNoGammas can be used to inhibit writing of gammas and pi0.
43 Revision 1.37 2002/02/08 16:50:50 morsch
44 Add name and title in constructor.
46 Revision 1.36 2002/01/31 20:17:55 morsch
47 Allow for triggered jets with simplified topology: Exact pT, back-to-back
49 Revision 1.35 2001/12/13 07:56:25 hristov
50 Set pointers to zero in the default constructor
52 Revision 1.34 2001/12/11 16:55:42 morsch
53 Correct initialization for jet phi-range.
55 Revision 1.33 2001/12/05 10:18:51 morsch
56 Possibility of kinematic biasing of jet phi range. (J. Klay)
58 Revision 1.32 2001/11/28 13:51:11 morsch
59 Introduce kinematic biasing (etamin, etamax) of jet trigger. Bookkeeping
60 (number of trials) done in AliGenHijingEventHeader.
62 Revision 1.31 2001/11/06 12:30:34 morsch
63 Add Boost() method to boost all particles to LHC lab frame. Needed for asymmetric collision systems.
65 Revision 1.30 2001/10/21 18:35:56 hristov
66 Several pointers were set to zero in the default constructors to avoid memory management problems
68 Revision 1.29 2001/10/15 08:12:24 morsch
69 - Vertex smearing with truncated gaussian.
70 - Store triggered jet info before and after final state radiation into mc-heade
72 Revision 1.28 2001/10/08 11:55:25 morsch
73 Store 4-momenta of trigegred jets in event header.
74 Possibility to switch of initial and final state radiation.
76 Revision 1.27 2001/10/08 07:13:14 morsch
77 Add setter for minimum transverse momentum of triggered jet.
79 Revision 1.26 2001/10/04 08:12:24 morsch
80 Redefinition of stable condition.
82 Revision 1.25 2001/07/27 17:09:36 morsch
83 Use local SetTrack, KeepTrack and SetHighWaterMark methods
84 to delegate either to local stack or to stack owned by AliRun.
85 (Piotr Skowronski, A.M.)
87 Revision 1.24 2001/07/20 09:34:56 morsch
88 Count the number of spectator neutrons and protons and add information
89 to the event header. (Chiara Oppedisano)
91 Revision 1.23 2001/07/13 17:30:22 morsch
94 Revision 1.22 2001/06/11 13:09:23 morsch
95 - Store cross-Section and number of binary collisions as a function of impact parameter
96 - Pass AliGenHijingEventHeader to gAlice.
98 Revision 1.21 2001/02/28 17:35:24 morsch
99 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
101 Revision 1.20 2001/02/14 15:50:40 hristov
102 The last particle in event marked using SetHighWaterMark
104 Revision 1.19 2000/12/21 16:24:06 morsch
105 Coding convention clean-up
107 Revision 1.18 2000/12/06 17:46:30 morsch
108 Avoid random numbers 1 and 0.
110 Revision 1.17 2000/12/04 11:22:03 morsch
111 Init of sRandom as in 1.15
113 Revision 1.16 2000/12/02 11:41:39 morsch
114 Use SetRandom() to initialize random number generator in constructor.
116 Revision 1.15 2000/11/30 20:29:02 morsch
117 Initialise static variable sRandom in constructor: sRandom = fRandom;
119 Revision 1.14 2000/11/30 07:12:50 alibrary
120 Introducing new Rndm and QA classes
122 Revision 1.13 2000/11/09 17:40:27 morsch
123 Possibility to select/unselect spectator protons and neutrons.
124 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
126 Revision 1.12 2000/10/20 13:38:38 morsch
127 Debug printouts commented.
129 Revision 1.11 2000/10/20 13:22:26 morsch
130 - skip particle type 92 (string)
131 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
134 Revision 1.10 2000/10/17 15:10:20 morsch
135 Write first all the parent particles to the stack and then the final state particles.
137 Revision 1.9 2000/10/17 13:38:59 morsch
138 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
140 Revision 1.8 2000/10/17 12:46:31 morsch
141 Protect EvaluateCrossSections() against division by zero.
143 Revision 1.7 2000/10/02 21:28:06 fca
144 Removal of useless dependecies via forward declarations
146 Revision 1.6 2000/09/11 13:23:37 morsch
147 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
148 luget_hijing and luset_hijing.
150 Revision 1.5 2000/09/07 16:55:40 morsch
151 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
153 Revision 1.4 2000/07/11 18:24:56 fca
154 Coding convention corrections + few minor bug fixes
156 Revision 1.3 2000/06/30 12:08:36 morsch
157 In member data: char* replaced by TString, Init takes care of resizing the strings to
158 8 characters required by Hijing.
160 Revision 1.2 2000/06/15 14:15:05 morsch
161 Add possibility for heavy flavor selection: charm and beauty.
163 Revision 1.1 2000/06/09 20:47:27 morsch
164 AliGenerator interface class to HIJING using THijing (test version)
170 // Generator using HIJING as an external generator
171 // The main HIJING options are accessable for the user through this interface.
172 // Uses the THijing implementation of TGenerator.
174 // andreas.morsch@cern.ch
176 #include "AliGenHijing.h"
177 #include "AliGenHijingEventHeader.h"
182 #include <TParticle.h>
185 #include <TLorentzVector.h>
188 ClassImp(AliGenHijing)
190 AliGenHijing::AliGenHijing()
200 AliGenHijing::AliGenHijing(Int_t npart)
203 // Default PbPb collisions at 5. 5 TeV
206 fTitle= "Particle Generator using HIJING";
209 SetImpactParameterRange();
234 fParticles = new TClonesArray("TParticle",10000);
236 // Set random number generator
242 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
248 AliGenHijing::~AliGenHijing()
251 if ( fDsigmaDb) delete fDsigmaDb;
252 if ( fDnDb) delete fDnDb;
256 void AliGenHijing::Init()
261 fProjectile.Resize(8);
263 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
264 fAProjectile, fZProjectile, fATarget, fZTarget,
265 fMinImpactParam, fMaxImpactParam));
267 fHijing=(THijing*) fgMCEvGen;
268 fHijing->SetIHPR2(2, fRadiation);
269 fHijing->SetIHPR2(3, fTrigger);
270 fHijing->SetIHPR2(6, fShadowing);
271 fHijing->SetIHPR2(12, fDecaysOff);
272 fHijing->SetIHPR2(21, fKeep);
273 fHijing->SetHIPR1(10, fPtMinJet);
274 fHijing->SetHIPR1(50, fSimpleJet);
279 // fQuench = 0: no quenching
280 // fQuench = 1: hijing default
281 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
282 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
283 // fQuench = 4: new LHC parameters with log(e) dependence
284 // fQuench = 5: new RHIC parameters with log(e) dependence
285 fHijing->SetIHPR2(50, 0);
287 fHijing->SetIHPR2(4, 1);
289 fHijing->SetIHPR2(4, 0);
290 // New LHC parameters from Xin-Nian Wang
292 fHijing->SetHIPR1(14, 1.1);
293 fHijing->SetHIPR1(11, 3.7);
294 } else if (fQuench == 3) {
295 fHijing->SetHIPR1(14, 0.20);
296 fHijing->SetHIPR1(11, 2.5);
297 } else if (fQuench == 4) {
298 fHijing->SetIHPR2(50, 1);
299 fHijing->SetHIPR1(14, 4.*0.34);
300 fHijing->SetHIPR1(11, 3.7);
301 } else if (fQuench == 5) {
302 fHijing->SetIHPR2(50, 1);
303 fHijing->SetHIPR1(14, 0.34);
304 fHijing->SetHIPR1(11, 2.5);
312 fHijing->Initialize();
314 if (fEvaluate) EvaluateCrossSections();
318 void AliGenHijing::Generate()
320 // Generate one event
322 Float_t polar[3] = {0,0,0};
323 Float_t origin[3] = {0,0,0};
324 Float_t origin0[3] = {0,0,0};
325 Float_t p[3], random[6];
328 // converts from mm/c to s
329 const Float_t kconv = 0.001/2.999792458e8;
333 Int_t j, kf, ks, imo;
339 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
340 if(fVertexSmear == kPerEvent) {
343 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
345 for (j=0; j < 3; j++) {
346 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
347 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
350 for (j=0; j < 3; j++) origin0[j] += dv[j];
351 } else if (fVertexSmear == kPerTrack) {
352 // fHijing->SetMSTP(151,0);
353 for (j = 0; j < 3; j++) {
354 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
359 // Generate one event
360 // --------------------------------------------------------------------------
363 // --------------------------------------------------------------------------
364 fHijing->GenerateEvent();
366 fHijing->ImportParticles(fParticles,"All");
367 if (fTrigger != kNoTrigger) {
368 if (!CheckTrigger()) continue;
373 Int_t np = fParticles->GetEntriesFast();
374 printf("\n **************************************************%d\n",np);
376 if (np == 0 ) continue;
378 Int_t* newPos = new Int_t[np];
379 Int_t* pSelected = new Int_t[np];
381 for (i = 0; i < np; i++) {
388 TParticle * iparticle = (TParticle *) fParticles->At(0);
389 fEventVertex[0] = origin0[0];
390 fEventVertex[1] = origin0[1];
391 fEventVertex[2] = origin0[2];
394 // First select parent particles
397 for (i = 0; i < np; i++) {
398 iparticle = (TParticle *) fParticles->At(i);
400 // Is this a parent particle ?
401 if (Stable(iparticle)) continue;
403 Bool_t selected = kTRUE;
404 Bool_t hasSelectedDaughters = kFALSE;
407 kf = iparticle->GetPdgCode();
408 ks = iparticle->GetStatusCode();
409 if (kf == 92) continue;
411 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
413 hasSelectedDaughters = DaughtersSelection(iparticle);
415 // Put particle on the stack if it is either selected or
416 // it is the mother of at least one seleted particle
418 if (selected || hasSelectedDaughters) {
422 } // particle loop parents
424 // Now select the final state particles
427 for (i = 0; i<np; i++) {
428 TParticle * iparticle = (TParticle *) fParticles->At(i);
429 // Is this a final state particle ?
430 if (!Stable(iparticle)) continue;
432 Bool_t selected = kTRUE;
433 kf = iparticle->GetPdgCode();
434 ks = iparticle->GetStatusCode();
436 // --------------------------------------------------------------------------
437 // Count spectator neutrons and protons
438 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
439 if(kf == kNeutron) fSpecn += 1;
440 if(kf == kProton) fSpecp += 1;
442 // --------------------------------------------------------------------------
445 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
446 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
450 // Put particle on the stack if selected
456 } // particle loop final state
458 // Write particles to stack
460 for (i = 0; i<np; i++) {
461 TParticle * iparticle = (TParticle *) fParticles->At(i);
462 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
463 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
466 kf = iparticle->GetPdgCode();
467 ks = iparticle->GetStatusCode();
468 p[0] = iparticle->Px();
469 p[1] = iparticle->Py();
470 p[2] = iparticle->Pz();
471 origin[0] = origin0[0]+iparticle->Vx()/10;
472 origin[1] = origin0[1]+iparticle->Vy()/10;
473 origin[2] = origin0[2]+iparticle->Vz()/10;
474 tof = kconv*iparticle->T();
476 TParticle* mother = 0;
478 imo = iparticle->GetFirstMother();
479 mother = (TParticle *) fParticles->At(imo);
480 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
482 Bool_t tFlag = (fTrackIt && !hasDaughter);
483 SetTrack(tFlag,imo,kf,p,origin,polar,
484 tof,kPNoProcess,nt, 1., ks);
492 printf("\n I've put %i particles on the stack \n",nc);
495 if (jev >= fNpart || fNpart == -1) {
496 fKineBias = Float_t(fNpart)/Float_t(fTrials);
497 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
503 SetHighWaterMark(nt);
506 void AliGenHijing::KeepFullEvent()
511 void AliGenHijing::EvaluateCrossSections()
513 // Glauber Calculation of geometrical x-section
515 Float_t xTot = 0.; // barn
516 Float_t xTotHard = 0.; // barn
517 Float_t xPart = 0.; // barn
518 Float_t xPartHard = 0.; // barn
519 Float_t sigmaHard = 0.1; // mbarn
521 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
522 const Float_t kdib = 0.2;
523 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
526 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
527 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
529 Float_t oldvalue= 0.;
531 Float_t* b = new Float_t[kMax];
532 Float_t* si1 = new Float_t[kMax];
533 Float_t* si2 = new Float_t[kMax];
535 for (i = 0; i < kMax; i++)
537 Float_t xb = bMin+i*kdib;
539 ov=fHijing->Profile(xb);
540 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
541 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
544 if (xb > fMinImpactParam && xb < fMaxImpactParam)
550 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
552 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
553 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
561 printf("\n Total cross section (barn): %f \n",xTot);
562 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
563 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
564 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
566 // Store result as a graph
571 fDsigmaDb = new TGraph(i, b, si1);
572 fDnDb = new TGraph(i, b, si2);
575 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
578 // Looks recursively if one of the daughters has been selected
580 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
584 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
585 Bool_t selected = kFALSE;
587 imin = iparticle->GetFirstDaughter();
588 imax = iparticle->GetLastDaughter();
589 for (i = imin; i <= imax; i++){
590 TParticle * jparticle = (TParticle *) fParticles->At(i);
591 Int_t ip = jparticle->GetPdgCode();
592 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
593 selected=kTRUE; break;
595 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
604 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
606 // Select flavor of particle
608 // 4: charm and beauty
615 Int_t ifl = TMath::Abs(pid/100);
616 if (ifl > 10) ifl/=10;
617 res = (fFlavor == ifl);
620 // This part if gamma writing is inhibited
622 res = res && (pid != kGamma && pid != kPi0);
627 Bool_t AliGenHijing::Stable(TParticle* particle)
629 // Return true for a stable particle
632 if (particle->GetFirstDaughter() < 0 )
641 void AliGenHijing::Boost()
644 // Boost cms into LHC lab frame
646 Double_t dy = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
647 (Double_t(fZTarget) * Double_t(fAProjectile)));
648 Double_t beta = TMath::TanH(dy);
649 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
650 Double_t gb = gamma * beta;
652 printf("\n Boosting particles to lab frame %f %f %f", dy, beta, gamma);
655 Int_t np = fParticles->GetEntriesFast();
656 for (i = 0; i < np; i++)
658 TParticle* iparticle = (TParticle*) fParticles->At(i);
660 Double_t e = iparticle->Energy();
661 Double_t px = iparticle->Px();
662 Double_t py = iparticle->Py();
663 Double_t pz = iparticle->Pz();
665 Double_t eb = gamma * e - gb * pz;
666 Double_t pzb = -gb * e + gamma * pz;
668 iparticle->SetMomentum(px, py, pzb, eb);
673 void AliGenHijing::MakeHeader()
675 // Builds the event header, to be called after each event
676 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
677 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
678 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
679 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
680 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
681 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
682 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
686 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
688 // 4-momentum vectors of the triggered jets.
690 // Before final state gluon radiation.
691 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
692 fHijing->GetHINT1(22),
693 fHijing->GetHINT1(23),
694 fHijing->GetHINT1(24));
696 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
697 fHijing->GetHINT1(32),
698 fHijing->GetHINT1(33),
699 fHijing->GetHINT1(34));
700 // After final state gluon radiation.
701 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
702 fHijing->GetHINT1(27),
703 fHijing->GetHINT1(28),
704 fHijing->GetHINT1(29));
706 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
707 fHijing->GetHINT1(37),
708 fHijing->GetHINT1(38),
709 fHijing->GetHINT1(39));
710 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
711 // Bookkeeping for kinematic bias
712 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
714 header->SetPrimaryVertex(fEventVertex);
715 gAlice->SetGenEventHeader(header);
718 Bool_t AliGenHijing::CheckTrigger()
720 // Check the kinematic trigger condition
722 Bool_t triggered = kFALSE;
728 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
729 fHijing->GetHINT1(27),
730 fHijing->GetHINT1(28),
731 fHijing->GetHINT1(29));
733 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
734 fHijing->GetHINT1(37),
735 fHijing->GetHINT1(38),
736 fHijing->GetHINT1(39));
737 Double_t eta1 = jet1->Eta();
738 Double_t eta2 = jet2->Eta();
739 Double_t phi1 = jet1->Phi();
740 Double_t phi2 = jet2->Phi();
741 // printf("\n Trigger: %f %f %f %f",
742 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
744 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
745 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
747 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
748 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
751 } else if (fTrigger == 2) {
754 Int_t np = fParticles->GetEntriesFast();
755 for (Int_t i = 0; i < np; i++) {
756 TParticle* part = (TParticle*) fParticles->At(i);
757 Int_t kf = part->GetPdgCode();
758 Int_t ks = part->GetStatusCode();
759 if (kf == 22 && ks == 40) {
760 Float_t phi = part->Phi();
761 Float_t eta = part->Eta();
762 if (eta < fEtaMaxJet &&
768 } // check phi,eta within limits
778 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
780 // Assignment operator
785 # define rluget_hijing rluget_hijing_
786 # define rluset_hijing rluset_hijing_
787 # define rlu_hijing rlu_hijing_
788 # define type_of_call
790 # define rluget_hijing RLUGET_HIJING
791 # define rluset_hijing RLUSET_HIJING
792 # define rlu_hijing RLU_HIJING
793 # define type_of_call _stdcall
798 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
799 {printf("Dummy version of rluget_hijing reached\n");}
801 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
802 {printf("Dummy version of rluset_hijing reached\n");}
804 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
807 do r=sRandom->Rndm(); while(0 >= r || r >= 1);