CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtPythia.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See BelEvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtJetSet.cc
12//
13// Description: Routine to use JetSet for decaying particles.
14//
15// Modification history:
16//
17// RYD July 24, 1997 Module created
18// RS October 28, 2002 copied from JETSET module
19//------------------------------------------------------------------------
20//
26#include "EvtGenBase/EvtPDL.hh"
29#include "EvtGenBase/EvtId.hh"
30#include <iostream>
31#include <iomanip>
32#include <fstream>
33#include <string.h>
34#include <stdlib.h>
35#include <unistd.h>
36#include <stdio.h>
37using std::endl;
38using std::fstream;
39using std::ios;
40using std::ofstream;
41using std::resetiosflags;
42using std::setiosflags;
43using std::setw;
44
45using std::string;
46
47int EvtPythia::njetsetdecays=0;
48 EvtDecayBasePtr* EvtPythia::jetsetdecays=0;
49int EvtPythia::ntable=0;
50
51int EvtPythia::ncommand=0;
52int EvtPythia::lcommand=0;
53std::string* EvtPythia::commands=0;
54
55
56extern "C" {
57 extern void pycontinuum_(double *,int *, int *,
58 double *,double *,double *,double *);
59}
60
61extern "C" {
62 extern void evtpythiainit_(const char* fname, int len);
63}
64
65extern "C" {
66 extern void init_cont_();
67}
68
69extern "C" {
70 extern void pythiadec_(int *,double *,int *,int *,int *,
71 double *,double *,double *,double *);
72}
73
74extern "C" {
75 extern void initpythia_(int *);
76}
77
78extern "C" {
79 extern void pygive_(const char *cnfgstr,int length);
80}
81
82extern "C" {
83 extern int pycomp_(int* kf);
84}
85
86extern "C" {
87 extern void pylist_(int &);
88}
89
90
92
94
95
96 int i;
97
98
99 //the deletion of commands is really uggly!
100
101 if (njetsetdecays==0) {
102 delete [] commands;
103 commands=0;
104 return;
105 }
106
107 for(i=0;i<njetsetdecays;i++){
108 if (jetsetdecays[i]==this){
109 jetsetdecays[i]=jetsetdecays[njetsetdecays-1];
110 njetsetdecays--;
111 if (njetsetdecays==0) {
112 delete [] commands;
113 commands=0;
114 }
115 return;
116 }
117 }
118
119 report(ERROR,"EvtGen") << "Error in destroying Pythia model!"<<endl;
120
121}
122
123
124void EvtPythia::getName(std::string& model_name){
125
126 model_name="PYTHIA";
127
128}
129
131
132 return new EvtPythia;
133
134}
135
136
138
139 noProbMax();
140
141}
142
143
145
146 checkNArg(1);
147
148
149 if (getParentId().isAlias()){
150
151 report(ERROR,"EvtGen") << "EvtPythia finds that you are decaying the"<<endl
152 << " aliased particle "
153 << EvtPDL::name(getParentId()).c_str()
154 << " with the Pythia model"<<endl
155 << " this does not work, please modify decay table."
156 << endl;
157 report(ERROR,"EvtGen") << "Will terminate execution!"<<endl;
158 ::abort();
159
160 }
161
162 store(this);
163
164}
165
166
168
169 return std::string("JetSetPar");
170
171}
172
173
174void EvtPythia::command(std::string cmd){
175
176 if (ncommand==lcommand){
177
178 lcommand=10+2*lcommand;
179
180 std::string* newcommands=new std::string[lcommand];
181
182 int i;
183
184 for(i=0;i<ncommand;i++){
185 newcommands[i]=commands[i];
186 }
187
188 delete [] commands;
189
190 commands=newcommands;
191
192 }
193
194 commands[ncommand]=cmd;
195
196 ncommand++;
197
198}
199
200void EvtPythia::pythiacont(double *energy, int *ndaugjs, int *kf,
201 double *px, double *py, double *pz, double *e)
202{
203 pycontinuum_(energy,ndaugjs,kf,px,py,pz,e);
204}
205
206
207
209
210 //added by Lange Jan4,2000
211 static EvtId STRNG=EvtPDL::getId("string");
212
213 int istdheppar=EvtPDL::getStdHep(p->getId());
214
215 if (pycomp_(&istdheppar)==0){
216 report(ERROR,"EvtGen") << "Pythia can not decay:"
217 <<EvtPDL::name(p->getId()).c_str()<<endl;
218 return;
219 }
220
221
222 double mp=p->mass();
223
224 EvtVector4R p4[20];
225
226 int i,more;
227 int ip=EvtPDL::getStdHep(p->getId());
228
229 int ndaugjs;
230 int kf[100];
231 EvtId evtnumstable[100],evtnumparton[100];
232 int stableindex[100],partonindex[100];
233 int numstable;
234 int numparton;
235 int km[100];
236 EvtId type[MAX_DAUG];
237
238 pythiaInit(0);
239
240 double px[100],py[100],pz[100],e[100];
241 if ( p->getNDaug() != 0 ) { p->deleteDaughters(true);}
242
243 int count=0;
244
245 do{
246
247 pythiadec_(&ip,&mp,&ndaugjs,kf,km,px,py,pz,e);
248
249
250 numstable=0;
251 numparton=0;
252
253 for(i=0;i<ndaugjs;i++){
254 // std::cout<<"EvtPDL::evtIdFromStdHep(kf[i]),i= "<<i<<" "<<EvtPDL::evtIdFromStdHep(kf[i])<<std::endl;
255 if (EvtPDL::evtIdFromStdHep(kf[i])==EvtId(-1,-1)) {
256 report(ERROR,"EvtGen") << "Pythia returned particle:"<<kf[i]<<endl;
257 report(ERROR,"EvtGen") << "This can not be translated to evt number"<<endl;
258 report(ERROR,"EvtGen") << "and the decay will be rejected!"<<endl;
259 report(ERROR,"EvtGen") << "The decay was of particle:"<<ip<<endl;
260 int i=1;
261 pylist_(i);
262 }
263
264 //sort out the partons
265 if (abs(kf[i])<=6||kf[i]==21){
266 partonindex[numparton]=i;
267 evtnumparton[numparton]=EvtPDL::evtIdFromStdHep(kf[i]);
268 numparton++;
269 }
270 else{
271 stableindex[numstable]=i;
272 evtnumstable[numstable]=EvtPDL::evtIdFromStdHep(kf[i]);
273 numstable++;
274 }
275
276
277 // have to protect against negative mass^2 for massless particles
278 // i.e. neutrinos and photons.
279 // this is uggly but I need to fix it right now....
280
281 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
282
283 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000000001;
284
285 }
286
287 p4[i].set(e[i],px[i],py[i],pz[i]);
288
289
290 }
291
292 int channel= EvtDecayTable::inChannelList(p->getId(),numstable,evtnumstable);
293
294 more=(channel!=-1);
295
296
297 count++;
298
299 }while( more && (count<10000) );
300
301
302 if (count>9999) {
303 report(INFO,"EvtGen") << "Too many loops in EvtPythia!!!"<<endl;
304 report(INFO,"EvtGen") << "Parent:"<<EvtPDL::name(getParentId()).c_str()<<endl;
305 for(i=0;i<numstable;i++){
306 report(INFO,"EvtGen") << "Daug("<<i<<")"<<EvtPDL::name(evtnumstable[i]).c_str()<<endl;
307 }
308
309 }
310
311
312
313 if (numparton==0){
314
315 p->makeDaughters(numstable,evtnumstable);
316
317 for(i=0;i<numstable;i++){
318 p->getDaug(i)->init(evtnumstable[i],p4[stableindex[i]]);
319 }
320
321 fixPolarizations(p);
322
323 return ;
324
325 }
326 else{
327
328 //have partons in JETSET
329
330 EvtVector4R p4string(0.0,0.0,0.0,0.0);
331
332 for(i=0;i<numparton;i++){
333 p4string+=p4[partonindex[i]];
334 }
335
336 int nprimary=1;
337 type[0]=STRNG;
338 for(i=0;i<numstable;i++){
339 if (km[stableindex[i]]==0){
340 type[nprimary++]=evtnumstable[i];
341 }
342 }
343
344 p->makeDaughters(nprimary,type);
345
346 p->getDaug(0)->init(STRNG,p4string);
347
348 EvtVector4R p4partons[10];
349
350 for(i=0;i<numparton;i++){
351 p4partons[i]=p4[partonindex[i]];
352 }
353
354 ((EvtStringParticle*)p->getDaug(0))->initPartons(numparton,p4partons,evtnumparton);
355
356
357
358 nprimary=1;
359
360 for(i=0;i<numstable;i++){
361
362 if (km[stableindex[i]]==0){
363 p->getDaug(nprimary++)->init(evtnumstable[i],p4[stableindex[i]]);
364 }
365 }
366
367
368 int nsecond=0;
369 for(i=0;i<numstable;i++){
370 if (km[stableindex[i]]!=0){
371 type[nsecond++]=evtnumstable[i];
372 }
373 }
374
375
376 p->getDaug(0)->makeDaughters(nsecond,type);
377
378 nsecond=0;
379 for(i=0;i<numstable;i++){
380 if (km[stableindex[i]]!=0){
381 p4[stableindex[i]]=boostTo(p4[stableindex[i]],p4string);
382 p->getDaug(0)->getDaug(nsecond)->init(evtnumstable[i],p4[stableindex[i]]);
383 p->getDaug(0)->getDaug(nsecond)->setDiagonalSpinDensity();
384 p->getDaug(0)->getDaug(nsecond)->decay();
385 nsecond++;
386 }
387 }
388
389 fixPolarizations(p);
390
391 return ;
392
393 }
394
395}
396
397void EvtPythia::fixPolarizations(EvtParticle *p){
398
399 //special case for now to handle the J/psi polarization
400
401 int ndaug=p->getNDaug();
402
403 int i;
404
405 static EvtId Jpsi=EvtPDL::getId("J/psi");
406
407 for(i=0;i<ndaug;i++){
408 if(p->getDaug(i)->getId()==Jpsi){
409
410 EvtSpinDensity rho;
411
412 rho.SetDim(3);
413 rho.Set(0,0,0.5);
414 rho.Set(0,1,0.0);
415 rho.Set(0,2,0.0);
416
417 rho.Set(1,0,0.0);
418 rho.Set(1,1,1.0);
419 rho.Set(1,2,0.0);
420
421 rho.Set(2,0,0.0);
422 rho.Set(2,1,0.0);
423 rho.Set(2,2,0.5);
424
425 EvtVector4R p4Psi=p->getDaug(i)->getP4();
426
427 double alpha=atan2(p4Psi.get(2),p4Psi.get(1));
428 double beta=acos(p4Psi.get(3)/p4Psi.d3mag());
429
430
433
434 }
435 }
436
437}
438
439void EvtPythia::store(EvtDecayBase* jsdecay){
440
441 if (njetsetdecays==ntable){
442
443 EvtDecayBasePtr* newjetsetdecays=new EvtDecayBasePtr[2*ntable+10];
444 int i;
445 for(i=0;i<ntable;i++){
446 newjetsetdecays[i]=jetsetdecays[i];
447 }
448 ntable=2*ntable+10;
449 delete [] jetsetdecays;
450 jetsetdecays=newjetsetdecays;
451 }
452
453 jetsetdecays[njetsetdecays++]=jsdecay;
454
455
456
457}
458
459
460void EvtPythia::WritePythiaEntryHeader(ofstream &outdec, int lundkc,
461 EvtId evtnum,std::string name,
462 int chg, int cchg, int spin2,double mass,
463 double width, double maxwidth,double ctau,
464 int stable,double rawbrfrsum){
465
466 char sname[100];
467 char ccsname[100];
468
469 // RS changed to 16, new PYTHIA standard
470 int namelength=16;
471
472 int i,j;
473 int temp;
474 temp = spin2;
475
476 if (ctau>1000000.0) ctau=0.0;
477
478 strcpy(sname,name.c_str());
479
480 i=0;
481
482 while (sname[i]!=0){
483 i++;
484 }
485
486 // strip up to two + or -
487
488 if(evtnum.getId()>=0) {
489 if (sname[i-1]=='+'||sname[i-1]=='-'){
490 sname[i-1]=0;
491 i--;
492 }
493 if (sname[i-1]=='+'||sname[i-1]=='-'){
494 sname[i-1]=0;
495 i--;
496 }
497 // strip 0 except for _0 and chi...0
498 if (sname[i-1]=='0' && sname[i-2]!='_' && !(sname[0]=='c' && sname[1]=='h')){
499 sname[i-1]=0;
500 i--;
501 }
502 }
503
504 if (i>namelength) {
505 for(j=1;j<namelength;j++){
506 sname[j]=sname[j+i-namelength];
507 }
508 sname[namelength]=0;
509 }
510
511 // RS: copy name for cc particle
512 for(j=0;j<=namelength;j++)
513 ccsname[j]=sname[j];
514 i=0;
515 while (ccsname[i]!=' '){
516 i++;
517 if(ccsname[i]==0) break;
518 }
519 if(i<namelength)
520 {
521 ccsname[i]='b';
522 ccsname[i+1]=0;
523 }
524
525 //cchg=0;
526
527 if(evtnum.getId()>=0) {
528 if (abs(EvtPDL::getStdHep(evtnum))==21) cchg=2;
529 if (abs(EvtPDL::getStdHep(evtnum))==90) cchg=-1;
530 if ((abs(EvtPDL::getStdHep(evtnum))<=8)&&
531 (abs(EvtPDL::getStdHep(evtnum))!=0)) cchg=1;
532
533 }
534
535 // RS output format changed to new PYTHIA style
536 outdec << " " << setw(9) << lundkc;
537 outdec << " ";
538 outdec.width(namelength);
539 outdec << setiosflags(ios::left)
540 << sname;
541 // RS: name for cc paricle
542 if ((evtnum.getId()>=0) && (EvtPDL::chargeConj(evtnum)!=evtnum))
543 {
544 outdec << " ";
545 outdec.width(namelength);
546 outdec << ccsname;
547 }else{
548 // 2+16 spaces
549 outdec << " ";
550 }
551
552 outdec << resetiosflags(ios::left);
553 outdec << setw(3) << chg;
554 outdec << setw(3) << cchg;
555 outdec.width(3);
556 if (evtnum.getId()>=0) {
557 if (EvtPDL::chargeConj(evtnum)==evtnum) {
558 outdec << 0;
559 }
560 else{
561 outdec << 1;
562 }
563 }
564 else{
565 outdec << 0;
566 }
567 outdec.setf(ios::fixed,ios::floatfield);
568 outdec.precision(5);
569 outdec << setw(12) << mass;
570 outdec.setf(ios::fixed,ios::floatfield);
571 outdec << setw(12) << width;
572 outdec.setf(ios::fixed,ios::floatfield);
573 outdec.width(12);
574 if (fabs(width)<0.0000000001) {
575 outdec << 0.0 ;
576 }
577 else{
578 outdec << maxwidth;
579 }
580 // scientific notation ... outdec << setw(14) << ctau;
581 outdec.setf(ios::scientific,ios::floatfield);
582 outdec << " ";
583 outdec << ctau;
584 outdec.width(3);
585 if (evtnum.getId()>=0) {
586 if (ctau>1.0 || rawbrfrsum<0.000001) {
587 stable=0;
588 }
589 }
590 //resonance width treatment
591 outdec.width(3);
592 outdec << 0;
593 outdec.width(3);
594 outdec << stable;
595 outdec << endl;
596 outdec.width(0);
597 //outdec.setf(0,0);
598
599}
600
601void EvtPythia::WritePythiaParticle(ofstream &outdec,EvtId ipar,
602 EvtId iparname,int &first){
603
604 int ijetset;
605
606 double br_sum=0.0;
607
608 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
609
610 if (jetsetdecays[ijetset]->getParentId()==ipar){
611 br_sum+=jetsetdecays[ijetset]->getBranchingFraction();
612 }
613 if (jetsetdecays[ijetset]->getParentId()!=
614 EvtPDL::chargeConj(jetsetdecays[ijetset]->getParentId())&&
615 EvtPDL::chargeConj(jetsetdecays[ijetset]->getParentId())==ipar){
616 br_sum+=jetsetdecays[ijetset]->getBranchingFraction();
617 }
618
619
620 }
621
622 double br_sum_true=br_sum;
623
624 if (br_sum<0.000001) br_sum=1.0;
625
626 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
627 if (jetsetdecays[ijetset]->getParentId()==ipar){
628
629 double br=jetsetdecays[ijetset]->getBranchingFraction();
630
631 int i,daugs[5];
632 EvtId cdaugs[5];
633
634 for(i=0;i<5;i++){
635
636 if(i<jetsetdecays[ijetset]->getNDaug()){
637 daugs[i]=EvtPDL::getStdHep(
638 jetsetdecays[ijetset]->getDaugs()[i]);
639 cdaugs[i]=EvtPDL::chargeConj(jetsetdecays[ijetset]->getDaugs()[i]);
640 }
641 else{
642 daugs[i]=0;
643 }
644 }
645
646 int channel;
647
649 jetsetdecays[ijetset]->getModelName(),
650 jetsetdecays[ijetset]->getNDaug(),
651 cdaugs,
652 jetsetdecays[ijetset]->getNArg(),
653 jetsetdecays[ijetset]->getArgsStr());
654
655 if (jetsetdecays[ijetset]->getModelName()=="PYTHIA"){
656
657 if (first) {
658 first=0;
659 WritePythiaEntryHeader(outdec,
660 //EvtPDL::getLundKC(iparname),
661 EvtPDL::getStdHep(iparname),
662 iparname,
663 EvtPDL::name(iparname),
664 EvtPDL::chg3(iparname),
665 0,0,EvtPDL::getMeanMass(ipar),
666 EvtPDL::getWidth(ipar),
668 EvtPDL::getctau(ipar),1,br_sum_true);
669 }
670
671 int dflag=2;
672
673 if (EvtPDL::getStdHep(ipar)<0) {
674 dflag=3;
675 for(i=0;i<jetsetdecays[ijetset]->getNDaug();i++){
676 daugs[i]=EvtPDL::getStdHep(cdaugs[i]);
677 }
678
679 }
680
681 /* RS
682 PYTHIA allows to introduce new particles via a call to PYUPDA
683 so no need for this check any more
684
685 //now lets check to make sure that jetset, lucomp, knows
686 //about all particles!
687 int unknown=0;
688 for(i=0;i<jetsetdecays[ijetset]->getNDaug();i++){
689 if (pycomp_(&daugs[i])==0) {
690 unknown=1;
691 report(ERROR,"EvtGen") << "Pythia (pycomp) does not "
692 << "know the particle:"<<
693 EvtPDL::name(jetsetdecays[ijetset]->getDaugs()[i])<<endl;
694 }
695 }
696
697 int istdheppar=EvtPDL::getStdHep(ipar);
698
699 if (pycomp_(&istdheppar)==0){
700 unknown=1;
701 report(ERROR,"EvtGen") << "Pythia (pycomp) does not "
702 << "know the particle:"<<
703 EvtPDL::name(ipar)<<endl;
704 }
705
706
707
708 if (unknown){
709 report(ERROR,"EvtGen") << "Therfore the decay:"<<endl;
710 report(ERROR,"EvtGen") << EvtPDL::name(jetsetdecays[ijetset]->getParentId())<<" -> ";
711 for(i=0;i<jetsetdecays[ijetset]->getNDaug();i++){
712 report(ERROR,"") << EvtPDL::name(jetsetdecays[ijetset]->getDaugs()[i])<<" ";
713 }
714 report(ERROR,"")<<endl;
715 report(ERROR,"EvtGen")<<"Will not be generated."<<endl;
716 return;
717 }
718 */
719
720 if (EvtPDL::chargeConj(ipar)==ipar) {
721 dflag=1;
722 //report(INFO,"EvtGen") << EvtPDL::name(iparname) << " dflag=1 because C(ipar)=ipar!"<<endl;
723 }
724
725
726 //if (channel>=0) {
727 // dflag=1;
728 //report(INFO,"EvtGen") << EvtPDL::name(iparname) << " dflag=1 because channel>=0"<<endl;
729 //}
730
731 // if (!(EvtPDL::getStdHep(ipar)<0&&channel>=0)){
732 if (1){
733
734 // RS changed format to new PYTHIA one
735 outdec << " ";
736 outdec.width(5);
737 outdec <<dflag;
738 outdec.width(5);
739 outdec <<(int)jetsetdecays[ijetset]->getArgs()[0];
740 outdec.width(12);
741 if (fabs(br)<0.000000001) {
742 outdec <<"0.00000";
743 }
744 else{
745 outdec <<br/br_sum;
746 }
747 outdec.width(10);
748 outdec <<daugs[0];
749 outdec.width(10);
750 outdec <<daugs[1];
751 outdec.width(10);
752 outdec <<daugs[2];
753 outdec.width(10);
754 outdec <<daugs[3];
755 outdec.width(10);
756 outdec <<daugs[4];
757 outdec<<endl;
758 outdec.width(0);
759 }
760 }
761 }
762 }
763}
764
765bool
766EvtPythia::diquark(int ID)
767{
768 switch(ID)
769 {
770 case 1103:
771 case 2101:
772 case 2103:
773 case 2203:
774 case 3101:
775 case 3103:
776 case 3201:
777 case 3203:
778 case 3303:
779 case 4101:
780 case 4103:
781 case 4201:
782 case 4203:
783 case 4301:
784 case 4303:
785 case 4403:
786 case 5101:
787 case 5103:
788 case 5201:
789 case 5203:
790 case 5301:
791 case 5303:
792 case 5401:
793 case 5403:
794 case 5503:
795 return true;
796 break;
797 default:
798 return false;
799 break;
800 }
801}
802
803double
804EvtPythia::NominalMass(int ID)
805{
806 // return default mass in PYTHIA
807 switch(ID)
808 {
809 case 1103:
810 return 0.77133;
811 case 2101:
812 return 0.57933;
813 case 2103:
814 return 0.77133;
815 case 2203:
816 return 0.77133;
817 case 3101:
818 return 0.80473;
819 case 3103:
820 return 0.92953;
821 case 3201:
822 return 0.80473;
823 case 3203:
824 return 0.92953;
825 case 3303:
826 return 1.09361;
827 case 4101:
828 return 1.96908;
829 case 4103:
830 return 2.00808;
831 case 4201:
832 return 1.96908;
833 case 4203:
834 return 2.00808;
835 case 4301:
836 return 2.15432;
837 case 4303:
838 return 2.17967;
839 case 4403:
840 return 3.27531;
841 case 5101:
842 return 5.38897;
843 case 5103:
844 return 5.40145;
845 case 5201:
846 return 5.38897;
847 case 5203:
848 return 5.40145;
849 case 5301:
850 return 5.56725;
851 case 5303:
852 return 5.57536;
853 case 5401:
854 return 6.67143;
855 case 5403:
856 return 6.67397;
857 case 5503:
858 return 10.07354;
859 break;
860 default:
861 return 0.0;
862 break;
863 }
864}
865
866int
868{
869 // return default mass in PYTHIA
870 switch(ID)
871 {
872 case 1103:
873 return -2;
874 case 2101:
875 return 1;
876 case 2103:
877 return 1;
878 case 2203:
879 return 4;
880 case 3101:
881 return -2;
882 case 3103:
883 return -2;
884 case 3201:
885 return 1;
886 case 3203:
887 return 1;
888 case 3303:
889 return -2;
890 case 4101:
891 return 1;
892 case 4103:
893 return 1;
894 case 4201:
895 return 4;
896 case 4203:
897 return 4;
898 case 4301:
899 return 1;
900 case 4303:
901 return 1;
902 case 4403:
903 return 4;
904 case 5101:
905 return -2;
906 case 5103:
907 return -2;
908 case 5201:
909 return 1;
910 case 5203:
911 return 1;
912 case 5301:
913 return -2;
914 case 5303:
915 return -2;
916 case 5401:
917 return 1;
918 case 5403:
919 return 1;
920 case 5503:
921 return -2;
922 break;
923 default:
924 return 0;
925 break;
926 }
927}
928
929void EvtPythia::MakePythiaFile(char* fname){
930
931 EvtId ipar;
932 int lundkc;
933
934 //int part_list[MAX_PART];
935
936 ofstream outdec;
937
938 outdec.open(fname);
939
940 //outdec << "ERROR;"<<endl;
941 //outdec << ";"<<endl;
942 //outdec << ";This decayfile has been automatically created by"<<endl;
943 //outdec << ";EvtGen from the DECAY.DEC file"<<endl;
944 //outdec << ";"<<endl;
945
946 int nokcentry;
947
948 for(lundkc=1;lundkc<500;lundkc++){
949
950 nokcentry=1;
951
952 int iipar;
953
954 for(iipar=0;iipar<EvtPDL::entries();iipar++){
955
956 ipar=EvtId(iipar,iipar);
957 //no aliased particles!
958 std::string tempStr = EvtPDL::name(ipar);
959 EvtId realId = EvtPDL::getId(tempStr);
960 if ( realId.isAlias() != 0 ) continue;
961
962 if(!(
963 EvtPDL::getStdHep(ipar)==21 ||
964 EvtPDL::getStdHep(ipar)==22 ||
965 EvtPDL::getStdHep(ipar)==23))
966 {
967
968 if (lundkc==EvtPDL::getLundKC(ipar)){
969
970 nokcentry=0;
971
972 int first=1;
973
974 WritePythiaParticle(outdec,ipar,ipar,first);
975
976
977 EvtId ipar2=EvtPDL::chargeConj(ipar);
978
979
980 if (ipar2!=ipar){
981 WritePythiaParticle(outdec,ipar2,ipar,first);
982 }
983
984 if (first){
985 WritePythiaEntryHeader(outdec,
986 //EvtPDL::getLundKC(ipar),
987 EvtPDL::getStdHep(ipar),
988 ipar,
989 EvtPDL::name(ipar),
990 EvtPDL::chg3(ipar),
991 0,0,EvtPDL::getMeanMass(ipar),
992 EvtPDL::getWidth(ipar),
994 EvtPDL::getctau(ipar),0,0.0);
995
996 }
997 }
998 }
999 }
1000 if (lundkc==99999) // Write out diquarks after quarks, but only once
1001 for(iipar=0;iipar<EvtPDL::entries();iipar++){
1002
1003 ipar=EvtId(iipar,iipar);
1004
1005 if (diquark(EvtPDL::getStdHep(ipar))){
1006
1007 nokcentry=0;
1008
1009 int first=1;
1010
1011 WritePythiaParticle(outdec,ipar,ipar,first);
1012
1013
1014 EvtId ipar2=EvtPDL::chargeConj(ipar);
1015
1016
1017 if (ipar2!=ipar){
1018 WritePythiaParticle(outdec,ipar2,ipar,first);
1019 }
1020
1021 if (first){
1022 WritePythiaEntryHeader(outdec,
1023 EvtPDL::getStdHep(ipar),
1024 ipar,
1025 EvtPDL::name(ipar),
1027 -1,0,
1028 NominalMass(EvtPDL::getStdHep(ipar)),
1029 0, 0, 0, 0,0.0);
1030
1031 }
1032 }
1033 }
1034 /* if (nokcentry){
1035
1036 WritePythiaEntryHeader(outdec,
1037 lundkc,EvtId(-1,-1)," ",
1038 0,0,0,EvtPDL::getNominalMass(ipar),0.0,0.0,
1039 EvtPDL::getctau(ipar),0,0.0);
1040
1041 } */
1042 }
1043 outdec.close();
1044}
1045
1047
1048 static int first=1;
1049 if (first){
1050
1051 first=0;
1052
1053 report(INFO,"EvtGen") << "Will initialize Pythia."<<endl;
1054 for(int i=0;i<ncommand;i++)
1055 pygive_(commands[i].c_str(),strlen(commands[i].c_str()));
1056
1057 char fname[200];
1058
1059 char hostBuffer[100];
1060
1061 if ( gethostname( hostBuffer, 100 ) != 0 ){
1062 report(ERROR,"EvtGen") << " couldn't get hostname." << endl;
1063 strncpy( hostBuffer, "hostnameNotFound", 100 );
1064 }
1065
1066 char pid[100];
1067
1068 int thePid=getpid();
1069
1070 if ( sprintf( pid, "%d", thePid ) == 0 ){
1071 report(ERROR,"EvtGen") << " couldn't get process ID." << endl;
1072 strncpy( pid, "666", 100 );
1073 }
1074
1075 strcpy(fname,"jet.d-");
1076 strcat(fname,hostBuffer);
1077 strcat(fname,"-");
1078 strcat(fname,pid);
1079
1080 MakePythiaFile(fname);
1081 evtpythiainit_(fname,strlen(fname));
1082 initpythia_(&dummy);
1083
1084 if (0==getenv("EVTSAVEJETD")){
1085 char delcmd[300];
1086 strcpy(delcmd,"rm -f ");
1087 strcat(delcmd,fname);
1088 system(delcmd);
1089 }
1090
1091 report(INFO,"EvtGen") << "Done initializing Pythia."<<endl;
1092
1093 }
1094
1095}
double mass
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
const int MAX_DAUG
Definition: EvtParticle.hh:38
int NominalCharge(int ID)
Definition: EvtPythia.cc:867
void init_cont_()
void pygive_(const char *cnfgstr, int length)
void pycontinuum_(double *, int *, int *, double *, double *, double *, double *)
void pylist_(int &)
void evtpythiainit_(const char *fname, int len)
void pythiadec_(int *, double *, int *, int *, int *, double *, double *, double *, double *)
void initpythia_(int *)
int pycomp_(int *kf)
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ ERROR
Definition: EvtReport.hh:49
@ INFO
Definition: EvtReport.hh:52
const double alpha
************Class m_ypar INTEGER m_KeyWgt INTEGER m_nphot INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
Definition: KK2f.h:50
std::string * getArgsStr()
Definition: EvtDecayBase.hh:73
void noProbMax()
std::string getModelName()
Definition: EvtDecayBase.hh:76
EvtId getParentId()
Definition: EvtDecayBase.hh:60
double * getArgs()
double getBranchingFraction()
Definition: EvtDecayBase.hh:61
EvtId * getDaugs()
Definition: EvtDecayBase.hh:65
void checkNArg(int a1, int a2=-1, int a3=-1, int a4=-1)
void setDaughterSpinDensity(int daughter)
static int findChannel(EvtId parent, std::string model, int ndaug, EvtId *daugs, int narg, std::string *args)
static int inChannelList(EvtId parent, int ndaug, EvtId *daugs)
Definition: EvtId.hh:27
int getId() const
Definition: EvtId.hh:41
int isAlias() const
Definition: EvtId.hh:45
static double getWidth(EvtId i)
Definition: EvtPDL.hh:54
static int getStdHep(EvtId id)
Definition: EvtPDL.hh:56
static double getMeanMass(EvtId i)
Definition: EvtPDL.hh:45
static int entries()
Definition: EvtPDL.hh:67
static EvtId evtIdFromStdHep(int stdhep)
Definition: EvtPDL.cc:244
static std::string name(EvtId i)
Definition: EvtPDL.hh:64
static EvtId chargeConj(EvtId id)
Definition: EvtPDL.cc:208
static double getMinMass(EvtId i)
Definition: EvtPDL.hh:51
static int chg3(EvtId i)
Definition: EvtPDL.hh:60
static int getLundKC(EvtId id)
Definition: EvtPDL.hh:57
static EvtId getId(const std::string &name)
Definition: EvtPDL.cc:287
static double getctau(EvtId i)
Definition: EvtPDL.hh:55
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
Definition: EvtParticle.cc:178
void makeDaughters(int ndaug, EvtId *id)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void decay()
Definition: EvtParticle.cc:404
EvtId getId() const
Definition: EvtParticle.cc:113
void setDiagonalSpinDensity()
Definition: EvtParticle.cc:133
const EvtVector4R & getP4() const
Definition: EvtParticle.cc:121
int getNDaug() const
Definition: EvtParticle.cc:125
EvtParticle * getDaug(int i)
Definition: EvtParticle.cc:85
void deleteDaughters(bool keepChannel=false)
Definition: EvtParticle.cc:538
double mass() const
Definition: EvtParticle.cc:127
static void pythiaInit(int f)
Definition: EvtPythia.cc:1046
virtual ~EvtPythia()
Definition: EvtPythia.cc:93
void initProbMax()
Definition: EvtPythia.cc:137
static void pythiacont(double *, int *, int *, double *, double *, double *, double *)
Definition: EvtPythia.cc:200
void command(std::string cmd)
Definition: EvtPythia.cc:174
void decay(EvtParticle *p)
Definition: EvtPythia.cc:208
void getName(std::string &name)
Definition: EvtPythia.cc:124
std::string commandName()
Definition: EvtPythia.cc:167
EvtDecayBase * clone()
Definition: EvtPythia.cc:130
void init()
Definition: EvtPythia.cc:144
void Set(int i, int j, const EvtComplex &rhoij)
void SetDim(int n)
double get(int i) const
Definition: EvtVector4R.hh:179
double d3mag() const
Definition: EvtVector4R.cc:186
void set(int i, double d)
Definition: EvtVector4R.hh:183
const double mp
Definition: incllambda.cxx:45
Index first(Pair i)
Definition: EvtCyclic3.cc:195