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)
27 #include <TLorentzVector.h>
29 #include <TParticle.h>
31 #include "AliGenHijing.h"
32 #include "AliGenHijingEventHeader.h"
34 #include "AliHijingRndm.h"
36 ClassImp(AliGenHijing)
38 AliGenHijing::AliGenHijing()
65 fPhiMaxJet(2. * TMath::Pi()),
75 fNoHeavyQuarks(kFALSE)
79 AliHijingRndm::SetHijingRandom(GetRandom());
82 AliGenHijing::AliGenHijing(Int_t npart)
109 fPhiMaxJet(2. * TMath::Pi()),
119 fNoHeavyQuarks(kFALSE)
121 // Default PbPb collisions at 5. 5 TeV
124 fTitle= "Particle Generator using HIJING";
126 fParticles = new TClonesArray("TParticle",10000);
128 // Set random number generator
129 AliHijingRndm::SetHijingRandom(GetRandom());
132 AliGenHijing::AliGenHijing(const AliGenHijing & hijing):
159 fPhiMaxJet(2. * TMath::Pi()),
169 fNoHeavyQuarks(kFALSE)
175 AliGenHijing::~AliGenHijing()
178 if ( fDsigmaDb) delete fDsigmaDb;
179 if ( fDnDb) delete fDnDb;
183 void AliGenHijing::Init()
188 fProjectile.Resize(8);
190 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
191 fAProjectile, fZProjectile, fATarget, fZTarget,
192 fMinImpactParam, fMaxImpactParam));
194 fHijing=(THijing*) fMCEvGen;
195 fHijing->SetIHPR2(2, fRadiation);
196 fHijing->SetIHPR2(3, fTrigger);
197 fHijing->SetIHPR2(6, fShadowing);
198 fHijing->SetIHPR2(12, fDecaysOff);
199 fHijing->SetIHPR2(21, fKeep);
200 fHijing->SetHIPR1(10, fPtMinJet);
201 fHijing->SetHIPR1(50, fSimpleJet);
206 // fQuench = 0: no quenching
207 // fQuench = 1: hijing default
208 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
209 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
210 // fQuench = 4: new LHC parameters with log(e) dependence
211 // fQuench = 5: new RHIC parameters with log(e) dependence
212 fHijing->SetIHPR2(50, 0);
214 fHijing->SetIHPR2(4, 1);
216 fHijing->SetIHPR2(4, 0);
217 // New LHC parameters from Xin-Nian Wang
219 fHijing->SetHIPR1(14, 1.1);
220 fHijing->SetHIPR1(11, 3.7);
221 } else if (fQuench == 3) {
222 fHijing->SetHIPR1(14, 0.20);
223 fHijing->SetHIPR1(11, 2.5);
224 } else if (fQuench == 4) {
225 fHijing->SetIHPR2(50, 1);
226 fHijing->SetHIPR1(14, 4.*0.34);
227 fHijing->SetHIPR1(11, 3.7);
228 } else if (fQuench == 5) {
229 fHijing->SetIHPR2(50, 1);
230 fHijing->SetHIPR1(14, 0.34);
231 fHijing->SetHIPR1(11, 2.5);
237 if (fNoHeavyQuarks) {
238 fHijing->SetIHPR2(49, 1);
240 fHijing->SetIHPR2(49, 0);
249 fHijing->Initialize();
251 if (fEvaluate) EvaluateCrossSections();
255 void AliGenHijing::Generate()
257 // Generate one event
259 Float_t polar[3] = {0,0,0};
260 Float_t origin[3] = {0,0,0};
261 Float_t origin0[3] = {0,0,0};
265 // converts from mm/c to s
266 const Float_t kconv = 0.001/2.999792458e8;
270 Int_t j, kf, ks, ksp, imo;
276 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
277 if(fVertexSmear == kPerEvent) {
279 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
283 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
286 // Generate one event
287 // --------------------------------------------------------------------------
288 fProjectileSpecn = 0;
289 fProjectileSpecp = 0;
292 // --------------------------------------------------------------------------
293 fHijing->GenerateEvent();
295 fHijing->ImportParticles(fParticles,"All");
296 if (fTrigger != kNoTrigger) {
297 if (!CheckTrigger()) continue;
302 Int_t np = fParticles->GetEntriesFast();
303 printf("\n **************************************************%d\n",np);
305 if (np == 0 ) continue;
307 Int_t* newPos = new Int_t[np];
308 Int_t* pSelected = new Int_t[np];
310 for (i = 0; i < np; i++) {
317 TParticle * iparticle = (TParticle *) fParticles->At(0);
318 fVertex[0] = origin0[0];
319 fVertex[1] = origin0[1];
320 fVertex[2] = origin0[2];
323 // First select parent particles
326 for (i = 0; i < np; i++) {
327 iparticle = (TParticle *) fParticles->At(i);
329 // Is this a parent particle ?
330 if (Stable(iparticle)) continue;
332 Bool_t selected = kTRUE;
333 Bool_t hasSelectedDaughters = kFALSE;
336 kf = iparticle->GetPdgCode();
337 ks = iparticle->GetStatusCode();
338 if (kf == 92) continue;
340 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
342 hasSelectedDaughters = DaughtersSelection(iparticle);
344 // Put particle on the stack if it is either selected or
345 // it is the mother of at least one seleted particle
347 if (selected || hasSelectedDaughters) {
351 } // particle loop parents
353 // Now select the final state particles
356 for (i = 0; i<np; i++) {
357 TParticle * iparticle = (TParticle *) fParticles->At(i);
358 // Is this a final state particle ?
359 if (!Stable(iparticle)) continue;
361 Bool_t selected = kTRUE;
362 kf = iparticle->GetPdgCode();
363 ks = iparticle->GetStatusCode();
364 ksp = iparticle->GetUniqueID();
366 // --------------------------------------------------------------------------
367 // Count spectator neutrons and protons
368 if(ksp == 0 || ksp == 1){
369 if(kf == kNeutron) fProjectileSpecn += 1;
370 if(kf == kProton) fProjectileSpecp += 1;
372 else if(ksp == 10 || ksp == 11){
373 if(kf == kNeutron) fTargetSpecn += 1;
374 if(kf == kProton) fTargetSpecp += 1;
376 // --------------------------------------------------------------------------
379 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
380 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
384 // Put particle on the stack if selected
390 } // particle loop final state
393 // Time of the interactions
395 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
398 // Write particles to stack
400 for (i = 0; i<np; i++) {
401 TParticle * iparticle = (TParticle *) fParticles->At(i);
402 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
403 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
405 kf = iparticle->GetPdgCode();
406 ks = iparticle->GetStatusCode();
407 p[0] = iparticle->Px();
408 p[1] = iparticle->Py();
409 p[2] = iparticle->Pz() * sign;
410 origin[0] = origin0[0]+iparticle->Vx()/10;
411 origin[1] = origin0[1]+iparticle->Vy()/10;
412 origin[2] = origin0[2]+iparticle->Vz()/10;
413 tof = kconv * iparticle->T() + sign * origin0[2] / 3.e10;
414 if (fPileUpTimeWindow > 0.) tof += tInt;
417 TParticle* mother = 0;
419 imo = iparticle->GetFirstMother();
420 mother = (TParticle *) fParticles->At(imo);
421 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
423 Bool_t tFlag = (fTrackIt && !hasDaughter);
424 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
434 printf("\n I've put %i particles on the stack \n",nc);
437 if (jev >= fNpart || fNpart == -1) {
438 fKineBias = Float_t(fNpart)/Float_t(fTrials);
439 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
445 SetHighWaterMark(nt);
448 void AliGenHijing::KeepFullEvent()
453 void AliGenHijing::EvaluateCrossSections()
455 // Glauber Calculation of geometrical x-section
457 Float_t xTot = 0.; // barn
458 Float_t xTotHard = 0.; // barn
459 Float_t xPart = 0.; // barn
460 Float_t xPartHard = 0.; // barn
461 Float_t sigmaHard = 0.1; // mbarn
463 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
464 const Float_t kdib = 0.2;
465 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
468 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
469 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
471 Float_t oldvalue= 0.;
473 Float_t* b = new Float_t[kMax];
474 Float_t* si1 = new Float_t[kMax];
475 Float_t* si2 = new Float_t[kMax];
477 for (i = 0; i < kMax; i++)
479 Float_t xb = bMin+i*kdib;
481 ov=fHijing->Profile(xb);
482 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
483 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
486 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
488 if (xb > fMinImpactParam && xb < fMaxImpactParam)
494 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
496 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
497 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
505 printf("\n Total cross section (barn): %f \n",xTot);
506 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
507 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
508 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
510 // Store result as a graph
515 fDsigmaDb = new TGraph(i, b, si1);
516 fDnDb = new TGraph(i, b, si2);
519 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
522 // Looks recursively if one of the daughters has been selected
524 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
528 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
529 Bool_t selected = kFALSE;
531 imin = iparticle->GetFirstDaughter();
532 imax = iparticle->GetLastDaughter();
533 for (i = imin; i <= imax; i++){
534 TParticle * jparticle = (TParticle *) fParticles->At(i);
535 Int_t ip = jparticle->GetPdgCode();
536 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
537 selected=kTRUE; break;
539 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
548 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
550 // Select flavor of particle
552 // 4: charm and beauty
559 Int_t ifl = TMath::Abs(pid/100);
560 if (ifl > 10) ifl/=10;
561 res = (fFlavor == ifl);
564 // This part if gamma writing is inhibited
566 res = res && (pid != kGamma && pid != kPi0);
571 Bool_t AliGenHijing::Stable(TParticle* particle) const
573 // Return true for a stable particle
576 if (particle->GetFirstDaughter() < 0 )
586 void AliGenHijing::MakeHeader()
588 // Builds the event header, to be called after each event
589 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
590 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
591 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
592 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
593 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
594 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
595 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
599 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
600 fTargetSpecn,fTargetSpecp);
601 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
605 // 4-momentum vectors of the triggered jets.
607 // Before final state gluon radiation.
608 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
609 fHijing->GetHINT1(22),
610 fHijing->GetHINT1(23),
611 fHijing->GetHINT1(24));
613 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
614 fHijing->GetHINT1(32),
615 fHijing->GetHINT1(33),
616 fHijing->GetHINT1(34));
617 // After final state gluon radiation.
618 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
619 fHijing->GetHINT1(27),
620 fHijing->GetHINT1(28),
621 fHijing->GetHINT1(29));
623 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
624 fHijing->GetHINT1(37),
625 fHijing->GetHINT1(38),
626 fHijing->GetHINT1(39));
627 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
628 // Bookkeeping for kinematic bias
629 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
631 header->SetPrimaryVertex(fVertex);
633 fCollisionGeometry = (AliGenHijingEventHeader*) header;
636 void AliGenHijing::AddHeader(AliGenEventHeader* header)
638 // Passes header either to the container or to gAlice
640 fContainer->AddHeader(header);
642 gAlice->SetGenEventHeader(header);
647 Bool_t AliGenHijing::CheckTrigger()
649 // Check the kinematic trigger condition
651 Bool_t triggered = kFALSE;
657 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
658 fHijing->GetHINT1(27),
659 fHijing->GetHINT1(28),
660 fHijing->GetHINT1(29));
662 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
663 fHijing->GetHINT1(37),
664 fHijing->GetHINT1(38),
665 fHijing->GetHINT1(39));
666 Double_t eta1 = jet1->Eta();
667 Double_t eta2 = jet2->Eta();
668 Double_t phi1 = jet1->Phi();
669 Double_t phi2 = jet2->Phi();
670 // printf("\n Trigger: %f %f %f %f",
671 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
673 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
674 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
676 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
677 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
680 } else if (fTrigger == 2) {
683 Int_t np = fParticles->GetEntriesFast();
684 for (Int_t i = 0; i < np; i++) {
685 TParticle* part = (TParticle*) fParticles->At(i);
686 Int_t kf = part->GetPdgCode();
687 Int_t ksp = part->GetUniqueID();
688 if (kf == 22 && ksp == 40) {
689 Float_t phi = part->Phi();
690 Float_t eta = part->Eta();
691 if (eta < fEtaMaxJet &&
697 } // check phi,eta within limits
705 void AliGenHijing::Copy(TObject &) const
707 Fatal("Copy","Not implemented!\n");
710 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)