41using std::resetiosflags;
42using std::setiosflags;
47int EvtPythia::njetsetdecays=0;
49int EvtPythia::ntable=0;
51int EvtPythia::ncommand=0;
52int EvtPythia::lcommand=0;
53std::string* EvtPythia::commands=0;
57 double *,
double *,
double *,
double *);
70 double *,
double *,
double *,
double *);
78 extern void pygive_(
const char *cnfgstr,
int length);
104 if (njetsetdecays==0) {
110 for(i=0;i<njetsetdecays;i++){
111 if (jetsetdecays[i]==
this){
112 jetsetdecays[i]=jetsetdecays[njetsetdecays-1];
114 if (njetsetdecays==0) {
122 report(
ERROR,
"EvtGen") <<
"Error in destroying Pythia model!"<<endl;
154 report(
ERROR,
"EvtGen") <<
"EvtPythia finds that you are decaying the"<<endl
155 <<
" aliased particle "
157 <<
" with the Pythia model"<<endl
158 <<
" this does not work, please modify decay table."
160 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
172 return std::string(
"JetSetPar");
179 if (ncommand==lcommand){
181 lcommand=10+2*lcommand;
183 std::string* newcommands=
new std::string[lcommand];
187 for(i=0;i<ncommand;i++){
188 newcommands[i]=commands[i];
193 commands=newcommands;
197 commands[ncommand]=cmd;
204 double *px,
double *py,
double *pz,
double *e)
234 EvtId evtnumstable[100],evtnumparton[100];
235 int stableindex[100],partonindex[100];
242 if(
mp==0){std::cout<<
"Particle "<<
EvtPDL::name(p->
getId())<<
" has zero mass"<<std::endl;abort();}
245 double px[100],py[100],pz[100],e[100];
258 for(i=0;i<ndaugjs;i++){
261 report(
ERROR,
"EvtGen") <<
"Pythia returned particle:"<<kf[i]<<endl;
262 report(
ERROR,
"EvtGen") <<
"This can not be translated to evt number"<<endl;
263 report(
ERROR,
"EvtGen") <<
"and the decay will be rejected!"<<endl;
264 report(
ERROR,
"EvtGen") <<
"The decay was of particle:"<<ip<<endl;
270 if (
abs(kf[i])<=6||kf[i]==21){
271 partonindex[numparton]=i;
276 stableindex[numstable]=i;
286 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
288 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000000001;
292 p4[i].
set(e[i],px[i],py[i],pz[i]);
304 }
while( more && (
count<10000) );
308 report(
INFO,
"EvtGen") <<
"Too many loops in EvtPythia!!!"<<endl;
310 for(i=0;i<numstable;i++){
322 for(i=0;i<numstable;i++){
323 p->
getDaug(i)->
init(evtnumstable[i],p4[stableindex[i]]);
337 for(i=0;i<numparton;i++){
338 p4string+=p4[partonindex[i]];
343 for(i=0;i<numstable;i++){
344 if (km[stableindex[i]]==0){
345 type[nprimary++]=evtnumstable[i];
355 for(i=0;i<numparton;i++){
356 p4partons[i]=p4[partonindex[i]];
365 for(i=0;i<numstable;i++){
367 if (km[stableindex[i]]==0){
368 p->
getDaug(nprimary++)->
init(evtnumstable[i],p4[stableindex[i]]);
374 for(i=0;i<numstable;i++){
375 if (km[stableindex[i]]!=0){
376 type[nsecond++]=evtnumstable[i];
384 for(i=0;i<numstable;i++){
385 if (km[stableindex[i]]!=0){
386 p4[stableindex[i]]=
boostTo(p4[stableindex[i]],p4string);
412 for(i=0;i<ndaug;i++){
433 double beta=acos(p4Psi.
get(3)/p4Psi.
d3mag());
446 if (njetsetdecays==ntable){
450 for(i=0;i<ntable;i++){
451 newjetsetdecays[i]=jetsetdecays[i];
454 delete [] jetsetdecays;
455 jetsetdecays=newjetsetdecays;
458 jetsetdecays[njetsetdecays++]=jsdecay;
465void EvtPythia::WritePythiaEntryHeader(ofstream &outdec,
int lundkc,
466 EvtId evtnum,std::string name,
467 int chg,
int cchg,
int spin2,
double mass,
468 double width,
double maxwidth,
double ctau,
469 int stable,
double rawbrfrsum){
481 if (ctau>1000000.0) ctau=0.0;
483 strcpy(sname,name.c_str());
493 if(evtnum.
getId()>=0) {
494 if (sname[i-1]==
'+'||sname[i-1]==
'-'){
498 if (sname[i-1]==
'+'||sname[i-1]==
'-'){
503 if (sname[i-1]==
'0' && sname[i-2]!=
'_' && !(sname[0]==
'c' && sname[1]==
'h')){
510 for(j=1;j<namelength;j++){
511 sname[j]=sname[j+i-namelength];
517 for(j=0;j<=namelength;j++)
520 while (ccsname[i]!=
' '){
522 if(ccsname[i]==0)
break;
532 if(evtnum.
getId()>=0) {
541 outdec <<
" " << setw(9) << lundkc;
543 outdec.width(namelength);
544 outdec << setiosflags(ios::left)
550 outdec.width(namelength);
557 outdec << resetiosflags(ios::left);
558 outdec << setw(3) << chg;
559 outdec << setw(3) << cchg;
561 if (evtnum.
getId()>=0) {
572 outdec.setf(ios::fixed,ios::floatfield);
574 outdec << setw(12) <<
mass;
575 outdec.setf(ios::fixed,ios::floatfield);
576 outdec << setw(12) << width;
577 outdec.setf(ios::fixed,ios::floatfield);
579 if (fabs(width)<0.0000000001) {
586 outdec.setf(ios::scientific,ios::floatfield);
590 if (evtnum.
getId()>=0) {
591 if (ctau>1.0 || rawbrfrsum<0.000001) {
606void EvtPythia::WritePythiaParticle(ofstream &outdec,
EvtId ipar,
607 EvtId iparname,
int &first){
613 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
627 double br_sum_true=br_sum;
629 if (br_sum<0.000001) br_sum=1.0;
631 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
641 if(i<jetsetdecays[ijetset]->
getNDaug()){
643 jetsetdecays[ijetset]->
getDaugs()[i]);
657 jetsetdecays[ijetset]->
getNArg(),
664 WritePythiaEntryHeader(outdec,
680 for(i=0;i<jetsetdecays[ijetset]->
getNDaug();i++){
744 outdec <<(int)jetsetdecays[ijetset]->
getArgs()[0];
746 if (fabs(br)<0.000000001) {
771EvtPythia::diquark(
int ID)
809EvtPythia::NominalMass(
int ID)
934void EvtPythia::MakePythiaFile(
char* fname){
953 for(lundkc=1;lundkc<500;lundkc++){
961 ipar=
EvtId(iipar,iipar);
965 if ( realId.
isAlias() != 0 )
continue;
979 WritePythiaParticle(outdec,ipar,ipar,first);
986 WritePythiaParticle(outdec,ipar2,ipar,first);
990 WritePythiaEntryHeader(outdec,
1008 ipar=
EvtId(iipar,iipar);
1016 WritePythiaParticle(outdec,ipar,ipar,first);
1023 WritePythiaParticle(outdec,ipar2,ipar,first);
1027 WritePythiaEntryHeader(outdec,
1058 report(
INFO,
"EvtGen") <<
"Will initialize Pythia."<<endl;
1059 for(
int i=0;i<ncommand;i++)
1060 pygive_(commands[i].c_str(),strlen(commands[i].c_str()));
1064 char hostBuffer[100];
1066 if ( gethostname( hostBuffer, 100 ) != 0 ){
1067 report(
ERROR,
"EvtGen") <<
" couldn't get hostname." << endl;
1068 strncpy( hostBuffer,
"hostnameNotFound", 100 );
1073 int thePid=getpid();
1075 if ( sprintf( pid,
"%d", thePid ) == 0 ){
1076 report(
ERROR,
"EvtGen") <<
" couldn't get process ID." << endl;
1077 strncpy( pid,
"666", 100 );
1080 strcpy(fname,
"jet.d-");
1081 strcat(fname,hostBuffer);
1085 MakePythiaFile(fname);
1089 if (0==getenv(
"EVTSAVEJETD")){
1091 strcpy(delcmd,
"rm -f ");
1092 strcat(delcmd,fname);
1096 report(
INFO,
"EvtGen") <<
"Done initializing Pythia."<<endl;
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
DOUBLE_PRECISION count[2]
int NominalCharge(int ID)
void pygive_(const char *cnfgstr, int length)
void pycontinuum_(double *, int *, int *, double *, double *, double *, double *)
void evtpythiainit_(const char *fname, int len)
void pythiadec_(int *, double *, int *, int *, int *, double *, double *, double *, double *)
ostream & report(Severity severity, const char *facility)
************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
std::string * getArgsStr()
std::string getModelName()
double getBranchingFraction()
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)
static double getWidth(EvtId i)
static int getStdHep(EvtId id)
static double getMeanMass(EvtId i)
static EvtId evtIdFromStdHep(int stdhep)
static std::string name(EvtId i)
static EvtId chargeConj(EvtId id)
static double getMinMass(EvtId i)
static int getLundKC(EvtId id)
static EvtId getId(const std::string &name)
static double getctau(EvtId i)
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
void makeDaughters(int ndaug, EvtId *id)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void setDiagonalSpinDensity()
const EvtVector4R & getP4() const
EvtParticle * getDaug(int i)
void deleteDaughters(bool keepChannel=false)
static void pythiaInit(int f)
static void pythiacont(double *, int *, int *, double *, double *, double *, double *)
void command(std::string cmd)
void decay(EvtParticle *p)
void getName(std::string &name)
std::string commandName()
void Set(int i, int j, const EvtComplex &rhoij)
void set(int i, double d)