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