]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TDPMjet/TDPMjet.cxx
Minor changes (Yu.Belikov)
[u/mrichter/AliRoot.git] / TDPMjet / TDPMjet.cxx
1 //*KEEP,CopyRight,T=C.
2 /*************************************************************************
3  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
4  * All rights reserved.                                                  *
5  *                                                                       *
6  * For the licensing terms see $ROOTSYS/LICENSE.                         *
7  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
8  *************************************************************************/
9 //*KEND.
10
11 //*    +-------------------------------------------------------------+
12 //*    |                                                             |
13 //*    |                                                             |
14 //*    |                        DPMJET 3.0                           |
15 //*    |                                                             |
16 //*    |                                                             |
17 //*    |         S. Roesler+), R. Engel#), J. Ranft*)                |
18 //*    |                                                             |
19 //*    |         +) CERN, TIS-RP                                     |
20 //*    |            CH-1211 Geneva 23, Switzerland                   |
21 //*    |            Email: Stefan.Roesler@cern.ch                    |
22 //*    |                                                             |
23 //*    |         #) University of Delaware, BRI                      |
24 //*    |            Newark, DE 19716, USA                            |
25 //*    |                                                             |
26 //*    |         *) University of Siegen, Dept. of Physics           |
27 //*    |            D-57068 Siegen, Germany                          |
28 //*    |                                                             |
29 //*    |                                                             |
30 //*    |       http://home.cern.ch/sroesler/dpmjet3.html             |
31 //*    |                                                             |
32 //*    |                                                             |
33 //*    |       Monte Carlo models used for event generation:         |
34 //*    |          PHOJET 1.12, JETSET 7.4 and LEPTO 6.5.1            |
35 //*    |                                                             |
36 //*    +-------------------------------------------------------------+
37
38 //*KEEP,TDPMjet.
39 #include "TDPMjet.h"
40 //*KEEP,DPMCOMMON.
41 #include "DPMcommon.h"
42 //*KEEP,TParticle,T=C++.
43 #include "TParticle.h"
44 //*KEND.
45
46 //*KEEP,TROOT.
47 #include "TROOT.h"
48 //*KEND.
49
50 #ifndef WIN32
51 # define dt_dtuini dt_dtuini_
52 # define dt_getemu de_getemu_
53 # define dt_kkinc  dt_kkinc_
54 # define pho_phist pho_phist_
55 # define dt_dtuout dt_dtuout_
56 # define dt_rndm   dt_rndm_
57 # define dt_rndmst dt_rndmst_
58 # define dt_rndmin dt_rndmin_
59 # define dt_rndmou dt_rndmou_
60 # define type_of_call
61 #else
62 # define dt_dtuini DT_DTUINI
63 # define dt_getemu DT_GETEMU
64 # define dt_kkinc  DT_KKINC
65 # define pho_phist PHO_PHIST
66 # define dt_dtuout DT_DTUOUT
67 # define dt_rndm   DT_RNDM
68 # define dt_rndmst DT_RNDMST
69 # define dt_rndmin DT_RNDMIN
70 # define dt_rndmou DT_RNDMOU
71 # define type_of_call _stdcall
72 #endif
73
74 #ifndef WIN32
75 extern "C" void   type_of_call dt_dtuini(Int_t & , Double_t &, Int_t & , Int_t &, 
76                         Int_t &, Int_t &, Int_t &, Int_t &);
77 extern "C" double type_of_call dt_getemu(Int_t &, Int_t &, Int_t &, Int_t &);
78 extern "C" void   type_of_call dt_kkinc(Int_t &, Int_t &, Int_t &, Int_t &,
79                                     Int_t &, Double_t &, Int_t &, Int_t &);
80 extern "C" void   type_of_call pho_phist(Int_t &, Double_t &);
81 extern "C" void   type_of_call dt_dtuout();
82 extern "C" void   type_of_call dt_rndm(Int_t &);
83 extern "C" void   type_of_call dt_rndmst(Int_t &, Int_t &, Int_t &, Int_t &);
84 extern "C" void   type_of_call dt_rndmin(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &);
85 extern "C" void   type_of_call dt_rndmou(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &);
86
87 #else
88
89 #endif
90
91 ClassImp(TDPMjet)
92
93 //______________________________________________________________________________
94 TDPMjet::TDPMjet() : TGenerator("dpmjet","dpmjet")
95 {
96     fNEvent  = 0;
97     fIp      = 0;
98     fIpz     = 0;
99     fIt      = 0;
100     fItz     = 0;
101     fEpn     = 0;
102     fCMEn    = 0;
103     fIdp     = 0;
104     fProcess = kDpmMb;
105 }
106
107 //______________________________________________________________________________
108 TDPMjet::TDPMjet(DpmProcess_t  iproc, Int_t Ip=208, Int_t Ipz=82, Int_t It=208, Int_t Itz=82, 
109         Double_t Epn=2700., Double_t CMEn=5400.) 
110         : TGenerator("dpmjet","dpmjet")
111 {  
112     printf("TDPMJet Constructor %d %d %d %d \n", Ip, Ipz, It, Itz);
113     
114    fNEvent  = 0;
115    fIp      = Ip;
116    fIpz     = Ipz;
117    fIt      = It;
118    fItz     = Itz;
119    fEpn     = Epn;
120    fCMEn    = CMEn;
121    fIdp     = 0;
122    fProcess = iproc;
123 }
124
125
126 //______________________________________________________________________________
127 Int_t TDPMjet::ImportParticles(TClonesArray *particles, Option_t *option)
128 {
129 //
130 //  Default primary creation method. It reads the /HEPEVT/ common block which
131 //  has been filled by the GenerateEvent method. If the event generator does
132 //  not use the HEPEVT common block, This routine has to be overloaded by
133 //  the subclasses.
134 //  The function loops on the generated particles and store them in
135 //  the TClonesArray pointed by the argument particles.
136 //  The default action is to store only the stable particles 
137 //  This can be demanded explicitly by setting the option = "Final"
138 //  If the option = "All", all the particles are stored.
139 //
140   if(particles==0) return 0;
141   TClonesArray &Particles = *particles;
142   Particles.Clear();
143   Int_t numpart = 0;     // Total number of produced particles
144   Int_t numStabpart = 0; // Total number of produced stable particles
145   Double_t entot = 0;    // Total energy in final state (from stable particles)
146   
147   numpart = DTEVT1.nhkk;
148   for(Int_t i=0; i<numpart; i++){
149      if(DTEVT1.isthkk[i]==1 || DTEVT1.isthkk[i]==-1 || DTEVT1.isthkk[i]==1001){
150         numStabpart++;
151         entot += DTEVT1.phkk[i][3]; // PHKK[i][3] <-> PHKK(4,i)
152      } 
153   }
154   //printf("\n TDPMjet: DPMJET stack contains %d particles", numpart);
155   // printf("\n TDPMjet: Final not decayed particles: %d",    numStabpart);
156   //printf("\n TDPMjet: Total energy: %f GeV          \n",   entot);
157   Int_t nump = 0;
158   
159   if(!strcmp(option,"") || !strcmp(option,"Final")){
160       for (Int_t i=0; i < numpart; i++) {
161           
162           if (DTEVT1.isthkk[i] == 1) {
163            //
164            //  Use the common block values for the TParticle constructor
165            //
166               new(Particles[nump]) TParticle(
167                   DTEVT1.idhkk[i],
168                   DTEVT1.isthkk[i],
169                   -1,
170                   -1,
171                   -1,
172                   -1,
173                   DTEVT1.phkk[i][0],
174                   DTEVT1.phkk[i][1],
175                   DTEVT1.phkk[i][2],
176                   DTEVT1.phkk[i][3],
177                   
178                   DTEVT1.vhkk[i][0],
179                   DTEVT1.vhkk[i][1],
180                   DTEVT1.vhkk[i][2],
181                   DTEVT1.vhkk[i][3]);
182               nump++;
183           }
184       }
185   }
186   else if(!strcmp(option,"All")){
187       nump = numpart; 
188       for (Int_t i=0; i <= numpart; i++){
189         
190           // DTEVT1.JMOHKK[i][0] pointer to the entry of the 1st mother of entry i
191           Int_t iParent = DTEVT1.jmohkk[i][0] - 1;
192              
193           if(iParent >= 0){
194               TParticle *mother = (TParticle*) (Particles.UncheckedAt(iParent));
195               mother->SetLastDaughter(i);
196               if(mother->GetFirstDaughter() == -1) mother->SetFirstDaughter(i);
197           } 
198           // --- PDGcode for residual nuclei (idhkk=80000) 
199           // ---        10000*Z + 10*A
200           // --- DPMJET -> idres = mass #, idxres = charge
201           if(DTEVT1.idhkk[i] == 80000) 
202               DTEVT1.idhkk[i] = 10000*DTEVT2.idxres[i]+10*DTEVT2.idres[i];
203 /*
204           if(DTEVT2.idxres[i] != 0) 
205               printf("\n        pc#%d -> A = %d, Z = %d -> PDGcode = %d\n",
206                      i,DTEVT2.idres[i],DTEVT2.idxres[i],DTEVT1.idhkk[i]);
207 */        
208           new(Particles[i]) TParticle(
209               DTEVT1.idhkk[i],
210               DTEVT1.isthkk[i],
211               iParent,
212               -1,
213               -1,
214               -1,
215               
216               DTEVT1.phkk[i][0],
217               DTEVT1.phkk[i][1],
218               DTEVT1.phkk[i][2],
219               DTEVT1.phkk[i][3],
220               
221               DTEVT1.vhkk[i][0],
222               DTEVT1.vhkk[i][1],
223               DTEVT1.vhkk[i][2],
224               DTEVT1.vhkk[i][3]);
225       } // Particle loop  
226   }
227   return nump;
228 }
229
230
231 //====================== access to dpmjet subroutines =========================
232 //______________________________________________________________________________
233 void TDPMjet::Initialize()
234 {
235 //
236 //  Write standard DPMJET input cards 
237 //
238     FILE* out = fopen("dpmjet.inp","w");
239 //  Projectile and Target definition 
240     fprintf(out, "PROJPAR   %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n", (Float_t) fIp, (Float_t) fIpz,  0., 0., 0., 0.);
241     fprintf(out, "TARPAR    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n", (Float_t) fIt, (Float_t) fItz,  0., 0., 0., 0.);
242 //  Beam energy and crossing-angle
243     fprintf(out, "BEAM      %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",fEpn, fEpn, 0., 0., 0., 0.);
244 //  Centrality
245     fprintf(out, "CENTRAL   %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",-1., fBmin, fBmax, 0., 0., 0.);
246
247 //
248 //  PHOJET specific
249     fprintf(out, "PHOINPUT\n");
250     fprintf(out, "DEBUG      0 0 0 \n");
251     
252     if (fProcess == kDpmMb) {
253         fprintf(out, "PROCESS           1 0 1 1 1 1 1 1\n");
254     } else if (fProcess == kDpmMbNonDiffr) {
255         fprintf(out, "PROCESS           1 0 1 1 0 0 0 1\n");
256     }
257     
258     fprintf(out, "ENDINPUT\n");
259 //
260 //  START card
261     fprintf(out, "START            1.0       0.0\n");
262     fprintf(out, "STOP\n");
263     fclose(out);
264 //
265 //  Call DPMJET initialisation
266     Int_t iemu = 0; // No emulsion (default)
267     Dt_Dtuini(1, fEpn, fIp, fIpz, fIt, fItz, fIdp, iemu);
268
269 }
270
271
272 //______________________________________________________________________________
273 void TDPMjet::GenerateEvent()
274 {
275    // Generates one event;
276    fNEvent++;
277    DTEVNO.nevent=fNEvent;
278    Int_t kkmat=-1;
279    Float_t Elab = fEpn;
280    Int_t irej=0;
281    Dt_Kkinc(fIp, fIpz, fIt, fItz, fIdp, Elab, kkmat, irej);
282    if(irej!=0) return;
283 }
284 //______________________________________________________________________________
285 void TDPMjet::Dt_Dtuini(int nevts, double epn, int npmass, int npchar, 
286                         int ntmass, int ntchar, int idp, int iemu)
287 {
288   // Call dmpjet routine DT_DTUINI passing the parameters 
289   // in a way accepted by Fortran routines                                 
290      
291
292    printf("\n-------------------------------------------\n");
293    printf("\n           Dt_Dtuini called with:\n\n");
294    printf(" Projectile  -> A = %d, Z = %d \n",npmass, npchar);
295    printf(" Target      -> A = %d, Z = %d \n",ntmass, ntchar);
296    printf(" Proj. LAB E -> E = %f GeV \n",epn);
297    printf(" nevts = %d, idp = %d, iemu = %d \n",nevts,idp,iemu);
298    printf("\n-------------------------------------------\n");
299
300    dt_dtuini(nevts, epn, npmass, npchar, ntmass, ntchar, idp, iemu);
301     
302 }
303
304 //______________________________________________________________________________
305 void TDPMjet::Dt_Kkinc(int npmass, int npchar, int ntmass, int ntchar, 
306                        int idp, double elab, int kkmat, int irej)
307 {
308   // Call dmpjet routine DT_KKINC passing the parameters 
309   // in a way accepted by Fortran routines                                 
310   dt_kkinc(npmass, npchar, ntmass, ntchar, idp, elab, kkmat, irej);
311 }
312
313 //______________________________________________________________________________
314 void TDPMjet::Pho_Phist(int imode, double weight)
315 {
316   // Call dmpjet routine PHO_PHIST passing the parameters 
317   // in a way accepted by Fortran routines
318   
319   pho_phist(imode,weight);                                 
320
321 }
322
323 //______________________________________________________________________________
324 void TDPMjet::Dt_Dtuout()
325 {
326   // Call dmpjet routine DT_DTUOT passing the parameters 
327   // in a way accepted by Fortran routines                                 
328   
329   dt_dtuout();
330
331 }
332
333 //______________________________________________________________________________
334 Int_t TDPMjet::GetEvNum() const
335 {
336         return DTEVT1.nevhkk;
337 }
338 //______________________________________________________________________________
339 Int_t TDPMjet::GetEntriesNum() const
340 {
341         return DTEVT1.nhkk;
342 }
343 //______________________________________________________________________________
344 Int_t TDPMjet::GetNumStablePc() const
345 {
346         Int_t NumStablePc = 0;
347         for(Int_t i=0; i<DTEVT1.nhkk; i++){
348            if(DTEVT1.isthkk[i] == 1) NumStablePc++;
349         }
350         return NumStablePc;
351 }
352
353 //______________________________________________________________________________
354 Float_t TDPMjet::GetTotEnergy() const
355 {
356         Float_t TotEnergy = 0.;
357         for(Int_t i=0; i<DTEVT1.nhkk; i++){
358           if(DTEVT1.isthkk[i] == 1)
359             TotEnergy += DTEVT1.phkk[i][3]; // PHKK[i][3] <-> PHKK(4,i)
360         }
361         return TotEnergy;
362 }
363
364 //______________________________________________________________________________
365 Int_t TDPMjet::GetStatusCode(Int_t evnum) const 
366 {
367         return DTEVT1.isthkk[evnum];    
368 }
369 //______________________________________________________________________________
370 Int_t TDPMjet::GetPDGCode(Int_t evnum) const   
371 {
372         return DTEVT1.idhkk[evnum];
373 }
374 //______________________________________________________________________________
375 Double_t TDPMjet::Getpx(Int_t evnum) const       
376 {
377         return DTEVT1.phkk[evnum][0];
378 }
379 //______________________________________________________________________________
380 Double_t TDPMjet::Getpy(Int_t evnum) const      
381 {
382         return DTEVT1.phkk[evnum][1];
383 }
384 //______________________________________________________________________________
385 Double_t TDPMjet::Getpz(Int_t evnum) const       
386 {
387         return DTEVT1.phkk[evnum][2];
388 }
389 //______________________________________________________________________________
390 Double_t TDPMjet::GetEnergy(Int_t evnum) const        
391 {
392         return DTEVT1.phkk[evnum][3];
393 }
394 //______________________________________________________________________________
395 Double_t TDPMjet::GetMass(Int_t evnum) const          
396 {
397         return DTEVT1.phkk[evnum][4];
398 }
399 //______________________________________________________________________________
400 Int_t    TDPMjet::GetFragmentA(Int_t evnum) const       
401 {
402         return DTEVT2.idres[evnum];
403 }
404 //______________________________________________________________________________
405 Int_t    TDPMjet::GetFragmentZ(Int_t evnum) const       
406 {
407         return DTEVT2.idxres[evnum];
408 }
409 //______________________________________________________________________________
410 Double_t TDPMjet::GetXSFrac() const           
411 {
412         return DTIMPA.xsfrac;
413 }
414 //______________________________________________________________________________
415 Double_t TDPMjet::GetBImpac() const           
416 {
417         return DTGLCP.bimpac;
418 }
419 //______________________________________________________________________________
420 Double_t TDPMjet::GetProjRadius() const               
421 {
422         return DTGLCP.rproj;
423 }
424 //______________________________________________________________________________
425 Double_t TDPMjet::GetTargRadius() const               
426 {
427         return DTGLCP.rtarg;
428 }
429 //______________________________________________________________________________
430 Int_t TDPMjet::GetProjWounded() const
431 {
432         return DTGLCP.nwasam;
433 }
434 //______________________________________________________________________________
435 Int_t TDPMjet::GetTargWounded() const
436 {
437         return DTGLCP.nwbsam;
438 }
439 //______________________________________________________________________________
440 Int_t TDPMjet::GetProjSpectators() const
441 {
442         return DTGLCP.nwtaac;
443 }
444 //______________________________________________________________________________
445 Int_t TDPMjet::GetTargSpectators() const
446 {
447         return DTGLCP.nwtbac;
448 }
449
450 //______________________________________________________________________________
451 void TDPMjet::Dt_Rndm(int idummy)
452 {
453         dt_rndm(idummy);
454 }
455
456 //______________________________________________________________________________
457 void TDPMjet::Dt_Rndmst(int na1, int na2, int na3, int nb1)
458 {
459         dt_rndmst(na1, na2, na3, nb1);
460 }
461
462 //______________________________________________________________________________
463 void TDPMjet::Dt_Rndmin(int u, int c, int cd, int cm, int i, int j)
464 {
465         dt_rndmin(u, c, cd, cm, i, j);
466 }
467
468 //______________________________________________________________________________
469 void TDPMjet::Dt_Rndmou(int u, int c, int cd, int cm, int i, int j)
470 {
471         dt_rndmou(u, c, cd, cm, i, j);
472 }
473