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()
66 fPhiMaxJet(2. * TMath::Pi()),
76 fNoHeavyQuarks(kFALSE)
80 AliHijingRndm::SetHijingRandom(GetRandom());
83 AliGenHijing::AliGenHijing(Int_t npart)
110 fPhiMaxJet(2. * TMath::Pi()),
120 fNoHeavyQuarks(kFALSE)
122 // Default PbPb collisions at 5. 5 TeV
125 fTitle= "Particle Generator using HIJING";
127 fParticles = new TClonesArray("TParticle",10000);
129 // Set random number generator
130 AliHijingRndm::SetHijingRandom(GetRandom());
133 AliGenHijing::~AliGenHijing()
136 if ( fDsigmaDb) delete fDsigmaDb;
137 if ( fDnDb) delete fDnDb;
141 void AliGenHijing::Init()
146 fProjectile.Resize(8);
148 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
149 fAProjectile, fZProjectile, fATarget, fZTarget,
150 fMinImpactParam, fMaxImpactParam));
152 fHijing=(THijing*) fMCEvGen;
153 fHijing->SetIHPR2(2, fRadiation);
154 fHijing->SetIHPR2(3, fTrigger);
155 fHijing->SetIHPR2(6, fShadowing);
156 fHijing->SetIHPR2(12, fDecaysOff);
157 fHijing->SetIHPR2(21, fKeep);
158 fHijing->SetHIPR1(10, fPtMinJet);
159 fHijing->SetHIPR1(50, fSimpleJet);
164 // fQuench = 0: no quenching
165 // fQuench = 1: hijing default
166 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
167 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
168 // fQuench = 4: new LHC parameters with log(e) dependence
169 // fQuench = 5: new RHIC parameters with log(e) dependence
170 fHijing->SetIHPR2(50, 0);
172 fHijing->SetIHPR2(4, 1);
174 fHijing->SetIHPR2(4, 0);
175 // New LHC parameters from Xin-Nian Wang
177 fHijing->SetHIPR1(14, 1.1);
178 fHijing->SetHIPR1(11, 3.7);
179 } else if (fQuench == 3) {
180 fHijing->SetHIPR1(14, 0.20);
181 fHijing->SetHIPR1(11, 2.5);
182 } else if (fQuench == 4) {
183 fHijing->SetIHPR2(50, 1);
184 fHijing->SetHIPR1(14, 4.*0.34);
185 fHijing->SetHIPR1(11, 3.7);
186 } else if (fQuench == 5) {
187 fHijing->SetIHPR2(50, 1);
188 fHijing->SetHIPR1(14, 0.34);
189 fHijing->SetHIPR1(11, 2.5);
195 if (fNoHeavyQuarks) {
196 fHijing->SetIHPR2(49, 1);
198 fHijing->SetIHPR2(49, 0);
207 fHijing->Initialize();
209 if (fEvaluate) EvaluateCrossSections();
213 void AliGenHijing::Generate()
215 // Generate one event
217 Float_t polar[3] = {0,0,0};
218 Float_t origin[3] = {0,0,0};
219 Float_t origin0[3] = {0,0,0};
223 // converts from mm/c to s
224 const Float_t kconv = 0.001/2.99792458e8;
228 Int_t j, kf, ks, ksp, imo;
235 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
236 if(fVertexSmear == kPerEvent) {
238 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
242 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();
263 printf("\n **************************************************%d\n",np);
265 if (np == 0 ) continue;
267 Int_t* newPos = new Int_t[np];
268 Int_t* pSelected = new Int_t[np];
270 for (i = 0; i < np; i++) {
277 TParticle * iparticle = (TParticle *) fParticles->At(0);
278 fVertex[0] = origin0[0];
279 fVertex[1] = origin0[1];
280 fVertex[2] = origin0[2];
283 // First select parent particles
286 for (i = 0; i < np; i++) {
287 iparticle = (TParticle *) fParticles->At(i);
289 // Is this a parent particle ?
290 if (Stable(iparticle)) continue;
292 Bool_t selected = kTRUE;
293 Bool_t hasSelectedDaughters = kFALSE;
296 kf = iparticle->GetPdgCode();
297 ks = iparticle->GetStatusCode();
298 if (kf == 92) continue;
300 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
302 hasSelectedDaughters = DaughtersSelection(iparticle);
304 // Put particle on the stack if it is either selected or
305 // it is the mother of at least one seleted particle
307 if (selected || hasSelectedDaughters) {
311 } // particle loop parents
313 // Now select the final state particles
316 for (i = 0; i<np; i++) {
317 TParticle * iparticle = (TParticle *) fParticles->At(i);
318 // Is this a final state particle ?
319 if (!Stable(iparticle)) continue;
321 Bool_t selected = kTRUE;
322 kf = iparticle->GetPdgCode();
323 ks = iparticle->GetStatusCode();
324 ksp = iparticle->GetUniqueID();
326 // --------------------------------------------------------------------------
327 // Count spectator neutrons and protons
328 if(ksp == 0 || ksp == 1){
329 if(kf == kNeutron) fProjectileSpecn += 1;
330 if(kf == kProton) fProjectileSpecp += 1;
332 else if(ksp == 10 || ksp == 11){
333 if(kf == kNeutron) fTargetSpecn += 1;
334 if(kf == kProton) fTargetSpecp += 1;
336 // --------------------------------------------------------------------------
339 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
340 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
344 // Put particle on the stack if selected
350 } // particle loop final state
353 // Time of the interactions
355 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
358 // Write particles to stack
360 for (i = 0; i<np; i++) {
361 TParticle * iparticle = (TParticle *) fParticles->At(i);
362 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
363 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
365 kf = iparticle->GetPdgCode();
366 ks = iparticle->GetStatusCode();
367 p[0] = iparticle->Px();
368 p[1] = iparticle->Py();
369 p[2] = iparticle->Pz() * sign;
370 origin[0] = origin0[0]+iparticle->Vx()/10;
371 origin[1] = origin0[1]+iparticle->Vy()/10;
372 origin[2] = origin0[2]+iparticle->Vz()/10;
373 tof = kconv * iparticle->T() + sign * origin0[2] / 3.e10;
374 if (fPileUpTimeWindow > 0.) tof += tInt;
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 printf("\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 printf("\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));
430 Float_t oldvalue= 0.;
432 Float_t* b = new Float_t[kMax];
433 Float_t* si1 = new Float_t[kMax];
434 Float_t* si2 = new Float_t[kMax];
436 for (i = 0; i < kMax; i++)
438 Float_t xb = bMin+i*kdib;
440 ov=fHijing->Profile(xb);
441 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
442 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
445 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
447 if (xb > fMinImpactParam && xb < fMaxImpactParam)
453 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
455 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
456 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
464 printf("\n Total cross section (barn): %f \n",xTot);
465 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
466 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
467 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
469 // Store result as a graph
474 fDsigmaDb = new TGraph(i, b, si1);
475 fDnDb = new TGraph(i, b, si2);
478 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
481 // Looks recursively if one of the daughters has been selected
483 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
487 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
488 Bool_t selected = kFALSE;
490 imin = iparticle->GetFirstDaughter();
491 imax = iparticle->GetLastDaughter();
492 for (i = imin; i <= imax; i++){
493 TParticle * jparticle = (TParticle *) fParticles->At(i);
494 Int_t ip = jparticle->GetPdgCode();
495 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
496 selected=kTRUE; break;
498 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
507 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
509 // Select flavor of particle
511 // 4: charm and beauty
518 Int_t ifl = TMath::Abs(pid/100);
519 if (ifl > 10) ifl/=10;
520 res = (fFlavor == ifl);
523 // This part if gamma writing is inhibited
525 res = res && (pid != kGamma && pid != kPi0);
530 Bool_t AliGenHijing::Stable(TParticle* particle) const
532 // Return true for a stable particle
535 if (particle->GetFirstDaughter() < 0 )
545 void AliGenHijing::MakeHeader()
547 // Builds the event header, to be called after each event
548 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
549 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
550 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
551 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
552 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
553 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
554 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
558 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
559 fTargetSpecn,fTargetSpecp);
560 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
564 // 4-momentum vectors of the triggered jets.
566 // Before final state gluon radiation.
567 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
568 fHijing->GetHINT1(22),
569 fHijing->GetHINT1(23),
570 fHijing->GetHINT1(24));
572 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
573 fHijing->GetHINT1(32),
574 fHijing->GetHINT1(33),
575 fHijing->GetHINT1(34));
576 // After final state gluon radiation.
577 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
578 fHijing->GetHINT1(27),
579 fHijing->GetHINT1(28),
580 fHijing->GetHINT1(29));
582 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
583 fHijing->GetHINT1(37),
584 fHijing->GetHINT1(38),
585 fHijing->GetHINT1(39));
586 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
587 // Bookkeeping for kinematic bias
588 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
590 header->SetPrimaryVertex(fVertex);
592 fCollisionGeometry = (AliGenHijingEventHeader*) header;
596 Bool_t AliGenHijing::CheckTrigger()
598 // Check the kinematic trigger condition
600 Bool_t triggered = kFALSE;
606 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
607 fHijing->GetHINT1(27),
608 fHijing->GetHINT1(28),
609 fHijing->GetHINT1(29));
611 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
612 fHijing->GetHINT1(37),
613 fHijing->GetHINT1(38),
614 fHijing->GetHINT1(39));
615 Double_t eta1 = jet1->Eta();
616 Double_t eta2 = jet2->Eta();
617 Double_t phi1 = jet1->Phi();
618 Double_t phi2 = jet2->Phi();
619 // printf("\n Trigger: %f %f %f %f",
620 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
622 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
623 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
625 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
626 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
629 } else if (fTrigger == 2) {
632 Int_t np = fParticles->GetEntriesFast();
633 for (Int_t i = 0; i < np; i++) {
634 TParticle* part = (TParticle*) fParticles->At(i);
635 Int_t kf = part->GetPdgCode();
636 Int_t ksp = part->GetUniqueID();
637 if (kf == 22 && ksp == 40) {
638 Float_t phi = part->Phi();
639 Float_t eta = part->Eta();
640 if (eta < fEtaMaxJet &&
646 } // check phi,eta within limits