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 Revision 1.35 2001/12/13 07:56:25 hristov
19 Set pointers to zero in the default constructor
21 Revision 1.34 2001/12/11 16:55:42 morsch
22 Correct initialization for jet phi-range.
24 Revision 1.33 2001/12/05 10:18:51 morsch
25 Possibility of kinematic biasing of jet phi range. (J. Klay)
27 Revision 1.32 2001/11/28 13:51:11 morsch
28 Introduce kinematic biasing (etamin, etamax) of jet trigger. Bookkeeping
29 (number of trials) done in AliGenHijingEventHeader.
31 Revision 1.31 2001/11/06 12:30:34 morsch
32 Add Boost() method to boost all particles to LHC lab frame. Needed for asymmetric collision systems.
34 Revision 1.30 2001/10/21 18:35:56 hristov
35 Several pointers were set to zero in the default constructors to avoid memory management problems
37 Revision 1.29 2001/10/15 08:12:24 morsch
38 - Vertex smearing with truncated gaussian.
39 - Store triggered jet info before and after final state radiation into mc-heade
41 Revision 1.28 2001/10/08 11:55:25 morsch
42 Store 4-momenta of trigegred jets in event header.
43 Possibility to switch of initial and final state radiation.
45 Revision 1.27 2001/10/08 07:13:14 morsch
46 Add setter for minimum transverse momentum of triggered jet.
48 Revision 1.26 2001/10/04 08:12:24 morsch
49 Redefinition of stable condition.
51 Revision 1.25 2001/07/27 17:09:36 morsch
52 Use local SetTrack, KeepTrack and SetHighWaterMark methods
53 to delegate either to local stack or to stack owned by AliRun.
54 (Piotr Skowronski, A.M.)
56 Revision 1.24 2001/07/20 09:34:56 morsch
57 Count the number of spectator neutrons and protons and add information
58 to the event header. (Chiara Oppedisano)
60 Revision 1.23 2001/07/13 17:30:22 morsch
63 Revision 1.22 2001/06/11 13:09:23 morsch
64 - Store cross-Section and number of binary collisions as a function of impact parameter
65 - Pass AliGenHijingEventHeader to gAlice.
67 Revision 1.21 2001/02/28 17:35:24 morsch
68 Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
70 Revision 1.20 2001/02/14 15:50:40 hristov
71 The last particle in event marked using SetHighWaterMark
73 Revision 1.19 2000/12/21 16:24:06 morsch
74 Coding convention clean-up
76 Revision 1.18 2000/12/06 17:46:30 morsch
77 Avoid random numbers 1 and 0.
79 Revision 1.17 2000/12/04 11:22:03 morsch
80 Init of sRandom as in 1.15
82 Revision 1.16 2000/12/02 11:41:39 morsch
83 Use SetRandom() to initialize random number generator in constructor.
85 Revision 1.15 2000/11/30 20:29:02 morsch
86 Initialise static variable sRandom in constructor: sRandom = fRandom;
88 Revision 1.14 2000/11/30 07:12:50 alibrary
89 Introducing new Rndm and QA classes
91 Revision 1.13 2000/11/09 17:40:27 morsch
92 Possibility to select/unselect spectator protons and neutrons.
93 Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
95 Revision 1.12 2000/10/20 13:38:38 morsch
96 Debug printouts commented.
98 Revision 1.11 2000/10/20 13:22:26 morsch
99 - skip particle type 92 (string)
100 - Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
103 Revision 1.10 2000/10/17 15:10:20 morsch
104 Write first all the parent particles to the stack and then the final state particles.
106 Revision 1.9 2000/10/17 13:38:59 morsch
107 Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
109 Revision 1.8 2000/10/17 12:46:31 morsch
110 Protect EvaluateCrossSections() against division by zero.
112 Revision 1.7 2000/10/02 21:28:06 fca
113 Removal of useless dependecies via forward declarations
115 Revision 1.6 2000/09/11 13:23:37 morsch
116 Write last seed to file (fortran lun 50) and reed back from same lun using calls to
117 luget_hijing and luset_hijing.
119 Revision 1.5 2000/09/07 16:55:40 morsch
120 fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
122 Revision 1.4 2000/07/11 18:24:56 fca
123 Coding convention corrections + few minor bug fixes
125 Revision 1.3 2000/06/30 12:08:36 morsch
126 In member data: char* replaced by TString, Init takes care of resizing the strings to
127 8 characters required by Hijing.
129 Revision 1.2 2000/06/15 14:15:05 morsch
130 Add possibility for heavy flavor selection: charm and beauty.
132 Revision 1.1 2000/06/09 20:47:27 morsch
133 AliGenerator interface class to HIJING using THijing (test version)
139 // Generator using HIJING as an external generator
140 // The main HIJING options are accessable for the user through this interface.
141 // Uses the THijing implementation of TGenerator.
143 // andreas.morsch@cern.ch
145 #include "AliGenHijing.h"
146 #include "AliGenHijingEventHeader.h"
151 #include <TParticle.h>
154 #include <TLorentzVector.h>
157 ClassImp(AliGenHijing)
159 AliGenHijing::AliGenHijing()
168 AliGenHijing::AliGenHijing(Int_t npart)
171 // Default PbPb collisions at 5. 5 TeV
174 SetImpactParameterRange();
199 // Set random number generator
205 AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
211 AliGenHijing::~AliGenHijing()
214 if ( fDsigmaDb) delete fDsigmaDb;
215 if ( fDnDb) delete fDnDb;
218 void AliGenHijing::Init()
223 fProjectile.Resize(8);
225 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
226 fAProjectile, fZProjectile, fATarget, fZTarget,
227 fMinImpactParam, fMaxImpactParam));
229 fHijing=(THijing*) fgMCEvGen;
230 fHijing->SetIHPR2(2, fRadiation);
231 fHijing->SetIHPR2(3, fTrigger);
232 fHijing->SetIHPR2(4, fQuench);
233 fHijing->SetIHPR2(6, fShadowing);
234 fHijing->SetIHPR2(12, fDecaysOff);
235 fHijing->SetIHPR2(21, fKeep);
236 fHijing->SetHIPR1(10, fPtMinJet);
237 fHijing->SetHIPR1(50, fSimpleJet);
238 fHijing->Initialize();
240 if (fEvaluate) EvaluateCrossSections();
243 // Initialize random generator
246 void AliGenHijing::Generate()
248 // Generate one event
250 Float_t polar[3] = {0,0,0};
251 Float_t origin[3] = {0,0,0};
252 Float_t origin0[3] = {0,0,0};
253 Float_t p[3], random[6];
256 static TClonesArray *particles;
257 // converts from mm/c to s
258 const Float_t kconv = 0.001/2.999792458e8;
262 Int_t j, kf, ks, imo;
265 if(!particles) particles = new TClonesArray("TParticle",10000);
268 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
269 if(fVertexSmear == kPerEvent) {
272 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
274 for (j=0; j < 3; j++) {
275 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
276 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
279 for (j=0; j < 3; j++) origin0[j] += dv[j];
280 } else if (fVertexSmear == kPerTrack) {
281 // fHijing->SetMSTP(151,0);
282 for (j = 0; j < 3; j++) {
283 // fHijing->SetPARP(151+j, fOsigma[j]*10.);
288 // Generate one event
289 // --------------------------------------------------------------------------
292 // --------------------------------------------------------------------------
293 fHijing->GenerateEvent();
295 if (fTrigger != kNoTrigger) {
296 if (!CheckTrigger()) continue;
299 fHijing->ImportParticles(particles,"All");
300 if (fLHC) Boost(particles);
303 Int_t np = particles->GetEntriesFast();
304 printf("\n **************************************************%d\n",np);
306 if (np == 0 ) continue;
308 Int_t * newPos = new Int_t[np];
310 for (i = 0; i < np; i++) *(newPos+i) = i;
313 TParticle * iparticle = (TParticle *) particles->At(0);
314 fEventVertex[0] = origin0[0];
315 fEventVertex[1] = origin0[1];
316 fEventVertex[2] = origin0[2];
319 // First write parent particles
322 for (i = 0; i < np; i++) {
323 iparticle = (TParticle *) particles->At(i);
324 // Is this a parent particle ?
325 if (Stable(iparticle)) continue;
327 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
328 Bool_t selected = kTRUE;
329 Bool_t hasSelectedDaughters = kFALSE;
332 kf = iparticle->GetPdgCode();
333 ks = iparticle->GetStatusCode();
334 if (kf == 92) continue;
336 if (!fSelectAll) selected = KinematicSelection(iparticle, 0)&&SelectFlavor(kf);
337 hasSelectedDaughters = DaughtersSelection(iparticle, particles);
339 // Put particle on the stack if it is either selected or it is the mother of at least one seleted particle
341 if (selected || hasSelectedDaughters) {
343 p[0] = iparticle->Px();
344 p[1] = iparticle->Py();
345 p[2] = iparticle->Pz();
346 origin[0] = origin0[0]+iparticle->Vx()/10;
347 origin[1] = origin0[1]+iparticle->Vy()/10;
348 origin[2] = origin0[2]+iparticle->Vz()/10;
349 tof = kconv*iparticle->T();
351 TParticle* mother = 0;
353 imo = iparticle->GetFirstMother();
354 mother = (TParticle *) particles->At(imo);
355 imo = (mother->GetPdgCode() != 92) ? imo =* (newPos+imo) : -1;
358 // Put particle on the stack ...
359 // printf("\n set track mother: %d %d %d %d %d %d ",i,imo, kf, nt+1, selected, hasSelectedDaughters);
361 SetTrack(0,imo,kf,p,origin,polar, tof,kPPrimary,nt);
362 // ... and keep it there
367 } // particle loop parents
369 // Now write the final state particles
372 for (i = 0; i<np; i++) {
373 TParticle * iparticle = (TParticle *) particles->At(i);
374 // Is this a final state particle ?
375 if (!Stable(iparticle)) continue;
377 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
378 Bool_t selected = kTRUE;
379 kf = iparticle->GetPdgCode();
380 ks = iparticle->GetStatusCode();
381 // --------------------------------------------------------------------------
382 // Count spectator neutrons and protons
383 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
384 if(kf == kNeutron) fSpecn += 1;
385 if(kf == kProton) fSpecp += 1;
387 // --------------------------------------------------------------------------
390 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
391 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
395 // Put particle on the stack if selected
399 p[0] = iparticle->Px();
400 p[1] = iparticle->Py();
401 p[2] = iparticle->Pz();
402 origin[0] = origin0[0]+iparticle->Vx()/10;
403 origin[1] = origin0[1]+iparticle->Vy()/10;
404 origin[2] = origin0[2]+iparticle->Vz()/10;
405 tof = kconv*iparticle->T();
407 TParticle* mother = 0;
409 imo = iparticle->GetFirstMother();
410 mother = (TParticle *) particles->At(imo);
411 imo = (mother->GetPdgCode() != 92) ? imo=*(newPos+imo) : -1;
413 // Put particle on the stack
414 SetTrack(fTrackIt,imo,kf,p,origin,polar,
419 } // particle loop final state
423 printf("\n I've put %i particles on the stack \n",nc);
426 if (jev >= fNpart || fNpart == -1) {
427 fKineBias = Float_t(fNpart)/Float_t(fTrials);
428 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
435 SetHighWaterMark(nt);
438 void AliGenHijing::KeepFullEvent()
443 void AliGenHijing::EvaluateCrossSections()
445 // Glauber Calculation of geometrical x-section
447 Float_t xTot = 0.; // barn
448 Float_t xTotHard = 0.; // barn
449 Float_t xPart = 0.; // barn
450 Float_t xPartHard = 0.; // barn
451 Float_t sigmaHard = 0.1; // mbarn
453 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
454 const Float_t kdib = 0.2;
455 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
458 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
459 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
461 Float_t oldvalue= 0.;
463 Float_t* b = new Float_t[kMax];
464 Float_t* si1 = new Float_t[kMax];
465 Float_t* si2 = new Float_t[kMax];
467 for (i = 0; i < kMax; i++)
469 Float_t xb = bMin+i*kdib;
471 ov=fHijing->Profile(xb);
472 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
473 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
476 if (xb > fMinImpactParam && xb < fMaxImpactParam)
482 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
484 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
485 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
493 printf("\n Total cross section (barn): %f \n",xTot);
494 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
495 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
496 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
498 // Store result as a graph
503 fDsigmaDb = new TGraph(i, b, si1);
504 fDnDb = new TGraph(i, b, si2);
507 Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle, TClonesArray* particles)
510 // Looks recursively if one of the daughters has been selected
512 // printf("\n Consider daughters %d:",iparticle->GetPdgCode());
516 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
517 Bool_t selected = kFALSE;
519 imin = iparticle->GetFirstDaughter();
520 imax = iparticle->GetLastDaughter();
521 for (i = imin; i <= imax; i++){
522 TParticle * jparticle = (TParticle *) particles->At(i);
523 Int_t ip = jparticle->GetPdgCode();
524 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
525 selected=kTRUE; break;
527 if (DaughtersSelection(jparticle, particles)) {selected=kTRUE; break; }
536 Bool_t AliGenHijing::SelectFlavor(Int_t pid)
538 // Select flavor of particle
540 // 4: charm and beauty
542 if (fFlavor == 0) return kTRUE;
544 Int_t ifl = TMath::Abs(pid/100);
545 if (ifl > 10) ifl/=10;
546 return (fFlavor == ifl);
549 Bool_t AliGenHijing::Stable(TParticle* particle)
551 // Return true for a stable particle
553 if (particle->GetFirstDaughter() < 0 )
562 void AliGenHijing::Boost(TClonesArray* particles)
565 // Boost cms into LHC lab frame
567 Double_t dy = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
568 (Double_t(fZTarget) * Double_t(fAProjectile)));
569 Double_t beta = TMath::TanH(dy);
570 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
571 Double_t gb = gamma * beta;
573 printf("\n Boosting particles to lab frame %f %f %f", dy, beta, gamma);
576 Int_t np = particles->GetEntriesFast();
577 for (i = 0; i < np; i++)
579 TParticle* iparticle = (TParticle*) particles->At(i);
581 Double_t e = iparticle->Energy();
582 Double_t px = iparticle->Px();
583 Double_t py = iparticle->Py();
584 Double_t pz = iparticle->Pz();
586 Double_t eb = gamma * e - gb * pz;
587 Double_t pzb = -gb * e + gamma * pz;
589 iparticle->SetMomentum(px, py, pzb, eb);
594 void AliGenHijing::MakeHeader()
596 // Builds the event header, to be called after each event
597 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
598 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
599 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
600 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
601 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
602 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
603 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
607 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
609 // 4-momentum vectors of the triggered jets.
611 // Before final state gluon radiation.
612 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
613 fHijing->GetHINT1(22),
614 fHijing->GetHINT1(23),
615 fHijing->GetHINT1(24));
617 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
618 fHijing->GetHINT1(32),
619 fHijing->GetHINT1(33),
620 fHijing->GetHINT1(34));
621 // After final state gluon radiation.
622 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
623 fHijing->GetHINT1(27),
624 fHijing->GetHINT1(28),
625 fHijing->GetHINT1(29));
627 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
628 fHijing->GetHINT1(37),
629 fHijing->GetHINT1(38),
630 fHijing->GetHINT1(39));
631 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
632 // Bookkeeping for kinematic bias
633 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
635 header->SetPrimaryVertex(fEventVertex);
636 gAlice->SetGenEventHeader(header);
639 Bool_t AliGenHijing::CheckTrigger()
641 // Check the kinematic trigger condition
643 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
644 fHijing->GetHINT1(27),
645 fHijing->GetHINT1(28),
646 fHijing->GetHINT1(29));
648 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
649 fHijing->GetHINT1(37),
650 fHijing->GetHINT1(38),
651 fHijing->GetHINT1(39));
652 Double_t eta1 = jet1->Eta();
653 Double_t eta2 = jet2->Eta();
654 Double_t phi1 = jet1->Phi();
655 Double_t phi2 = jet2->Phi();
656 Bool_t triggered = kFALSE;
657 //Check eta range first...
658 if ((eta1 < fEtaMaxJet && eta1 > fEtaMinJet) ||
659 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet))
661 //Eta is okay, now check phi range
662 if ((phi1 < fPhiMaxJet && phi1 > fPhiMinJet) ||
663 (phi2 < fPhiMaxJet && phi2 > fPhiMinJet))
674 AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
676 // Assignment operator
681 # define rluget_hijing rluget_hijing_
682 # define rluset_hijing rluset_hijing_
683 # define rlu_hijing rlu_hijing_
684 # define type_of_call
686 # define rluget_hijing RLUGET_HIJING
687 # define rluset_hijing RLUSET_HIJING
688 # define rlu_hijing RLU_HIJING
689 # define type_of_call _stdcall
694 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
695 {printf("Dummy version of rluget_hijing reached\n");}
697 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
698 {printf("Dummy version of rluset_hijing reached\n");}
700 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
703 do r=sRandom->Rndm(); while(0 >= r || r >= 1);