]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - THijing/AliGenHijing.cxx
Merge remote-tracking branch 'origin/master' into flatdev
[u/mrichter/AliRoot.git] / THijing / AliGenHijing.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
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.
21// Author:
22// Andreas Morsch (andreas.morsch@cern.ch)
23//
24
25#include <TClonesArray.h>
26#include <TGraph.h>
27#include <THijing.h>
28#include <TLorentzVector.h>
29#include <TPDGCode.h>
30#include <TParticle.h>
31
32#include "AliGenHijing.h"
33#include "AliGenHijingEventHeader.h"
34#include "AliHijingRndm.h"
35#include "AliLog.h"
36#include "AliRun.h"
37
38ClassImp(AliGenHijing)
39
40AliGenHijing::AliGenHijing()
41 :AliGenMC(),
42 fFrame("CMS"),
43 fMinImpactParam(0.),
44 fMaxImpactParam(5.),
45 fKeep(0),
46 fQuench(1),
47 fShadowing(1),
48 fDecaysOff(3),
49 fTrigger(0),
50 fEvaluate(0),
51 fSelectAll(0),
52 fFlavor(0),
53 fKineBias(0.),
54 fTrials(0),
55 fXsection(0.),
56 fHijing(0),
57 fPtHardMin(2.0),
58 fPtHardMax(-1),
59 fSpectators(1),
60 fDsigmaDb(0),
61 fDnDb(0),
62 fPtMinJet(-2.5),
63 fEtaMinJet(-20.),
64 fEtaMaxJet(+20.),
65 fPhiMinJet(0.),
66 fPhiMaxJet(2. * TMath::Pi()),
67 fRadiation(3),
68 fSimpleJet(kFALSE),
69 fNoGammas(kFALSE),
70 fProjectileSpecn(0),
71 fProjectileSpecp(0),
72 fTargetSpecn(0),
73 fTargetSpecp(0),
74 fLHC(kFALSE),
75 fRandomPz(kFALSE),
76 fNoHeavyQuarks(kFALSE),
77 fHeader(AliGenHijingEventHeader("Hijing")),
78 fSigmaNN(-1),
79 fNoElas(0)
80{
81 // Constructor
82 fEnergyCMS = 5500.;
83 AliHijingRndm::SetHijingRandom(GetRandom());
84}
85
86AliGenHijing::AliGenHijing(Int_t npart)
87 :AliGenMC(npart),
88 fFrame("CMS"),
89 fMinImpactParam(0.),
90 fMaxImpactParam(5.),
91 fKeep(0),
92 fQuench(1),
93 fShadowing(1),
94 fDecaysOff(3),
95 fTrigger(0),
96 fEvaluate(0),
97 fSelectAll(0),
98 fFlavor(0),
99 fKineBias(0.),
100 fTrials(0),
101 fXsection(0.),
102 fHijing(0),
103 fPtHardMin(2.0),
104 fPtHardMax(-1),
105 fSpectators(1),
106 fDsigmaDb(0),
107 fDnDb(0),
108 fPtMinJet(-2.5),
109 fEtaMinJet(-20.),
110 fEtaMaxJet(+20.),
111 fPhiMinJet(0.),
112 fPhiMaxJet(2. * TMath::Pi()),
113 fRadiation(3),
114 fSimpleJet(kFALSE),
115 fNoGammas(kFALSE),
116 fProjectileSpecn(0),
117 fProjectileSpecp(0),
118 fTargetSpecn(0),
119 fTargetSpecp(0),
120 fLHC(kFALSE),
121 fRandomPz(kFALSE),
122 fNoHeavyQuarks(kFALSE),
123 fHeader(AliGenHijingEventHeader("Hijing")),
124 fSigmaNN(-1),
125 fNoElas(0)
126{
127// Default PbPb collisions at 5. 5 TeV
128//
129 fEnergyCMS = 5500.;
130 fName = "Hijing";
131 fTitle= "Particle Generator using HIJING";
132//
133//
134// Set random number generator
135 AliHijingRndm::SetHijingRandom(GetRandom());
136
137}
138
139AliGenHijing::~AliGenHijing()
140{
141// Destructor
142 if ( fDsigmaDb) delete fDsigmaDb;
143 if ( fDnDb) delete fDnDb;
144}
145
146void AliGenHijing::Init()
147{
148// Initialisation
149 fFrame.Resize(8);
150 fTarget.Resize(8);
151 fProjectile.Resize(8);
152
153 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
154 fAProjectile, fZProjectile, fATarget, fZTarget,
155 fMinImpactParam, fMaxImpactParam));
156
157 fHijing=(THijing*) fMCEvGen;
158 fHijing->SetIHPR2(2, fRadiation);
159 fHijing->SetIHPR2(3, fTrigger);
160 fHijing->SetIHPR2(6, fShadowing);
161 fHijing->SetIHPR2(12, fDecaysOff);
162 fHijing->SetIHPR2(21, fKeep);
163 fHijing->SetHIPR1(8, fPtHardMin);
164 fHijing->SetHIPR1(9, fPtHardMax);
165 fHijing->SetHIPR1(10, fPtMinJet);
166 if (fSigmaNN>0)
167 fHijing->SetHIPR1(31, fSigmaNN/2.);
168 fHijing->SetHIPR1(50, fSimpleJet);
169 //
170 // Switching off elastic scattering
171 if (fNoElas)
172 fHijing->SetIHPR2(14, 0);
173//
174// Quenching
175//
176//
177// fQuench = 0: no quenching
178// fQuench = 1: hijing default
179// fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
180// fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
181// fQuench = 4: new LHC parameters with log(e) dependence
182// fQuench = 5: new RHIC parameters with log(e) dependence
183 fHijing->SetIHPR2(50, 0);
184 if (fQuench > 0)
185 fHijing->SetIHPR2(4, 1);
186 else
187 fHijing->SetIHPR2(4, 0);
188// New LHC parameters from Xin-Nian Wang
189 if (fQuench == 2) {
190 fHijing->SetHIPR1(14, 1.1);
191 fHijing->SetHIPR1(11, 3.7);
192 } else if (fQuench == 3) {
193 fHijing->SetHIPR1(14, 0.20);
194 fHijing->SetHIPR1(11, 2.5);
195 } else if (fQuench == 4) {
196 fHijing->SetIHPR2(50, 1);
197 fHijing->SetHIPR1(14, 4.*0.34);
198 fHijing->SetHIPR1(11, 3.7);
199 } else if (fQuench == 5) {
200 fHijing->SetIHPR2(50, 1);
201 fHijing->SetHIPR1(14, 0.34);
202 fHijing->SetHIPR1(11, 2.5);
203 }
204
205//
206// Heavy quarks
207//
208 if (fNoHeavyQuarks) {
209 fHijing->SetIHPR2(49, 1);
210 } else {
211 fHijing->SetIHPR2(49, 0);
212 }
213
214
215 AliGenMC::Init();
216
217//
218// Initialize Hijing
219//
220 fHijing->Initialize();
221//
222 if (fEvaluate) EvaluateCrossSections();
223//
224}
225
226void AliGenHijing::Generate()
227{
228// Generate one event
229
230 Float_t polar[3] = {0,0,0};
231 Float_t origin[3] = {0,0,0};
232 Float_t origin0[3] = {0,0,0};
233 Float_t time0 = 0.;
234 Float_t p[3];
235 Float_t tof;
236
237// converts from mm/c to s
238 const Float_t kconv = 0.001/2.99792458e8;
239//
240 Int_t nt = 0;
241 Int_t jev = 0;
242 Int_t j, kf, ks, ksp, imo;
243 kf = 0;
244
245
246
247 fTrials = 0;
248
249 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
250 time0 = fTimeOrigin;
251
252 if(fVertexSmear == kPerEvent) {
253 Vertex();
254 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
255 time0 = fTime;
256 }
257
258
259 Float_t sign = (fRandomPz && (Rndm() < 0.5))? -1. : 1.;
260
261 while(1)
262 {
263// Generate one event
264// --------------------------------------------------------------------------
265 fProjectileSpecn = 0;
266 fProjectileSpecp = 0;
267 fTargetSpecn = 0;
268 fTargetSpecp = 0;
269// --------------------------------------------------------------------------
270 fHijing->GenerateEvent();
271 fTrials++;
272 fNprimaries = 0;
273 fHijing->ImportParticles(&fParticles,"All");
274 if (fTrigger != kNoTrigger) {
275 if (!CheckTrigger()) continue;
276 }
277 if (fLHC) Boost();
278
279
280 Int_t np = fParticles.GetEntriesFast();
281 Int_t nc = 0;
282 if (np == 0 ) continue;
283 Int_t i;
284 Int_t* newPos = new Int_t[np];
285 Int_t* pSelected = new Int_t[np];
286
287 for (i = 0; i < np; i++) {
288 newPos[i] = i;
289 pSelected[i] = 0;
290 }
291
292// Get event vertex
293//
294 fVertex[0] = origin0[0];
295 fVertex[1] = origin0[1];
296 fVertex[2] = origin0[2];
297 fTime = time0;
298//
299// First select parent particles
300//
301 TParticle * iparticle = 0;
302 for (i = 0; i < np; i++) {
303 iparticle = (TParticle *) fParticles.At(i);
304
305// Is this a parent particle ?
306 if (Stable(iparticle)) continue;
307//
308 Bool_t selected = kTRUE;
309 Bool_t hasSelectedDaughters = kFALSE;
310
311
312 kf = iparticle->GetPdgCode();
313 ks = iparticle->GetStatusCode();
314 if (kf == 92) continue;
315
316 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
317 SelectFlavor(kf);
318 hasSelectedDaughters = DaughtersSelection(iparticle);
319//
320// Put particle on the stack if it is either selected or
321// it is the mother of at least one seleted particle
322//
323 if (selected || hasSelectedDaughters) {
324 nc++;
325 pSelected[i] = 1;
326 } // selected
327 } // particle loop parents
328//
329// Now select the final state particles
330//
331
332 for (i = 0; i<np; i++) {
333 iparticle = (TParticle *) fParticles.At(i);
334// Is this a final state particle ?
335 if (!Stable(iparticle)) continue;
336
337 Bool_t selected = kTRUE;
338 kf = iparticle->GetPdgCode();
339 ks = iparticle->GetStatusCode();
340 ksp = iparticle->GetUniqueID();
341
342// --------------------------------------------------------------------------
343// Count spectator neutrons and protons
344 if(ksp == 0 || ksp == 1){
345 if(kf == kNeutron) fProjectileSpecn += 1;
346 if(kf == kProton) fProjectileSpecp += 1;
347 }
348 else if(ksp == 10 || ksp == 11){
349 if(kf == kNeutron) fTargetSpecn += 1;
350 if(kf == kProton) fTargetSpecp += 1;
351 }
352// --------------------------------------------------------------------------
353//
354 if (!fSelectAll) {
355 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
356 if (!fSpectators && selected) selected = (ksp != 0 && ksp != 1 && ksp != 10
357 && ksp != 11);
358 }
359//
360// Put particle on the stack if selected
361//
362 if (selected) {
363 nc++;
364 pSelected[i] = 1;
365 } // selected
366 } // particle loop final state
367
368//
369// Write particles to stack
370
371 for (i = 0; i<np; i++) {
372 iparticle = (TParticle *) fParticles.At(i);
373 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
374 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
375 if (pSelected[i]) {
376 kf = iparticle->GetPdgCode();
377 ks = iparticle->GetStatusCode();
378 p[0] = iparticle->Px();
379 p[1] = iparticle->Py();
380 p[2] = iparticle->Pz() * sign;
381 origin[0] = origin0[0]+iparticle->Vx()/10;
382 origin[1] = origin0[1]+iparticle->Vy()/10;
383 origin[2] = origin0[2]+iparticle->Vz()/10;
384 tof = time0+kconv * iparticle->T();
385
386 imo = -1;
387 TParticle* mother = 0;
388 if (hasMother) {
389 imo = iparticle->GetFirstMother();
390 mother = (TParticle *) fParticles.At(imo);
391 imo = (mother->GetPdgCode() != 92) ? newPos[imo] : -1;
392 } // if has mother
393 Bool_t tFlag = (fTrackIt && !hasDaughter);
394 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
395 fNprimaries++;
396 KeepTrack(nt);
397 newPos[i] = nt;
398 } // if selected
399 } // particle loop
400 delete[] newPos;
401 delete[] pSelected;
402
403 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
404 if (nc > 0) {
405 jev += nc;
406 if (jev >= fNpart || fNpart == -1) {
407 fKineBias = Float_t(fNpart)/Float_t(fTrials);
408 AliInfo(Form("\n Trials: %i %i %i\n",fTrials, fNpart, jev));
409 break;
410 }
411 }
412 } // event loop
413
414 MakeHeader();
415 SetHighWaterMark(nt);
416}
417
418void AliGenHijing::KeepFullEvent()
419{
420 fKeep=1;
421}
422
423void AliGenHijing::EvaluateCrossSections()
424{
425// Glauber Calculation of geometrical x-section
426//
427 Float_t xTot = 0.; // barn
428 Float_t xTotHard = 0.; // barn
429 Float_t xPart = 0.; // barn
430 Float_t xPartHard = 0.; // barn
431 Float_t sigmaHard = 0.1; // mbarn
432 Float_t bMin = 0.;
433 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
434 const Float_t kdib = 0.2;
435 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
436
437
438 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
439 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
440 printf("\n Inelastic and total cross section (mb) %f %f \n",fHijing->GetHINT1(12), fHijing->GetHINT1(13));
441 Int_t i;
442 Float_t oldvalue= 0.;
443
444 Float_t* b = new Float_t[kMax];
445 Float_t* si1 = new Float_t[kMax];
446 Float_t* si2 = new Float_t[kMax];
447 for (i = 0; i < kMax; i++){
448 b[i] = 0.;
449 si1[i] = 0.;
450 si2[i] = 0.;
451 }
452
453 for (i = 0; i < kMax; i++)
454 {
455 Float_t xb = bMin+i*kdib;
456 Float_t ov;
457 ov=fHijing->Profile(xb);
458 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
459 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
460 xTot+=gb;
461 xTotHard += gbh;
462 printf("profile %f %f %f\n", xb, ov, fHijing->GetHINT1(12));
463
464 if (xb > fMinImpactParam && xb < fMaxImpactParam)
465 {
466 xPart += gb;
467 xPartHard += gbh;
468 }
469
470 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
471 oldvalue = xTot;
472 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
473 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
474 if (i>0) {
475 si1[i] = gb/kdib;
476 si2[i] = gbh/gb;
477 b[i] = xb;
478 }
479 }
480
481 printf("\n Total cross section (barn): %f \n",xTot);
482 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
483 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
484 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
485
486// Store result as a graph
487 b[0] = 0;
488 si1[0] = 0;
489 si2[0]=si2[1];
490
491 fDsigmaDb = new TGraph(i, b, si1);
492 fDnDb = new TGraph(i, b, si2);
493}
494
495Bool_t AliGenHijing::DaughtersSelection(const TParticle* iparticle)
496{
497//
498// Looks recursively if one of the daughters has been selected
499//
500// printf("\n Consider daughters %d:",iparticle->GetPdgCode());
501 Int_t imin = -1;
502 Int_t imax = -1;
503 Int_t i;
504 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
505 Bool_t selected = kFALSE;
506 if (hasDaughters) {
507 imin = iparticle->GetFirstDaughter();
508 imax = iparticle->GetLastDaughter();
509 for (i = imin; i <= imax; i++){
510 TParticle * jparticle = (TParticle *) fParticles.At(i);
511 Int_t ip = jparticle->GetPdgCode();
512 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
513 selected=kTRUE; break;
514 }
515 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
516 }
517 } else {
518 return kFALSE;
519 }
520 return selected;
521}
522
523
524Bool_t AliGenHijing::SelectFlavor(Int_t pid)
525{
526// Select flavor of particle
527// 0: all
528// 4: charm and beauty
529// 5: beauty
530 Bool_t res = 0;
531
532 if (fFlavor == 0) {
533 res = kTRUE;
534 } else {
535 Int_t ifl = TMath::Abs(pid/100);
536 if (ifl > 10) ifl/=10;
537 res = (fFlavor == ifl);
538 }
539//
540// This part if gamma writing is inhibited
541 if (fNoGammas)
542 res = res && (pid != kGamma && pid != kPi0);
543//
544 return res;
545}
546
547Bool_t AliGenHijing::Stable(const TParticle* particle) const
548{
549// Return true for a stable particle
550//
551
552 if (particle->GetFirstDaughter() < 0 )
553 {
554 return kTRUE;
555 } else {
556 return kFALSE;
557 }
558}
559
560
561
562void AliGenHijing::MakeHeader()
563{
564// Builds the event header, to be called after each event
565 fHeader.SetNProduced(fNprimaries);
566 fHeader.SetImpactParameter(fHijing->GetHINT1(19));
567 fHeader.SetTotalEnergy(fHijing->GetEATT());
568 fHeader.SetHardScatters(fHijing->GetJATT());
569 fHeader.SetParticipants(fHijing->GetNP(), fHijing->GetNT());
570 fHeader.SetCollisions(fHijing->GetN0(),
571 fHijing->GetN01(),
572 fHijing->GetN10(),
573 fHijing->GetN11());
574 fHeader.SetSpectators(fProjectileSpecn, fProjectileSpecp,
575 fTargetSpecn,fTargetSpecp);
576 fHeader.SetReactionPlaneAngle(fHijing->GetHINT1(20));
577 fHeader.SetTrueNPart(fHijing->GetNPART());
578
579// 4-momentum vectors of the triggered jets.
580//
581// Before final state gluon radiation.
582 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
583 fHijing->GetHINT1(22),
584 fHijing->GetHINT1(23),
585 fHijing->GetHINT1(24));
586
587 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
588 fHijing->GetHINT1(32),
589 fHijing->GetHINT1(33),
590 fHijing->GetHINT1(34));
591// After final state gluon radiation.
592 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
593 fHijing->GetHINT1(27),
594 fHijing->GetHINT1(28),
595 fHijing->GetHINT1(29));
596
597 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
598 fHijing->GetHINT1(37),
599 fHijing->GetHINT1(38),
600 fHijing->GetHINT1(39));
601 fHeader.SetJets(jet1, jet2, jet3, jet4);
602// Bookkeeping for kinematic bias
603 fHeader.SetTrials(fTrials);
604// Event Vertex
605 fHeader.SetPrimaryVertex(fVertex);
606 fHeader.SetInteractionTime(fTime);
607
608 Int_t nsd1 = 0,nsd2 = 0,ndd = 0;
609 Int_t nT = fHijing->GetNT();
610 Int_t nP = fHijing->GetNP();
611 for (Int_t i = 1; i <= nP; ++i) {
612 for (Int_t j = 1; j <= nT; ++j) {
613 Int_t tp = fHijing->GetNFP(i, 5);
614 Int_t tt = fHijing->GetNFT(j, 5);
615 if (tp == 2)
616 nsd1++;
617 if (tt == 2)
618 nsd2++;
619 if (tp == 2 && tt == 2)
620 ndd++;
621 }
622 }
623 fHeader.SetNDiffractive(nsd1, nsd2, ndd);
624 AddHeader(&fHeader);
625 fCollisionGeometry = &fHeader;
626}
627
628
629Bool_t AliGenHijing::CheckTrigger()
630{
631// Check the kinematic trigger condition
632//
633 Bool_t triggered = kFALSE;
634
635 if (fTrigger == 1) {
636//
637// jet-jet Trigger
638
639 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
640 fHijing->GetHINT1(27),
641 fHijing->GetHINT1(28),
642 fHijing->GetHINT1(29));
643
644 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
645 fHijing->GetHINT1(37),
646 fHijing->GetHINT1(38),
647 fHijing->GetHINT1(39));
648 Double_t eta1 = jet1->Eta();
649 Double_t eta2 = jet2->Eta();
650 Double_t phi1 = jet1->Phi();
651 Double_t phi2 = jet2->Phi();
652// printf("\n Trigger: %f %f %f %f",
653// fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
654 if (
655 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
656 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
657 ||
658 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
659 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
660 )
661 triggered = kTRUE;
662 } else if (fTrigger == 2) {
663// Gamma Jet
664//
665 Int_t np = fParticles.GetEntriesFast();
666 for (Int_t i = 0; i < np; i++) {
667 TParticle* part = (TParticle*) fParticles.At(i);
668 Int_t kf = part->GetPdgCode();
669 Int_t ksp = part->GetUniqueID();
670 if (kf == 22 && ksp == 40) {
671 Float_t phi = part->Phi();
672 Float_t eta = part->Eta();
673 if (eta < fEtaMaxJet &&
674 eta > fEtaMinJet &&
675 phi < fPhiMaxJet &&
676 phi > fPhiMinJet) {
677 triggered = 1;
678 break;
679 } // check phi,eta within limits
680 } // direct gamma ?
681 } // particle loop
682 } // fTrigger == 2
683 return triggered;
684}