2 /*************************************************************************
3 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
4 * All rights reserved. *
6 * For the licensing terms see $ROOTSYS/LICENSE. *
7 * For the list of contributors see $ROOTSYS/README/CREDITS. *
8 *************************************************************************/
11 //* +-------------------------------------------------------------+
17 //* | S. Roesler+), R. Engel#), J. Ranft*) |
19 //* | +) CERN, TIS-RP |
20 //* | CH-1211 Geneva 23, Switzerland |
21 //* | Email: Stefan.Roesler@cern.ch |
23 //* | #) University of Delaware, BRI |
24 //* | Newark, DE 19716, USA |
26 //* | *) University of Siegen, Dept. of Physics |
27 //* | D-57068 Siegen, Germany |
30 //* | http://home.cern.ch/sroesler/dpmjet3.html |
33 //* | Monte Carlo models used for event generation: |
34 //* | PHOJET 1.12, JETSET 7.4 and LEPTO 6.5.1 |
36 //* +-------------------------------------------------------------+
41 #include "DPMcommon.h"
42 //*KEEP,TParticle,T=C++
43 #include "TParticle.h"
44 #include "TClonesArray.h"
52 # define dt_dtuini dt_dtuini_
53 # define dt_getemu de_getemu_
54 # define dt_kkinc dt_kkinc_
55 # define pho_phist pho_phist_
56 # define dt_dtuout dt_dtuout_
57 # define dt_rndm dt_rndm_
58 # define dt_rndmst dt_rndmst_
59 # define dt_rndmin dt_rndmin_
60 # define dt_rndmou dt_rndmou_
61 # define dpmjet_openinp dpmjet_openinp_
62 # define dt_evtout dt_evtout_
65 # define dt_dtuini DT_DTUINI
66 # define dt_getemu DT_GETEMU
67 # define dt_kkinc DT_KKINC
68 # define pho_phist PHO_PHIST
69 # define dt_dtuout DT_DTUOUT
70 # define dt_rndm DT_RNDM
71 # define dt_rndmst DT_RNDMST
72 # define dt_rndmin DT_RNDMIN
73 # define dt_rndmou DT_RNDMOU
74 # define dt_evtout DT_EVTOUT_
75 # define dpmjet_openinp DPMJET_OPENINP
76 # define type_of_call _stdcall
81 extern "C" void type_of_call dt_dtuini(Int_t & , Double_t &, Int_t & , Int_t &,
82 Int_t &, Int_t &, Int_t &, Int_t &);
83 extern "C" double type_of_call dt_getemu(Int_t &, Int_t &, Int_t &, Int_t &);
84 extern "C" void type_of_call dt_kkinc(Int_t &, Int_t &, Int_t &, Int_t &,
85 Int_t &, Double_t &, Int_t &, Int_t &);
86 extern "C" void type_of_call pho_phist(Int_t &, Double_t &);
87 extern "C" void type_of_call dt_dtuout();
88 extern "C" int type_of_call dt_evtout(const Int_t &);
89 extern "C" void type_of_call dt_rndm(Int_t &);
90 extern "C" void type_of_call dt_rndmst(Int_t &, Int_t &, Int_t &, Int_t &);
91 extern "C" void type_of_call dt_rndmin(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &);
92 extern "C" void type_of_call dt_rndmou(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &);
93 extern "C" void type_of_call dpmjet_openinp();
102 //______________________________________________________________________________
104 TGenerator("dpmjet","dpmjet"),
120 fFragmentation(kFALSE)
122 // Default Constructor
125 //______________________________________________________________________________
126 TDPMjet::TDPMjet(DpmProcess_t iproc, Int_t Ip=208, Int_t Ipz=82, Int_t It=208, Int_t Itz=82,
127 Double_t Epn=2700., Double_t CMEn=5400.)
128 : TGenerator("dpmjet","dpmjet"),
144 fFragmentation(kFALSE)
146 printf("TDPMJet Constructor %d %d %d %d \n", Ip, Ipz, It, Itz);
150 //______________________________________________________________________________
151 Int_t TDPMjet::ImportParticles(TClonesArray *particles, Option_t *option)
154 // Default primary creation method. It reads the /HEPEVT/ common block which
155 // has been filled by the GenerateEvent method. If the event generator does
156 // not use the HEPEVT common block, This routine has to be overloaded by
158 // The function loops on the generated particles and store them in
159 // the TClonesArray pointed by the argument particles.
160 // The default action is to store only the stable particles
161 // This can be demanded explicitly by setting the option = "Final"
162 // If the option = "All", all the particles are stored.
164 if(particles==0) return 0;
165 TClonesArray &Particles = *particles;
167 Int_t numpart = 0; // Total number of produced particles
168 Int_t numStabpart = 0; // Total number of produced stable particles
169 Double_t entot = 0; // Total energy in final state (from stable particles)
171 numpart = DTEVT1.nhkk;
172 for(Int_t i=0; i<numpart; i++){
173 if(DTEVT1.isthkk[i]==1 || DTEVT1.isthkk[i]==-1 || DTEVT1.isthkk[i]==1001){
175 entot += DTEVT1.phkk[i][3]; // PHKK[i][3] <-> PHKK(4,i)
180 if(!strcmp(option,"") || !strcmp(option,"Final")){
181 for (Int_t i=0; i < numpart; i++) {
183 if (DTEVT1.isthkk[i] == 1) {
185 // Use the common block values for the TParticle constructor
187 new(Particles[nump]) TParticle(
207 else if(!strcmp(option,"All")){
209 for (Int_t i=0; i <= numpart; i++){
211 // DTEVT1.JMOHKK[i][0] pointer to the entry of the 1st mother of entry i
212 Int_t iParent = DTEVT1.jmohkk[i][0] - 1;
215 TParticle *mother = (TParticle*) (Particles.UncheckedAt(iParent));
216 mother->SetLastDaughter(i);
217 if(mother->GetFirstDaughter() == -1) mother->SetFirstDaughter(i);
219 // --- PDGcode for residual nuclei (idhkk=80000)
220 // --- 10000*Z + 10*A
221 // --- DPMJET -> idres = mass #, idxres = charge
222 if(DTEVT1.idhkk[i] == 80000)
223 DTEVT1.idhkk[i] = 10000*DTEVT2.idxres[i]+10*DTEVT2.idres[i];
225 if(DTEVT2.idxres[i] != 0)
226 printf("\n pc#%d -> A = %d, Z = %d -> PDGcode = %d\n",
227 i,DTEVT2.idres[i],DTEVT2.idxres[i],DTEVT1.idhkk[i]);
230 printf("%5d %5d %5d %5d %13.3f %13.3f %13.3f %13.3f \n", i,
240 new(Particles[i]) TParticle(
264 //====================== access to dpmjet subroutines =========================
265 //______________________________________________________________________________
266 void TDPMjet::Initialize()
269 // Write standard DPMJET input cards
271 if(fFragmentation) printf("\tTDPMJet fragmentation/evaporation applied\n");
273 FILE* out = fopen("dpmjet.inp","w");
274 // Projectile and Target definition
275 if (fIp == 1 && fIpz ==1) {
276 fprintf(out, "PROJPAR PROTON\n");
277 } else if (fIp == 1 && fIpz == -1) {
278 fprintf(out, "PROJPAR APROTON\n");
280 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.);
283 if (fIt == 1 && fItz ==1) {
284 fprintf(out, "TARPAR PROTON\n");
285 } else if (fIt == 1 && fItz == -1) {
286 fprintf(out, "TARPAR APROTON\n");
288 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.);
291 // Beam energy and crossing-angle
292 fprintf(out, "CMENERGY %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",fCMEn, 0., 0., 0., 0., 0.);
293 if(fIt == 1 && fIp ==1){
294 fprintf(out, "BEAM %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",fEpn, fEpn, 0., 0., 0., 0.); //p-p
296 else if(fIp > 1 || fIt > 1){
297 if(fIp>1 && fIt>1) fprintf(out, "BEAM %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",fEpn, fEpn, 0., 0., 0., 0.);//A-A
298 else if(fIp==1 && fIt>1){ // proton towards A side (directed z>0)
299 fprintf(out, "BEAM %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n", fEpn,fEpn*fItz/fIt, 0., 0., 0., 0.);//pA
300 printf("\n TDPMjet::Initialize() -> p-A: projectile (p) energy = %10.1f, CMS energy = %10.1f\n\n",fEpn,fCMEn);
302 else if(fIt==1 && fIp>1){ // proton towards C side (directed z<0)
303 fprintf(out, "BEAM %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n", fEpn, fEpn*fIp/fIpz, 0., 0., 0., 0.);//A-p
304 printf("\n TDPMjet::Initialize() -> A-p: projectile (A) energy = %10.1f, CMS energy = %10.1f\n\n",fEpn,fCMEn);
308 if((fIp > 1 || fIt > 1) && fFragmentation)
309 fprintf(out, "CENTRAL %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",-2., fBmin, fBmax, 0., 0., 0.);
310 else if((fIp > 1 || fIt > 1) && !fFragmentation)
311 fprintf(out, "CENTRAL %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",-1., fBmin, fBmax, 0., 0., 0.);
314 fprintf(out, "PARDECAY %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n", 2., 0., 0., 0., 0., 0.);
319 fprintf(out, "PHOINPUT\n");
320 fprintf(out, "DEBUG 0 0 0 \n");
322 if (fProcess == kDpmMb) {
323 fprintf(out, "PROCESS 1 0 1 1 1 1 1 1\n");
324 } else if (fProcess == kDpmMbNonDiffr) {
325 fprintf(out, "PROCESS 1 0 1 0 0 0 0 1\n");
326 } else if (fProcess == kDpmDiffr) {
327 fprintf(out, "PROCESS 0 0 0 1 1 1 1 0\n");
328 }else if (fProcess == kDpmSingleDiffr) {
329 fprintf(out, "PROCESS 0 0 0 0 1 1 0 0\n");
330 }else if (fProcess == kDpmDoubleDiffr) {
331 fprintf(out, "PROCESS 0 0 0 0 0 0 1 0\n");
332 } else if (fProcess == kDpmCentralDiffr){
333 fprintf(out, "PROCESS 0 0 0 1 0 0 0 0\n");
338 // K0s pi0 lam sig+ sig- tet0
339 310, 111, 3122, 3222, 3112, 3322,
340 // tet- om- D+ D0 Ds+
341 3312, 3334, 411, 421, 431,
342 // etac lamc+ sigc++ sigc+ sigc0 Ksic+
343 441, 4122, 4222, 4212, 4112, 4232,
349 Int_t iON = (fDecayAll) ? 1:0;
350 for (Int_t i = 0; i < 8; i++) {
351 fprintf(out, "LUND-DECAY%5d %5d\n", iPDG[i], iON);
354 fprintf(out, "LUND-MSTJ %5d %5d\n", 22, 1);
356 fprintf(out, "ENDINPUT\n");
359 fprintf(out, "START 1.0 0.0\n");
360 fprintf(out, "STOP\n");
365 // Call DPMJET initialisation
366 Int_t iemu = 0; // No emulsion (default)
367 Dt_Dtuini(1, fEpn, fIp, fIpz, fIt, fItz, fIdp, iemu);
372 //______________________________________________________________________________
373 void TDPMjet::GenerateEvent()
375 // Generates one event;
377 DTEVNO.nevent=fNEvent;
381 Dt_Kkinc(fIp, fIpz, fIt, fItz, fIdp, Elab, kkmat, irej);
383 //______________________________________________________________________________
384 void TDPMjet::Dt_Dtuini(int nevts, double epn, int npmass, int npchar,
385 int ntmass, int ntchar, int idp, int iemu)
387 // Call dmpjet routine DT_DTUINI passing the parameters
388 // in a way accepted by Fortran routines
391 printf("\n-------------------------------------------\n");
392 printf("\n Dt_Dtuini called with:\n\n");
393 printf(" Projectile -> A = %d, Z = %d \n",npmass, npchar);
394 printf(" Target -> A = %d, Z = %d \n",ntmass, ntchar);
395 printf(" Proj. LAB E -> E = %f GeV \n",epn);
396 printf(" nevts = %d, idp = %d, iemu = %d \n",nevts,idp,iemu);
397 printf("\n-------------------------------------------\n");
399 dt_dtuini(nevts, epn, npmass, npchar, ntmass, ntchar, idp, iemu);
403 //______________________________________________________________________________
404 void TDPMjet::Dt_Kkinc(int npmass, int npchar, int ntmass, int ntchar,
405 int idp, double elab, int kkmat, int irej)
407 // Call dmpjet routine DT_KKINC passing the parameters
408 // in a way accepted by Fortran routines
409 dt_kkinc(npmass, npchar, ntmass, ntchar, idp, elab, kkmat, irej);
412 //______________________________________________________________________________
413 void TDPMjet::Pho_Phist(int imode, double weight)
415 // Call dmpjet routine PHO_PHIST passing the parameters
416 // in a way accepted by Fortran routines
418 pho_phist(imode,weight);
422 //______________________________________________________________________________
423 void TDPMjet::Dt_Dtuout()
425 // Call dmpjet routine DT_DTUOT passing the parameters
426 // in a way accepted by Fortran routines
432 //______________________________________________________________________________
433 Int_t TDPMjet::GetEvNum() const
435 return DTEVT1.nevhkk;
437 //______________________________________________________________________________
438 Int_t TDPMjet::GetEntriesNum() const
442 //______________________________________________________________________________
443 Int_t TDPMjet::GetNumStablePc() const
445 Int_t NumStablePc = 0;
446 for(Int_t i=0; i<DTEVT1.nhkk; i++){
447 if(DTEVT1.isthkk[i] == 1) NumStablePc++;
452 //______________________________________________________________________________
453 Float_t TDPMjet::GetTotEnergy() const
455 Float_t TotEnergy = 0.;
456 for(Int_t i=0; i<DTEVT1.nhkk; i++){
457 if(DTEVT1.isthkk[i] == 1)
458 TotEnergy += DTEVT1.phkk[i][3]; // PHKK[i][3] <-> PHKK(4,i)
463 //______________________________________________________________________________
464 Int_t TDPMjet::GetStatusCode(Int_t evnum) const
466 return DTEVT1.isthkk[evnum];
468 //______________________________________________________________________________
469 Int_t TDPMjet::GetPDGCode(Int_t evnum) const
471 return DTEVT1.idhkk[evnum];
473 //______________________________________________________________________________
474 Double_t TDPMjet::Getpx(Int_t evnum) const
476 return DTEVT1.phkk[evnum][0];
478 //______________________________________________________________________________
479 Double_t TDPMjet::Getpy(Int_t evnum) const
481 return DTEVT1.phkk[evnum][1];
483 //______________________________________________________________________________
484 Double_t TDPMjet::Getpz(Int_t evnum) const
486 return DTEVT1.phkk[evnum][2];
488 //______________________________________________________________________________
489 Double_t TDPMjet::GetEnergy(Int_t evnum) const
491 return DTEVT1.phkk[evnum][3];
493 //______________________________________________________________________________
494 Double_t TDPMjet::GetMass(Int_t evnum) const
496 return DTEVT1.phkk[evnum][4];
498 //______________________________________________________________________________
499 Int_t TDPMjet::GetFragmentA(Int_t evnum) const
501 return DTEVT2.idres[evnum];
503 //______________________________________________________________________________
504 Int_t TDPMjet::GetFragmentZ(Int_t evnum) const
506 return DTEVT2.idxres[evnum];
508 //______________________________________________________________________________
509 Double_t TDPMjet::GetXSFrac() const
511 return DTIMPA.xsfrac;
513 //______________________________________________________________________________
514 Double_t TDPMjet::GetBImpac() const
516 return DTGLCP.bimpac;
518 //______________________________________________________________________________
519 Double_t TDPMjet::GetProjRadius() const
523 //______________________________________________________________________________
524 Double_t TDPMjet::GetTargRadius() const
528 //______________________________________________________________________________
529 Int_t TDPMjet::GetProjWounded() const
531 return DTGLCP.nwasam;
533 //______________________________________________________________________________
534 Int_t TDPMjet::GetTargWounded() const
536 return DTGLCP.nwbsam;
539 //______________________________________________________________________________
540 Int_t TDPMjet::GetProjParticipants() const
542 return DTGLCP.nwtaac;
544 //______________________________________________________________________________
545 Int_t TDPMjet::GetTargParticipants() const
547 return DTGLCP.nwtbac;
549 //______________________________________________________________________________
550 Int_t TDPMjet::GetProcessCode() const
552 return POPRCS.iproce;
554 //______________________________________________________________________________
555 void TDPMjet::Dt_Rndm(int idummy)
560 //______________________________________________________________________________
561 void TDPMjet::Dt_Rndmst(int na1, int na2, int na3, int nb1)
563 dt_rndmst(na1, na2, na3, nb1);
566 //______________________________________________________________________________
567 void TDPMjet::Dt_Rndmin(int u, int c, int cd, int cm, int i, int j)
569 dt_rndmin(u, c, cd, cm, i, j);
572 //______________________________________________________________________________
573 void TDPMjet::Dt_Rndmou(int u, int c, int cd, int cm, int i, int j)
575 dt_rndmou(u, c, cd, cm, i, j);
579 Int_t TDPMjet::NHEP() const {return POEVT1.nhep;}
580 Int_t TDPMjet::ISTHEP(Int_t i) const {return POEVT1.isthep[i];}
581 Int_t TDPMjet::IDHEP(Int_t i) const {return POEVT1.idhep[i];}
582 Double_t TDPMjet::PHEP(Int_t i, Int_t j) const {return POEVT1.phep[i][j];}