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 // Generator using HIJING as an external generator
19 // The main HIJING options are accessable for the user through this interface.
20 // Uses the THijing implementation of TGenerator.
22 // Andreas Morsch (andreas.morsch@cern.ch)
25 #include <TClonesArray.h>
28 #include <TLorentzVector.h>
30 #include <TParticle.h>
32 #include "AliGenHijing.h"
33 #include "AliGenHijingEventHeader.h"
34 #include "AliHijingRndm.h"
38 ClassImp(AliGenHijing)
40 AliGenHijing::AliGenHijing()
66 fPhiMaxJet(2. * TMath::Pi()),
76 fNoHeavyQuarks(kFALSE),
77 fHeader(AliGenHijingEventHeader("Hijing")),
83 AliHijingRndm::SetHijingRandom(GetRandom());
86 AliGenHijing::AliGenHijing(Int_t npart)
112 fPhiMaxJet(2. * TMath::Pi()),
122 fNoHeavyQuarks(kFALSE),
123 fHeader(AliGenHijingEventHeader("Hijing")),
127 // Default PbPb collisions at 5. 5 TeV
131 fTitle= "Particle Generator using HIJING";
134 // Set random number generator
135 AliHijingRndm::SetHijingRandom(GetRandom());
139 AliGenHijing::~AliGenHijing()
142 if ( fDsigmaDb) delete fDsigmaDb;
143 if ( fDnDb) delete fDnDb;
146 void AliGenHijing::Init()
151 fProjectile.Resize(8);
153 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
154 fAProjectile, fZProjectile, fATarget, fZTarget,
155 fMinImpactParam, fMaxImpactParam));
157 fHijing=(THijing*) fMCEvGen;
158 fHijing->SetIHPR2(2, fRadiation);
159 fHijing->SetIHPR2(3, fTrigger);
160 fHijing->SetIHPR2(6, fShadowing);
161 fHijing->SetIHPR2(12, fDecaysOff);
162 fHijing->SetIHPR2(21, fKeep);
163 fHijing->SetHIPR1(8, fPtHardMin);
164 fHijing->SetHIPR1(9, fPtHardMax);
165 fHijing->SetHIPR1(10, fPtMinJet);
167 fHijing->SetHIPR1(31, fSigmaNN/2.);
168 fHijing->SetHIPR1(50, fSimpleJet);
170 // Switching off elastic scattering
172 fHijing->SetIHPR2(14, 0);
177 // fQuench = 0: no quenching
178 // fQuench = 1: hijing default
179 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
180 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
181 // fQuench = 4: new LHC parameters with log(e) dependence
182 // fQuench = 5: new RHIC parameters with log(e) dependence
183 fHijing->SetIHPR2(50, 0);
185 fHijing->SetIHPR2(4, 1);
187 fHijing->SetIHPR2(4, 0);
188 // New LHC parameters from Xin-Nian Wang
190 fHijing->SetHIPR1(14, 1.1);
191 fHijing->SetHIPR1(11, 3.7);
192 } else if (fQuench == 3) {
193 fHijing->SetHIPR1(14, 0.20);
194 fHijing->SetHIPR1(11, 2.5);
195 } else if (fQuench == 4) {
196 fHijing->SetIHPR2(50, 1);
197 fHijing->SetHIPR1(14, 4.*0.34);
198 fHijing->SetHIPR1(11, 3.7);
199 } else if (fQuench == 5) {
200 fHijing->SetIHPR2(50, 1);
201 fHijing->SetHIPR1(14, 0.34);
202 fHijing->SetHIPR1(11, 2.5);
208 if (fNoHeavyQuarks) {
209 fHijing->SetIHPR2(49, 1);
211 fHijing->SetIHPR2(49, 0);
220 fHijing->Initialize();
222 if (fEvaluate) EvaluateCrossSections();
226 void AliGenHijing::SetSeed(UInt_t seed)
228 AliHijingRndm::GetHijingRandom()->SetSeed(seed);
231 void AliGenHijing::Generate()
233 // Generate one event
235 Float_t polar[3] = {0,0,0};
236 Float_t origin[3] = {0,0,0};
237 Float_t origin0[3] = {0,0,0};
242 // converts from mm/c to s
243 const Float_t kconv = 0.001/2.99792458e8;
247 Int_t j, kf, ks, ksp, imo;
254 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
257 if(fVertexSmear == kPerEvent) {
259 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
264 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
268 // Generate one event
269 // --------------------------------------------------------------------------
270 fProjectileSpecn = 0;
271 fProjectileSpecp = 0;
274 // --------------------------------------------------------------------------
275 fHijing->GenerateEvent();
278 fHijing->ImportParticles(&fParticles,"All");
279 if (fTrigger != kNoTrigger) {
280 if (!CheckTrigger()) continue;
285 Int_t np = fParticles.GetEntriesFast();
287 if (np == 0 ) continue;
289 Int_t* newPos = new Int_t[np];
290 Int_t* pSelected = new Int_t[np];
292 for (i = 0; i < np; i++) {
299 fVertex[0] = origin0[0];
300 fVertex[1] = origin0[1];
301 fVertex[2] = origin0[2];
304 // First select parent particles
306 TParticle * iparticle = 0;
307 for (i = 0; i < np; i++) {
308 iparticle = (TParticle *) fParticles.At(i);
310 // Is this a parent particle ?
311 if (Stable(iparticle)) continue;
313 Bool_t selected = kTRUE;
314 Bool_t hasSelectedDaughters = kFALSE;
317 kf = iparticle->GetPdgCode();
318 ks = iparticle->GetStatusCode();
319 if (kf == 92) continue;
321 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
323 hasSelectedDaughters = DaughtersSelection(iparticle);
325 // Put particle on the stack if it is either selected or
326 // it is the mother of at least one seleted particle
328 if (selected || hasSelectedDaughters) {
332 } // particle loop parents
334 // Now select the final state particles
337 for (i = 0; i<np; i++) {
338 iparticle = (TParticle *) fParticles.At(i);
339 // Is this a final state particle ?
340 if (!Stable(iparticle)) continue;
342 Bool_t selected = kTRUE;
343 kf = iparticle->GetPdgCode();
344 ks = iparticle->GetStatusCode();
345 ksp = iparticle->GetUniqueID();
347 // --------------------------------------------------------------------------
348 // Count spectator neutrons and protons
349 if(ksp == 0 || ksp == 1){
350 if(kf == kNeutron) fProjectileSpecn += 1;
351 if(kf == kProton) fProjectileSpecp += 1;
353 else if(ksp == 10 || ksp == 11){
354 if(kf == kNeutron) fTargetSpecn += 1;
355 if(kf == kProton) fTargetSpecp += 1;
357 // --------------------------------------------------------------------------
360 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
361 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
365 // Put particle on the stack if selected
371 } // particle loop final state
374 // Write particles to stack
376 for (i = 0; i<np; i++) {
377 iparticle = (TParticle *) fParticles.At(i);
378 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
379 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
381 kf = iparticle->GetPdgCode();
382 ks = iparticle->GetStatusCode();
383 p[0] = iparticle->Px();
384 p[1] = iparticle->Py();
385 p[2] = iparticle->Pz() * sign;
386 origin[0] = origin0[0]+iparticle->Vx()/10;
387 origin[1] = origin0[1]+iparticle->Vy()/10;
388 origin[2] = origin0[2]+iparticle->Vz()/10;
389 tof = time0+kconv * iparticle->T();
392 TParticle* mother = 0;
394 imo = iparticle->GetFirstMother();
395 mother = (TParticle *) fParticles.At(imo);
396 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
398 Bool_t tFlag = (fTrackIt && !hasDaughter);
399 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
408 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
411 if (jev >= fNpart || fNpart == -1) {
412 fKineBias = Float_t(fNpart)/Float_t(fTrials);
413 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
420 SetHighWaterMark(nt);
423 void AliGenHijing::KeepFullEvent()
428 void AliGenHijing::EvaluateCrossSections()
430 // Glauber Calculation of geometrical x-section
432 Float_t xTot = 0.; // barn
433 Float_t xTotHard = 0.; // barn
434 Float_t xPart = 0.; // barn
435 Float_t xPartHard = 0.; // barn
436 Float_t sigmaHard = 0.1; // mbarn
438 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
439 const Float_t kdib = 0.2;
440 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
443 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
444 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
445 printf("\n Inelastic and total cross section (mb) %f %f \n",fHijing->GetHINT1(12), fHijing->GetHINT1(13));
447 Float_t oldvalue= 0.;
449 Float_t* b = new Float_t[kMax];
450 Float_t* si1 = new Float_t[kMax];
451 Float_t* si2 = new Float_t[kMax];
452 for (i = 0; i < kMax; i++){
458 for (i = 0; i < kMax; i++)
460 Float_t xb = bMin+i*kdib;
462 ov=fHijing->Profile(xb);
463 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
464 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
467 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
469 if (xb > fMinImpactParam && xb < fMaxImpactParam)
475 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
477 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
478 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
486 printf("\n Total cross section (barn): %f \n",xTot);
487 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
488 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
489 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
491 // Store result as a graph
496 fDsigmaDb = new TGraph(i, b, si1);
497 fDnDb = new TGraph(i, b, si2);
500 Bool_t AliGenHijing::DaughtersSelection(const TParticle* iparticle)
503 // Looks recursively if one of the daughters has been selected
505 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
509 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
510 Bool_t selected = kFALSE;
512 imin = iparticle->GetFirstDaughter();
513 imax = iparticle->GetLastDaughter();
514 for (i = imin; i <= imax; i++){
515 TParticle * jparticle = (TParticle *) fParticles.At(i);
516 Int_t ip = jparticle->GetPdgCode();
517 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
518 selected=kTRUE; break;
520 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
529 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
531 // Select flavor of particle
533 // 4: charm and beauty
540 Int_t ifl = TMath::Abs(pid/100);
541 if (ifl > 10) ifl/=10;
542 res = (fFlavor == ifl);
545 // This part if gamma writing is inhibited
547 res = res && (pid != kGamma && pid != kPi0);
552 Bool_t AliGenHijing::Stable(const TParticle* particle) const
554 // Return true for a stable particle
557 if (particle->GetFirstDaughter() < 0 )
567 void AliGenHijing::MakeHeader()
569 // Builds the event header, to be called after each event
570 fHeader.SetNProduced(fNprimaries);
571 fHeader.SetImpactParameter(fHijing->GetHINT1(19));
572 fHeader.SetTotalEnergy(fHijing->GetEATT());
573 fHeader.SetHardScatters(fHijing->GetJATT());
574 fHeader.SetParticipants(fHijing->GetNP(), fHijing->GetNT());
575 fHeader.SetCollisions(fHijing->GetN0(),
579 fHeader.SetSpectators(fProjectileSpecn, fProjectileSpecp,
580 fTargetSpecn,fTargetSpecp);
581 fHeader.SetReactionPlaneAngle(fHijing->GetHINT1(20));
582 fHeader.SetTrueNPart(fHijing->GetNPART());
584 // 4-momentum vectors of the triggered jets.
586 // Before final state gluon radiation.
587 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
588 fHijing->GetHINT1(22),
589 fHijing->GetHINT1(23),
590 fHijing->GetHINT1(24));
592 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
593 fHijing->GetHINT1(32),
594 fHijing->GetHINT1(33),
595 fHijing->GetHINT1(34));
596 // After final state gluon radiation.
597 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
598 fHijing->GetHINT1(27),
599 fHijing->GetHINT1(28),
600 fHijing->GetHINT1(29));
602 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
603 fHijing->GetHINT1(37),
604 fHijing->GetHINT1(38),
605 fHijing->GetHINT1(39));
606 fHeader.SetJets(jet1, jet2, jet3, jet4);
607 // Bookkeeping for kinematic bias
608 fHeader.SetTrials(fTrials);
610 fHeader.SetPrimaryVertex(fVertex);
611 fHeader.SetInteractionTime(fTime);
613 Int_t nsd1 = 0,nsd2 = 0,ndd = 0;
614 Int_t nT = fHijing->GetNT();
615 Int_t nP = fHijing->GetNP();
616 for (Int_t i = 1; i <= nP; ++i) {
617 for (Int_t j = 1; j <= nT; ++j) {
618 Int_t tp = fHijing->GetNFP(i, 5);
619 Int_t tt = fHijing->GetNFT(j, 5);
624 if (tp == 2 && tt == 2)
628 fHeader.SetNDiffractive(nsd1, nsd2, ndd);
630 fCollisionGeometry = &fHeader;
634 Bool_t AliGenHijing::CheckTrigger()
636 // Check the kinematic trigger condition
638 Bool_t triggered = kFALSE;
644 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
645 fHijing->GetHINT1(27),
646 fHijing->GetHINT1(28),
647 fHijing->GetHINT1(29));
649 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
650 fHijing->GetHINT1(37),
651 fHijing->GetHINT1(38),
652 fHijing->GetHINT1(39));
653 Double_t eta1 = jet1->Eta();
654 Double_t eta2 = jet2->Eta();
655 Double_t phi1 = jet1->Phi();
656 Double_t phi2 = jet2->Phi();
657 // printf("\n Trigger: %f %f %f %f",
658 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
660 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
661 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
663 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
664 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
667 } else if (fTrigger == 2) {
670 Int_t np = fParticles.GetEntriesFast();
671 for (Int_t i = 0; i < np; i++) {
672 TParticle* part = (TParticle*) fParticles.At(i);
673 Int_t kf = part->GetPdgCode();
674 Int_t ksp = part->GetUniqueID();
675 if (kf == 22 && ksp == 40) {
676 Float_t phi = part->Phi();
677 Float_t eta = part->Eta();
678 if (eta < fEtaMaxJet &&
684 } // check phi,eta within limits