]> git.uio.no Git - u/mrichter/AliRoot.git/blob - THijing/THijing.cxx
Additional protection (Yu.Belikov)
[u/mrichter/AliRoot.git] / THijing / THijing.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 //                                                                            //
3 // THijing                                                                    //
4 //                                                                            //
5 // THijing is an interface class to F77 version of Hijing 1.36                //
6 // event generator, written by X.N. Wang and  M. Gyulassy.                    //
7 // For details see http://nta2.lbl.gov/~xnwang                                //
8 //                                                                            //
9 //          **************************************************                //
10 //          *     |             _______      /  ------/      *                //
11 //          *   ----- ------     |_____|     /_/     /       *                //
12 //          *    ||    /        |_____|      /    /          *                //
13 //          *    /|   /_/       /_______    /_  /    _       *                //
14 //          *   / |     / /     /  /  / |        -------     *                //
15 //          *     |    / /       /  /  |     /     |         *                //
16 //          *     |   / /       /  / _|    /   -------       *                //
17 //          *                                                *                //
18 //          **************************************************                //
19 //                                HIJING                                      //
20 //                 Heavy Ion Jet INteraction Generator                        //
21 //                                  by                                        //
22 //                     X. N. Wang  and  M. Gyulassy                           //
23 //                     Lawrence Berkeley Laboratory                           //
24 //****************************************************************************//
25
26
27 #include "THijing.h"
28 #include "Hcommon.h"
29 #include "TParticle.h"
30 #include "TROOT.h"
31
32 #ifndef WIN32
33 # define hijset hijset_
34 # define hijing hijing_
35 # define profile profile_
36 # define rluget_hijing rluget_hijing_
37 # define rluset_hijing rluset_hijing_
38 # define type_of_call
39 #else
40 # define hijset HIJSET
41 # define hijing HIJING
42 # define profile PROFILE
43 # define rluget_hijing RLUGET_HIJING
44 # define rluset_hijing RLUSET_HIJING
45 # define type_of_call _stdcall
46 #endif
47
48 #ifndef WIN32
49 extern "C" void type_of_call hijset(Float_t & , const char *, 
50                                    const char *, const char *,
51                                    Int_t & , Int_t &, Int_t &,
52                                    Int_t &, const int, 
53                                    const int, const int);
54 extern "C" float type_of_call profile(Float_t &);
55 extern "C" void type_of_call hijing(const char *, Float_t  &,
56                                    Float_t &, const int);
57 extern "C" void type_of_call rluget_hijing(Int_t & lfn, Int_t & move);
58
59 extern "C" void type_of_call rluset_hijing(Int_t & lfn, Int_t & move);
60
61 #else
62 #endif
63
64
65
66 ClassImp(THijing)
67
68 THijing::THijing() : TGenerator("Hijing","Hijing")
69 {
70 // Default constructor 
71 }
72
73 //______________________________________________________________________________
74 THijing::THijing(Float_t efrm, const char *frame="CMS", 
75         const char *proj="A", const char *targ="A", Int_t iap=207, 
76         Int_t izp=82, Int_t iat=207, Int_t izt=82, Float_t bmin=0, 
77         Float_t bmax=20) : TGenerator("Hijing","Hijing")
78 {
79 // THijing constructor: 
80 // Note that there may be only one functional THijing object
81 // at a time, so it's not use to create more than one instance of it.
82       fEfrm=efrm;
83       fFrame=frame;
84       fProj=proj;
85       fTarg=targ;
86       fIap=iap;
87       fIzp=izp;
88       fIat=iat;
89       fIzt=izt;
90       fBmin=bmin;
91       fBmax=bmax;
92 }
93
94 //______________________________________________________________________________
95 THijing::~THijing()
96 {
97 // Destructor
98 }
99
100
101
102 Int_t THijing::ImportParticles(TClonesArray *particles, Option_t *option)
103 {
104 //
105 //  Default primary creation method. It reads the /HEPEVT/ common block which
106 //  has been filled by the GenerateEvent method. If the event generator does
107 //  not use the HEPEVT common block, This routine has to be overloaded by
108 //  the subclasses.
109 //  The function loops on the generated particles and store them in
110 //  the TClonesArray pointed by the argument particles.
111 //  The default action is to store only the stable particles (ISTHEP = 1)
112 //  This can be demanded explicitly by setting the option = "Final"
113 //  If the option = "All", all the particles are stored.
114 //
115   if (particles == 0) return 0;
116   TClonesArray &particlesR = *particles;
117   particlesR.Clear();
118   Int_t numpart = HIMAIN1.natt;
119   printf("\n THijing: HIJING stack contains %d particles.", numpart);
120   printf("\n THijing: Total energy:         %f           ", HIMAIN1.eatt);
121   printf("\n THijing: Number of hard scatterings: %d     ", HIMAIN1.jatt);
122   Int_t nump = 0;
123   if (!strcmp(option,"") || !strcmp(option,"Final")) {
124       for (Int_t i = 0; i < numpart; i++) {
125           
126           if (HIMAIN2.katt[3][i] == 1) {
127 //
128 //  Use the common block values for the TParticle constructor
129 //
130             nump++;
131             new(particlesR[i]) TParticle(
132                   HIMAIN2.katt[0][i] ,
133                   HIMAIN2.katt[1][i] ,
134                   -1 ,
135                   -1,
136                   -1,
137                   -1,
138                   
139                   HIMAIN2.patt[0][i] ,
140                   HIMAIN2.patt[1][i] ,
141                   HIMAIN2.patt[2][i] ,
142                   HIMAIN2.patt[3][i] ,
143
144                   HIMAIN2.vatt[0][i] ,
145                   HIMAIN2.vatt[1][i] ,
146                   HIMAIN2.vatt[2][i] ,
147                   HIMAIN2.vatt[3][i] 
148                   );
149           }
150       }
151   }
152   else if (!strcmp(option,"All")) {
153       nump = numpart; 
154       for (Int_t i = 0; i < numpart; i++) {
155
156           Int_t iParent = HIMAIN2.katt[2][i]-1;
157           
158           if (iParent >= 0) {
159               TParticle *mother = (TParticle*) (particlesR.UncheckedAt(iParent));          
160               mother->SetLastDaughter(i);
161               if (mother->GetFirstDaughter()==-1)
162                   mother->SetFirstDaughter(i);
163           }
164
165           new(particlesR[i]) TParticle(
166               HIMAIN2.katt[0][i] ,
167               HIMAIN2.katt[1][i] ,
168               iParent,
169               -1,
170               -1,
171               -1,
172               
173               HIMAIN2.patt[0][i] ,
174               HIMAIN2.patt[1][i] ,
175               HIMAIN2.patt[2][i] ,
176               HIMAIN2.patt[3][i] ,
177               
178               HIMAIN2.vatt[0][i] ,
179               HIMAIN2.vatt[1][i] ,
180               HIMAIN2.vatt[2][i] ,
181               HIMAIN2.vatt[3][i]
182               );
183       }
184   }
185   return nump;
186 }
187
188 //______________________________________________________________________________
189 void THijing::SetEFRM(Float_t efrm)
190 {
191 // Set the centre of mass (CMS) or lab-energy (LAB)
192    fEfrm=efrm;
193
194 //______________________________________________________________________________
195 void THijing::SetFRAME(const char* frame)
196 {
197 // Set the frame type ("CMS" or "LAB")
198    fFrame=frame;
199
200 //______________________________________________________________________________
201 void THijing::SetPROJ(const char* proj)
202 {
203 // Set the projectile type
204    fProj=proj;
205
206 //______________________________________________________________________________
207 void THijing::SetTARG(const char* targ)
208 {
209 // Set the target type
210    fTarg=targ;
211
212 //______________________________________________________________________________
213 void THijing::SetIAP(Int_t iap)
214 {
215 // Set the projectile atomic number
216    fIap=iap;
217
218 //______________________________________________________________________________
219 void THijing::SetIZP(Int_t izp)
220 {
221 // Set the projectile charge number
222    fIzp=izp;
223
224 //______________________________________________________________________________
225 void THijing::SetIAT(Int_t iat)
226 {
227 // Set the target atomic number
228    fIat=iat;
229
230 //______________________________________________________________________________
231 void THijing::SetIZT(Int_t izt)
232 {
233 // Set the target charge number
234    fIzt=izt;
235
236 //______________________________________________________________________________
237 void THijing::SetBMIN(Float_t bmin)
238 {
239 // Set the minimum impact parameter
240    fBmin=bmin;
241
242 //______________________________________________________________________________
243 void THijing::SetBMAX(Float_t bmax)
244 {
245 // Set the maximum impact parameter
246    fBmax=bmax;
247
248 //______________________________________________________________________________
249 Float_t THijing::GetEFRM() const
250 {
251 // Get the centre of mass (CMS) or lab-energy (LAB)
252    return fEfrm;
253
254 //______________________________________________________________________________
255 const char* THijing::GetFRAME() const
256 {
257 // Get the frame type ("CMS" or "LAB")
258    return fFrame.Data();
259
260 //______________________________________________________________________________
261 const char* THijing::GetPROJ() const
262 {
263 // Get the projectile type
264    return fProj;
265
266 //______________________________________________________________________________
267 const char* THijing::GetTARG() const
268 {
269 // Set the target type
270    return fTarg;
271
272 //______________________________________________________________________________
273 Int_t THijing::GetIAP() const
274 {
275 // Get the projectile atomic number
276    return fIap;
277
278 //______________________________________________________________________________
279 Int_t THijing::GetIZP() const
280 {
281 // Get the projectile charge number
282    return fIzp;
283
284 //______________________________________________________________________________
285 Int_t THijing::GetIAT() const
286 {
287 // Get the target atomic number
288    return fIat;
289
290 //______________________________________________________________________________
291 Int_t THijing::GetIZT() const
292 {
293 // Get the target charge number
294    return fIzt;
295
296 //______________________________________________________________________________
297 Float_t THijing::GetBMIN() const
298 {
299 // Get the minimum impact parameter
300    return fBmin;
301
302 //______________________________________________________________________________
303 Float_t THijing::GetBMAX() const
304 {
305 // Get the maximum impact parameter
306    return fBmax;
307
308
309 //====================== access to common HIPARNT ===============================
310
311 //______________________________________________________________________________
312 void THijing::SetHIPR1(Int_t key,Float_t value)
313 {
314 // Set the values of array HIPR1 in common HIPARNT
315    if ( key<1 || key>100 ) {
316       printf ("ERROR in THijing:SetHIPR1(key,value): \n ");
317       printf ("      key=%i is out of range [1..100]!\n",key);
318       return;
319    }
320
321    HIPARNT.hipr1[key-1]=value;
322
323 }
324
325 //______________________________________________________________________________
326 Float_t THijing::GetHIPR1(Int_t key) const
327 {
328 // Get the values of array HIPR1 in common HIPARNT
329    if ( key<1 || key>100 ) {
330       printf ("ERROR in THijing:GetHIPR1(key): \n ");
331       printf ("      key=%i is out of range [1..100]!\n",key);
332       return 0;
333    }
334
335    return HIPARNT.hipr1[key-1];
336
337 }
338
339 //______________________________________________________________________________
340 void THijing::SetIHPR2(Int_t key,Int_t value)
341 {
342 // Set the values of array HIPR2 in common HIPARNT
343    if ( key<1 || key>50 ) {
344       printf ("ERROR in THijing:SetIHPR2(key,value): \n ");
345       printf ("      key=%i is out of range [1..50]!\n",key);
346       return;
347    }
348
349    HIPARNT.ihpr2[key-1]=value;
350
351 }
352
353 //______________________________________________________________________________
354 Int_t THijing::GetIHPR2(Int_t key) const
355 {
356 // Get the values of array HIPR2 in common HIPARNT
357    if ( key<1 || key>50 ) {
358       printf ("ERROR in THijing:GetIHPR2(key): \n ");
359       printf ("      key=%i is out of range [1..50]!\n",key);
360       return 0;
361    }
362
363    return HIPARNT.ihpr2[key-1];
364
365 }
366
367
368 //______________________________________________________________________________
369 Float_t THijing::GetHINT1(Int_t key) const
370 {
371 // Get the values of array HINT1 in common HIPARNT
372    if ( key<1 || key>100 ) {
373       printf ("ERROR in THijing:GetHINT1(key): \n ");
374       printf ("      key=%i is out of range [1..100]!\n",key);
375       return 0;
376    }
377
378    return HIPARNT.hint1[key-1];
379
380 }
381
382
383 //______________________________________________________________________________
384 Int_t THijing::GetIHNT2(Int_t key) const
385 {
386 // Get the values of array HINT2 in common HIPARNT
387    if ( key<1 || key>50 ) {
388       printf ("ERROR in THijing:GetIHNT2(key): \n ");
389       printf ("      key=%i is out of range [1..50]!\n",key);
390       return 0;
391    }
392
393    return HIPARNT.ihnt2[key-1];
394
395 }
396
397
398 //====================== access to common HIMAIN1 ===============================
399
400 //______________________________________________________________________________
401 Int_t  THijing::GetNATT() const
402 {
403 // Get the number of particles produces
404    return HIMAIN1.natt;
405
406 }
407
408 //______________________________________________________________________________
409 Float_t  THijing::GetEATT() const
410 {
411 // Get total energy of particles
412
413    return HIMAIN1.eatt;
414
415 }
416
417 //______________________________________________________________________________
418 Int_t  THijing::GetJATT() const
419 {
420 // Get number of hard scatterings
421
422    return HIMAIN1.jatt;
423
424 }
425
426 //______________________________________________________________________________
427 Int_t  THijing::GetNT() const
428 {
429 // Get number of target participants
430
431    return HIMAIN1.nt;
432
433 }
434
435 //______________________________________________________________________________
436 Int_t  THijing::GetNP() const
437 {
438 // Get number of projectile participants
439    return HIMAIN1.np;
440
441 }
442
443
444 //______________________________________________________________________________
445 Int_t  THijing::GetN0() const
446 {
447 // Get number of N-N collisions
448    return HIMAIN1.n0;
449
450 }
451 //______________________________________________________________________________
452 Int_t  THijing::GetN01() const
453 {
454 // Get number of N-wounded collisions
455
456    return HIMAIN1.n01;
457
458 }
459
460 //______________________________________________________________________________
461 Int_t  THijing::GetN10() const
462 {
463 // Get number of wounded-N collisions
464
465    return HIMAIN1.n10;
466
467 }
468
469 //______________________________________________________________________________
470 Int_t  THijing::GetN11() const
471 {
472 // Get number of wounded-wounded collisions
473
474    return HIMAIN1.n11;
475
476 }
477
478 //______________________________________________________________________________
479 Float_t  THijing::GetBB() const
480 {
481 // Get impact parameter
482
483    return HIMAIN1.bb;
484
485 }
486
487 //====================== access to common HIMAIN2 ===============================
488
489 //______________________________________________________________________________
490 Int_t THijing::GetKATT(Int_t key1, Int_t key2) const
491 {
492 // Get values of array KATT in common HIMAIN2
493    if ( key1<1 || key1>200000 ) {
494       printf("ERROR in THijing::GetKATT(key1,key2):\n");
495       printf("      key1=%i is out of range [1..200000]\n",key1);
496       return 0;
497    }
498
499    if ( key2<1 || key2>4 ) {
500       printf("ERROR in THijing::GetKATT(key1,key2):\n");
501       printf("      key2=%i is out of range [1..4]\n",key2);
502       return 0;
503    }
504    
505    return   HIMAIN2.katt[key2-1][key1-1];
506 }
507
508 //______________________________________________________________________________
509 Float_t THijing::GetPATT(Int_t key1, Int_t key2) const
510 {
511 // Get values of array PATT in common HIMAIN2
512    if ( key1<1 || key1>200000 ) {
513       printf("ERROR in THijing::GetPATT(key1,key2):\n");
514       printf("      key1=%i is out of range [1..130000]\n",key1);
515       return 0;
516    }
517
518    if ( key2<1 || key2>4 ) {
519       printf("ERROR in THijing::GetPATT(key1,key2):\n");
520       printf("      key2=%i is out of range [1..4]\n",key2);
521       return 0;
522    }
523    
524    return   HIMAIN2.patt[key2-1][key1-1];
525 }
526
527 Float_t THijing::GetVATT(Int_t key1, Int_t key2) const
528 {
529 // Get values of array VATT in common HIMAIN2
530    if ( key1<1 || key1>200000 ) {
531       printf("ERROR in THijing::GetVATT(key1,key2):\n");
532       printf("      key1=%i is out of range [1..130000]\n",key1);
533       return 0;
534    }
535
536    if ( key2<1 || key2>4 ) {
537       printf("ERROR in THijing::GetVATT(key1,key2):\n");
538       printf("      key2=%i is out of range [1..4]\n",key2);
539       return 0;
540    }
541    
542    return   HIMAIN2.vatt[key2-1][key1-1];
543 }
544
545 //====================== access to common HIJJET1 ===============================
546
547 //______________________________________________________________________________
548 Int_t THijing::GetNPJ(Int_t key) const
549 {
550 // Get values of array NPJ of common HIJJET1
551    if ( key<1 || key>300 ) {
552       printf("ERROR in THijing::GetNPJ(key):\n");
553       printf("      key=%i is out of range [1..300]\n",key);
554       return 0;
555    }
556    return HIJJET1.npj[key-1];
557 }
558
559 //______________________________________________________________________________
560 Int_t THijing::GetKFPJ(Int_t key1, Int_t key2) const
561 {
562 // Get values of array KFPJ in common HIJJET1
563    if ( key1<1 || key1>300 ) {
564       printf("ERROR in THijing::GetKFPJ(key1):\n");
565       printf("      key1=%i is out of range [1..300]\n",key1);
566       return 0;
567    }
568    if ( key2<1 || key2>500 ) {
569       printf("ERROR in THijing::GetKFPJ(key1,key2):\n");
570       printf("      key2=%i is out of range [1..500]\n",key2);
571       return 0;
572    }
573    
574    return HIJJET1.kfpj[key2-1][key1-1];
575 }
576
577 //______________________________________________________________________________
578 Float_t THijing::GetPJPX(Int_t key1, Int_t key2) const
579 {
580 // Get values of array PJPX in common HIJJET1
581    if ( key1<1 || key1>300 ) {
582       printf("ERROR in THijing::GetPJPX(key1):\n");
583       printf("      key1=%i is out of range [1..300]\n",key1);
584       return 0;
585    }
586    if ( key2<1 || key2>500 ) {
587       printf("ERROR in THijing::GetPJPX(key1,key2):\n");
588       printf("      key2=%i is out of range [1..500]\n",key2);
589       return 0;
590    }
591    
592    return HIJJET1.pjpx[key2-1][key1-1];
593 }
594
595 //______________________________________________________________________________
596 Float_t THijing::GetPJPY(Int_t key1, Int_t key2) const
597 {
598 // Get values of array PJPY in common HIJJET1
599    if ( key1<1 || key1>300 ) {
600       printf("ERROR in THijing::GetPJPY(key1):\n");
601       printf("      key1=%i is out of range [1..300]\n",key1);
602       return 0;
603    }
604    if ( key2<1 || key2>500 ) {
605       printf("ERROR in THijing::GetPJPY(key1,key2):\n");
606       printf("      key2=%i is out of range [1..500]\n",key2);
607       return 0;
608    }
609    
610    return HIJJET1.pjpy[key2-1][key1-1];
611 }
612
613 //______________________________________________________________________________
614 Float_t THijing::GetPJPZ(Int_t key1, Int_t key2) const
615 {
616 // Get values of array PJPZ in common HIJJET1
617    if ( key1<1 || key1>300 ) {
618       printf("ERROR in THijing::GetPJPZ(key1):\n");
619       printf("      key1=%i is out of range [1..300]\n",key1);
620       return 0;
621    }
622    if ( key2<1 || key2>500 ) {
623       printf("ERROR in THijing::GetPJPZ(key1,key2):\n");
624       printf("      key2=%i is out of range [1..500]\n",key2);
625       return 0;
626    }
627    
628    return HIJJET1.pjpz[key2-1][key1-1];
629 }
630
631 //______________________________________________________________________________
632 Float_t THijing::GetPJPE(Int_t key1, Int_t key2) const
633 {
634 // Get values of array PJPE in common HIJJET1
635    if ( key1<1 || key1>300 ) {
636       printf("ERROR in THijing::GetPJPE(key1):\n");
637       printf("      key1=%i is out of range [1..300]\n",key1);
638       return 0;
639    }
640    if ( key2<1 || key2>500 ) {
641       printf("ERROR in THijing::GetPJPE(key1,key2):\n");
642       printf("      key2=%i is out of range [1..500]\n",key2);
643       return 0;
644    }
645    
646    return HIJJET1.pjpe[key2-1][key1-1];
647 }
648
649 //______________________________________________________________________________
650 Float_t THijing::GetPJPM(Int_t key1, Int_t key2) const
651 {
652 // Get values of array PJPM in common HIJJET1
653    if ( key1<1 || key1>300 ) {
654       printf("ERROR in THijing::GetPJPM(key1):\n");
655       printf("      key1=%i is out of range [1..300]\n",key1);
656       return 0;
657    }
658    if ( key2<1 || key2>500 ) {
659       printf("ERROR in THijing::GetPJPM(key1,key2):\n");
660       printf("      key2=%i is out of range [1..500]\n",key2);
661       return 0;
662    }
663    
664    return HIJJET1.pjpm[key2-1][key1-1];
665 }
666
667 //______________________________________________________________________________
668 Int_t THijing::GetNTJ(Int_t key) const
669 {
670 // Get values of array NTJ in common HIJJET1
671    if ( key<1 || key>300 ) {
672       printf("ERROR in THijing::GetNTJ(key):\n");
673       printf("      key=%i is out of range [1..300]\n",key);
674       return 0;
675    }
676    return HIJJET1.ntj[key-1];
677 }
678
679 //______________________________________________________________________________
680 Int_t THijing::GetKFTJ(Int_t key1, Int_t key2) const
681 {
682 // Get values of array KFTJ in common HIJJET1
683    if ( key1<1 || key1>300 ) {
684       printf("ERROR in THijing::GetKFTJ(key1):\n");
685       printf("      key1=%i is out of range [1..300]\n",key1);
686       return 0;
687    }
688    if ( key2<1 || key2>500 ) {
689       printf("ERROR in THijing::GetKFTJ(key1,key2):\n");
690       printf("      key2=%i is out of range [1..500]\n",key2);
691       return 0;
692    }
693    
694    return HIJJET1.kftj[key2-1][key1-1];
695 }
696
697 //______________________________________________________________________________
698 Float_t THijing::GetPJTX(Int_t key1, Int_t key2) const
699 {
700 // Get values of array PJTX in common HIJJET1
701    if ( key1<1 || key1>300 ) {
702       printf("ERROR in THijing::GetPJTX(key1):\n");
703       printf("      key1=%i is out of range [1..300]\n",key1);
704       return 0;
705    }
706    if ( key2<1 || key2>500 ) {
707       printf("ERROR in THijing::GetPJTX(key1,key2):\n");
708       printf("      key2=%i is out of range [1..500]\n",key2);
709       return 0;
710    }
711    
712    return HIJJET1.pjtx[key2-1][key1-1];
713 }
714
715 //______________________________________________________________________________
716 Float_t THijing::GetPJTY(Int_t key1, Int_t key2) const
717 {
718 // Get values of array PJTY in common HIJJET1
719    if ( key1<1 || key1>300 ) {
720       printf("ERROR in THijing::GetPJTY(key1):\n");
721       printf("      key1=%i is out of range [1..300]\n",key1);
722       return 0;
723    }
724    if ( key2<1 || key2>500 ) {
725       printf("ERROR in THijing::GetPJTY(key1,key2):\n");
726       printf("      key2=%i is out of range [1..500]\n",key2);
727       return 0;
728    }
729    
730    return HIJJET1.pjty[key2-1][key1-1];
731 }
732
733 //______________________________________________________________________________
734 Float_t THijing::GetPJTZ(Int_t key1, Int_t key2) const
735 {
736 // Get values of array PJTZ in common HIJJET1
737    if ( key1<1 || key1>300 ) {
738       printf("ERROR in THijing::GetPJTZ(key1):\n");
739       printf("      key1=%i is out of range [1..300]\n",key1);
740       return 0;
741    }
742    if ( key2<1 || key2>500 ) {
743       printf("ERROR in THijing::GetPJTZ(key1,key2):\n");
744       printf("      key2=%i is out of range [1..500]\n",key2);
745       return 0;
746    }
747    
748    return HIJJET1.pjtz[key2-1][key1-1];
749 }
750
751 //______________________________________________________________________________
752 Float_t THijing::GetPJTE(Int_t key1, Int_t key2) const
753 {
754 // Get values of array PJTE in common HIJJET1
755    if ( key1<1 || key1>300 ) {
756       printf("ERROR in THijing::GetPJTE(key1):\n");
757       printf("      key1=%i is out of range [1..300]\n",key1);
758       return 0;
759    }
760    if ( key2<1 || key2>500 ) {
761       printf("ERROR in THijing::GetPJTE(key1,key2):\n");
762       printf("      key2=%i is out of range [1..500]\n",key2);
763       return 0;
764    }
765    
766    return HIJJET1.pjte[key2-1][key1-1];
767 }
768
769 //______________________________________________________________________________
770 Float_t THijing::GetPJTM(Int_t key1, Int_t key2) const
771 {
772 // Get values of array PJTM in common HIJJET1
773    if ( key1<1 || key1>300 ) {
774       printf("ERROR in THijing::GetPJTM(key1):\n");
775       printf("      key1=%i is out of range [1..300]\n",key1);
776       return 0;
777    }
778    if ( key2<1 || key2>500 ) {
779       printf("ERROR in THijing::GetPJTM(key1,key2):\n");
780       printf("      key2=%i is out of range [1..500]\n",key2);
781       return 0;
782    }
783    
784    return HIJJET1.pjtm[key2-1][key1-1];
785 }
786
787 //====================== access to common HIJJET1 ===============================
788
789 //______________________________________________________________________________
790 Int_t THijing::GetNSG() const
791 {
792 // Get value of NSG in common HIJJET2
793    return HIJJET2.nsg;
794 }
795
796 //______________________________________________________________________________
797 Int_t THijing::GetNJSG(Int_t key) const
798 {
799 // Get values of array NJSG in common HIJJET2
800    if ( key<1 || key>900 ) {
801       printf ("ERROR in THijing:GetNJSG(key): \n ");
802       printf ("      key=%i is out of range [1..900]!\n",key);
803       return 0;
804    }
805
806    return HIJJET2.njsg[key-1];
807
808 }
809
810 //______________________________________________________________________________
811 Int_t THijing::GetIASG(Int_t key1, Int_t key2) const
812 {
813 // Get values of IASG in common HIJJET2
814    if ( key1<1 || key1>900 ) {
815       printf("ERROR in THijing::GetIASG(key1):\n");
816       printf("      key1=%i is out of range [1..900]\n",key1);
817       return 0;
818    }
819    if ( key2<1 || key2>3 ) {
820       printf("ERROR in THijing::GetIASG(key1,key2):\n");
821       printf("      key2=%i is out of range [1..3]\n",key2);
822       return 0;
823    }
824    
825    return HIJJET2.iasg[key2-1][key1-1];
826 }
827
828 //______________________________________________________________________________
829 Int_t THijing::GetK1SG(Int_t key1, Int_t key2) const
830 {
831 // Get values of K1SG in common HIJJET2
832    if ( key1<1 || key1>900 ) {
833       printf("ERROR in THijing::GetK1SG(key1):\n");
834       printf("      key1=%i is out of range [1..900]\n",key1);
835       return 0;
836    }
837    if ( key2<1 || key2>100 ) {
838       printf("ERROR in THijing::GetK1SG(key1,key2):\n");
839       printf("      key2=%i is out of range [1..100]\n",key2);
840       return 0;
841    }
842    
843    return HIJJET2.k1sg[key2-1][key1-1];
844 }
845
846 //______________________________________________________________________________
847 Int_t THijing::GetK2SG(Int_t key1, Int_t key2) const
848 {
849 // Get values of K2SG in common HIJJET2
850    if ( key1<1 || key1>900 ) {
851       printf("ERROR in THijing::GetK2SG(key1):\n");
852       printf("      key1=%i is out of range [1..900]\n",key1);
853       return 0;
854    }
855    if ( key2<1 || key2>100 ) {
856       printf("ERROR in THijing::GetK2SG(key1,key2):\n");
857       printf("      key2=%i is out of range [1..100]\n",key2);
858       return 0;
859    }
860    
861    return HIJJET2.k2sg[key2-1][key1-1];
862 }
863
864 //______________________________________________________________________________
865 Float_t THijing::GetPXSG(Int_t key1, Int_t key2) const
866 {
867 // Get values of PXSG in common HIJJET2
868    if ( key1<1 || key1>900 ) {
869       printf("ERROR in THijing::GetPXSG(key1):\n");
870       printf("      key1=%i is out of range [1..900]\n",key1);
871       return 0;
872    }
873    if ( key2<1 || key2>100 ) {
874       printf("ERROR in THijing::GetPXSG(key1,key2):\n");
875       printf("      key2=%i is out of range [1..100]\n",key2);
876       return 0;
877    }
878    
879    return HIJJET2.pxsg[key2-1][key1-1];
880 }
881
882 //______________________________________________________________________________
883 Float_t THijing::GetPYSG(Int_t key1, Int_t key2) const
884 {
885 // Get values of PYSG in common HIJJET2
886    if ( key1<1 || key1>900 ) {
887       printf("ERROR in THijing::GetPYSG(key1):\n");
888       printf("      key1=%i is out of range [1..900]\n",key1);
889       return 0;
890    }
891    if ( key2<1 || key2>100 ) {
892       printf("ERROR in THijing::GetPYSG(key1,key2):\n");
893       printf("      key2=%i is out of range [1..100]\n",key2);
894       return 0;
895    }
896    
897    return HIJJET2.pysg[key2-1][key1-1];
898 }
899
900 //______________________________________________________________________________
901 Float_t THijing::GetPZSG(Int_t key1, Int_t key2) const
902 {
903 // Get values of PZSG in common HIJJET2
904    if ( key1<1 || key1>900 ) {
905       printf("ERROR in THijing::GetPZSG(key1):\n");
906       printf("      key1=%i is out of range [1..900]\n",key1);
907       return 0;
908    }
909    if ( key2<1 || key2>100 ) {
910       printf("ERROR in THijing::GetPZSG(key1,key2):\n");
911       printf("      key2=%i is out of range [1..100]\n",key2);
912       return 0;
913    }
914    
915    return HIJJET2.pzsg[key2-1][key1-1];
916 }
917
918 //______________________________________________________________________________
919 Float_t THijing::GetPESG(Int_t key1, Int_t key2) const
920 {
921 // Get values of PESG in common HIJJET2
922    if ( key1<1 || key1>900 ) {
923       printf("ERROR in THijing::GetPESG(key1):\n");
924       printf("      key1=%i is out of range [1..900]\n",key1);
925       return 0;
926    }
927    if ( key2<1 || key2>100 ) {
928       printf("ERROR in THijing::GetPESG(key1,key2):\n");
929       printf("      key2=%i is out of range [1..100]\n",key2);
930       return 0;
931    }
932    
933    return HIJJET2.pesg[key2-1][key1-1];
934 }
935
936 //______________________________________________________________________________
937 Float_t THijing::GetPMSG(Int_t key1, Int_t key2) const
938 {
939 // Get values of PMSG in common HIJJET2
940    if ( key1<1 || key1>900 ) {
941       printf("ERROR in THijing::GetPMSG(key1):\n");
942       printf("      key1=%i is out of range [1..900]\n",key1);
943       return 0;
944    }
945    if ( key2<1 || key2>100 ) {
946       printf("ERROR in THijing::GetPMSG(key1,key2):\n");
947       printf("      key2=%i is out of range [1..100]\n",key2);
948       return 0;
949    }
950    
951    return HIJJET2.pmsg[key2-1][key1-1];
952 }
953
954 //====================== access to common HISTRNG ===============================
955
956 //______________________________________________________________________________
957 Int_t THijing::GetNFP(Int_t key1, Int_t key2) const
958 {
959 // Get values of array NFP in common HISTRNG
960    if ( key1<1 || key1>300 ) {
961       printf("ERROR in THijing::GetNFP(key1):\n");
962       printf("      key1=%i is out of range [1..300]\n",key1);
963       return 0;
964    }
965    if ( key2<1 || key2>15 ) {
966       printf("ERROR in THijing::GetNFP(key1,key2):\n");
967       printf("      key2=%i is out of range [1..15]\n",key2);
968       return 0;
969    }
970    
971    return HISTRNG.nfp[key2-1][key1-1];
972 }
973
974 //______________________________________________________________________________
975 Float_t THijing::GetPP(Int_t key1, Int_t key2) const
976 {
977 // Get values of array PP in common HISTRNG
978    if ( key1<1 || key1>300 ) {
979       printf("ERROR in THijing::GetPP(key1):\n");
980       printf("      key1=%i is out of range [1..300]\n",key1);
981       return 0;
982    }
983    if ( key2<1 || key2>15 ) {
984       printf("ERROR in THijing::GetPP(key1,key2):\n");
985       printf("      key2=%i is out of range [1..15]\n",key2);
986       return 0;
987    }
988    
989    return HISTRNG.pp[key2-1][key1-1];
990 }
991
992 //______________________________________________________________________________
993 Int_t THijing::GetNFT(Int_t key1, Int_t key2) const
994 {
995 // Get values of array NFT in common HISTRNG
996    if ( key1<1 || key1>300 ) {
997       printf("ERROR in THijing::GetNFT(key1):\n");
998       printf("      key1=%i is out of range [1..300]\n",key1);
999       return 0;
1000    }
1001    if ( key2<1 || key2>15 ) {
1002       printf("ERROR in THijing::GetNFT(key1,key2):\n");
1003       printf("      key2=%i is out of range [1..15]\n",key2);
1004       return 0;
1005    }
1006    
1007    return HISTRNG.nft[key2-1][key1-1];
1008 }
1009
1010 //______________________________________________________________________________
1011 Float_t THijing::GetPT(Int_t key1, Int_t key2) const
1012 {
1013 // Get values of array PT in common HISTRNG
1014    if ( key1<1 || key1>300 ) {
1015       printf("ERROR in THijing::GetPT(key1):\n");
1016       printf("      key1=%i is out of range [1..300]\n",key1);
1017       return 0;
1018    }
1019    if ( key2<1 || key2>15 ) {
1020       printf("ERROR in THijing::GetPT(key1,key2):\n");
1021       printf("      key2=%i is out of range [1..15]\n",key2);
1022       return 0;
1023    }
1024    
1025    return HISTRNG.pt[key2-1][key1-1];
1026 }
1027
1028 void THijing::SetPARJ(Int_t key, Float_t parm) 
1029 {
1030 // Set values of array PARJ in common HISTRNG
1031     if ( key < 1 || key > 200) {
1032         printf("ERROR in THijing::SetPARJ(key,parm):\n");
1033         printf("      key=%i is out of range [1..200]\n",key);
1034     }
1035     
1036     LUDAT1_HIJING.parj[key-1] = parm;
1037 }
1038
1039
1040 void THijing::SetMSTJ(Int_t key, Int_t parm) 
1041 {
1042 // Set values of array MSTJ in common HISTRNG
1043     if ( key < 1 || key > 200) {
1044         printf("ERROR in THijing::SetMSTJ(key,parm):\n");
1045         printf("      key=%i is out of range [1..200]\n",key);
1046     }
1047     
1048     LUDAT1_HIJING.mstj[key-1] = parm;
1049 }
1050
1051
1052 //====================== access to Hijing subroutines =========================
1053
1054
1055 //______________________________________________________________________________
1056 void THijing::Initialize()
1057 {
1058 //////////////////////////////////////////////////////////////////////////////////
1059 // Calls Hijset with the either default parameters or the ones set by the user  //
1060 // via SetEFRM, SetFRAME, SetPROJ, SetTARG, SetIAP, SetIZP, SetIAT, SetIZT      //
1061 //////////////////////////////////////////////////////////////////////////////////
1062
1063    if ( (!strcmp(fFrame.Data(), "CMS     "  )) &&
1064         (!strcmp(fFrame.Data(), "LAB     "  ))){
1065       printf("WARNING! In THijing:Initialize():\n");
1066       printf(" specified frame=%s is neither CMS or LAB\n",fFrame.Data());
1067       printf(" resetting to default \"CMS\" .");
1068       fFrame="CMS";
1069    }
1070
1071    if ( (!strcmp(fProj.Data(), "A       "     )) &&
1072         (!strcmp(fProj.Data(), "P       "     )) &&
1073         (!strcmp(fProj.Data(), "PBAR    "  ))){
1074       printf("WARNING! In THijing:Initialize():\n");
1075       printf(" specified projectile=%s is neither A, P or PBAR\n",fProj.Data());
1076       printf(" resetting to default \"A\" .");
1077       fProj="A";
1078    }
1079
1080    if ( (!strcmp(fTarg.Data(), "A       "     )) &&
1081         (!strcmp(fTarg.Data(), "P       "     )) &&
1082         (!strcmp(fTarg.Data(), "PBAR    "  ))){
1083       printf("WARNING! In THijing:Initialize():\n");
1084       printf(" specified target=%s is neither A, P or PBAR\n",fTarg.Data());
1085       printf(" resetting to default \"A\" .");
1086       fTarg="A";
1087    }
1088
1089    printf(" %s-%s at %f GeV \n",fProj.Data(),fTarg.Data(),fEfrm);
1090
1091    Hijset(fEfrm,fFrame.Data(),fProj.Data(),fTarg.Data(),fIap,fIzp,fIat,fIzt);
1092
1093    printf(" %s-%s at %f GeV \n",fProj.Data(),fTarg.Data(),fEfrm);
1094 }
1095
1096
1097 //______________________________________________________________________________
1098 void THijing::GenerateEvent()
1099 {
1100 // Generates one event;
1101
1102    Hijing(fFrame.Data(),fBmin,fBmax);
1103
1104 }
1105 //______________________________________________________________________________
1106 void THijing::Hijset(float efrm, const char *frame, const char *proj,  
1107                      const char *targ, int iap, int izp, int iat, int izt)
1108 {
1109 // Call HIJING routine HIJSET passing the parameters in a way accepted by
1110 // Fortran routines                                
1111
1112   int s1 = strlen(frame);
1113   int s2 = strlen(proj);
1114   int s3 = strlen(targ);
1115   printf("s1 = %d s2 = %d s3 = %d\n",s1,s2,s3);
1116 #ifndef WIN32 
1117   hijset(efrm, frame, proj, targ, iap, izp, iat, izt, s1, s2, s3);
1118 #else
1119   hijset(efrm, frame, s1, proj, s2, targ, s3, iap, izp, iat, izt);
1120 #endif
1121 }
1122 //______________________________________________________________________________
1123 void THijing::Hijing(const char *frame, float bmin, float bmax)
1124 {
1125 // Call HIJING routine HIJSET passing the parameters in a way accepted by
1126 // Fortran routines                                
1127
1128   int s1 = strlen(frame);
1129   
1130 #ifndef WIN32 
1131   hijing(frame, bmin, bmax, s1);
1132 #else
1133   hijing(frame, s1, bmin, bmax);
1134 #endif
1135 }
1136
1137
1138 Float_t  THijing::Profile(float b)
1139 {
1140 // Call HIJING routine PROFILE 
1141   return profile(b);
1142 }
1143
1144
1145 void  THijing::Rluget(Int_t lfn, Int_t move)
1146 {
1147 // write seed to file
1148   rluget_hijing(lfn, move);
1149 }
1150
1151
1152 void  THijing::Rluset(Int_t lfn, Int_t move)
1153 {
1154 // read seed from file 
1155   rluset_hijing(lfn, move);
1156 }
1157