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