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"))
81 AliHijingRndm::SetHijingRandom(GetRandom());
84 AliGenHijing::AliGenHijing(Int_t npart)
110 fPhiMaxJet(2. * TMath::Pi()),
120 fNoHeavyQuarks(kFALSE),
121 fHeader(AliGenHijingEventHeader("Hijing"))
123 // Default PbPb collisions at 5. 5 TeV
127 fTitle= "Particle Generator using HIJING";
130 // Set random number generator
131 AliHijingRndm::SetHijingRandom(GetRandom());
135 AliGenHijing::~AliGenHijing()
138 if ( fDsigmaDb) delete fDsigmaDb;
139 if ( fDnDb) delete fDnDb;
142 void AliGenHijing::Init()
147 fProjectile.Resize(8);
149 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
150 fAProjectile, fZProjectile, fATarget, fZTarget,
151 fMinImpactParam, fMaxImpactParam));
153 fHijing=(THijing*) fMCEvGen;
154 fHijing->SetIHPR2(2, fRadiation);
155 fHijing->SetIHPR2(3, fTrigger);
156 fHijing->SetIHPR2(6, fShadowing);
157 fHijing->SetIHPR2(12, fDecaysOff);
158 fHijing->SetIHPR2(21, fKeep);
159 fHijing->SetHIPR1(8, fPtHardMin);
160 fHijing->SetHIPR1(9, fPtHardMax);
161 fHijing->SetHIPR1(10, fPtMinJet);
162 fHijing->SetHIPR1(50, fSimpleJet);
167 // fQuench = 0: no quenching
168 // fQuench = 1: hijing default
169 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
170 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
171 // fQuench = 4: new LHC parameters with log(e) dependence
172 // fQuench = 5: new RHIC parameters with log(e) dependence
173 fHijing->SetIHPR2(50, 0);
175 fHijing->SetIHPR2(4, 1);
177 fHijing->SetIHPR2(4, 0);
178 // New LHC parameters from Xin-Nian Wang
180 fHijing->SetHIPR1(14, 1.1);
181 fHijing->SetHIPR1(11, 3.7);
182 } else if (fQuench == 3) {
183 fHijing->SetHIPR1(14, 0.20);
184 fHijing->SetHIPR1(11, 2.5);
185 } else if (fQuench == 4) {
186 fHijing->SetIHPR2(50, 1);
187 fHijing->SetHIPR1(14, 4.*0.34);
188 fHijing->SetHIPR1(11, 3.7);
189 } else if (fQuench == 5) {
190 fHijing->SetIHPR2(50, 1);
191 fHijing->SetHIPR1(14, 0.34);
192 fHijing->SetHIPR1(11, 2.5);
198 if (fNoHeavyQuarks) {
199 fHijing->SetIHPR2(49, 1);
201 fHijing->SetIHPR2(49, 0);
210 fHijing->Initialize();
212 if (fEvaluate) EvaluateCrossSections();
216 void AliGenHijing::Generate()
218 // Generate one event
220 Float_t polar[3] = {0,0,0};
221 Float_t origin[3] = {0,0,0};
222 Float_t origin0[3] = {0,0,0};
227 // converts from mm/c to s
228 const Float_t kconv = 0.001/2.99792458e8;
232 Int_t j, kf, ks, ksp, imo;
239 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];
249 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
253 // Generate one event
254 // --------------------------------------------------------------------------
255 fProjectileSpecn = 0;
256 fProjectileSpecp = 0;
259 // --------------------------------------------------------------------------
260 fHijing->GenerateEvent();
263 fHijing->ImportParticles(&fParticles,"All");
264 if (fTrigger != kNoTrigger) {
265 if (!CheckTrigger()) continue;
270 Int_t np = fParticles.GetEntriesFast();
272 if (np == 0 ) continue;
274 Int_t* newPos = new Int_t[np];
275 Int_t* pSelected = new Int_t[np];
277 for (i = 0; i < np; i++) {
284 fVertex[0] = origin0[0];
285 fVertex[1] = origin0[1];
286 fVertex[2] = origin0[2];
289 // First select parent particles
291 TParticle * iparticle = 0;
292 for (i = 0; i < np; i++) {
293 iparticle = (TParticle *) fParticles.At(i);
295 // Is this a parent particle ?
296 if (Stable(iparticle)) continue;
298 Bool_t selected = kTRUE;
299 Bool_t hasSelectedDaughters = kFALSE;
302 kf = iparticle->GetPdgCode();
303 ks = iparticle->GetStatusCode();
304 if (kf == 92) continue;
306 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
308 hasSelectedDaughters = DaughtersSelection(iparticle);
310 // Put particle on the stack if it is either selected or
311 // it is the mother of at least one seleted particle
313 if (selected || hasSelectedDaughters) {
317 } // particle loop parents
319 // Now select the final state particles
322 for (i = 0; i<np; i++) {
323 iparticle = (TParticle *) fParticles.At(i);
324 // Is this a final state particle ?
325 if (!Stable(iparticle)) continue;
327 Bool_t selected = kTRUE;
328 kf = iparticle->GetPdgCode();
329 ks = iparticle->GetStatusCode();
330 ksp = iparticle->GetUniqueID();
332 // --------------------------------------------------------------------------
333 // Count spectator neutrons and protons
334 if(ksp == 0 || ksp == 1){
335 if(kf == kNeutron) fProjectileSpecn += 1;
336 if(kf == kProton) fProjectileSpecp += 1;
338 else if(ksp == 10 || ksp == 11){
339 if(kf == kNeutron) fTargetSpecn += 1;
340 if(kf == kProton) fTargetSpecp += 1;
342 // --------------------------------------------------------------------------
345 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
346 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
350 // Put particle on the stack if selected
356 } // particle loop final state
359 // Write particles to stack
361 for (i = 0; i<np; i++) {
362 iparticle = (TParticle *) fParticles.At(i);
363 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
364 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
366 kf = iparticle->GetPdgCode();
367 ks = iparticle->GetStatusCode();
368 p[0] = iparticle->Px();
369 p[1] = iparticle->Py();
370 p[2] = iparticle->Pz() * sign;
371 origin[0] = origin0[0]+iparticle->Vx()/10;
372 origin[1] = origin0[1]+iparticle->Vy()/10;
373 origin[2] = origin0[2]+iparticle->Vz()/10;
374 tof = time0+kconv * iparticle->T();
377 TParticle* mother = 0;
379 imo = iparticle->GetFirstMother();
380 mother = (TParticle *) fParticles.At(imo);
381 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
383 Bool_t tFlag = (fTrackIt && !hasDaughter);
384 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
393 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
396 if (jev >= fNpart || fNpart == -1) {
397 fKineBias = Float_t(fNpart)/Float_t(fTrials);
398 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
404 SetHighWaterMark(nt);
407 void AliGenHijing::KeepFullEvent()
412 void AliGenHijing::EvaluateCrossSections()
414 // Glauber Calculation of geometrical x-section
416 Float_t xTot = 0.; // barn
417 Float_t xTotHard = 0.; // barn
418 Float_t xPart = 0.; // barn
419 Float_t xPartHard = 0.; // barn
420 Float_t sigmaHard = 0.1; // mbarn
422 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
423 const Float_t kdib = 0.2;
424 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
427 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
428 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
429 printf("\n Inelastic and total cross section (mb) %f %f \n",fHijing->GetHINT1(12), fHijing->GetHINT1(13));
431 Float_t oldvalue= 0.;
433 Float_t* b = new Float_t[kMax];
434 Float_t* si1 = new Float_t[kMax];
435 Float_t* si2 = new Float_t[kMax];
436 for (i = 0; i < kMax; i++){
442 for (i = 0; i < kMax; i++)
444 Float_t xb = bMin+i*kdib;
446 ov=fHijing->Profile(xb);
447 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
448 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
451 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
453 if (xb > fMinImpactParam && xb < fMaxImpactParam)
459 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
461 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
462 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
470 printf("\n Total cross section (barn): %f \n",xTot);
471 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
472 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
473 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
475 // Store result as a graph
480 fDsigmaDb = new TGraph(i, b, si1);
481 fDnDb = new TGraph(i, b, si2);
484 Bool_t AliGenHijing::DaughtersSelection(const TParticle* iparticle)
487 // Looks recursively if one of the daughters has been selected
489 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
493 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
494 Bool_t selected = kFALSE;
496 imin = iparticle->GetFirstDaughter();
497 imax = iparticle->GetLastDaughter();
498 for (i = imin; i <= imax; i++){
499 TParticle * jparticle = (TParticle *) fParticles.At(i);
500 Int_t ip = jparticle->GetPdgCode();
501 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
502 selected=kTRUE; break;
504 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
513 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
515 // Select flavor of particle
517 // 4: charm and beauty
524 Int_t ifl = TMath::Abs(pid/100);
525 if (ifl > 10) ifl/=10;
526 res = (fFlavor == ifl);
529 // This part if gamma writing is inhibited
531 res = res && (pid != kGamma && pid != kPi0);
536 Bool_t AliGenHijing::Stable(const TParticle* particle) const
538 // Return true for a stable particle
541 if (particle->GetFirstDaughter() < 0 )
551 void AliGenHijing::MakeHeader()
553 // Builds the event header, to be called after each event
554 fHeader.SetNProduced(fNprimaries);
555 fHeader.SetImpactParameter(fHijing->GetHINT1(19));
556 fHeader.SetTotalEnergy(fHijing->GetEATT());
557 fHeader.SetHardScatters(fHijing->GetJATT());
558 fHeader.SetParticipants(fHijing->GetNP(), fHijing->GetNT());
559 fHeader.SetCollisions(fHijing->GetN0(),
563 fHeader.SetSpectators(fProjectileSpecn, fProjectileSpecp,
564 fTargetSpecn,fTargetSpecp);
565 fHeader.SetReactionPlaneAngle(fHijing->GetHINT1(20));
566 fHeader.SetTrueNPart(fHijing->GetNPART());
568 // 4-momentum vectors of the triggered jets.
570 // Before final state gluon radiation.
571 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
572 fHijing->GetHINT1(22),
573 fHijing->GetHINT1(23),
574 fHijing->GetHINT1(24));
576 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
577 fHijing->GetHINT1(32),
578 fHijing->GetHINT1(33),
579 fHijing->GetHINT1(34));
580 // After final state gluon radiation.
581 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
582 fHijing->GetHINT1(27),
583 fHijing->GetHINT1(28),
584 fHijing->GetHINT1(29));
586 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
587 fHijing->GetHINT1(37),
588 fHijing->GetHINT1(38),
589 fHijing->GetHINT1(39));
590 fHeader.SetJets(jet1, jet2, jet3, jet4);
591 // Bookkeeping for kinematic bias
592 fHeader.SetTrials(fTrials);
594 fHeader.SetPrimaryVertex(fVertex);
595 fHeader.SetInteractionTime(fTime);
597 fCollisionGeometry = &fHeader;
601 Bool_t AliGenHijing::CheckTrigger()
603 // Check the kinematic trigger condition
605 Bool_t triggered = kFALSE;
611 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
612 fHijing->GetHINT1(27),
613 fHijing->GetHINT1(28),
614 fHijing->GetHINT1(29));
616 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
617 fHijing->GetHINT1(37),
618 fHijing->GetHINT1(38),
619 fHijing->GetHINT1(39));
620 Double_t eta1 = jet1->Eta();
621 Double_t eta2 = jet2->Eta();
622 Double_t phi1 = jet1->Phi();
623 Double_t phi2 = jet2->Phi();
624 // printf("\n Trigger: %f %f %f %f",
625 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
627 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
628 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
630 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
631 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
634 } else if (fTrigger == 2) {
637 Int_t np = fParticles.GetEntriesFast();
638 for (Int_t i = 0; i < np; i++) {
639 TParticle* part = (TParticle*) fParticles.At(i);
640 Int_t kf = part->GetPdgCode();
641 Int_t ksp = part->GetUniqueID();
642 if (kf == 22 && ksp == 40) {
643 Float_t phi = part->Phi();
644 Float_t eta = part->Eta();
645 if (eta < fEtaMaxJet &&
651 } // check phi,eta within limits