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"
35 #include "AliHijingRndm.h"
37 ClassImp(AliGenHijing)
39 AliGenHijing::AliGenHijing()
65 fPhiMaxJet(2. * TMath::Pi()),
75 fNoHeavyQuarks(kFALSE)
79 AliHijingRndm::SetHijingRandom(GetRandom());
82 AliGenHijing::AliGenHijing(Int_t npart)
108 fPhiMaxJet(2. * TMath::Pi()),
118 fNoHeavyQuarks(kFALSE)
120 // Default PbPb collisions at 5. 5 TeV
124 fTitle= "Particle Generator using HIJING";
127 // Set random number generator
128 AliHijingRndm::SetHijingRandom(GetRandom());
131 AliGenHijing::~AliGenHijing()
134 if ( fDsigmaDb) delete fDsigmaDb;
135 if ( fDnDb) delete fDnDb;
138 void AliGenHijing::Init()
143 fProjectile.Resize(8);
145 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
146 fAProjectile, fZProjectile, fATarget, fZTarget,
147 fMinImpactParam, fMaxImpactParam));
149 fHijing=(THijing*) fMCEvGen;
150 fHijing->SetIHPR2(2, fRadiation);
151 fHijing->SetIHPR2(3, fTrigger);
152 fHijing->SetIHPR2(6, fShadowing);
153 fHijing->SetIHPR2(12, fDecaysOff);
154 fHijing->SetIHPR2(21, fKeep);
155 fHijing->SetHIPR1(10, fPtMinJet);
156 fHijing->SetHIPR1(50, fSimpleJet);
161 // fQuench = 0: no quenching
162 // fQuench = 1: hijing default
163 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
164 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
165 // fQuench = 4: new LHC parameters with log(e) dependence
166 // fQuench = 5: new RHIC parameters with log(e) dependence
167 fHijing->SetIHPR2(50, 0);
169 fHijing->SetIHPR2(4, 1);
171 fHijing->SetIHPR2(4, 0);
172 // New LHC parameters from Xin-Nian Wang
174 fHijing->SetHIPR1(14, 1.1);
175 fHijing->SetHIPR1(11, 3.7);
176 } else if (fQuench == 3) {
177 fHijing->SetHIPR1(14, 0.20);
178 fHijing->SetHIPR1(11, 2.5);
179 } else if (fQuench == 4) {
180 fHijing->SetIHPR2(50, 1);
181 fHijing->SetHIPR1(14, 4.*0.34);
182 fHijing->SetHIPR1(11, 3.7);
183 } else if (fQuench == 5) {
184 fHijing->SetIHPR2(50, 1);
185 fHijing->SetHIPR1(14, 0.34);
186 fHijing->SetHIPR1(11, 2.5);
192 if (fNoHeavyQuarks) {
193 fHijing->SetIHPR2(49, 1);
195 fHijing->SetIHPR2(49, 0);
204 fHijing->Initialize();
206 if (fEvaluate) EvaluateCrossSections();
210 void AliGenHijing::Generate()
212 // Generate one event
214 Float_t polar[3] = {0,0,0};
215 Float_t origin[3] = {0,0,0};
216 Float_t origin0[3] = {0,0,0};
220 // converts from mm/c to s
221 const Float_t kconv = 0.001/2.99792458e8;
225 Int_t j, kf, ks, ksp, imo;
232 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
233 if(fVertexSmear == kPerEvent) {
235 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
239 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
242 // Generate one event
243 // --------------------------------------------------------------------------
244 fProjectileSpecn = 0;
245 fProjectileSpecp = 0;
248 // --------------------------------------------------------------------------
249 fHijing->GenerateEvent();
252 fHijing->ImportParticles(&fParticles,"All");
253 if (fTrigger != kNoTrigger) {
254 if (!CheckTrigger()) continue;
259 Int_t np = fParticles.GetEntriesFast();
260 printf("\n **************************************************%d\n",np);
262 if (np == 0 ) continue;
264 Int_t* newPos = new Int_t[np];
265 Int_t* pSelected = new Int_t[np];
267 for (i = 0; i < np; i++) {
274 TParticle * iparticle = (TParticle *) fParticles.At(0);
275 fVertex[0] = origin0[0];
276 fVertex[1] = origin0[1];
277 fVertex[2] = origin0[2];
280 // First select parent particles
283 for (i = 0; i < np; i++) {
284 iparticle = (TParticle *) fParticles.At(i);
286 // Is this a parent particle ?
287 if (Stable(iparticle)) continue;
289 Bool_t selected = kTRUE;
290 Bool_t hasSelectedDaughters = kFALSE;
293 kf = iparticle->GetPdgCode();
294 ks = iparticle->GetStatusCode();
295 if (kf == 92) continue;
297 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
299 hasSelectedDaughters = DaughtersSelection(iparticle);
301 // Put particle on the stack if it is either selected or
302 // it is the mother of at least one seleted particle
304 if (selected || hasSelectedDaughters) {
308 } // particle loop parents
310 // Now select the final state particles
313 for (i = 0; i<np; i++) {
314 iparticle = (TParticle *) fParticles.At(i);
315 // Is this a final state particle ?
316 if (!Stable(iparticle)) continue;
318 Bool_t selected = kTRUE;
319 kf = iparticle->GetPdgCode();
320 ks = iparticle->GetStatusCode();
321 ksp = iparticle->GetUniqueID();
323 // --------------------------------------------------------------------------
324 // Count spectator neutrons and protons
325 if(ksp == 0 || ksp == 1){
326 if(kf == kNeutron) fProjectileSpecn += 1;
327 if(kf == kProton) fProjectileSpecp += 1;
329 else if(ksp == 10 || ksp == 11){
330 if(kf == kNeutron) fTargetSpecn += 1;
331 if(kf == kProton) fTargetSpecp += 1;
333 // --------------------------------------------------------------------------
336 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
337 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
341 // Put particle on the stack if selected
347 } // particle loop final state
350 // Time of the interactions
352 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
355 // Write particles to stack
357 for (i = 0; i<np; i++) {
358 iparticle = (TParticle *) fParticles.At(i);
359 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
360 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
362 kf = iparticle->GetPdgCode();
363 ks = iparticle->GetStatusCode();
364 p[0] = iparticle->Px();
365 p[1] = iparticle->Py();
366 p[2] = iparticle->Pz() * sign;
367 origin[0] = origin0[0]+iparticle->Vx()/10;
368 origin[1] = origin0[1]+iparticle->Vy()/10;
369 origin[2] = origin0[2]+iparticle->Vz()/10;
370 tof = kconv * iparticle->T() + sign * origin0[2] / 3.e10;
371 if (fPileUpTimeWindow > 0.) tof += tInt;
374 TParticle* mother = 0;
376 imo = iparticle->GetFirstMother();
377 mother = (TParticle *) fParticles.At(imo);
378 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
380 Bool_t tFlag = (fTrackIt && !hasDaughter);
381 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
390 printf("\n I've put %i particles on the stack \n",nc);
393 if (jev >= fNpart || fNpart == -1) {
394 fKineBias = Float_t(fNpart)/Float_t(fTrials);
395 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
401 SetHighWaterMark(nt);
404 void AliGenHijing::KeepFullEvent()
409 void AliGenHijing::EvaluateCrossSections()
411 // Glauber Calculation of geometrical x-section
413 Float_t xTot = 0.; // barn
414 Float_t xTotHard = 0.; // barn
415 Float_t xPart = 0.; // barn
416 Float_t xPartHard = 0.; // barn
417 Float_t sigmaHard = 0.1; // mbarn
419 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
420 const Float_t kdib = 0.2;
421 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
424 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
425 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
427 Float_t oldvalue= 0.;
429 Float_t* b = new Float_t[kMax];
430 Float_t* si1 = new Float_t[kMax];
431 Float_t* si2 = new Float_t[kMax];
433 for (i = 0; i < kMax; i++)
435 Float_t xb = bMin+i*kdib;
437 ov=fHijing->Profile(xb);
438 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
439 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
442 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
444 if (xb > fMinImpactParam && xb < fMaxImpactParam)
450 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
452 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
453 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
461 printf("\n Total cross section (barn): %f \n",xTot);
462 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
463 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
464 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
466 // Store result as a graph
471 fDsigmaDb = new TGraph(i, b, si1);
472 fDnDb = new TGraph(i, b, si2);
475 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
478 // Looks recursively if one of the daughters has been selected
480 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
484 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
485 Bool_t selected = kFALSE;
487 imin = iparticle->GetFirstDaughter();
488 imax = iparticle->GetLastDaughter();
489 for (i = imin; i <= imax; i++){
490 TParticle * jparticle = (TParticle *) fParticles.At(i);
491 Int_t ip = jparticle->GetPdgCode();
492 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
493 selected=kTRUE; break;
495 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
504 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
506 // Select flavor of particle
508 // 4: charm and beauty
515 Int_t ifl = TMath::Abs(pid/100);
516 if (ifl > 10) ifl/=10;
517 res = (fFlavor == ifl);
520 // This part if gamma writing is inhibited
522 res = res && (pid != kGamma && pid != kPi0);
527 Bool_t AliGenHijing::Stable(TParticle* particle) const
529 // Return true for a stable particle
532 if (particle->GetFirstDaughter() < 0 )
542 void AliGenHijing::MakeHeader()
544 // Builds the event header, to be called after each event
545 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
546 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
547 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
548 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
549 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
550 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
551 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
555 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
556 fTargetSpecn,fTargetSpecp);
557 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
561 // 4-momentum vectors of the triggered jets.
563 // Before final state gluon radiation.
564 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
565 fHijing->GetHINT1(22),
566 fHijing->GetHINT1(23),
567 fHijing->GetHINT1(24));
569 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
570 fHijing->GetHINT1(32),
571 fHijing->GetHINT1(33),
572 fHijing->GetHINT1(34));
573 // After final state gluon radiation.
574 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
575 fHijing->GetHINT1(27),
576 fHijing->GetHINT1(28),
577 fHijing->GetHINT1(29));
579 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
580 fHijing->GetHINT1(37),
581 fHijing->GetHINT1(38),
582 fHijing->GetHINT1(39));
583 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
584 // Bookkeeping for kinematic bias
585 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
587 header->SetPrimaryVertex(fVertex);
589 fCollisionGeometry = (AliGenHijingEventHeader*) header;
593 Bool_t AliGenHijing::CheckTrigger()
595 // Check the kinematic trigger condition
597 Bool_t triggered = kFALSE;
603 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
604 fHijing->GetHINT1(27),
605 fHijing->GetHINT1(28),
606 fHijing->GetHINT1(29));
608 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
609 fHijing->GetHINT1(37),
610 fHijing->GetHINT1(38),
611 fHijing->GetHINT1(39));
612 Double_t eta1 = jet1->Eta();
613 Double_t eta2 = jet2->Eta();
614 Double_t phi1 = jet1->Phi();
615 Double_t phi2 = jet2->Phi();
616 // printf("\n Trigger: %f %f %f %f",
617 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
619 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
620 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
622 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
623 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
626 } else if (fTrigger == 2) {
629 Int_t np = fParticles.GetEntriesFast();
630 for (Int_t i = 0; i < np; i++) {
631 TParticle* part = (TParticle*) fParticles.At(i);
632 Int_t kf = part->GetPdgCode();
633 Int_t ksp = part->GetUniqueID();
634 if (kf == 22 && ksp == 40) {
635 Float_t phi = part->Phi();
636 Float_t eta = part->Eta();
637 if (eta < fEtaMaxJet &&
643 } // check phi,eta within limits