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];
234 if(fVertexSmear == kPerEvent) {
236 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
240 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
243 // Generate one event
244 // --------------------------------------------------------------------------
245 fProjectileSpecn = 0;
246 fProjectileSpecp = 0;
249 // --------------------------------------------------------------------------
250 fHijing->GenerateEvent();
253 fHijing->ImportParticles(&fParticles,"All");
254 if (fTrigger != kNoTrigger) {
255 if (!CheckTrigger()) continue;
260 Int_t np = fParticles.GetEntriesFast();
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 tof = kconv * iparticle->T();
372 if (fPileUpTimeWindow > 0.) tof += tInt;
375 TParticle* mother = 0;
377 imo = iparticle->GetFirstMother();
378 mother = (TParticle *) fParticles.At(imo);
379 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
381 Bool_t tFlag = (fTrackIt && !hasDaughter);
382 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
391 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
394 if (jev >= fNpart || fNpart == -1) {
395 fKineBias = Float_t(fNpart)/Float_t(fTrials);
396 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
402 SetHighWaterMark(nt);
405 void AliGenHijing::KeepFullEvent()
410 void AliGenHijing::EvaluateCrossSections()
412 // Glauber Calculation of geometrical x-section
414 Float_t xTot = 0.; // barn
415 Float_t xTotHard = 0.; // barn
416 Float_t xPart = 0.; // barn
417 Float_t xPartHard = 0.; // barn
418 Float_t sigmaHard = 0.1; // mbarn
420 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
421 const Float_t kdib = 0.2;
422 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
425 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
426 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
428 Float_t oldvalue= 0.;
430 Float_t* b = new Float_t[kMax];
431 Float_t* si1 = new Float_t[kMax];
432 Float_t* si2 = new Float_t[kMax];
434 for (i = 0; i < kMax; i++)
436 Float_t xb = bMin+i*kdib;
438 ov=fHijing->Profile(xb);
439 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
440 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
443 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
445 if (xb > fMinImpactParam && xb < fMaxImpactParam)
451 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
453 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
454 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
462 printf("\n Total cross section (barn): %f \n",xTot);
463 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
464 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
465 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
467 // Store result as a graph
472 fDsigmaDb = new TGraph(i, b, si1);
473 fDnDb = new TGraph(i, b, si2);
476 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
479 // Looks recursively if one of the daughters has been selected
481 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
485 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
486 Bool_t selected = kFALSE;
488 imin = iparticle->GetFirstDaughter();
489 imax = iparticle->GetLastDaughter();
490 for (i = imin; i <= imax; i++){
491 TParticle * jparticle = (TParticle *) fParticles.At(i);
492 Int_t ip = jparticle->GetPdgCode();
493 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
494 selected=kTRUE; break;
496 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
505 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
507 // Select flavor of particle
509 // 4: charm and beauty
516 Int_t ifl = TMath::Abs(pid/100);
517 if (ifl > 10) ifl/=10;
518 res = (fFlavor == ifl);
521 // This part if gamma writing is inhibited
523 res = res && (pid != kGamma && pid != kPi0);
528 Bool_t AliGenHijing::Stable(TParticle* particle) const
530 // Return true for a stable particle
533 if (particle->GetFirstDaughter() < 0 )
543 void AliGenHijing::MakeHeader()
545 // Builds the event header, to be called after each event
546 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
547 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
548 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
549 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
550 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
551 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
552 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
556 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
557 fTargetSpecn,fTargetSpecp);
558 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
562 // 4-momentum vectors of the triggered jets.
564 // Before final state gluon radiation.
565 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
566 fHijing->GetHINT1(22),
567 fHijing->GetHINT1(23),
568 fHijing->GetHINT1(24));
570 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
571 fHijing->GetHINT1(32),
572 fHijing->GetHINT1(33),
573 fHijing->GetHINT1(34));
574 // After final state gluon radiation.
575 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
576 fHijing->GetHINT1(27),
577 fHijing->GetHINT1(28),
578 fHijing->GetHINT1(29));
580 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
581 fHijing->GetHINT1(37),
582 fHijing->GetHINT1(38),
583 fHijing->GetHINT1(39));
584 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
585 // Bookkeeping for kinematic bias
586 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
588 header->SetPrimaryVertex(fVertex);
590 fCollisionGeometry = (AliGenHijingEventHeader*) header;
594 Bool_t AliGenHijing::CheckTrigger()
596 // Check the kinematic trigger condition
598 Bool_t triggered = kFALSE;
604 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
605 fHijing->GetHINT1(27),
606 fHijing->GetHINT1(28),
607 fHijing->GetHINT1(29));
609 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
610 fHijing->GetHINT1(37),
611 fHijing->GetHINT1(38),
612 fHijing->GetHINT1(39));
613 Double_t eta1 = jet1->Eta();
614 Double_t eta2 = jet2->Eta();
615 Double_t phi1 = jet1->Phi();
616 Double_t phi2 = jet2->Phi();
617 // printf("\n Trigger: %f %f %f %f",
618 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
620 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
621 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
623 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
624 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
627 } else if (fTrigger == 2) {
630 Int_t np = fParticles.GetEntriesFast();
631 for (Int_t i = 0; i < np; i++) {
632 TParticle* part = (TParticle*) fParticles.At(i);
633 Int_t kf = part->GetPdgCode();
634 Int_t ksp = part->GetUniqueID();
635 if (kf == 22 && ksp == 40) {
636 Float_t phi = part->Phi();
637 Float_t eta = part->Eta();
638 if (eta < fEtaMaxJet &&
644 } // check phi,eta within limits