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()
46 AliHijingRndm::SetHijingRandom(GetRandom());
49 AliGenHijing::AliGenHijing(Int_t npart)
52 // Default PbPb collisions at 5. 5 TeV
55 fTitle= "Particle Generator using HIJING";
58 SetImpactParameterRange();
80 SwitchOffHeavyQuarks(kFALSE);
82 fParticles = new TClonesArray("TParticle",10000);
84 // Set random number generator
85 AliHijingRndm::SetHijingRandom(GetRandom());
90 AliGenHijing::AliGenHijing(const AliGenHijing & hijing):
97 AliGenHijing::~AliGenHijing()
100 if ( fDsigmaDb) delete fDsigmaDb;
101 if ( fDnDb) delete fDnDb;
105 void AliGenHijing::Init()
110 fProjectile.Resize(8);
112 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
113 fAProjectile, fZProjectile, fATarget, fZTarget,
114 fMinImpactParam, fMaxImpactParam));
116 fHijing=(THijing*) fMCEvGen;
117 fHijing->SetIHPR2(2, fRadiation);
118 fHijing->SetIHPR2(3, fTrigger);
119 fHijing->SetIHPR2(6, fShadowing);
120 fHijing->SetIHPR2(12, fDecaysOff);
121 fHijing->SetIHPR2(21, fKeep);
122 fHijing->SetHIPR1(10, fPtMinJet);
123 fHijing->SetHIPR1(50, fSimpleJet);
128 // fQuench = 0: no quenching
129 // fQuench = 1: hijing default
130 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
131 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
132 // fQuench = 4: new LHC parameters with log(e) dependence
133 // fQuench = 5: new RHIC parameters with log(e) dependence
134 fHijing->SetIHPR2(50, 0);
136 fHijing->SetIHPR2(4, 1);
138 fHijing->SetIHPR2(4, 0);
139 // New LHC parameters from Xin-Nian Wang
141 fHijing->SetHIPR1(14, 1.1);
142 fHijing->SetHIPR1(11, 3.7);
143 } else if (fQuench == 3) {
144 fHijing->SetHIPR1(14, 0.20);
145 fHijing->SetHIPR1(11, 2.5);
146 } else if (fQuench == 4) {
147 fHijing->SetIHPR2(50, 1);
148 fHijing->SetHIPR1(14, 4.*0.34);
149 fHijing->SetHIPR1(11, 3.7);
150 } else if (fQuench == 5) {
151 fHijing->SetIHPR2(50, 1);
152 fHijing->SetHIPR1(14, 0.34);
153 fHijing->SetHIPR1(11, 2.5);
159 if (fNoHeavyQuarks) {
160 fHijing->SetIHPR2(49, 1);
162 fHijing->SetIHPR2(49, 0);
171 fHijing->Initialize();
173 if (fEvaluate) EvaluateCrossSections();
177 void AliGenHijing::Generate()
179 // Generate one event
181 Float_t polar[3] = {0,0,0};
182 Float_t origin[3] = {0,0,0};
183 Float_t origin0[3] = {0,0,0};
187 // converts from mm/c to s
188 const Float_t kconv = 0.001/2.999792458e8;
192 Int_t j, kf, ks, ksp, imo;
198 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
199 if(fVertexSmear == kPerEvent) {
201 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
205 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
208 // Generate one event
209 // --------------------------------------------------------------------------
210 fProjectileSpecn = 0;
211 fProjectileSpecp = 0;
214 // --------------------------------------------------------------------------
215 fHijing->GenerateEvent();
217 fHijing->ImportParticles(fParticles,"All");
218 if (fTrigger != kNoTrigger) {
219 if (!CheckTrigger()) continue;
224 Int_t np = fParticles->GetEntriesFast();
225 printf("\n **************************************************%d\n",np);
227 if (np == 0 ) continue;
229 Int_t* newPos = new Int_t[np];
230 Int_t* pSelected = new Int_t[np];
232 for (i = 0; i < np; i++) {
239 TParticle * iparticle = (TParticle *) fParticles->At(0);
240 fVertex[0] = origin0[0];
241 fVertex[1] = origin0[1];
242 fVertex[2] = origin0[2];
245 // First select parent particles
248 for (i = 0; i < np; i++) {
249 iparticle = (TParticle *) fParticles->At(i);
251 // Is this a parent particle ?
252 if (Stable(iparticle)) continue;
254 Bool_t selected = kTRUE;
255 Bool_t hasSelectedDaughters = kFALSE;
258 kf = iparticle->GetPdgCode();
259 ks = iparticle->GetStatusCode();
260 if (kf == 92) continue;
262 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
264 hasSelectedDaughters = DaughtersSelection(iparticle);
266 // Put particle on the stack if it is either selected or
267 // it is the mother of at least one seleted particle
269 if (selected || hasSelectedDaughters) {
273 } // particle loop parents
275 // Now select the final state particles
278 for (i = 0; i<np; i++) {
279 TParticle * iparticle = (TParticle *) fParticles->At(i);
280 // Is this a final state particle ?
281 if (!Stable(iparticle)) continue;
283 Bool_t selected = kTRUE;
284 kf = iparticle->GetPdgCode();
285 ks = iparticle->GetStatusCode();
286 ksp = iparticle->GetUniqueID();
288 // --------------------------------------------------------------------------
289 // Count spectator neutrons and protons
290 if(ksp == 0 || ksp == 1){
291 if(kf == kNeutron) fProjectileSpecn += 1;
292 if(kf == kProton) fProjectileSpecp += 1;
294 else if(ksp == 10 || ksp == 11){
295 if(kf == kNeutron) fTargetSpecn += 1;
296 if(kf == kProton) fTargetSpecp += 1;
298 // --------------------------------------------------------------------------
301 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
302 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
306 // Put particle on the stack if selected
312 } // particle loop final state
315 // Time of the interactions
317 if (fPileUpTimeWindow > 0.) tInt = fPileUpTimeWindow * (2. * gRandom->Rndm() - 1.);
320 // Write particles to stack
322 for (i = 0; i<np; i++) {
323 TParticle * iparticle = (TParticle *) fParticles->At(i);
324 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
325 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
327 kf = iparticle->GetPdgCode();
328 ks = iparticle->GetStatusCode();
329 p[0] = iparticle->Px();
330 p[1] = iparticle->Py();
331 p[2] = iparticle->Pz() * sign;
332 origin[0] = origin0[0]+iparticle->Vx()/10;
333 origin[1] = origin0[1]+iparticle->Vy()/10;
334 origin[2] = origin0[2]+iparticle->Vz()/10;
335 tof = kconv * iparticle->T() + sign * origin0[2] / 3.e10;
336 if (fPileUpTimeWindow > 0.) tof += tInt;
339 TParticle* mother = 0;
341 imo = iparticle->GetFirstMother();
342 mother = (TParticle *) fParticles->At(imo);
343 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
345 Bool_t tFlag = (fTrackIt && !hasDaughter);
346 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
356 printf("\n I've put %i particles on the stack \n",nc);
359 if (jev >= fNpart || fNpart == -1) {
360 fKineBias = Float_t(fNpart)/Float_t(fTrials);
361 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
367 SetHighWaterMark(nt);
370 void AliGenHijing::KeepFullEvent()
375 void AliGenHijing::EvaluateCrossSections()
377 // Glauber Calculation of geometrical x-section
379 Float_t xTot = 0.; // barn
380 Float_t xTotHard = 0.; // barn
381 Float_t xPart = 0.; // barn
382 Float_t xPartHard = 0.; // barn
383 Float_t sigmaHard = 0.1; // mbarn
385 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
386 const Float_t kdib = 0.2;
387 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
390 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
391 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
393 Float_t oldvalue= 0.;
395 Float_t* b = new Float_t[kMax];
396 Float_t* si1 = new Float_t[kMax];
397 Float_t* si2 = new Float_t[kMax];
399 for (i = 0; i < kMax; i++)
401 Float_t xb = bMin+i*kdib;
403 ov=fHijing->Profile(xb);
404 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
405 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
408 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
410 if (xb > fMinImpactParam && xb < fMaxImpactParam)
416 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
418 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
419 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
427 printf("\n Total cross section (barn): %f \n",xTot);
428 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
429 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
430 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
432 // Store result as a graph
437 fDsigmaDb = new TGraph(i, b, si1);
438 fDnDb = new TGraph(i, b, si2);
441 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
444 // Looks recursively if one of the daughters has been selected
446 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
450 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
451 Bool_t selected = kFALSE;
453 imin = iparticle->GetFirstDaughter();
454 imax = iparticle->GetLastDaughter();
455 for (i = imin; i <= imax; i++){
456 TParticle * jparticle = (TParticle *) fParticles->At(i);
457 Int_t ip = jparticle->GetPdgCode();
458 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
459 selected=kTRUE; break;
461 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
470 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
472 // Select flavor of particle
474 // 4: charm and beauty
481 Int_t ifl = TMath::Abs(pid/100);
482 if (ifl > 10) ifl/=10;
483 res = (fFlavor == ifl);
486 // This part if gamma writing is inhibited
488 res = res && (pid != kGamma && pid != kPi0);
493 Bool_t AliGenHijing::Stable(TParticle* particle) const
495 // Return true for a stable particle
498 if (particle->GetFirstDaughter() < 0 )
508 void AliGenHijing::MakeHeader()
510 // Builds the event header, to be called after each event
511 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
512 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
513 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
514 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
515 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
516 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
517 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
521 ((AliGenHijingEventHeader*) header)->SetSpectators(fProjectileSpecn, fProjectileSpecp,
522 fTargetSpecn,fTargetSpecp);
523 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(fHijing->GetHINT1(20));
527 // 4-momentum vectors of the triggered jets.
529 // Before final state gluon radiation.
530 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
531 fHijing->GetHINT1(22),
532 fHijing->GetHINT1(23),
533 fHijing->GetHINT1(24));
535 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
536 fHijing->GetHINT1(32),
537 fHijing->GetHINT1(33),
538 fHijing->GetHINT1(34));
539 // After final state gluon radiation.
540 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
541 fHijing->GetHINT1(27),
542 fHijing->GetHINT1(28),
543 fHijing->GetHINT1(29));
545 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
546 fHijing->GetHINT1(37),
547 fHijing->GetHINT1(38),
548 fHijing->GetHINT1(39));
549 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
550 // Bookkeeping for kinematic bias
551 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
553 header->SetPrimaryVertex(fVertex);
555 fCollisionGeometry = (AliGenHijingEventHeader*) header;
558 void AliGenHijing::AddHeader(AliGenEventHeader* header)
560 // Passes header either to the container or to gAlice
562 fContainer->AddHeader(header);
564 gAlice->SetGenEventHeader(header);
569 Bool_t AliGenHijing::CheckTrigger()
571 // Check the kinematic trigger condition
573 Bool_t triggered = kFALSE;
579 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
580 fHijing->GetHINT1(27),
581 fHijing->GetHINT1(28),
582 fHijing->GetHINT1(29));
584 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
585 fHijing->GetHINT1(37),
586 fHijing->GetHINT1(38),
587 fHijing->GetHINT1(39));
588 Double_t eta1 = jet1->Eta();
589 Double_t eta2 = jet2->Eta();
590 Double_t phi1 = jet1->Phi();
591 Double_t phi2 = jet2->Phi();
592 // printf("\n Trigger: %f %f %f %f",
593 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
595 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
596 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
598 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
599 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
602 } else if (fTrigger == 2) {
605 Int_t np = fParticles->GetEntriesFast();
606 for (Int_t i = 0; i < np; i++) {
607 TParticle* part = (TParticle*) fParticles->At(i);
608 Int_t kf = part->GetPdgCode();
609 Int_t ksp = part->GetUniqueID();
610 if (kf == 22 && ksp == 40) {
611 Float_t phi = part->Phi();
612 Float_t eta = part->Eta();
613 if (eta < fEtaMaxJet &&
619 } // check phi,eta within limits
627 void AliGenHijing::Copy(TObject &) const
629 Fatal("Copy","Not implemented!\n");
632 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)