71 TPythia6* TPythia6::fgInstance = 0;
75 # define pydiff pydiff_
76 # define pyevnt pyevnt_
77 # define pyinit pyinit_
78 # define pychge pychge_
79 # define pycomp pycomp_
80 # define pyedit pyedit_
81 # define pyexec pyexec_
82 # define pyhepc pyhepc_
83 # define pygive pygive_
84 # define pylist pylist_
85 # define pymass pymass_
86 # define pyname pyname_
88 # define pyrget pyrget_
89 # define pyrset pyrset_
90 # define pystat pystat_
91 # define pytest pytest_
92 # define pytune pytune_
93 # define pyupda pyupda_
94 # define py1ent py1ent_
95 # ifdef PYTHIA6_DOUBLE_UNDERSCORE
96 # define tpythia6_open_fortran_file tpythia6_open_fortran_file__
97 # define tpythia6_close_fortran_file tpythia6_close_fortran_file__
98 # define pythia6_common_address pythia6_common_address__
99 # elif PYTHIA6_SINGLE_UNDERSCORE
100 # define tpythia6_open_fortran_file tpythia6_open_fortran_file_
101 # define tpythia6_close_fortran_file tpythia6_close_fortran_file_
102 # define pythia6_common_address pythia6_common_address
104 # define pythia6_common_address pythia6_common_address
105 # define tpythia6_open_fortran_file tpythia6_open_fortran_file_
106 # define tpythia6_close_fortran_file tpythia6_close_fortran_file_
108 # define type_of_call
110 # define pydiff PYDIFF
111 # define pyevnt PYEVNT
112 # define pyinit PYINIT
113 # define pychge PYCHGE
114 # define pycomp PYCOMP
115 # define pyedit PYEDIT
116 # define pyexec PYEXEC
117 # define pygive PYGIVE
118 # define pyhepc PYHEPC
119 # define pylist PYLIST
120 # define pymass PYMASS
121 # define pyname PYNAME
123 # define pyrget PYRGET
124 # define pyrset PYRSET
125 # define pystat PYSTAT
126 # define pytest PYTEST
127 # define pytune PYTUNE
128 # define pyupda PYUPDA
129 # define py1ent PY1ENT
130 # define tpythia6_open_fortran_file TPYTHIA6_OPEN_FORTRAN_FILE
131 # define tpythia6_close_fortran_file TPYTHIA6_CLOSE_FORTRAN_FILE
132 # define type_of_call _stdcall
136 extern "C" void type_of_call pyevnt();
137 extern "C" void type_of_call pystat(
int *key);
138 extern "C" void type_of_call pylist(
int *key);
139 extern "C" void type_of_call pyedit(
int *medit);
140 extern "C" void type_of_call pydiff();
141 extern "C" void type_of_call pyexec();
142 extern "C" void type_of_call pygive(
const char *param, Long_t lparam);
143 extern "C" void type_of_call pyhepc(
int *mconv);
144 extern "C" void type_of_call pylist(
int *flag);
145 extern "C" int type_of_call pychge(
int *kf);
146 extern "C" int type_of_call pycomp(
int *kf);
147 extern "C" double type_of_call pymass(
int *kf);
148 extern "C" void type_of_call pyname(
int *kf,
char *name, Long_t l_name);
149 extern "C" int type_of_call pyr(
int *dummy);
150 extern "C" int type_of_call pyrget(
int *lun,
int *move);
151 extern "C" int type_of_call pyrset(
int *lun,
int *move);
152 extern "C" int type_of_call pytest(
int *flag);
153 extern "C" int type_of_call pytune(
int *itune);
154 extern "C" int type_of_call pyupda(
int *mupda,
int *lun);
155 extern "C" void type_of_call py1ent(Int_t&, Int_t&, Double_t&, Double_t&, Double_t&);
158 extern "C" void type_of_call pyinit(
char *frame,
char *beam,
char *target,
159 double *win, Long_t l_frame, Long_t l_beam,
162 extern "C" void type_of_call pyinit(
char *frame, Long_t l_frame,
163 char *beam, Long_t l_beam,
164 char *target, Long_t l_target,
170 void* pythia6_common_address(
const char*);
171 void type_of_call tpythia6_open_fortran_file(
int* lun,
char* name,
int);
172 void type_of_call tpythia6_close_fortran_file(
int* lun);
183 TPythia6::TPythia6Cleaner::TPythia6Cleaner() {
189 TPythia6::TPythia6Cleaner::~TPythia6Cleaner() {
190 if (TPythia6::fgInstance) {
191 delete TPythia6::fgInstance;
192 TPythia6::fgInstance = 0;
204 TPythia6::TPythia6() : TGenerator(
"TPythia6",
"TPythia6") {
208 Fatal(
"TPythia6",
"There's already an instance of TPythia6");
212 fParticles =
new TClonesArray(
"TMCParticle",50);
218 fPyjets = (Pyjets_t*) pythia6_common_address(
"PYJETS");
219 fPydat1 = (Pydat1_t*) pythia6_common_address(
"PYDAT1");
220 fPydat2 = (Pydat2_t*) pythia6_common_address(
"PYDAT2");
221 fPydat3 = (Pydat3_t*) pythia6_common_address(
"PYDAT3");
222 fPydat4 = (Pydat4_t*) pythia6_common_address(
"PYDAT4");
223 fPydatr = (Pydatr_t*) pythia6_common_address(
"PYDATR");
224 fPysubs = (Pysubs_t*) pythia6_common_address(
"PYSUBS");
225 fPypars = (Pypars_t*) pythia6_common_address(
"PYPARS");
226 fPyint1 = (Pyint1_t*) pythia6_common_address(
"PYINT1");
227 fPyint2 = (Pyint2_t*) pythia6_common_address(
"PYINT2");
228 fPyint3 = (Pyint3_t*) pythia6_common_address(
"PYINT3");
229 fPyint4 = (Pyint4_t*) pythia6_common_address(
"PYINT4");
230 fPyint5 = (Pyint5_t*) pythia6_common_address(
"PYINT5");
231 fPyint6 = (Pyint6_t*) pythia6_common_address(
"PYINT6");
232 fPyint7 = (Pyint7_t*) pythia6_common_address(
"PYINT7");
233 fPyint8 = (Pyint8_t*) pythia6_common_address(
"PYINT8");
234 fPyint9 = (Pyint9_t*) pythia6_common_address(
"PYINT9");
235 fPymssm = (Pymssm_t*) pythia6_common_address(
"PYMSSM");
236 fPyssmt = (Pyssmt_t*) pythia6_common_address(
"PYSSMT");
237 fPyints = (Pyints_t*) pythia6_common_address(
"PYINTS");
238 fPybins = (Pybins_t*) pythia6_common_address(
"PYBINS");
243 TPythia6::TPythia6(
const TPythia6& p6) :
271 TPythia6::~TPythia6()
274 fParticles->Delete();
285 TPythia6* TPythia6::Instance() {
286 static TPythia6::TPythia6Cleaner cleaner;
287 return fgInstance ? fgInstance : (fgInstance=
new TPythia6()) ;
297 void TPythia6::GenerateEvent() {
305 void TPythia6::OpenFortranFile(
int lun,
char* name) {
306 tpythia6_open_fortran_file(&lun, name, strlen(name));
312 void TPythia6::CloseFortranFile(
int lun) {
313 tpythia6_close_fortran_file(&lun);
325 TObjArray *TPythia6::ImportParticles(Option_t *)
328 Int_t numpart = fPyjets->N;
329 TClonesArray &a = *((TClonesArray*)fParticles);
330 for (Int_t i = 0; i<numpart; i++) {
331 new(a[i]) TMCParticle(fPyjets->K[0][i] ,
362 Int_t TPythia6::ImportParticles(TClonesArray *particles, Option_t *option)
364 if (particles == 0)
return 0;
365 TClonesArray &clonesParticles = *particles;
366 clonesParticles.Clear();
367 Int_t numpart = fPyjets->N;
369 if (!strcmp(option,
"") || !strcmp(option,
"Final")) {
370 for (Int_t i = 0; i<numpart; i++) {
372 if (fPyjets->K[0][i] == 1) {
376 new(clonesParticles[nparts]) TParticle(
396 }
else if (!strcmp(option,
"All")) {
397 for (Int_t i = 0; i<numpart; i++) {
398 new(clonesParticles[i]) TParticle(
436 void TPythia6::Initialize(
const char *frame,
const char *beam,
const char *target,
float win)
439 strlcpy(cframe,frame,4);
441 strlcpy(cbeam,beam,10);
443 strlcpy(ctarget,target,10);
448 if ( (!strncmp(frame,
"CMS" ,3)) &&
449 (!strncmp(frame,
"FIXT" ,4)) &&
450 (!strncmp(frame,
"USER" ,4)) &&
451 (!strncmp(frame,
"FOUR" ,4)) &&
452 (!strncmp(frame,
"FIVE" ,4)) &&
453 (!strncmp(frame,
"3MOM" ,4)) &&
454 (!strncmp(frame,
"4MOM" ,4)) &&
455 (!strncmp(frame,
"5MOM" ,4)) &&
456 (!strncmp(frame,
"NONE" ,4)) ) {
457 printf(
"WARNING! In TPythia6:Initialize():\n");
458 printf(
" specified frame=%s is neither of CMS,FIXT,USER,FOUR,FIVE,NONE,3MOM,4MOM,5MOM\n",frame);
459 printf(
" resetting to \"CMS\" .");
460 snprintf(cframe,4,
"CMS");
463 if ( (!strncmp(beam,
"e" ,1)) &&
464 (!strncmp(beam,
"nu_e" ,4)) &&
465 (!strncmp(beam,
"mu" ,2)) &&
466 (!strncmp(beam,
"nu_mu" ,5)) &&
467 (!strncmp(beam,
"tau" ,3)) &&
468 (!strncmp(beam,
"nu_tau" ,6)) &&
469 (!strncmp(beam,
"gamma" ,5)) &&
470 (!strncmp(beam,
"pi" ,2)) &&
471 (!strncmp(beam,
"n" ,1)) &&
472 (!strncmp(beam,
"p" ,1)) &&
473 (!strncmp(beam,
"Lambda" ,6)) &&
474 (!strncmp(beam,
"Sigma" ,5)) &&
475 (!strncmp(beam,
"Xi" ,2)) &&
476 (!strncmp(beam,
"Omega" ,5)) &&
477 (!strncmp(beam,
"pomeron" ,7)) &&
478 (!strncmp(beam,
"reggeon" ,7)) ) {
479 printf(
"WARNING! In TPythia6:Initialize():\n");
480 printf(
" specified beam=%s is unrecognized .\n",beam);
481 printf(
" resetting to \"p+\" .");
482 snprintf(cbeam,8,
"p+");
485 if ( (!strncmp(target,
"e" ,1)) &&
486 (!strncmp(target,
"nu_e" ,4)) &&
487 (!strncmp(target,
"mu" ,2)) &&
488 (!strncmp(target,
"nu_mu" ,5)) &&
489 (!strncmp(target,
"tau" ,3)) &&
490 (!strncmp(target,
"nu_tau" ,6)) &&
491 (!strncmp(target,
"gamma" ,5)) &&
492 (!strncmp(target,
"pi" ,2)) &&
493 (!strncmp(target,
"n" ,1)) &&
494 (!strncmp(target,
"p" ,1)) &&
495 (!strncmp(target,
"Lambda" ,6)) &&
496 (!strncmp(target,
"Sigma" ,5)) &&
497 (!strncmp(target,
"Xi" ,2)) &&
498 (!strncmp(target,
"Omega" ,5)) &&
499 (!strncmp(target,
"pomeron" ,7)) &&
500 (!strncmp(target,
"reggeon" ,7)) ){
501 printf(
"WARNING! In TPythia6:Initialize():\n");
502 printf(
" specified target=%s is unrecognized.\n",target);
503 printf(
" resetting to \"p+\" .");
504 snprintf(ctarget,8,
"p+");
507 Pyinit(cframe, cbeam ,ctarget, win);
510 snprintf(atitle,
sizeof(atitle),
" %s-%s at %g GeV", cbeam, ctarget, win);
515 void TPythia6::Pyinit(
char* frame,
char* beam,
char* target,
double win)
534 Long_t s1 = strlen(frame);
535 Long_t s2 = strlen(beam);
536 Long_t s3 = strlen(target);
538 pyinit(frame,beam,target,&lwin,s1,s2,s3);
540 pyinit(frame, s1, beam , s2, target, s3, &lwin);
545 int TPythia6::Pycomp(
int kf) {
550 void TPythia6::Pyedit(
int medit) {
556 void TPythia6::Pydiff() {
561 void TPythia6::Pyevnt() {
566 void TPythia6::Pyexec() {
571 void TPythia6::Pygive(
const char *param) {
573 Long_t lparam = strlen(param);
574 pygive(param,lparam);
577 void TPythia6::Pyhepc(
int mconv) {
582 void TPythia6::Pylist(
int flag) {
587 void TPythia6::Pyname(
int kf,
char* name) {
599 double TPythia6::Pyr(
int idummy) {
604 void TPythia6::Pyrget(
int lun,
int move) {
609 void TPythia6::Pyrset(
int lun,
int move) {
614 void TPythia6::Pystat(
int flag) {
619 void TPythia6::Pytest(
int flag) {
624 void TPythia6::Pytune(
int itune) {
629 void TPythia6::Pyupda(
int mupda,
int lun) {
634 double TPythia6::Pymass(
int kf) {
639 int TPythia6::Pychge(
int kf) {
662 void TPythia6::Py1ent(Int_t ip, Int_t kf, Double_t pe, Double_t theta, Double_t phi)
664 py1ent(ip, kf, pe, theta, phi);
673 void TPythia6::SetupTest()