]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenHijing.cxx
Check whether USEFFLOAT variable is set, because if not
[u/mrichter/AliRoot.git] / EVGEN / AliGenHijing.cxx
CommitLineData
110410f9 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/*
17$Log$
116cbefd 18Revision 1.46 2003/01/07 14:12:33 morsch
19Provides collision geometry.
20
96a7d299 21Revision 1.45 2002/12/16 09:44:49 morsch
22Default for fRadiation is 3.
23
83a26417 24Revision 1.44 2002/10/14 14:55:35 hristov
25Merging the VirtualMC branch to the main development branch (HEAD)
26
b9d0a01d 27Revision 1.42.4.1 2002/08/28 15:06:50 alibrary
28Updating to v3-09-01
29
30Revision 1.43 2002/08/09 12:09:52 morsch
31Direct gamma trigger correctly included.
32
7a013373 33Revision 1.42 2002/03/12 11:07:08 morsch
34Add status code of particle to SetTrack call.
35
0d7c70a0 36Revision 1.41 2002/03/05 11:25:33 morsch
37- New quenching options
38- Correction in CheckTrigger()
39
9bf3f17b 40Revision 1.40 2002/02/12 11:05:53 morsch
41Get daughter indices right.
42
f477ff09 43Revision 1.39 2002/02/12 09:16:39 morsch
44Correction in SelectFlavor()
45
cdd538f1 46Revision 1.38 2002/02/12 08:53:21 morsch
47SetNoGammas can be used to inhibit writing of gammas and pi0.
48
0b22c984 49Revision 1.37 2002/02/08 16:50:50 morsch
50Add name and title in constructor.
51
8b31bfac 52Revision 1.36 2002/01/31 20:17:55 morsch
53Allow for triggered jets with simplified topology: Exact pT, back-to-back
54
3792091f 55Revision 1.35 2001/12/13 07:56:25 hristov
56Set pointers to zero in the default constructor
57
60b030a9 58Revision 1.34 2001/12/11 16:55:42 morsch
59Correct initialization for jet phi-range.
60
777b4893 61Revision 1.33 2001/12/05 10:18:51 morsch
62Possibility of kinematic biasing of jet phi range. (J. Klay)
63
7a186781 64Revision 1.32 2001/11/28 13:51:11 morsch
65Introduce kinematic biasing (etamin, etamax) of jet trigger. Bookkeeping
66(number of trials) done in AliGenHijingEventHeader.
67
e4ffda63 68Revision 1.31 2001/11/06 12:30:34 morsch
69Add Boost() method to boost all particles to LHC lab frame. Needed for asymmetric collision systems.
70
cc71f2d3 71Revision 1.30 2001/10/21 18:35:56 hristov
72Several pointers were set to zero in the default constructors to avoid memory management problems
73
2685bf00 74Revision 1.29 2001/10/15 08:12:24 morsch
75- Vertex smearing with truncated gaussian.
76- Store triggered jet info before and after final state radiation into mc-heade
77
f8b85aa9 78Revision 1.28 2001/10/08 11:55:25 morsch
79Store 4-momenta of trigegred jets in event header.
80Possibility to switch of initial and final state radiation.
81
332c8db0 82Revision 1.27 2001/10/08 07:13:14 morsch
83Add setter for minimum transverse momentum of triggered jet.
84
ed6361b0 85Revision 1.26 2001/10/04 08:12:24 morsch
86Redefinition of stable condition.
87
79bf94df 88Revision 1.25 2001/07/27 17:09:36 morsch
89Use local SetTrack, KeepTrack and SetHighWaterMark methods
90to delegate either to local stack or to stack owned by AliRun.
91(Piotr Skowronski, A.M.)
92
a99cf51f 93Revision 1.24 2001/07/20 09:34:56 morsch
94Count the number of spectator neutrons and protons and add information
95to the event header. (Chiara Oppedisano)
96
b46f2676 97Revision 1.23 2001/07/13 17:30:22 morsch
98Derive from AliGenMC.
99
55d6adcf 100Revision 1.22 2001/06/11 13:09:23 morsch
101- Store cross-Section and number of binary collisions as a function of impact parameter
102- Pass AliGenHijingEventHeader to gAlice.
103
21ce2e6f 104Revision 1.21 2001/02/28 17:35:24 morsch
105Consider elastic interactions (ks = 1 and ks = 11) as spectator (Chiara Oppedisano)
106
cf6bac7b 107Revision 1.20 2001/02/14 15:50:40 hristov
108The last particle in event marked using SetHighWaterMark
109
28adac24 110Revision 1.19 2000/12/21 16:24:06 morsch
111Coding convention clean-up
112
675e9664 113Revision 1.18 2000/12/06 17:46:30 morsch
114Avoid random numbers 1 and 0.
115
7498b3ad 116Revision 1.17 2000/12/04 11:22:03 morsch
117Init of sRandom as in 1.15
118
097ec7c1 119Revision 1.16 2000/12/02 11:41:39 morsch
120Use SetRandom() to initialize random number generator in constructor.
121
1ed25e11 122Revision 1.15 2000/11/30 20:29:02 morsch
123Initialise static variable sRandom in constructor: sRandom = fRandom;
124
ad1df918 125Revision 1.14 2000/11/30 07:12:50 alibrary
126Introducing new Rndm and QA classes
127
65fb704d 128Revision 1.13 2000/11/09 17:40:27 morsch
129Possibility to select/unselect spectator protons and neutrons.
130Method SetSpectators(Int_t spect) added. (FCA, Ch. Oppedisano)
131
2705454f 132Revision 1.12 2000/10/20 13:38:38 morsch
133Debug printouts commented.
134
1df2195f 135Revision 1.11 2000/10/20 13:22:26 morsch
136- skip particle type 92 (string)
137- Charmed and beauty baryions (5122, 4122) are considered as stable consistent with
138 mesons.
139
608708ba 140Revision 1.10 2000/10/17 15:10:20 morsch
141Write first all the parent particles to the stack and then the final state particles.
142
e06552ba 143Revision 1.9 2000/10/17 13:38:59 morsch
144Protection against division by zero in EvaluateCrossSection() and KinematicSelection(..) (FCA)
145
c007646a 146Revision 1.8 2000/10/17 12:46:31 morsch
147Protect EvaluateCrossSections() against division by zero.
148
73bc6a56 149Revision 1.7 2000/10/02 21:28:06 fca
150Removal of useless dependecies via forward declarations
151
94de3818 152Revision 1.6 2000/09/11 13:23:37 morsch
153Write last seed to file (fortran lun 50) and reed back from same lun using calls to
154luget_hijing and luset_hijing.
155
b78ff279 156Revision 1.5 2000/09/07 16:55:40 morsch
157fHijing->Initialize(); after change of parameters. (Dmitri Yurevitch Peressounko)
158
ba244bac 159Revision 1.4 2000/07/11 18:24:56 fca
160Coding convention corrections + few minor bug fixes
161
aee8290b 162Revision 1.3 2000/06/30 12:08:36 morsch
163In member data: char* replaced by TString, Init takes care of resizing the strings to
1648 characters required by Hijing.
165
3b8bd63f 166Revision 1.2 2000/06/15 14:15:05 morsch
167Add possibility for heavy flavor selection: charm and beauty.
168
eb342d2d 169Revision 1.1 2000/06/09 20:47:27 morsch
170AliGenerator interface class to HIJING using THijing (test version)
171
110410f9 172*/
173
675e9664 174
175
176// Generator using HIJING as an external generator
177// The main HIJING options are accessable for the user through this interface.
178// Uses the THijing implementation of TGenerator.
179//
180// andreas.morsch@cern.ch
181
110410f9 182#include <TArrayI.h>
21ce2e6f 183#include <TGraph.h>
116cbefd 184#include <THijing.h>
332c8db0 185#include <TLorentzVector.h>
116cbefd 186#include <TPDGCode.h>
187#include <TParticle.h>
188
189#include "AliGenHijing.h"
190#include "AliGenHijingEventHeader.h"
191#include "AliRun.h"
110410f9 192
ad1df918 193
116cbefd 194 ClassImp(AliGenHijing)
110410f9 195
196AliGenHijing::AliGenHijing()
55d6adcf 197 :AliGenMC()
110410f9 198{
199// Constructor
7a013373 200 fParticles = 0;
201 fHijing = 0;
202 fDsigmaDb = 0;
203 fDnDb = 0;
110410f9 204}
205
206AliGenHijing::AliGenHijing(Int_t npart)
55d6adcf 207 :AliGenMC(npart)
110410f9 208{
209// Default PbPb collisions at 5. 5 TeV
210//
8b31bfac 211 fName = "Hijing";
212 fTitle= "Particle Generator using HIJING";
213
110410f9 214 SetEnergyCMS();
215 SetImpactParameterRange();
216 SetTarget();
217 SetProjectile();
cc71f2d3 218 SetBoostLHC();
e4ffda63 219 SetJetEtaRange();
777b4893 220 SetJetPhiRange();
e4ffda63 221
ed6361b0 222 fKeep = 0;
223 fQuench = 1;
224 fShadowing = 1;
225 fTrigger = 0;
226 fDecaysOff = 1;
227 fEvaluate = 0;
228 fSelectAll = 0;
229 fFlavor = 0;
230 fSpectators = 1;
231 fDsigmaDb = 0;
232 fDnDb = 0;
233 fPtMinJet = -2.5;
83a26417 234 fRadiation = 3;
f8b85aa9 235 fEventVertex.Set(3);
3792091f 236//
237 SetSimpleJets();
0b22c984 238 SetNoGammas();
7a013373 239//
240 fParticles = new TClonesArray("TParticle",10000);
ad1df918 241//
1ed25e11 242// Set random number generator
097ec7c1 243 sRandom = fRandom;
2685bf00 244 fHijing = 0;
245
110410f9 246}
247
248AliGenHijing::AliGenHijing(const AliGenHijing & Hijing)
249{
250// copy constructor
251}
252
253
254AliGenHijing::~AliGenHijing()
255{
256// Destructor
21ce2e6f 257 if ( fDsigmaDb) delete fDsigmaDb;
258 if ( fDnDb) delete fDnDb;
7a013373 259 delete fParticles;
110410f9 260}
261
262void AliGenHijing::Init()
263{
264// Initialisation
3b8bd63f 265 fFrame.Resize(8);
266 fTarget.Resize(8);
267 fProjectile.Resize(8);
268
110410f9 269 SetMC(new THijing(fEnergyCMS, fFrame, fProjectile, fTarget,
270 fAProjectile, fZProjectile, fATarget, fZTarget,
271 fMinImpactParam, fMaxImpactParam));
272
273 fHijing=(THijing*) fgMCEvGen;
332c8db0 274 fHijing->SetIHPR2(2, fRadiation);
110410f9 275 fHijing->SetIHPR2(3, fTrigger);
110410f9 276 fHijing->SetIHPR2(6, fShadowing);
277 fHijing->SetIHPR2(12, fDecaysOff);
278 fHijing->SetIHPR2(21, fKeep);
ed6361b0 279 fHijing->SetHIPR1(10, fPtMinJet);
3792091f 280 fHijing->SetHIPR1(50, fSimpleJet);
9bf3f17b 281//
282// Quenching
283//
284//
285// fQuench = 0: no quenching
286// fQuench = 1: hijing default
287// fQuench = 2: new LHC parameters for HIPR1(11) and HIPR1(14)
288// fQuench = 3: new RHIC parameters for HIPR1(11) and HIPR1(14)
289// fQuench = 4: new LHC parameters with log(e) dependence
290// fQuench = 5: new RHIC parameters with log(e) dependence
291 fHijing->SetIHPR2(50, 0);
292 if (fQuench > 0)
293 fHijing->SetIHPR2(4, 1);
294 else
295 fHijing->SetIHPR2(4, 0);
296// New LHC parameters from Xin-Nian Wang
297 if (fQuench == 2) {
298 fHijing->SetHIPR1(14, 1.1);
299 fHijing->SetHIPR1(11, 3.7);
300 } else if (fQuench == 3) {
301 fHijing->SetHIPR1(14, 0.20);
302 fHijing->SetHIPR1(11, 2.5);
303 } else if (fQuench == 4) {
304 fHijing->SetIHPR2(50, 1);
305 fHijing->SetHIPR1(14, 4.*0.34);
306 fHijing->SetHIPR1(11, 3.7);
307 } else if (fQuench == 5) {
308 fHijing->SetIHPR2(50, 1);
309 fHijing->SetHIPR1(14, 0.34);
310 fHijing->SetHIPR1(11, 2.5);
311 }
312
313
314
315//
316// Initialize Hijing
317//
ba244bac 318 fHijing->Initialize();
110410f9 319//
320 if (fEvaluate) EvaluateCrossSections();
ad1df918 321//
110410f9 322}
323
324void AliGenHijing::Generate()
325{
326// Generate one event
327
21ce2e6f 328 Float_t polar[3] = {0,0,0};
329 Float_t origin[3] = {0,0,0};
330 Float_t origin0[3] = {0,0,0};
28adac24 331 Float_t p[3], random[6];
332 Float_t tof;
110410f9 333
110410f9 334// converts from mm/c to s
21ce2e6f 335 const Float_t kconv = 0.001/2.999792458e8;
110410f9 336//
21ce2e6f 337 Int_t nt = 0;
338 Int_t jev = 0;
28adac24 339 Int_t j, kf, ks, imo;
21ce2e6f 340 kf = 0;
eb342d2d 341
7a013373 342
110410f9 343
21ce2e6f 344 fTrials = 0;
345 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
346 if(fVertexSmear == kPerEvent) {
f8b85aa9 347 Float_t dv[3];
348 dv[2] = 1.e10;
349 while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
350 Rndm(random,6);
351 for (j=0; j < 3; j++) {
352 dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
353 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
354 }
355 }
356 for (j=0; j < 3; j++) origin0[j] += dv[j];
21ce2e6f 357 } else if (fVertexSmear == kPerTrack) {
28adac24 358// fHijing->SetMSTP(151,0);
21ce2e6f 359 for (j = 0; j < 3; j++) {
28adac24 360// fHijing->SetPARP(151+j, fOsigma[j]*10.);
21ce2e6f 361 }
28adac24 362 }
363 while(1)
21ce2e6f 364 {
365// Generate one event
b46f2676 366// --------------------------------------------------------------------------
367 fSpecn = 0;
368 fSpecp = 0;
369// --------------------------------------------------------------------------
28adac24 370 fHijing->GenerateEvent();
371 fTrials++;
7a013373 372 fHijing->ImportParticles(fParticles,"All");
e4ffda63 373 if (fTrigger != kNoTrigger) {
374 if (!CheckTrigger()) continue;
375 }
7a013373 376 if (fLHC) Boost();
cc71f2d3 377
e4ffda63 378
7a013373 379 Int_t np = fParticles->GetEntriesFast();
28adac24 380 printf("\n **************************************************%d\n",np);
21ce2e6f 381 Int_t nc = 0;
28adac24 382 if (np == 0 ) continue;
383 Int_t i;
f477ff09 384 Int_t* newPos = new Int_t[np];
385 Int_t* pSelected = new Int_t[np];
28adac24 386
f477ff09 387 for (i = 0; i < np; i++) {
388 newPos[i] = i;
389 pSelected[i] = 0;
390 }
391
f8b85aa9 392// Get event vertex
393//
7a013373 394 TParticle * iparticle = (TParticle *) fParticles->At(0);
f8b85aa9 395 fEventVertex[0] = origin0[0];
396 fEventVertex[1] = origin0[1];
397 fEventVertex[2] = origin0[2];
398
e06552ba 399//
f477ff09 400// First select parent particles
e06552ba 401//
402
21ce2e6f 403 for (i = 0; i < np; i++) {
7a013373 404 iparticle = (TParticle *) fParticles->At(i);
405
e06552ba 406// Is this a parent particle ?
f8b85aa9 407 if (Stable(iparticle)) continue;
e06552ba 408//
f477ff09 409 Bool_t selected = kTRUE;
410 Bool_t hasSelectedDaughters = kFALSE;
411
412
413 kf = iparticle->GetPdgCode();
414 ks = iparticle->GetStatusCode();
415 if (kf == 92) continue;
e06552ba 416
f477ff09 417 if (!fSelectAll) selected = KinematicSelection(iparticle, 0) &&
418 SelectFlavor(kf);
7a013373 419 hasSelectedDaughters = DaughtersSelection(iparticle);
110410f9 420//
f477ff09 421// Put particle on the stack if it is either selected or
422// it is the mother of at least one seleted particle
e06552ba 423//
f477ff09 424 if (selected || hasSelectedDaughters) {
425 nc++;
426 pSelected[i] = 1;
427 } // selected
28adac24 428 } // particle loop parents
e06552ba 429//
f477ff09 430// Now select the final state particles
e06552ba 431//
432
28adac24 433 for (i = 0; i<np; i++) {
7a013373 434 TParticle * iparticle = (TParticle *) fParticles->At(i);
e06552ba 435// Is this a final state particle ?
f477ff09 436 if (!Stable(iparticle)) continue;
437
438 Bool_t selected = kTRUE;
439 kf = iparticle->GetPdgCode();
440 ks = iparticle->GetStatusCode();
7a013373 441
b46f2676 442// --------------------------------------------------------------------------
443// Count spectator neutrons and protons
f477ff09 444 if(ks == 0 || ks == 1 || ks == 10 || ks == 11){
445 if(kf == kNeutron) fSpecn += 1;
446 if(kf == kProton) fSpecp += 1;
447 }
b46f2676 448// --------------------------------------------------------------------------
449//
f477ff09 450 if (!fSelectAll) {
451 selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
452 if (!fSpectators && selected) selected = (ks != 0 && ks != 1 && ks != 10
453 && ks != 11);
454 }
e06552ba 455//
456// Put particle on the stack if selected
457//
f477ff09 458 if (selected) {
459 nc++;
460 pSelected[i] = 1;
461 } // selected
28adac24 462 } // particle loop final state
f477ff09 463//
464// Write particles to stack
465//
466 for (i = 0; i<np; i++) {
7a013373 467 TParticle * iparticle = (TParticle *) fParticles->At(i);
f477ff09 468 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
469 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
470
471 if (pSelected[i]) {
472 kf = iparticle->GetPdgCode();
0d7c70a0 473 ks = iparticle->GetStatusCode();
f477ff09 474 p[0] = iparticle->Px();
475 p[1] = iparticle->Py();
476 p[2] = iparticle->Pz();
477 origin[0] = origin0[0]+iparticle->Vx()/10;
478 origin[1] = origin0[1]+iparticle->Vy()/10;
479 origin[2] = origin0[2]+iparticle->Vz()/10;
480 tof = kconv*iparticle->T();
481 imo = -1;
482 TParticle* mother = 0;
483 if (hasMother) {
484 imo = iparticle->GetFirstMother();
7a013373 485 mother = (TParticle *) fParticles->At(imo);
f477ff09 486 imo = (mother->GetPdgCode() != 92) ? imo = newPos[imo] : -1;
487 } // if has mother
488 Bool_t tFlag = (fTrackIt && !hasDaughter);
489 SetTrack(tFlag,imo,kf,p,origin,polar,
0d7c70a0 490 tof,kPNoProcess,nt, 1., ks);
f477ff09 491 KeepTrack(nt);
492 newPos[i] = nt;
493 } // if selected
494 } // particle loop
79bf94df 495 delete[] newPos;
f477ff09 496 delete[] pSelected;
497
28adac24 498 printf("\n I've put %i particles on the stack \n",nc);
499 if (nc > 0) {
21ce2e6f 500 jev += nc;
501 if (jev >= fNpart || fNpart == -1) {
502 fKineBias = Float_t(fNpart)/Float_t(fTrials);
503 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
504 break;
505 }
28adac24 506 }
21ce2e6f 507 } // event loop
508 MakeHeader();
a99cf51f 509 SetHighWaterMark(nt);
110410f9 510}
511
110410f9 512void AliGenHijing::KeepFullEvent()
513{
514 fKeep=1;
515}
516
517void AliGenHijing::EvaluateCrossSections()
518{
519// Glauber Calculation of geometrical x-section
520//
21ce2e6f 521 Float_t xTot = 0.; // barn
522 Float_t xTotHard = 0.; // barn
523 Float_t xPart = 0.; // barn
524 Float_t xPartHard = 0.; // barn
525 Float_t sigmaHard = 0.1; // mbarn
526 Float_t bMin = 0.;
527 Float_t bMax = fHijing->GetHIPR1(34)+fHijing->GetHIPR1(35);
528 const Float_t kdib = 0.2;
529 Int_t kMax = Int_t((bMax-bMin)/kdib)+1;
110410f9 530
531
532 printf("\n Projectile Radius (fm): %f \n",fHijing->GetHIPR1(34));
533 printf("\n Target Radius (fm): %f \n",fHijing->GetHIPR1(35));
534 Int_t i;
21ce2e6f 535 Float_t oldvalue= 0.;
536
537 Float_t* b = new Float_t[kMax];
538 Float_t* si1 = new Float_t[kMax];
539 Float_t* si2 = new Float_t[kMax];
110410f9 540
21ce2e6f 541 for (i = 0; i < kMax; i++)
110410f9 542 {
21ce2e6f 543 Float_t xb = bMin+i*kdib;
110410f9 544 Float_t ov;
545 ov=fHijing->Profile(xb);
21ce2e6f 546 Float_t gb = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*(1.-TMath::Exp(-fHijing->GetHINT1(12)*ov));
547 Float_t gbh = 2.*0.01*fHijing->GetHIPR1(40)*kdib*xb*sigmaHard*ov;
110410f9 548 xTot+=gb;
21ce2e6f 549 xTotHard += gbh;
110410f9 550 if (xb > fMinImpactParam && xb < fMaxImpactParam)
551 {
21ce2e6f 552 xPart += gb;
553 xPartHard += gbh;
110410f9 554 }
555
c007646a 556 if(oldvalue) if ((xTot-oldvalue)/oldvalue<0.0001) break;
21ce2e6f 557 oldvalue = xTot;
110410f9 558 printf("\n Total cross section (barn): %d %f %f \n",i, xb, xTot);
559 printf("\n Hard cross section (barn): %d %f %f \n\n",i, xb, xTotHard);
21ce2e6f 560 if (i>0) {
561 si1[i] = gb/kdib;
562 si2[i] = gbh/gb;
563 b[i] = xb;
564 }
110410f9 565 }
21ce2e6f 566
110410f9 567 printf("\n Total cross section (barn): %f \n",xTot);
568 printf("\n Hard cross section (barn): %f \n \n",xTotHard);
569 printf("\n Partial cross section (barn): %f %f \n",xPart, xPart/xTot*100.);
570 printf("\n Partial hard cross section (barn): %f %f \n",xPartHard, xPartHard/xTotHard*100.);
21ce2e6f 571
572// Store result as a graph
573 b[0] = 0;
574 si1[0] = 0;
575 si2[0]=si2[1];
576
577 fDsigmaDb = new TGraph(i, b, si1);
578 fDnDb = new TGraph(i, b, si2);
110410f9 579}
580
7a013373 581Bool_t AliGenHijing::DaughtersSelection(TParticle* iparticle)
110410f9 582{
583//
584// Looks recursively if one of the daughters has been selected
585//
586// printf("\n Consider daughters %d:",iparticle->GetPdgCode());
21ce2e6f 587 Int_t imin = -1;
588 Int_t imax = -1;
110410f9 589 Int_t i;
21ce2e6f 590 Bool_t hasDaughters = (iparticle->GetFirstDaughter() >=0);
591 Bool_t selected = kFALSE;
110410f9 592 if (hasDaughters) {
21ce2e6f 593 imin = iparticle->GetFirstDaughter();
594 imax = iparticle->GetLastDaughter();
595 for (i = imin; i <= imax; i++){
7a013373 596 TParticle * jparticle = (TParticle *) fParticles->At(i);
21ce2e6f 597 Int_t ip = jparticle->GetPdgCode();
55d6adcf 598 if (KinematicSelection(jparticle,0)&&SelectFlavor(ip)) {
608708ba 599 selected=kTRUE; break;
600 }
7a013373 601 if (DaughtersSelection(jparticle)) {selected=kTRUE; break; }
110410f9 602 }
603 } else {
604 return kFALSE;
605 }
110410f9 606 return selected;
607}
608
609
eb342d2d 610Bool_t AliGenHijing::SelectFlavor(Int_t pid)
611{
612// Select flavor of particle
613// 0: all
614// 4: charm and beauty
615// 5: beauty
0b22c984 616 Bool_t res = 0;
eb342d2d 617
cdd538f1 618 if (fFlavor == 0) {
619 res = kTRUE;
620 } else {
621 Int_t ifl = TMath::Abs(pid/100);
622 if (ifl > 10) ifl/=10;
623 res = (fFlavor == ifl);
624 }
625//
626// This part if gamma writing is inhibited
627 if (fNoGammas)
628 res = res && (pid != kGamma && pid != kPi0);
629//
0b22c984 630 return res;
608708ba 631}
eb342d2d 632
608708ba 633Bool_t AliGenHijing::Stable(TParticle* particle)
634{
675e9664 635// Return true for a stable particle
636//
0b22c984 637
79bf94df 638 if (particle->GetFirstDaughter() < 0 )
608708ba 639 {
640 return kTRUE;
641 } else {
642 return kFALSE;
643 }
eb342d2d 644}
110410f9 645
cc71f2d3 646
7a013373 647void AliGenHijing::Boost()
cc71f2d3 648{
649//
650// Boost cms into LHC lab frame
651//
652 Double_t dy = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
653 (Double_t(fZTarget) * Double_t(fAProjectile)));
654 Double_t beta = TMath::TanH(dy);
655 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
656 Double_t gb = gamma * beta;
657
658 printf("\n Boosting particles to lab frame %f %f %f", dy, beta, gamma);
659
660 Int_t i;
7a013373 661 Int_t np = fParticles->GetEntriesFast();
cc71f2d3 662 for (i = 0; i < np; i++)
663 {
7a013373 664 TParticle* iparticle = (TParticle*) fParticles->At(i);
cc71f2d3 665
666 Double_t e = iparticle->Energy();
667 Double_t px = iparticle->Px();
668 Double_t py = iparticle->Py();
669 Double_t pz = iparticle->Pz();
670
671 Double_t eb = gamma * e - gb * pz;
672 Double_t pzb = -gb * e + gamma * pz;
673
674 iparticle->SetMomentum(px, py, pzb, eb);
675 }
676}
677
678
3b8bd63f 679void AliGenHijing::MakeHeader()
680{
681// Builds the event header, to be called after each event
21ce2e6f 682 AliGenEventHeader* header = new AliGenHijingEventHeader("Hijing");
332c8db0 683 ((AliGenHijingEventHeader*) header)->SetNProduced(fHijing->GetNATT());
684 ((AliGenHijingEventHeader*) header)->SetImpactParameter(fHijing->GetHINT1(19));
685 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(fHijing->GetEATT());
686 ((AliGenHijingEventHeader*) header)->SetHardScatters(fHijing->GetJATT());
687 ((AliGenHijingEventHeader*) header)->SetParticipants(fHijing->GetNP(), fHijing->GetNT());
688 ((AliGenHijingEventHeader*) header)->SetCollisions(fHijing->GetN0(),
689 fHijing->GetN01(),
690 fHijing->GetN10(),
691 fHijing->GetN11());
692 ((AliGenHijingEventHeader*) header)->SetSpectators(fSpecn, fSpecp);
693
f8b85aa9 694// 4-momentum vectors of the triggered jets.
695//
696// Before final state gluon radiation.
332c8db0 697 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
698 fHijing->GetHINT1(22),
699 fHijing->GetHINT1(23),
700 fHijing->GetHINT1(24));
701
702 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
703 fHijing->GetHINT1(32),
704 fHijing->GetHINT1(33),
705 fHijing->GetHINT1(34));
f8b85aa9 706// After final state gluon radiation.
707 TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
708 fHijing->GetHINT1(27),
709 fHijing->GetHINT1(28),
710 fHijing->GetHINT1(29));
711
712 TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
713 fHijing->GetHINT1(37),
714 fHijing->GetHINT1(38),
715 fHijing->GetHINT1(39));
716 ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
7a186781 717// Bookkeeping for kinematic bias
e4ffda63 718 ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
f8b85aa9 719// Event Vertex
720 header->SetPrimaryVertex(fEventVertex);
96a7d299 721 gAlice->SetGenEventHeader(header);
722 fCollisionGeometry = (AliGenHijingEventHeader*) header;
3b8bd63f 723}
724
e4ffda63 725Bool_t AliGenHijing::CheckTrigger()
726{
727// Check the kinematic trigger condition
7a013373 728//
e4ffda63 729 Bool_t triggered = kFALSE;
7a013373 730
731 if (fTrigger == 1) {
732//
733// jet-jet Trigger
734
735 TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(26),
736 fHijing->GetHINT1(27),
737 fHijing->GetHINT1(28),
738 fHijing->GetHINT1(29));
739
740 TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(36),
741 fHijing->GetHINT1(37),
742 fHijing->GetHINT1(38),
743 fHijing->GetHINT1(39));
744 Double_t eta1 = jet1->Eta();
745 Double_t eta2 = jet2->Eta();
746 Double_t phi1 = jet1->Phi();
747 Double_t phi2 = jet2->Phi();
9bf3f17b 748// printf("\n Trigger: %f %f %f %f",
749// fEtaMinJet, fEtaMaxJet, fPhiMinJet, fPhiMaxJet);
7a013373 750 if (
751 (eta1 < fEtaMaxJet && eta1 > fEtaMinJet &&
752 phi1 < fPhiMaxJet && phi1 > fPhiMinJet)
753 ||
754 (eta2 < fEtaMaxJet && eta2 > fEtaMinJet &&
755 phi2 < fPhiMaxJet && phi2 > fPhiMinJet)
756 )
757 triggered = kTRUE;
758 } else if (fTrigger == 2) {
759// Gamma Jet
760//
761 Int_t np = fParticles->GetEntriesFast();
762 for (Int_t i = 0; i < np; i++) {
763 TParticle* part = (TParticle*) fParticles->At(i);
764 Int_t kf = part->GetPdgCode();
765 Int_t ks = part->GetStatusCode();
766 if (kf == 22 && ks == 40) {
767 Float_t phi = part->Phi();
768 Float_t eta = part->Eta();
769 if (eta < fEtaMaxJet &&
770 eta > fEtaMinJet &&
771 phi < fPhiMaxJet &&
772 phi > fPhiMinJet) {
773 triggered = 1;
774 break;
775 } // check phi,eta within limits
776 } // direct gamma ?
777 } // particle loop
778 } // fTrigger == 2
e4ffda63 779 return triggered;
780}
cc71f2d3 781
3792091f 782
783
784
110410f9 785AliGenHijing& AliGenHijing::operator=(const AliGenHijing& rhs)
786{
787// Assignment operator
788 return *this;
789}
608708ba 790
65fb704d 791#ifndef WIN32
792# define rluget_hijing rluget_hijing_
793# define rluset_hijing rluset_hijing_
794# define rlu_hijing rlu_hijing_
795# define type_of_call
796#else
797# define rluget_hijing RLUGET_HIJING
798# define rluset_hijing RLUSET_HIJING
799# define rlu_hijing RLU_HIJING
800# define type_of_call _stdcall
801#endif
802
803
804extern "C" {
805 void type_of_call rluget_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
806 {printf("Dummy version of rluget_hijing reached\n");}
807
808 void type_of_call rluset_hijing(Int_t & /*lfn*/, Int_t & /*move*/)
809 {printf("Dummy version of rluset_hijing reached\n");}
810
811 Double_t type_of_call rlu_hijing(Int_t & /*idum*/)
7498b3ad 812 {
813 Float_t r;
814 do r=sRandom->Rndm(); while(0 >= r || r >= 1);
815 return r;
816 }
65fb704d 817}