00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #include "TPythia6.h"
00063
00064 #include "TClonesArray.h"
00065 #include "TMCParticle.h"
00066 #include "TParticle.h"
00067
00068 TPythia6* TPythia6::fgInstance = 0;
00069
00070
00071 #ifndef WIN32
00072 # define pydiff pydiff_
00073 # define pyevnt pyevnt_
00074 # define pyinit pyinit_
00075 # define pychge pychge_
00076 # define pycomp pycomp_
00077 # define pyedit pyedit_
00078 # define pyexec pyexec_
00079 # define pyhepc pyhepc_
00080 # define pygive pygive_
00081 # define pylist pylist_
00082 # define pymass pymass_
00083 # define pyname pyname_
00084 # define pyr pyr_
00085 # define pyrget pyrget_
00086 # define pyrset pyrset_
00087 # define pystat pystat_
00088 # define pytest pytest_
00089 # define pytune pytune_
00090 # define pyupda pyupda_
00091 # define py1ent py1ent_
00092 # ifdef PYTHIA6_DOUBLE_UNDERSCORE
00093 # define tpythia6_open_fortran_file tpythia6_open_fortran_file__
00094 # define tpythia6_close_fortran_file tpythia6_close_fortran_file__
00095 # define pythia6_common_address pythia6_common_address__
00096 # elif PYTHIA6_SINGLE_UNDERSCORE
00097 # define tpythia6_open_fortran_file tpythia6_open_fortran_file_
00098 # define tpythia6_close_fortran_file tpythia6_close_fortran_file_
00099 # define pythia6_common_address pythia6_common_address
00100 # else
00101 # define pythia6_common_address pythia6_common_address
00102 # define tpythia6_open_fortran_file tpythia6_open_fortran_file_
00103 # define tpythia6_close_fortran_file tpythia6_close_fortran_file_
00104 # endif
00105 # define type_of_call
00106 #else
00107 # define pydiff PYDIFF
00108 # define pyevnt PYEVNT
00109 # define pyinit PYINIT
00110 # define pychge PYCHGE
00111 # define pycomp PYCOMP
00112 # define pyedit PYEDIT
00113 # define pyexec PYEXEC
00114 # define pygive PYGIVE
00115 # define pyhepc PYHEPC
00116 # define pylist PYLIST
00117 # define pymass PYMASS
00118 # define pyname PYNAME
00119 # define pyr PYR
00120 # define pyrget PYRGET
00121 # define pyrset PYRSET
00122 # define pystat PYSTAT
00123 # define pytest PYTEST
00124 # define pytune PYTUNE
00125 # define pyupda PYUPDA
00126 # define py1ent PY1ENT
00127 # define tpythia6_open_fortran_file TPYTHIA6_OPEN_FORTRAN_FILE
00128 # define tpythia6_close_fortran_file TPYTHIA6_CLOSE_FORTRAN_FILE
00129 # define type_of_call _stdcall
00130 #endif
00131
00132
00133 extern "C" void type_of_call pyevnt();
00134 extern "C" void type_of_call pystat(int *key);
00135 extern "C" void type_of_call pylist(int *key);
00136 extern "C" void type_of_call pyedit(int *medit);
00137 extern "C" void type_of_call pydiff();
00138 extern "C" void type_of_call pyexec();
00139 extern "C" void type_of_call pygive(const char *param, Long_t lparam);
00140 extern "C" void type_of_call pyhepc(int *mconv);
00141 extern "C" void type_of_call pylist(int *flag);
00142 extern "C" int type_of_call pychge(int *kf);
00143 extern "C" int type_of_call pycomp(int *kf);
00144 extern "C" double type_of_call pymass(int *kf);
00145 extern "C" void type_of_call pyname(int *kf, char *name, Long_t l_name);
00146 extern "C" int type_of_call pyr(int *dummy);
00147 extern "C" int type_of_call pyrget(int *lun, int *move);
00148 extern "C" int type_of_call pyrset(int *lun, int *move);
00149 extern "C" int type_of_call pytest(int *flag);
00150 extern "C" int type_of_call pytune(int *itune);
00151 extern "C" int type_of_call pyupda(int *mupda, int *lun);
00152 extern "C" void type_of_call py1ent(Int_t&, Int_t&, Double_t&, Double_t&, Double_t&);
00153
00154 #ifndef WIN32
00155 extern "C" void type_of_call pyinit(char *frame, char *beam, char *target,
00156 double *win, Long_t l_frame, Long_t l_beam,
00157 Long_t l_target);
00158 #else
00159 extern "C" void type_of_call pyinit(char *frame, Long_t l_frame,
00160 char *beam, Long_t l_beam,
00161 char *target, Long_t l_target,
00162 double *win
00163 );
00164 #endif
00165
00166 extern "C" {
00167 void* pythia6_common_address(const char*);
00168 void type_of_call tpythia6_open_fortran_file(int* lun, char* name, int);
00169 void type_of_call tpythia6_close_fortran_file(int* lun);
00170 }
00171
00172 ClassImp(TPythia6)
00173
00174
00175 TPythia6::TPythia6Cleaner::TPythia6Cleaner() {
00176
00177 }
00178
00179
00180 TPythia6::TPythia6Cleaner::~TPythia6Cleaner() {
00181
00182 if (TPythia6::fgInstance) {
00183 delete TPythia6::fgInstance;
00184 TPythia6::fgInstance = 0;
00185 }
00186 }
00187
00188
00189
00190
00191
00192 TPythia6::TPythia6() : TGenerator("TPythia6","TPythia6") {
00193
00194
00195
00196
00197
00198
00199 if (fgInstance)
00200 Fatal("TPythia6", "There's already an instance of TPythia6");
00201
00202 delete fParticles;
00203
00204 fParticles = new TClonesArray("TMCParticle",50);
00205
00206
00207
00208
00209
00210 fPyjets = (Pyjets_t*) pythia6_common_address("PYJETS");
00211 fPydat1 = (Pydat1_t*) pythia6_common_address("PYDAT1");
00212 fPydat2 = (Pydat2_t*) pythia6_common_address("PYDAT2");
00213 fPydat3 = (Pydat3_t*) pythia6_common_address("PYDAT3");
00214 fPydat4 = (Pydat4_t*) pythia6_common_address("PYDAT4");
00215 fPydatr = (Pydatr_t*) pythia6_common_address("PYDATR");
00216 fPysubs = (Pysubs_t*) pythia6_common_address("PYSUBS");
00217 fPypars = (Pypars_t*) pythia6_common_address("PYPARS");
00218 fPyint1 = (Pyint1_t*) pythia6_common_address("PYINT1");
00219 fPyint2 = (Pyint2_t*) pythia6_common_address("PYINT2");
00220 fPyint3 = (Pyint3_t*) pythia6_common_address("PYINT3");
00221 fPyint4 = (Pyint4_t*) pythia6_common_address("PYINT4");
00222 fPyint5 = (Pyint5_t*) pythia6_common_address("PYINT5");
00223 fPyint6 = (Pyint6_t*) pythia6_common_address("PYINT6");
00224 fPyint7 = (Pyint7_t*) pythia6_common_address("PYINT7");
00225 fPyint8 = (Pyint8_t*) pythia6_common_address("PYINT8");
00226 fPyint9 = (Pyint9_t*) pythia6_common_address("PYINT9");
00227 fPymssm = (Pymssm_t*) pythia6_common_address("PYMSSM");
00228 fPyssmt = (Pyssmt_t*) pythia6_common_address("PYSSMT");
00229 fPyints = (Pyints_t*) pythia6_common_address("PYINTS");
00230 fPybins = (Pybins_t*) pythia6_common_address("PYBINS");
00231 }
00232
00233
00234 TPythia6::TPythia6(const TPythia6& p6) :
00235 TGenerator(p6),
00236 fPyjets(p6.fPyjets),
00237 fPydat1(p6.fPydat1),
00238 fPydat2(p6.fPydat2),
00239 fPydat3(p6.fPydat3),
00240 fPydat4(p6.fPydat4),
00241 fPydatr(p6.fPydatr),
00242 fPysubs(p6.fPysubs),
00243 fPypars(p6.fPypars),
00244 fPyint1(p6.fPyint1),
00245 fPyint2(p6.fPyint2),
00246 fPyint3(p6.fPyint3),
00247 fPyint4(p6.fPyint4),
00248 fPyint5(p6.fPyint5),
00249 fPyint6(p6.fPyint6),
00250 fPyint7(p6.fPyint7),
00251 fPyint8(p6.fPyint8),
00252 fPyint9(p6.fPyint9),
00253 fPymssm(p6.fPymssm),
00254 fPyssmt(p6.fPyssmt),
00255 fPyints(p6.fPyints),
00256 fPybins(p6.fPybins)
00257 { }
00258
00259
00260 TPythia6::~TPythia6()
00261 {
00262
00263
00264 if (fParticles) {
00265 fParticles->Delete();
00266 delete fParticles;
00267 fParticles = 0;
00268 }
00269 }
00270
00271
00272 TPythia6* TPythia6::Instance() {
00273
00274
00275
00276
00277 static TPythia6::TPythia6Cleaner cleaner;
00278 return fgInstance ? fgInstance : (fgInstance=new TPythia6()) ;
00279 }
00280
00281
00282
00283
00284
00285
00286 void TPythia6::GenerateEvent() {
00287
00288
00289 pyevnt();
00290 ImportParticles();
00291 }
00292
00293
00294 void TPythia6::OpenFortranFile(int lun, char* name) {
00295
00296 tpythia6_open_fortran_file(&lun, name, strlen(name));
00297 }
00298
00299
00300 void TPythia6::CloseFortranFile(int lun) {
00301
00302 tpythia6_close_fortran_file(&lun);
00303 }
00304
00305
00306
00307 TObjArray *TPythia6::ImportParticles(Option_t *)
00308 {
00309
00310
00311
00312
00313
00314
00315
00316 fParticles->Clear();
00317 Int_t numpart = fPyjets->N;
00318 TClonesArray &a = *((TClonesArray*)fParticles);
00319 for (Int_t i = 0; i<numpart; i++) {
00320 new(a[i]) TMCParticle(fPyjets->K[0][i] ,
00321 fPyjets->K[1][i] ,
00322 fPyjets->K[2][i] ,
00323 fPyjets->K[3][i] ,
00324 fPyjets->K[4][i] ,
00325 fPyjets->P[0][i] ,
00326 fPyjets->P[1][i] ,
00327 fPyjets->P[2][i] ,
00328 fPyjets->P[3][i] ,
00329 fPyjets->P[4][i] ,
00330 fPyjets->V[0][i] ,
00331 fPyjets->V[1][i] ,
00332 fPyjets->V[2][i] ,
00333 fPyjets->V[3][i] ,
00334 fPyjets->V[4][i]);
00335 }
00336 return fParticles;
00337 }
00338
00339
00340 Int_t TPythia6::ImportParticles(TClonesArray *particles, Option_t *option)
00341 {
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 if (particles == 0) return 0;
00354 TClonesArray &clonesParticles = *particles;
00355 clonesParticles.Clear();
00356 Int_t numpart = fPyjets->N;
00357 Int_t nparts=0;
00358 if (!strcmp(option,"") || !strcmp(option,"Final")) {
00359 for (Int_t i = 0; i<numpart; i++) {
00360
00361 if (fPyjets->K[0][i] == 1) {
00362
00363
00364
00365 new(clonesParticles[nparts]) TParticle(
00366 fPyjets->K[1][i] ,
00367 fPyjets->K[0][i] ,
00368 fPyjets->K[2][i] ,
00369 -1,
00370 fPyjets->K[3][i] ,
00371 fPyjets->K[4][i] ,
00372 fPyjets->P[0][i] ,
00373 fPyjets->P[1][i] ,
00374 fPyjets->P[2][i] ,
00375 fPyjets->P[3][i] ,
00376 fPyjets->V[0][i] ,
00377 fPyjets->V[1][i] ,
00378 fPyjets->V[2][i] ,
00379 fPyjets->V[3][i]);
00380
00381
00382 nparts++;
00383 }
00384 }
00385 } else if (!strcmp(option,"All")) {
00386 for (Int_t i = 0; i<numpart; i++) {
00387 new(clonesParticles[i]) TParticle(
00388 fPyjets->K[1][i] ,
00389 fPyjets->K[0][i] ,
00390 fPyjets->K[2][i] ,
00391 -1,
00392 fPyjets->K[3][i] ,
00393 fPyjets->K[4][i] ,
00394 fPyjets->P[0][i] ,
00395 fPyjets->P[1][i] ,
00396 fPyjets->P[2][i] ,
00397 fPyjets->P[3][i] ,
00398 fPyjets->V[0][i] ,
00399 fPyjets->V[1][i] ,
00400 fPyjets->V[2][i] ,
00401 fPyjets->V[3][i]);
00402 }
00403 nparts=numpart;
00404 }
00405
00406 return nparts;
00407 }
00408
00409
00410 void TPythia6::Initialize(const char *frame, const char *beam, const char *target, float win)
00411 {
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 char cframe[4];
00428 strlcpy(cframe,frame,4);
00429 char cbeam[8];
00430 strlcpy(cbeam,beam,8);
00431 char ctarget[8];
00432 strlcpy(ctarget,target,8);
00433
00434 if ( (!strncmp(frame, "CMS" ,3)) &&
00435 (!strncmp(frame, "FIXT" ,4)) &&
00436 (!strncmp(frame, "USER" ,4)) &&
00437 (!strncmp(frame, "FOUR" ,4)) &&
00438 (!strncmp(frame, "FIVE" ,4)) &&
00439 (!strncmp(frame, "NONE" ,4)) ) {
00440 printf("WARNING! In TPythia6:Initialize():\n");
00441 printf(" specified frame=%s is neither of CMS,FIXT,USER,FOUR,FIVE,NONE\n",frame);
00442 printf(" resetting to \"CMS\" .");
00443 snprintf(cframe,4,"CMS");
00444 }
00445
00446 if ( (!strncmp(beam, "e" ,1)) &&
00447 (!strncmp(beam, "nu_e" ,4)) &&
00448 (!strncmp(beam, "mu" ,2)) &&
00449 (!strncmp(beam, "nu_mu" ,5)) &&
00450 (!strncmp(beam, "tau" ,3)) &&
00451 (!strncmp(beam, "nu_tau" ,6)) &&
00452 (!strncmp(beam, "gamma" ,5)) &&
00453 (!strncmp(beam, "pi" ,2)) &&
00454 (!strncmp(beam, "n" ,1)) &&
00455 (!strncmp(beam, "p" ,1)) &&
00456 (!strncmp(beam, "Lambda" ,6)) &&
00457 (!strncmp(beam, "Sigma" ,5)) &&
00458 (!strncmp(beam, "Xi" ,2)) &&
00459 (!strncmp(beam, "Omega" ,5)) &&
00460 (!strncmp(beam, "pomeron" ,7)) &&
00461 (!strncmp(beam, "reggeon" ,7)) ) {
00462 printf("WARNING! In TPythia6:Initialize():\n");
00463 printf(" specified beam=%s is unrecognized .\n",beam);
00464 printf(" resetting to \"p+\" .");
00465 snprintf(cbeam,8,"p+");
00466 }
00467
00468 if ( (!strncmp(target, "e" ,1)) &&
00469 (!strncmp(target, "nu_e" ,4)) &&
00470 (!strncmp(target, "mu" ,2)) &&
00471 (!strncmp(target, "nu_mu" ,5)) &&
00472 (!strncmp(target, "tau" ,3)) &&
00473 (!strncmp(target, "nu_tau" ,6)) &&
00474 (!strncmp(target, "gamma" ,5)) &&
00475 (!strncmp(target, "pi" ,2)) &&
00476 (!strncmp(target, "n" ,1)) &&
00477 (!strncmp(target, "p" ,1)) &&
00478 (!strncmp(target, "Lambda" ,6)) &&
00479 (!strncmp(target, "Sigma" ,5)) &&
00480 (!strncmp(target, "Xi" ,2)) &&
00481 (!strncmp(target, "Omega" ,5)) &&
00482 (!strncmp(target, "pomeron" ,7)) &&
00483 (!strncmp(target, "reggeon" ,7)) ){
00484 printf("WARNING! In TPythia6:Initialize():\n");
00485 printf(" specified target=%s is unrecognized.\n",target);
00486 printf(" resetting to \"p+\" .");
00487 snprintf(ctarget,8,"p+");
00488 }
00489
00490
00491
00492 Pyinit(cframe, cbeam ,ctarget, win);
00493
00494 char atitle[32];
00495 snprintf(atitle,32," %s-%s at %g GeV",cbeam,ctarget,win);
00496 SetTitle(atitle);
00497
00498 }
00499
00500
00501 void TPythia6::Pyinit(char* frame, char* beam, char* target, double win)
00502 {
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519 Double_t lwin = win;
00520 Long_t s1 = strlen(frame);
00521 Long_t s2 = strlen(beam);
00522 Long_t s3 = strlen(target);
00523 #ifndef WIN32
00524 pyinit(frame,beam,target,&lwin,s1,s2,s3);
00525 #else
00526 pyinit(frame, s1, beam , s2, target, s3, &lwin);
00527 #endif
00528 }
00529
00530
00531 int TPythia6::Pycomp(int kf) {
00532
00533 return pycomp(&kf);
00534 }
00535
00536 void TPythia6::Pyedit(int medit) {
00537
00538 pyedit(&medit);
00539 ImportParticles();
00540 }
00541
00542 void TPythia6::Pydiff() {
00543
00544 pydiff();
00545 }
00546
00547 void TPythia6::Pyevnt() {
00548
00549 pyevnt();
00550 }
00551
00552 void TPythia6::Pyexec() {
00553
00554 pyexec();
00555 }
00556
00557 void TPythia6::Pygive(const char *param) {
00558
00559 Long_t lparam = strlen(param);
00560 pygive(param,lparam);
00561 }
00562
00563 void TPythia6::Pyhepc(int mconv) {
00564
00565 pyhepc(&mconv);
00566 }
00567
00568 void TPythia6::Pylist(int flag) {
00569
00570 pylist(&flag);
00571 }
00572
00573 void TPythia6::Pyname(int kf, char* name) {
00574
00575
00576
00577 pyname(&kf,name,15);
00578
00579 name[15] = 0;
00580
00581
00582
00583 }
00584
00585 double TPythia6::Pyr(int idummy) {
00586
00587 return pyr(&idummy);
00588 }
00589
00590 void TPythia6::Pyrget(int lun, int move) {
00591
00592 pyrget(&lun,&move);
00593 }
00594
00595 void TPythia6::Pyrset(int lun, int move) {
00596
00597 pyrset(&lun,&move);
00598 }
00599
00600 void TPythia6::Pystat(int flag) {
00601
00602 pystat(&flag);
00603 }
00604
00605 void TPythia6::Pytest(int flag) {
00606
00607 pytest(&flag);
00608 }
00609
00610 void TPythia6::Pytune(int itune) {
00611
00612 pytune(&itune);
00613 }
00614
00615 void TPythia6::Pyupda(int mupda, int lun) {
00616
00617 pyupda(&mupda,&lun);
00618 }
00619
00620 double TPythia6::Pymass(int kf) {
00621
00622 return pymass(&kf);
00623 }
00624
00625 int TPythia6::Pychge(int kf) {
00626
00627 return pychge(&kf);
00628 }
00629
00630
00631 void TPythia6::Py1ent(Int_t ip, Int_t kf, Double_t pe, Double_t theta, Double_t phi)
00632 {
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650 py1ent(ip, kf, pe, theta, phi);
00651 }
00652
00653
00654
00655 void TPythia6::SetupTest()
00656 {
00657
00658
00659
00660
00661 SetMSEL(0);
00662
00663 SetMSUB(102,1);
00664 SetMSUB(123,1);
00665 SetMSUB(124,1);
00666
00667
00668 SetPMAS(6,1,175.0);
00669 SetPMAS(25,1,300);
00670
00671
00672 SetCKIN(1,290.0);
00673 SetCKIN(2,310.0);
00674
00675 SetMSTP(61, 0);
00676 SetMSTP(71, 0);
00677 SetMSTP(81, 0);
00678 SetMSTP(111, 0);
00679 }