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),
78 fHeader(AliGenHijingEventHeader("Hijing"))
82 AliHijingRndm::SetHijingRandom(GetRandom());
85 AliGenHijing::AliGenHijing(Int_t npart)
111 fPhiMaxJet(2. * TMath::Pi()),
121 fNoHeavyQuarks(kFALSE),
123 fHeader(AliGenHijingEventHeader("Hijing"))
125 // Default PbPb collisions at 5. 5 TeV
129 fTitle= "Particle Generator using HIJING";
132 // Set random number generator
133 AliHijingRndm::SetHijingRandom(GetRandom());
137 AliGenHijing::~AliGenHijing()
140 if ( fDsigmaDb) delete fDsigmaDb;
141 if ( fDnDb) delete fDnDb;
144 void AliGenHijing::Init()
149 fProjectile.Resize(8);
151 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
152 fAProjectile, fZProjectile, fATarget, fZTarget,
153 fMinImpactParam, fMaxImpactParam));
155 fHijing=(THijing*) fMCEvGen;
156 fHijing->SetIHPR2(2, fRadiation);
157 fHijing->SetIHPR2(3, fTrigger);
158 fHijing->SetIHPR2(6, fShadowing);
159 fHijing->SetIHPR2(12, fDecaysOff);
160 fHijing->SetIHPR2(21, fKeep);
161 fHijing->SetHIPR1(8, fPtHardMin);
162 fHijing->SetHIPR1(9, fPtHardMax);
163 fHijing->SetHIPR1(10, fPtMinJet);
164 fHijing->SetHIPR1(50, fSimpleJet);
169 // fQuench = 0: no quenching
170 // fQuench = 1: hijing default
171 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
172 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
173 // fQuench = 4: new LHC parameters with log(e) dependence
174 // fQuench = 5: new RHIC parameters with log(e) dependence
175 fHijing->SetIHPR2(50, 0);
177 fHijing->SetIHPR2(4, 1);
179 fHijing->SetIHPR2(4, 0);
180 // New LHC parameters from Xin-Nian Wang
182 fHijing->SetHIPR1(14, 1.1);
183 fHijing->SetHIPR1(11, 3.7);
184 } else if (fQuench == 3) {
185 fHijing->SetHIPR1(14, 0.20);
186 fHijing->SetHIPR1(11, 2.5);
187 } else if (fQuench == 4) {
188 fHijing->SetIHPR2(50, 1);
189 fHijing->SetHIPR1(14, 4.*0.34);
190 fHijing->SetHIPR1(11, 3.7);
191 } else if (fQuench == 5) {
192 fHijing->SetIHPR2(50, 1);
193 fHijing->SetHIPR1(14, 0.34);
194 fHijing->SetHIPR1(11, 2.5);
200 if (fNoHeavyQuarks) {
201 fHijing->SetIHPR2(49, 1);
203 fHijing->SetIHPR2(49, 0);
212 fHijing->Initialize();
214 if (fEvaluate) EvaluateCrossSections();
218 void AliGenHijing::Generate()
220 // Generate one event
222 Float_t polar[3] = {0,0,0};
223 Float_t origin[3] = {0,0,0};
224 Float_t origin0[3] = {0,0,0};
228 // converts from mm/c to s
229 const Float_t kconv = 0.001/2.99792458e8;
233 Int_t j, kf, ks, ksp, imo;
240 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
242 if(fVertexSmear == kPerEvent) {
244 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
248 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
252 // Generate one event
253 // --------------------------------------------------------------------------
254 fProjectileSpecn = 0;
255 fProjectileSpecp = 0;
258 // --------------------------------------------------------------------------
259 fHijing->GenerateEvent();
262 fHijing->ImportParticles(&fParticles,"All");
263 if (fTrigger != kNoTrigger) {
264 if (!CheckTrigger()) continue;
269 Int_t np = fParticles.GetEntriesFast();
271 if (np == 0 ) continue;
273 Int_t* newPos = new Int_t[np];
274 Int_t* pSelected = new Int_t[np];
276 for (i = 0; i < np; i++) {
283 fVertex[0] = origin0[0];
284 fVertex[1] = origin0[1];
285 fVertex[2] = origin0[2];
288 // First select parent particles
290 TParticle * iparticle = 0;
291 for (i = 0; i < np; i++) {
292 iparticle = (TParticle *) fParticles.At(i);
294 // Is this a parent particle ?
295 if (Stable(iparticle)) continue;
297 Bool_t selected = kTRUE;
298 Bool_t hasSelectedDaughters = kFALSE;
301 kf = iparticle->GetPdgCode();
302 ks = iparticle->GetStatusCode();
303 if (kf == 92) continue;
305 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
307 hasSelectedDaughters = DaughtersSelection(iparticle);
309 // Put particle on the stack if it is either selected or
310 // it is the mother of at least one seleted particle
312 if (selected || hasSelectedDaughters) {
316 } // particle loop parents
318 // Now select the final state particles
321 for (i = 0; i<np; i++) {
322 iparticle = (TParticle *) fParticles.At(i);
323 // Is this a final state particle ?
324 if (!Stable(iparticle)) continue;
326 Bool_t selected = kTRUE;
327 kf = iparticle->GetPdgCode();
328 ks = iparticle->GetStatusCode();
329 ksp = iparticle->GetUniqueID();
331 // --------------------------------------------------------------------------
332 // Count spectator neutrons and protons
333 if(ksp == 0 || ksp == 1){
334 if(kf == kNeutron) fProjectileSpecn += 1;
335 if(kf == kProton) fProjectileSpecp += 1;
337 else if(ksp == 10 || ksp == 11){
338 if(kf == kNeutron) fTargetSpecn += 1;
339 if(kf == kProton) fTargetSpecp += 1;
341 // --------------------------------------------------------------------------
344 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
345 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
349 // Put particle on the stack if selected
355 } // particle loop final state
358 // Time of the interactions
360 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
363 // Write particles to stack
365 for (i = 0; i<np; i++) {
366 iparticle = (TParticle *) fParticles.At(i);
367 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
368 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
370 kf = iparticle->GetPdgCode();
371 ks = iparticle->GetStatusCode();
372 p[0] = iparticle->Px();
373 p[1] = iparticle->Py();
374 p[2] = iparticle->Pz() * sign;
375 origin[0] = origin0[0]+iparticle->Vx()/10;
376 origin[1] = origin0[1]+iparticle->Vy()/10;
377 origin[2] = origin0[2]+iparticle->Vz()/10;
380 if (TestBit(kVertexRange)) {
381 fEventTime = sign * origin0[2] / 2.99792458e10;
382 tof = kconv * iparticle->T() + fEventTime;
384 tof = kconv * iparticle->T();
386 if (fPileUpTimeWindow > 0.) tof += tInt;
389 TParticle* mother = 0;
391 imo = iparticle->GetFirstMother();
392 mother = (TParticle *) fParticles.At(imo);
393 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
395 Bool_t tFlag = (fTrackIt && !hasDaughter);
396 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
405 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
408 if (jev >= fNpart || fNpart == -1) {
409 fKineBias = Float_t(fNpart)/Float_t(fTrials);
410 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
416 SetHighWaterMark(nt);
419 void AliGenHijing::KeepFullEvent()
424 void AliGenHijing::EvaluateCrossSections()
426 // Glauber Calculation of geometrical x-section
428 Float_t xTot = 0.; // barn
429 Float_t xTotHard = 0.; // barn
430 Float_t xPart = 0.; // barn
431 Float_t xPartHard = 0.; // barn
432 Float_t sigmaHard = 0.1; // mbarn
434 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
435 const Float_t kdib = 0.2;
436 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
439 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
440 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
441 printf("\n Inelastic and total cross section (mb) %f %f \n",fHijing->GetHINT1(12), fHijing->GetHINT1(13));
443 Float_t oldvalue= 0.;
445 Float_t* b = new Float_t[kMax];
446 Float_t* si1 = new Float_t[kMax];
447 Float_t* si2 = new Float_t[kMax];
448 for (i = 0; i < kMax; i++){
454 for (i = 0; i < kMax; i++)
456 Float_t xb = bMin+i*kdib;
458 ov=fHijing->Profile(xb);
459 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
460 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
463 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
465 if (xb > fMinImpactParam && xb < fMaxImpactParam)
471 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
473 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
474 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
482 printf("\n Total cross section (barn): %f \n",xTot);
483 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
484 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
485 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
487 // Store result as a graph
492 fDsigmaDb = new TGraph(i, b, si1);
493 fDnDb = new TGraph(i, b, si2);
496 Bool_t AliGenHijing::DaughtersSelection(const TParticle* iparticle)
499 // Looks recursively if one of the daughters has been selected
501 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
505 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
506 Bool_t selected = kFALSE;
508 imin = iparticle->GetFirstDaughter();
509 imax = iparticle->GetLastDaughter();
510 for (i = imin; i <= imax; i++){
511 TParticle * jparticle = (TParticle *) fParticles.At(i);
512 Int_t ip = jparticle->GetPdgCode();
513 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
514 selected=kTRUE; break;
516 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
525 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
527 // Select flavor of particle
529 // 4: charm and beauty
536 Int_t ifl = TMath::Abs(pid/100);
537 if (ifl > 10) ifl/=10;
538 res = (fFlavor == ifl);
541 // This part if gamma writing is inhibited
543 res = res && (pid != kGamma && pid != kPi0);
548 Bool_t AliGenHijing::Stable(const TParticle* particle) const
550 // Return true for a stable particle
553 if (particle->GetFirstDaughter() < 0 )
563 void AliGenHijing::MakeHeader()
565 // Builds the event header, to be called after each event
566 fHeader.SetNProduced(fNprimaries);
567 fHeader.SetImpactParameter(fHijing->GetHINT1(19));
568 fHeader.SetTotalEnergy(fHijing->GetEATT());
569 fHeader.SetHardScatters(fHijing->GetJATT());
570 fHeader.SetParticipants(fHijing->GetNP(), fHijing->GetNT());
571 fHeader.SetCollisions(fHijing->GetN0(),
575 fHeader.SetSpectators(fProjectileSpecn, fProjectileSpecp,
576 fTargetSpecn,fTargetSpecp);
577 fHeader.SetReactionPlaneAngle(fHijing->GetHINT1(20));
579 // 4-momentum vectors of the triggered jets.
581 // Before final state gluon radiation.
582 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
583 fHijing->GetHINT1(22),
584 fHijing->GetHINT1(23),
585 fHijing->GetHINT1(24));
587 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
588 fHijing->GetHINT1(32),
589 fHijing->GetHINT1(33),
590 fHijing->GetHINT1(34));
591 // After final state gluon radiation.
592 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
593 fHijing->GetHINT1(27),
594 fHijing->GetHINT1(28),
595 fHijing->GetHINT1(29));
597 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
598 fHijing->GetHINT1(37),
599 fHijing->GetHINT1(38),
600 fHijing->GetHINT1(39));
601 fHeader.SetJets(jet1, jet2, jet3, jet4);
602 // Bookkeeping for kinematic bias
603 fHeader.SetTrials(fTrials);
605 fHeader.SetPrimaryVertex(fVertex);
606 fHeader.SetInteractionTime(fEventTime);
608 fCollisionGeometry = &fHeader;
612 Bool_t AliGenHijing::CheckTrigger()
614 // Check the kinematic trigger condition
616 Bool_t triggered = kFALSE;
622 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
623 fHijing->GetHINT1(27),
624 fHijing->GetHINT1(28),
625 fHijing->GetHINT1(29));
627 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
628 fHijing->GetHINT1(37),
629 fHijing->GetHINT1(38),
630 fHijing->GetHINT1(39));
631 Double_t eta1 = jet1->Eta();
632 Double_t eta2 = jet2->Eta();
633 Double_t phi1 = jet1->Phi();
634 Double_t phi2 = jet2->Phi();
635 // printf("\n Trigger: %f %f %f %f",
636 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
638 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
639 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
641 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
642 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
645 } else if (fTrigger == 2) {
648 Int_t np = fParticles.GetEntriesFast();
649 for (Int_t i = 0; i < np; i++) {
650 TParticle* part = (TParticle*) fParticles.At(i);
651 Int_t kf = part->GetPdgCode();
652 Int_t ksp = part->GetUniqueID();
653 if (kf == 22 && ksp == 40) {
654 Float_t phi = part->Phi();
655 Float_t eta = part->Eta();
656 if (eta < fEtaMaxJet &&
662 } // check phi,eta within limits