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(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];
237 if(fVertexSmear == kPerEvent) {
239 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
243 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
247 // Generate one event
248 // --------------------------------------------------------------------------
249 fProjectileSpecn = 0;
250 fProjectileSpecp = 0;
253 // --------------------------------------------------------------------------
254 fHijing->GenerateEvent();
257 fHijing->ImportParticles(&fParticles,"All");
258 if (fTrigger != kNoTrigger) {
259 if (!CheckTrigger()) continue;
264 Int_t np = fParticles.GetEntriesFast();
266 if (np == 0 ) continue;
268 Int_t* newPos = new Int_t[np];
269 Int_t* pSelected = new Int_t[np];
271 for (i = 0; i < np; i++) {
278 TParticle * iparticle = (TParticle *) fParticles.At(0);
279 fVertex[0] = origin0[0];
280 fVertex[1] = origin0[1];
281 fVertex[2] = origin0[2];
284 // First select parent particles
287 for (i = 0; i < np; i++) {
288 iparticle = (TParticle *) fParticles.At(i);
290 // Is this a parent particle ?
291 if (Stable(iparticle)) continue;
293 Bool_t selected = kTRUE;
294 Bool_t hasSelectedDaughters = kFALSE;
297 kf = iparticle->GetPdgCode();
298 ks = iparticle->GetStatusCode();
299 if (kf == 92) continue;
301 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
303 hasSelectedDaughters = DaughtersSelection(iparticle);
305 // Put particle on the stack if it is either selected or
306 // it is the mother of at least one seleted particle
308 if (selected || hasSelectedDaughters) {
312 } // particle loop parents
314 // Now select the final state particles
317 for (i = 0; i<np; i++) {
318 iparticle = (TParticle *) fParticles.At(i);
319 // Is this a final state particle ?
320 if (!Stable(iparticle)) continue;
322 Bool_t selected = kTRUE;
323 kf = iparticle->GetPdgCode();
324 ks = iparticle->GetStatusCode();
325 ksp = iparticle->GetUniqueID();
327 // --------------------------------------------------------------------------
328 // Count spectator neutrons and protons
329 if(ksp == 0 || ksp == 1){
330 if(kf == kNeutron) fProjectileSpecn += 1;
331 if(kf == kProton) fProjectileSpecp += 1;
333 else if(ksp == 10 || ksp == 11){
334 if(kf == kNeutron) fTargetSpecn += 1;
335 if(kf == kProton) fTargetSpecp += 1;
337 // --------------------------------------------------------------------------
340 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
341 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
345 // Put particle on the stack if selected
351 } // particle loop final state
354 // Time of the interactions
356 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
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;
376 if (TestBit(kVertexRange)) {
377 fEventTime = sign * origin0[2] / 2.99792458e10;
378 tof = kconv * iparticle->T() + fEventTime;
380 tof = kconv * iparticle->T();
382 if (fPileUpTimeWindow > 0.) tof += tInt;
385 TParticle* mother = 0;
387 imo = iparticle->GetFirstMother();
388 mother = (TParticle *) fParticles.At(imo);
389 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
391 Bool_t tFlag = (fTrackIt && !hasDaughter);
392 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
401 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
404 if (jev >= fNpart || fNpart == -1) {
405 fKineBias = Float_t(fNpart)/Float_t(fTrials);
406 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
412 SetHighWaterMark(nt);
415 void AliGenHijing::KeepFullEvent()
420 void AliGenHijing::EvaluateCrossSections()
422 // Glauber Calculation of geometrical x-section
424 Float_t xTot = 0.; // barn
425 Float_t xTotHard = 0.; // barn
426 Float_t xPart = 0.; // barn
427 Float_t xPartHard = 0.; // barn
428 Float_t sigmaHard = 0.1; // mbarn
430 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
431 const Float_t kdib = 0.2;
432 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
435 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
436 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
438 Float_t oldvalue= 0.;
440 Float_t* b = new Float_t[kMax];
441 Float_t* si1 = new Float_t[kMax];
442 Float_t* si2 = new Float_t[kMax];
444 for (i = 0; i < kMax; i++)
446 Float_t xb = bMin+i*kdib;
448 ov=fHijing->Profile(xb);
449 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
450 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
453 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
455 if (xb > fMinImpactParam && xb < fMaxImpactParam)
461 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
463 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
464 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
472 printf("\n Total cross section (barn): %f \n",xTot);
473 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
474 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
475 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
477 // Store result as a graph
482 fDsigmaDb = new TGraph(i, b, si1);
483 fDnDb = new TGraph(i, b, si2);
486 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
489 // Looks recursively if one of the daughters has been selected
491 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
495 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
496 Bool_t selected = kFALSE;
498 imin = iparticle->GetFirstDaughter();
499 imax = iparticle->GetLastDaughter();
500 for (i = imin; i <= imax; i++){
501 TParticle * jparticle = (TParticle *) fParticles.At(i);
502 Int_t ip = jparticle->GetPdgCode();
503 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
504 selected=kTRUE; break;
506 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
515 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
517 // Select flavor of particle
519 // 4: charm and beauty
526 Int_t ifl = TMath::Abs(pid/100);
527 if (ifl > 10) ifl/=10;
528 res = (fFlavor == ifl);
531 // This part if gamma writing is inhibited
533 res = res && (pid != kGamma && pid != kPi0);
538 Bool_t AliGenHijing::Stable(TParticle* particle) const
540 // Return true for a stable particle
543 if (particle->GetFirstDaughter() < 0 )
553 void AliGenHijing::MakeHeader()
555 // Builds the event header, to be called after each event
556 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
557 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
558 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
559 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
560 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
561 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
562 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
566 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
567 fTargetSpecn,fTargetSpecp);
568 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
569 // printf("Impact Parameter %13.3f \n", fHijing->GetHINT1(19));
573 // 4-momentum vectors of the triggered jets.
575 // Before final state gluon radiation.
576 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
577 fHijing->GetHINT1(22),
578 fHijing->GetHINT1(23),
579 fHijing->GetHINT1(24));
581 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
582 fHijing->GetHINT1(32),
583 fHijing->GetHINT1(33),
584 fHijing->GetHINT1(34));
585 // After final state gluon radiation.
586 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
587 fHijing->GetHINT1(27),
588 fHijing->GetHINT1(28),
589 fHijing->GetHINT1(29));
591 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
592 fHijing->GetHINT1(37),
593 fHijing->GetHINT1(38),
594 fHijing->GetHINT1(39));
595 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
596 // Bookkeeping for kinematic bias
597 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
599 header->SetPrimaryVertex(fVertex);
600 header->SetInteractionTime(fEventTime);
602 fCollisionGeometry = (AliGenHijingEventHeader*) header;
606 Bool_t AliGenHijing::CheckTrigger()
608 // Check the kinematic trigger condition
610 Bool_t triggered = kFALSE;
616 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
617 fHijing->GetHINT1(27),
618 fHijing->GetHINT1(28),
619 fHijing->GetHINT1(29));
621 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
622 fHijing->GetHINT1(37),
623 fHijing->GetHINT1(38),
624 fHijing->GetHINT1(39));
625 Double_t eta1 = jet1->Eta();
626 Double_t eta2 = jet2->Eta();
627 Double_t phi1 = jet1->Phi();
628 Double_t phi2 = jet2->Phi();
629 // printf("\n Trigger: %f %f %f %f",
630 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
632 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
633 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
635 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
636 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
639 } else if (fTrigger == 2) {
642 Int_t np = fParticles.GetEntriesFast();
643 for (Int_t i = 0; i < np; i++) {
644 TParticle* part = (TParticle*) fParticles.At(i);
645 Int_t kf = part->GetPdgCode();
646 Int_t ksp = part->GetUniqueID();
647 if (kf == 22 && ksp == 40) {
648 Float_t phi = part->Phi();
649 Float_t eta = part->Eta();
650 if (eta < fEtaMaxJet &&
656 } // check phi,eta within limits