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)
80 AliHijingRndm::SetHijingRandom(GetRandom());
83 AliGenHijing::AliGenHijing(Int_t npart)
109 fPhiMaxJet(2. * TMath::Pi()),
119 fNoHeavyQuarks(kFALSE)
121 // Default PbPb collisions at 5. 5 TeV
125 fTitle= "Particle Generator using HIJING";
128 // Set random number generator
129 AliHijingRndm::SetHijingRandom(GetRandom());
132 AliGenHijing::~AliGenHijing()
135 if ( fDsigmaDb) delete fDsigmaDb;
136 if ( fDnDb) delete fDnDb;
139 void AliGenHijing::Init()
144 fProjectile.Resize(8);
146 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
147 fAProjectile, fZProjectile, fATarget, fZTarget,
148 fMinImpactParam, fMaxImpactParam));
150 fHijing=(THijing*) fMCEvGen;
151 fHijing->SetIHPR2(2, fRadiation);
152 fHijing->SetIHPR2(3, fTrigger);
153 fHijing->SetIHPR2(6, fShadowing);
154 fHijing->SetIHPR2(12, fDecaysOff);
155 fHijing->SetIHPR2(21, fKeep);
156 fHijing->SetHIPR1(10, fPtMinJet);
157 fHijing->SetHIPR1(50, fSimpleJet);
162 // fQuench = 0: no quenching
163 // fQuench = 1: hijing default
164 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
165 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
166 // fQuench = 4: new LHC parameters with log(e) dependence
167 // fQuench = 5: new RHIC parameters with log(e) dependence
168 fHijing->SetIHPR2(50, 0);
170 fHijing->SetIHPR2(4, 1);
172 fHijing->SetIHPR2(4, 0);
173 // New LHC parameters from Xin-Nian Wang
175 fHijing->SetHIPR1(14, 1.1);
176 fHijing->SetHIPR1(11, 3.7);
177 } else if (fQuench == 3) {
178 fHijing->SetHIPR1(14, 0.20);
179 fHijing->SetHIPR1(11, 2.5);
180 } else if (fQuench == 4) {
181 fHijing->SetIHPR2(50, 1);
182 fHijing->SetHIPR1(14, 4.*0.34);
183 fHijing->SetHIPR1(11, 3.7);
184 } else if (fQuench == 5) {
185 fHijing->SetIHPR2(50, 1);
186 fHijing->SetHIPR1(14, 0.34);
187 fHijing->SetHIPR1(11, 2.5);
193 if (fNoHeavyQuarks) {
194 fHijing->SetIHPR2(49, 1);
196 fHijing->SetIHPR2(49, 0);
205 fHijing->Initialize();
207 if (fEvaluate) EvaluateCrossSections();
211 void AliGenHijing::Generate()
213 // Generate one event
215 Float_t polar[3] = {0,0,0};
216 Float_t origin[3] = {0,0,0};
217 Float_t origin0[3] = {0,0,0};
221 // converts from mm/c to s
222 const Float_t kconv = 0.001/2.99792458e8;
226 Int_t j, kf, ks, ksp, imo;
233 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
235 if(fVertexSmear == kPerEvent) {
237 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
241 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
245 // Generate one event
246 // --------------------------------------------------------------------------
247 fProjectileSpecn = 0;
248 fProjectileSpecp = 0;
251 // --------------------------------------------------------------------------
252 fHijing->GenerateEvent();
255 fHijing->ImportParticles(&fParticles,"All");
256 if (fTrigger != kNoTrigger) {
257 if (!CheckTrigger()) continue;
262 Int_t np = fParticles.GetEntriesFast();
264 if (np == 0 ) continue;
266 Int_t* newPos = new Int_t[np];
267 Int_t* pSelected = new Int_t[np];
269 for (i = 0; i < np; i++) {
276 TParticle * iparticle = (TParticle *) fParticles.At(0);
277 fVertex[0] = origin0[0];
278 fVertex[1] = origin0[1];
279 fVertex[2] = origin0[2];
282 // First select parent particles
285 for (i = 0; i < np; i++) {
286 iparticle = (TParticle *) fParticles.At(i);
288 // Is this a parent particle ?
289 if (Stable(iparticle)) continue;
291 Bool_t selected = kTRUE;
292 Bool_t hasSelectedDaughters = kFALSE;
295 kf = iparticle->GetPdgCode();
296 ks = iparticle->GetStatusCode();
297 if (kf == 92) continue;
299 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
301 hasSelectedDaughters = DaughtersSelection(iparticle);
303 // Put particle on the stack if it is either selected or
304 // it is the mother of at least one seleted particle
306 if (selected || hasSelectedDaughters) {
310 } // particle loop parents
312 // Now select the final state particles
315 for (i = 0; i<np; i++) {
316 iparticle = (TParticle *) fParticles.At(i);
317 // Is this a final state particle ?
318 if (!Stable(iparticle)) continue;
320 Bool_t selected = kTRUE;
321 kf = iparticle->GetPdgCode();
322 ks = iparticle->GetStatusCode();
323 ksp = iparticle->GetUniqueID();
325 // --------------------------------------------------------------------------
326 // Count spectator neutrons and protons
327 if(ksp == 0 || ksp == 1){
328 if(kf == kNeutron) fProjectileSpecn += 1;
329 if(kf == kProton) fProjectileSpecp += 1;
331 else if(ksp == 10 || ksp == 11){
332 if(kf == kNeutron) fTargetSpecn += 1;
333 if(kf == kProton) fTargetSpecp += 1;
335 // --------------------------------------------------------------------------
338 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
339 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
343 // Put particle on the stack if selected
349 } // particle loop final state
352 // Time of the interactions
354 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
357 // Write particles to stack
359 for (i = 0; i<np; i++) {
360 iparticle = (TParticle *) fParticles.At(i);
361 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
362 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
364 kf = iparticle->GetPdgCode();
365 ks = iparticle->GetStatusCode();
366 p[0] = iparticle->Px();
367 p[1] = iparticle->Py();
368 p[2] = iparticle->Pz() * sign;
369 origin[0] = origin0[0]+iparticle->Vx()/10;
370 origin[1] = origin0[1]+iparticle->Vy()/10;
371 origin[2] = origin0[2]+iparticle->Vz()/10;
372 if (TestBit(kVertexRange)) {
373 tof = kconv * iparticle->T() + sign * origin0[2] / 2.99792458e10;
375 tof = kconv * iparticle->T();
376 if (fPileUpTimeWindow > 0.) tof += tInt;
379 TParticle* mother = 0;
381 imo = iparticle->GetFirstMother();
382 mother = (TParticle *) fParticles.At(imo);
383 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
385 Bool_t tFlag = (fTrackIt && !hasDaughter);
386 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
395 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
398 if (jev >= fNpart || fNpart == -1) {
399 fKineBias = Float_t(fNpart)/Float_t(fTrials);
400 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
406 SetHighWaterMark(nt);
409 void AliGenHijing::KeepFullEvent()
414 void AliGenHijing::EvaluateCrossSections()
416 // Glauber Calculation of geometrical x-section
418 Float_t xTot = 0.; // barn
419 Float_t xTotHard = 0.; // barn
420 Float_t xPart = 0.; // barn
421 Float_t xPartHard = 0.; // barn
422 Float_t sigmaHard = 0.1; // mbarn
424 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
425 const Float_t kdib = 0.2;
426 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
429 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
430 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
432 Float_t oldvalue= 0.;
434 Float_t* b = new Float_t[kMax];
435 Float_t* si1 = new Float_t[kMax];
436 Float_t* si2 = new Float_t[kMax];
438 for (i = 0; i < kMax; i++)
440 Float_t xb = bMin+i*kdib;
442 ov=fHijing->Profile(xb);
443 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
444 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
447 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
449 if (xb > fMinImpactParam && xb < fMaxImpactParam)
455 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
457 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
458 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
466 printf("\n Total cross section (barn): %f \n",xTot);
467 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
468 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
469 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
471 // Store result as a graph
476 fDsigmaDb = new TGraph(i, b, si1);
477 fDnDb = new TGraph(i, b, si2);
480 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
483 // Looks recursively if one of the daughters has been selected
485 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
489 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
490 Bool_t selected = kFALSE;
492 imin = iparticle->GetFirstDaughter();
493 imax = iparticle->GetLastDaughter();
494 for (i = imin; i <= imax; i++){
495 TParticle * jparticle = (TParticle *) fParticles.At(i);
496 Int_t ip = jparticle->GetPdgCode();
497 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
498 selected=kTRUE; break;
500 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
509 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
511 // Select flavor of particle
513 // 4: charm and beauty
520 Int_t ifl = TMath::Abs(pid/100);
521 if (ifl > 10) ifl/=10;
522 res = (fFlavor == ifl);
525 // This part if gamma writing is inhibited
527 res = res && (pid != kGamma && pid != kPi0);
532 Bool_t AliGenHijing::Stable(TParticle* particle) const
534 // Return true for a stable particle
537 if (particle->GetFirstDaughter() < 0 )
547 void AliGenHijing::MakeHeader()
549 // Builds the event header, to be called after each event
550 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
551 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
552 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
553 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
554 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
555 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
556 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
560 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
561 fTargetSpecn,fTargetSpecp);
562 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
563 // printf("Impact Parameter %13.3f \n", fHijing->GetHINT1(19));
567 // 4-momentum vectors of the triggered jets.
569 // Before final state gluon radiation.
570 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
571 fHijing->GetHINT1(22),
572 fHijing->GetHINT1(23),
573 fHijing->GetHINT1(24));
575 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
576 fHijing->GetHINT1(32),
577 fHijing->GetHINT1(33),
578 fHijing->GetHINT1(34));
579 // After final state gluon radiation.
580 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
581 fHijing->GetHINT1(27),
582 fHijing->GetHINT1(28),
583 fHijing->GetHINT1(29));
585 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
586 fHijing->GetHINT1(37),
587 fHijing->GetHINT1(38),
588 fHijing->GetHINT1(39));
589 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
590 // Bookkeeping for kinematic bias
591 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
593 header->SetPrimaryVertex(fVertex);
595 fCollisionGeometry = (AliGenHijingEventHeader*) header;
599 Bool_t AliGenHijing::CheckTrigger()
601 // Check the kinematic trigger condition
603 Bool_t triggered = kFALSE;
609 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
610 fHijing->GetHINT1(27),
611 fHijing->GetHINT1(28),
612 fHijing->GetHINT1(29));
614 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
615 fHijing->GetHINT1(37),
616 fHijing->GetHINT1(38),
617 fHijing->GetHINT1(39));
618 Double_t eta1 = jet1->Eta();
619 Double_t eta2 = jet2->Eta();
620 Double_t phi1 = jet1->Phi();
621 Double_t phi2 = jet2->Phi();
622 // printf("\n Trigger: %f %f %f %f",
623 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
625 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
626 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
628 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
629 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
632 } else if (fTrigger == 2) {
635 Int_t np = fParticles.GetEntriesFast();
636 for (Int_t i = 0; i < np; i++) {
637 TParticle* part = (TParticle*) fParticles.At(i);
638 Int_t kf = part->GetPdgCode();
639 Int_t ksp = part->GetUniqueID();
640 if (kf == 22 && ksp == 40) {
641 Float_t phi = part->Phi();
642 Float_t eta = part->Eta();
643 if (eta < fEtaMaxJet &&
649 } // check phi,eta within limits