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@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 fParticles = new TClonesArray("TParticle",10000);
82 // Set random number generator
83 AliHijingRndm::SetHijingRandom(GetRandom());
88 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
94 AliGenHijing::~AliGenHijing()
97 if ( fDsigmaDb) delete fDsigmaDb;
98 if ( fDnDb) delete fDnDb;
102 void AliGenHijing::Init()
107 fProjectile.Resize(8);
109 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
110 fAProjectile, fZProjectile, fATarget, fZTarget,
111 fMinImpactParam, fMaxImpactParam));
113 fHijing=(THijing*) fgMCEvGen;
114 fHijing->SetIHPR2(2, fRadiation);
115 fHijing->SetIHPR2(3, fTrigger);
116 fHijing->SetIHPR2(6, fShadowing);
117 fHijing->SetIHPR2(12, fDecaysOff);
118 fHijing->SetIHPR2(21, fKeep);
119 fHijing->SetHIPR1(10, fPtMinJet);
120 fHijing->SetHIPR1(50, fSimpleJet);
125 // fQuench = 0: no quenching
126 // fQuench = 1: hijing default
127 // fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
128 // fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
129 // fQuench = 4: new LHC parameters with log(e) dependence
130 // fQuench = 5: new RHIC parameters with log(e) dependence
131 fHijing->SetIHPR2(50, 0);
133 fHijing->SetIHPR2(4, 1);
135 fHijing->SetIHPR2(4, 0);
136 // New LHC parameters from Xin-Nian Wang
138 fHijing->SetHIPR1(14, 1.1);
139 fHijing->SetHIPR1(11, 3.7);
140 } else if (fQuench == 3) {
141 fHijing->SetHIPR1(14, 0.20);
142 fHijing->SetHIPR1(11, 2.5);
143 } else if (fQuench == 4) {
144 fHijing->SetIHPR2(50, 1);
145 fHijing->SetHIPR1(14, 4.*0.34);
146 fHijing->SetHIPR1(11, 3.7);
147 } else if (fQuench == 5) {
148 fHijing->SetIHPR2(50, 1);
149 fHijing->SetHIPR1(14, 0.34);
150 fHijing->SetHIPR1(11, 2.5);
159 fHijing->Initialize();
161 if (fEvaluate) EvaluateCrossSections();
165 void AliGenHijing::Generate()
167 // Generate one event
169 Float_t polar[3] = {0,0,0};
170 Float_t origin[3] = {0,0,0};
171 Float_t origin0[3] = {0,0,0};
175 // converts from mm/c to s
176 const Float_t kconv = 0.001/2.999792458e8;
180 Int_t j, kf, ks, imo;
186 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
187 if(fVertexSmear == kPerEvent) {
189 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
194 // Generate one event
195 // --------------------------------------------------------------------------
198 // --------------------------------------------------------------------------
199 fHijing->GenerateEvent();
201 fHijing->ImportParticles(fParticles,"All");
202 if (fTrigger != kNoTrigger) {
203 if (!CheckTrigger()) continue;
208 Int_t np = fParticles->GetEntriesFast();
209 printf("\n **************************************************%d\n",np);
211 if (np == 0 ) continue;
213 Int_t* newPos = new Int_t[np];
214 Int_t* pSelected = new Int_t[np];
216 for (i = 0; i < np; i++) {
223 TParticle * iparticle = (TParticle *) fParticles->At(0);
224 fVertex[0] = origin0[0];
225 fVertex[1] = origin0[1];
226 fVertex[2] = origin0[2];
229 // First select parent particles
232 for (i = 0; i < np; i++) {
233 iparticle = (TParticle *) fParticles->At(i);
235 // Is this a parent particle ?
236 if (Stable(iparticle)) continue;
238 Bool_t selected = kTRUE;
239 Bool_t hasSelectedDaughters = kFALSE;
242 kf = iparticle->GetPdgCode();
243 ks = iparticle->GetStatusCode();
244 if (kf == 92) continue;
246 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
248 hasSelectedDaughters = DaughtersSelection(iparticle);
250 // Put particle on the stack if it is either selected or
251 // it is the mother of at least one seleted particle
253 if (selected || hasSelectedDaughters) {
257 } // particle loop parents
259 // Now select the final state particles
262 for (i = 0; i<np; i++) {
263 TParticle * iparticle = (TParticle *) fParticles->At(i);
264 // Is this a final state particle ?
265 if (!Stable(iparticle)) continue;
267 Bool_t selected = kTRUE;
268 kf = iparticle->GetPdgCode();
269 ks = iparticle->GetStatusCode();
271 // --------------------------------------------------------------------------
272 // Count spectator neutrons and protons
273 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
274 if(kf == kNeutron) fSpecn += 1;
275 if(kf == kProton) fSpecp += 1;
277 // --------------------------------------------------------------------------
280 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
281 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
285 // Put particle on the stack if selected
291 } // particle loop final state
293 // Write particles to stack
295 for (i = 0; i<np; i++) {
296 TParticle * iparticle = (TParticle *) fParticles->At(i);
297 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
298 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
301 kf = iparticle->GetPdgCode();
302 ks = iparticle->GetStatusCode();
303 p[0] = iparticle->Px();
304 p[1] = iparticle->Py();
305 p[2] = iparticle->Pz();
306 origin[0] = origin0[0]+iparticle->Vx()/10;
307 origin[1] = origin0[1]+iparticle->Vy()/10;
308 origin[2] = origin0[2]+iparticle->Vz()/10;
309 tof = kconv*iparticle->T();
311 TParticle* mother = 0;
313 imo = iparticle->GetFirstMother();
314 mother = (TParticle *) fParticles->At(imo);
315 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
317 Bool_t tFlag = (fTrackIt && !hasDaughter);
318 SetTrack(tFlag,imo,kf,p,origin,polar,
319 tof,kPNoProcess,nt, 1., ks);
327 printf("\n I've put %i particles on the stack \n",nc);
330 if (jev >= fNpart || fNpart == -1) {
331 fKineBias = Float_t(fNpart)/Float_t(fTrials);
332 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
338 SetHighWaterMark(nt);
341 void AliGenHijing::KeepFullEvent()
346 void AliGenHijing::EvaluateCrossSections()
348 // Glauber Calculation of geometrical x-section
350 Float_t xTot = 0.; // barn
351 Float_t xTotHard = 0.; // barn
352 Float_t xPart = 0.; // barn
353 Float_t xPartHard = 0.; // barn
354 Float_t sigmaHard = 0.1; // mbarn
356 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
357 const Float_t kdib = 0.2;
358 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
361 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
362 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
364 Float_t oldvalue= 0.;
366 Float_t* b = new Float_t[kMax];
367 Float_t* si1 = new Float_t[kMax];
368 Float_t* si2 = new Float_t[kMax];
370 for (i = 0; i < kMax; i++)
372 Float_t xb = bMin+i*kdib;
374 ov=fHijing->Profile(xb);
375 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
376 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
379 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
381 if (xb > fMinImpactParam && xb < fMaxImpactParam)
387 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
389 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
390 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
398 printf("\n Total cross section (barn): %f \n",xTot);
399 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
400 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
401 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
403 // Store result as a graph
408 fDsigmaDb = new TGraph(i, b, si1);
409 fDnDb = new TGraph(i, b, si2);
412 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
415 // Looks recursively if one of the daughters has been selected
417 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
421 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
422 Bool_t selected = kFALSE;
424 imin = iparticle->GetFirstDaughter();
425 imax = iparticle->GetLastDaughter();
426 for (i = imin; i <= imax; i++){
427 TParticle * jparticle = (TParticle *) fParticles->At(i);
428 Int_t ip = jparticle->GetPdgCode();
429 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
430 selected=kTRUE; break;
432 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
441 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
443 // Select flavor of particle
445 // 4: charm and beauty
452 Int_t ifl = TMath::Abs(pid/100);
453 if (ifl > 10) ifl/=10;
454 res = (fFlavor == ifl);
457 // This part if gamma writing is inhibited
459 res = res && (pid != kGamma && pid != kPi0);
464 Bool_t AliGenHijing::Stable(TParticle* particle)
466 // Return true for a stable particle
469 if (particle->GetFirstDaughter() < 0 )
479 void AliGenHijing::MakeHeader()
481 // Builds the event header, to be called after each event
482 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
483 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
484 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
485 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
486 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
487 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
488 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
492 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
494 // 4-momentum vectors of the triggered jets.
496 // Before final state gluon radiation.
497 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
498 fHijing->GetHINT1(22),
499 fHijing->GetHINT1(23),
500 fHijing->GetHINT1(24));
502 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
503 fHijing->GetHINT1(32),
504 fHijing->GetHINT1(33),
505 fHijing->GetHINT1(34));
506 // After final state gluon radiation.
507 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
508 fHijing->GetHINT1(27),
509 fHijing->GetHINT1(28),
510 fHijing->GetHINT1(29));
512 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
513 fHijing->GetHINT1(37),
514 fHijing->GetHINT1(38),
515 fHijing->GetHINT1(39));
516 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
517 // Bookkeeping for kinematic bias
518 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
520 header->SetPrimaryVertex(fVertex);
521 gAlice->SetGenEventHeader(header);
522 fCollisionGeometry = (AliGenHijingEventHeader*) header;
525 Bool_t AliGenHijing::CheckTrigger()
527 // Check the kinematic trigger condition
529 Bool_t triggered = kFALSE;
535 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
536 fHijing->GetHINT1(27),
537 fHijing->GetHINT1(28),
538 fHijing->GetHINT1(29));
540 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
541 fHijing->GetHINT1(37),
542 fHijing->GetHINT1(38),
543 fHijing->GetHINT1(39));
544 Double_t eta1 = jet1->Eta();
545 Double_t eta2 = jet2->Eta();
546 Double_t phi1 = jet1->Phi();
547 Double_t phi2 = jet2->Phi();
548 // printf("\n Trigger: %f %f %f %f",
549 // fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
551 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
552 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
554 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
555 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
558 } else if (fTrigger == 2) {
561 Int_t np = fParticles->GetEntriesFast();
562 for (Int_t i = 0; i < np; i++) {
563 TParticle* part = (TParticle*) fParticles->At(i);
564 Int_t kf = part->GetPdgCode();
565 Int_t ks = part->GetStatusCode();
566 if (kf == 22 && ks == 40) {
567 Float_t phi = part->Phi();
568 Float_t eta = part->Eta();
569 if (eta < fEtaMaxJet &&
575 } // check phi,eta within limits
585 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
587 // Assignment operator