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),
81 AliHijingRndm::SetHijingRandom(GetRandom());
84 AliGenHijing::AliGenHijing(Int_t npart)
110 fPhiMaxJet(2. * TMath::Pi()),
120 fNoHeavyQuarks(kFALSE),
123 // Default PbPb collisions at 5. 5 TeV
127 fTitle= "Particle Generator using HIJING";
130 // Set random number generator
131 AliHijingRndm::SetHijingRandom(GetRandom());
134 AliGenHijing::~AliGenHijing()
137 if ( fDsigmaDb) delete fDsigmaDb;
138 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(8, fPtHardMin);
159 fHijing->SetHIPR1(9, fPtHardMax);
160 fHijing->SetHIPR1(10, fPtMinJet);
161 fHijing->SetHIPR1(50, fSimpleJet);
166 // fQuench = 0: no quenching
167 // fQuench = 1: hijing default
168 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
169 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
170 // fQuench = 4: new LHC parameters with log(e) dependence
171 // fQuench = 5: new RHIC parameters with log(e) dependence
172 fHijing->SetIHPR2(50, 0);
174 fHijing->SetIHPR2(4, 1);
176 fHijing->SetIHPR2(4, 0);
177 // New LHC parameters from Xin-Nian Wang
179 fHijing->SetHIPR1(14, 1.1);
180 fHijing->SetHIPR1(11, 3.7);
181 } else if (fQuench == 3) {
182 fHijing->SetHIPR1(14, 0.20);
183 fHijing->SetHIPR1(11, 2.5);
184 } else if (fQuench == 4) {
185 fHijing->SetIHPR2(50, 1);
186 fHijing->SetHIPR1(14, 4.*0.34);
187 fHijing->SetHIPR1(11, 3.7);
188 } else if (fQuench == 5) {
189 fHijing->SetIHPR2(50, 1);
190 fHijing->SetHIPR1(14, 0.34);
191 fHijing->SetHIPR1(11, 2.5);
197 if (fNoHeavyQuarks) {
198 fHijing->SetIHPR2(49, 1);
200 fHijing->SetIHPR2(49, 0);
209 fHijing->Initialize();
211 if (fEvaluate) EvaluateCrossSections();
215 void AliGenHijing::Generate()
217 // Generate one event
219 Float_t polar[3] = {0,0,0};
220 Float_t origin[3] = {0,0,0};
221 Float_t origin0[3] = {0,0,0};
225 // converts from mm/c to s
226 const Float_t kconv = 0.001/2.99792458e8;
230 Int_t j, kf, ks, ksp, imo;
237 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
239 if(fVertexSmear == kPerEvent) {
241 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
245 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
249 // Generate one event
250 // --------------------------------------------------------------------------
251 fProjectileSpecn = 0;
252 fProjectileSpecp = 0;
255 // --------------------------------------------------------------------------
256 fHijing->GenerateEvent();
259 fHijing->ImportParticles(&fParticles,"All");
260 if (fTrigger != kNoTrigger) {
261 if (!CheckTrigger()) continue;
266 Int_t np = fParticles.GetEntriesFast();
268 if (np == 0 ) continue;
270 Int_t* newPos = new Int_t[np];
271 Int_t* pSelected = new Int_t[np];
273 for (i = 0; i < np; i++) {
280 TParticle * iparticle = (TParticle *) fParticles.At(0);
281 fVertex[0] = origin0[0];
282 fVertex[1] = origin0[1];
283 fVertex[2] = origin0[2];
286 // First select parent particles
289 for (i = 0; i < np; i++) {
290 iparticle = (TParticle *) fParticles.At(i);
292 // Is this a parent particle ?
293 if (Stable(iparticle)) continue;
295 Bool_t selected = kTRUE;
296 Bool_t hasSelectedDaughters = kFALSE;
299 kf = iparticle->GetPdgCode();
300 ks = iparticle->GetStatusCode();
301 if (kf == 92) continue;
303 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
305 hasSelectedDaughters = DaughtersSelection(iparticle);
307 // Put particle on the stack if it is either selected or
308 // it is the mother of at least one seleted particle
310 if (selected || hasSelectedDaughters) {
314 } // particle loop parents
316 // Now select the final state particles
319 for (i = 0; i<np; i++) {
320 iparticle = (TParticle *) fParticles.At(i);
321 // Is this a final state particle ?
322 if (!Stable(iparticle)) continue;
324 Bool_t selected = kTRUE;
325 kf = iparticle->GetPdgCode();
326 ks = iparticle->GetStatusCode();
327 ksp = iparticle->GetUniqueID();
329 // --------------------------------------------------------------------------
330 // Count spectator neutrons and protons
331 if(ksp == 0 || ksp == 1){
332 if(kf == kNeutron) fProjectileSpecn += 1;
333 if(kf == kProton) fProjectileSpecp += 1;
335 else if(ksp == 10 || ksp == 11){
336 if(kf == kNeutron) fTargetSpecn += 1;
337 if(kf == kProton) fTargetSpecp += 1;
339 // --------------------------------------------------------------------------
342 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
343 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
347 // Put particle on the stack if selected
353 } // particle loop final state
356 // Time of the interactions
358 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
361 // Write particles to stack
363 for (i = 0; i<np; i++) {
364 iparticle = (TParticle *) fParticles.At(i);
365 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
366 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
368 kf = iparticle->GetPdgCode();
369 ks = iparticle->GetStatusCode();
370 p[0] = iparticle->Px();
371 p[1] = iparticle->Py();
372 p[2] = iparticle->Pz() * sign;
373 origin[0] = origin0[0]+iparticle->Vx()/10;
374 origin[1] = origin0[1]+iparticle->Vy()/10;
375 origin[2] = origin0[2]+iparticle->Vz()/10;
378 if (TestBit(kVertexRange)) {
379 fEventTime = sign * origin0[2] / 2.99792458e10;
380 tof = kconv * iparticle->T() + fEventTime;
382 tof = kconv * iparticle->T();
384 if (fPileUpTimeWindow > 0.) tof += tInt;
387 TParticle* mother = 0;
389 imo = iparticle->GetFirstMother();
390 mother = (TParticle *) fParticles.At(imo);
391 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
393 Bool_t tFlag = (fTrackIt && !hasDaughter);
394 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
403 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
406 if (jev >= fNpart || fNpart == -1) {
407 fKineBias = Float_t(fNpart)/Float_t(fTrials);
408 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
414 SetHighWaterMark(nt);
417 void AliGenHijing::KeepFullEvent()
422 void AliGenHijing::EvaluateCrossSections()
424 // Glauber Calculation of geometrical x-section
426 Float_t xTot = 0.; // barn
427 Float_t xTotHard = 0.; // barn
428 Float_t xPart = 0.; // barn
429 Float_t xPartHard = 0.; // barn
430 Float_t sigmaHard = 0.1; // mbarn
432 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
433 const Float_t kdib = 0.2;
434 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
437 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
438 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
440 Float_t oldvalue= 0.;
442 Float_t* b = new Float_t[kMax];
443 Float_t* si1 = new Float_t[kMax];
444 Float_t* si2 = new Float_t[kMax];
446 for (i = 0; i < kMax; i++)
448 Float_t xb = bMin+i*kdib;
450 ov=fHijing->Profile(xb);
451 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
452 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
455 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
457 if (xb > fMinImpactParam && xb < fMaxImpactParam)
463 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
465 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
466 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
474 printf("\n Total cross section (barn): %f \n",xTot);
475 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
476 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
477 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
479 // Store result as a graph
484 fDsigmaDb = new TGraph(i, b, si1);
485 fDnDb = new TGraph(i, b, si2);
488 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
491 // Looks recursively if one of the daughters has been selected
493 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
497 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
498 Bool_t selected = kFALSE;
500 imin = iparticle->GetFirstDaughter();
501 imax = iparticle->GetLastDaughter();
502 for (i = imin; i <= imax; i++){
503 TParticle * jparticle = (TParticle *) fParticles.At(i);
504 Int_t ip = jparticle->GetPdgCode();
505 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
506 selected=kTRUE; break;
508 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
517 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
519 // Select flavor of particle
521 // 4: charm and beauty
528 Int_t ifl = TMath::Abs(pid/100);
529 if (ifl > 10) ifl/=10;
530 res = (fFlavor == ifl);
533 // This part if gamma writing is inhibited
535 res = res && (pid != kGamma && pid != kPi0);
540 Bool_t AliGenHijing::Stable(TParticle* particle) const
542 // Return true for a stable particle
545 if (particle->GetFirstDaughter() < 0 )
555 void AliGenHijing::MakeHeader()
557 // Builds the event header, to be called after each event
558 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
559 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
560 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
561 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
562 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
563 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
564 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
568 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
569 fTargetSpecn,fTargetSpecp);
570 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
571 // printf("Impact Parameter %13.3f \n", fHijing->GetHINT1(19));
575 // 4-momentum vectors of the triggered jets.
577 // Before final state gluon radiation.
578 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
579 fHijing->GetHINT1(22),
580 fHijing->GetHINT1(23),
581 fHijing->GetHINT1(24));
583 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
584 fHijing->GetHINT1(32),
585 fHijing->GetHINT1(33),
586 fHijing->GetHINT1(34));
587 // After final state gluon radiation.
588 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
589 fHijing->GetHINT1(27),
590 fHijing->GetHINT1(28),
591 fHijing->GetHINT1(29));
593 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
594 fHijing->GetHINT1(37),
595 fHijing->GetHINT1(38),
596 fHijing->GetHINT1(39));
597 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
598 // Bookkeeping for kinematic bias
599 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
601 header->SetPrimaryVertex(fVertex);
602 header->SetInteractionTime(fEventTime);
604 fCollisionGeometry = (AliGenHijingEventHeader*) header;
608 Bool_t AliGenHijing::CheckTrigger()
610 // Check the kinematic trigger condition
612 Bool_t triggered = kFALSE;
618 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
619 fHijing->GetHINT1(27),
620 fHijing->GetHINT1(28),
621 fHijing->GetHINT1(29));
623 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
624 fHijing->GetHINT1(37),
625 fHijing->GetHINT1(38),
626 fHijing->GetHINT1(39));
627 Double_t eta1 = jet1->Eta();
628 Double_t eta2 = jet2->Eta();
629 Double_t phi1 = jet1->Phi();
630 Double_t phi2 = jet2->Phi();
631 // printf("\n Trigger: %f %f %f %f",
632 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
634 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
635 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
637 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
638 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
641 } else if (fTrigger == 2) {
644 Int_t np = fParticles.GetEntriesFast();
645 for (Int_t i = 0; i < np; i++) {
646 TParticle* part = (TParticle*) fParticles.At(i);
647 Int_t kf = part->GetPdgCode();
648 Int_t ksp = part->GetUniqueID();
649 if (kf == 22 && ksp == 40) {
650 Float_t phi = part->Phi();
651 Float_t eta = part->Eta();
652 if (eta < fEtaMaxJet &&
658 } // check phi,eta within limits