//-------------------------------------------------------------------------- // // Environment: // This software is part of the EvtGen package developed jointly // for the BaBar and CLEO collaborations. If you use all or part // of it, please give an appropriate acknowledgement. // // Copyright Information: See BelEvtGen/COPYRIGHT // Copyright (C) 1998 Caltech, UCSB // // Module: EvtJetSet.cc // // Description: Routine to use JetSet for decaying particles. // // Modification history: // // RYD July 24, 1997 Module created // RS October 28, 2002 copied from JETSET module //------------------------------------------------------------------------ // #include "EvtGenBase/EvtPatches.hh" #include "EvtGenBase/EvtPatches.hh" #include "EvtGenBase/EvtParticle.hh" #include "EvtGenBase/EvtStringParticle.hh" #include "EvtGenBase/EvtDecayTable.hh" #include "EvtGenBase/EvtPDL.hh" #include "EvtGenModels/EvtPythia.hh" #include "EvtGenBase/EvtReport.hh" #include "EvtGenBase/EvtId.hh" #include #include #include #include #include #include #include using std::endl; using std::fstream; using std::ios; using std::ofstream; using std::resetiosflags; using std::setiosflags; using std::setw; using std::string; int EvtPythia::njetsetdecays=0; EvtDecayBasePtr* EvtPythia::jetsetdecays=0; int EvtPythia::ntable=0; int EvtPythia::ncommand=0; int EvtPythia::lcommand=0; std::string* EvtPythia::commands=0; extern "C" { extern void pycontinuum_(double *,int *, int *, double *,double *,double *,double *); } extern "C" { extern void evtpythiainit_(const char* fname, int len); } extern "C" { extern void init_cont_(); } extern "C" { extern void pythiadec_(int *,double *,int *,int *,int *, double *,double *,double *,double *); } extern "C" { extern void initpythia_(int *); } extern "C" { extern void pygive_(const char *cnfgstr,int length); } extern "C" { extern int pycomp_(int* kf); } extern "C" { extern void pylist_(int &); } EvtPythia::EvtPythia(){} EvtPythia::~EvtPythia(){ int i; //the deletion of commands is really uggly! if (njetsetdecays==0) { delete [] commands; commands=0; return; } for(i=0;igetId()); if (pycomp_(&istdheppar)==0){ report(ERROR,"EvtGen") << "Pythia can not decay:" <getId()).c_str()<mass(); EvtVector4R p4[20]; int i,more; int ip=EvtPDL::getStdHep(p->getId()); int ndaugjs; int kf[100]; EvtId evtnumstable[100],evtnumparton[100]; int stableindex[100],partonindex[100]; int numstable; int numparton; int km[100]; EvtId type[MAX_DAUG]; pythiaInit(0); double px[100],py[100],pz[100],e[100]; if ( p->getNDaug() != 0 ) { p->deleteDaughters(true);} int count=0; do{ pythiadec_(&ip,&mp,&ndaugjs,kf,km,px,py,pz,e); numstable=0; numparton=0; for(i=0;i=e[i]*e[i]){ e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000000001; } p4[i].set(e[i],px[i],py[i],pz[i]); } int channel=EvtDecayTable::inChannelList(p->getId(),numstable,evtnumstable); more=(channel!=-1); count++; }while( more && (count<10000) ); if (count>9999) { report(INFO,"EvtGen") << "Too many loops in EvtPythia!!!"<makeDaughters(numstable,evtnumstable); for(i=0;igetDaug(i)->init(evtnumstable[i],p4[stableindex[i]]); } fixPolarizations(p); return ; } else{ //have partons in JETSET EvtVector4R p4string(0.0,0.0,0.0,0.0); for(i=0;imakeDaughters(nprimary,type); p->getDaug(0)->init(STRNG,p4string); EvtVector4R p4partons[10]; for(i=0;igetDaug(0))->initPartons(numparton,p4partons,evtnumparton); nprimary=1; for(i=0;igetDaug(nprimary++)->init(evtnumstable[i],p4[stableindex[i]]); } } int nsecond=0; for(i=0;igetDaug(0)->makeDaughters(nsecond,type); nsecond=0; for(i=0;igetDaug(0)->getDaug(nsecond)->init(evtnumstable[i],p4[stableindex[i]]); p->getDaug(0)->getDaug(nsecond)->setDiagonalSpinDensity(); p->getDaug(0)->getDaug(nsecond)->decay(); nsecond++; } } fixPolarizations(p); return ; } } void EvtPythia::fixPolarizations(EvtParticle *p){ //special case for now to handle the J/psi polarization int ndaug=p->getNDaug(); int i; static EvtId Jpsi=EvtPDL::getId("J/psi"); for(i=0;igetDaug(i)->getId()==Jpsi){ EvtSpinDensity rho; rho.setDim(3); rho.set(0,0,0.5); rho.set(0,1,0.0); rho.set(0,2,0.0); rho.set(1,0,0.0); rho.set(1,1,1.0); rho.set(1,2,0.0); rho.set(2,0,0.0); rho.set(2,1,0.0); rho.set(2,2,0.5); EvtVector4R p4Psi=p->getDaug(i)->getP4(); double alpha=atan2(p4Psi.get(2),p4Psi.get(1)); double beta=acos(p4Psi.get(3)/p4Psi.d3mag()); p->getDaug(i)->setSpinDensityForwardHelicityBasis(rho,alpha,beta,0.0); setDaughterSpinDensity(i); } } } void EvtPythia::store(EvtDecayBase* jsdecay){ if (njetsetdecays==ntable){ EvtDecayBasePtr* newjetsetdecays=new EvtDecayBasePtr[2*ntable+10]; int i; for(i=0;i1000000.0) ctau=0.0; strcpy(sname,name.c_str()); i=0; while (sname[i]!=0){ i++; } // strip up to two + or - if(evtnum.getId()>=0) { if (sname[i-1]=='+'||sname[i-1]=='-'){ sname[i-1]=0; i--; } if (sname[i-1]=='+'||sname[i-1]=='-'){ sname[i-1]=0; i--; } // strip 0 except for _0 and chi...0 if (sname[i-1]=='0' && sname[i-2]!='_' && !(sname[0]=='c' && sname[1]=='h')){ sname[i-1]=0; i--; } } if (i>namelength) { for(j=1;j=0) { if (abs(EvtPDL::getStdHep(evtnum))==21) cchg=2; if (abs(EvtPDL::getStdHep(evtnum))==90) cchg=-1; if ((abs(EvtPDL::getStdHep(evtnum))<=8)&& (abs(EvtPDL::getStdHep(evtnum))!=0)) cchg=1; } // RS output format changed to new PYTHIA style outdec << " " << setw(9) << lundkc; outdec << " "; outdec.width(namelength); outdec << setiosflags(ios::left) << sname; // RS: name for cc paricle if ((evtnum.getId()>=0) && (EvtPDL::chargeConj(evtnum)!=evtnum)) { outdec << " "; outdec.width(namelength); outdec << ccsname; }else{ // 2+16 spaces outdec << " "; } outdec << resetiosflags(ios::left); outdec << setw(3) << chg; outdec << setw(3) << cchg; outdec.width(3); if (evtnum.getId()>=0) { if (EvtPDL::chargeConj(evtnum)==evtnum) { outdec << 0; } else{ outdec << 1; } } else{ outdec << 0; } outdec.setf(ios::fixed,ios::floatfield); outdec.precision(5); outdec << setw(12) << mass; outdec.setf(ios::fixed,ios::floatfield); outdec << setw(12) << width; outdec.setf(ios::fixed,ios::floatfield); outdec.width(12); if (fabs(width)<0.0000000001) { outdec << 0.0 ; } else{ outdec << maxwidth; } // scientific notation ... outdec << setw(14) << ctau; outdec.setf(ios::scientific,ios::floatfield); outdec << " "; outdec << ctau; outdec.width(3); if (evtnum.getId()>=0) { if (ctau>1.0 || rawbrfrsum<0.000001) { stable=0; } } //resonance width treatment outdec.width(3); outdec << 0; outdec.width(3); outdec << stable; outdec << endl; outdec.width(0); //outdec.setf(0,0); } void EvtPythia::WritePythiaParticle(ofstream &outdec,EvtId ipar, EvtId iparname,int &first){ int ijetset; double br_sum=0.0; for(ijetset=0;ijetsetgetParentId()==ipar){ br_sum+=jetsetdecays[ijetset]->getBranchingFraction(); } if (jetsetdecays[ijetset]->getParentId()!= EvtPDL::chargeConj(jetsetdecays[ijetset]->getParentId())&& EvtPDL::chargeConj(jetsetdecays[ijetset]->getParentId())==ipar){ br_sum+=jetsetdecays[ijetset]->getBranchingFraction(); } } double br_sum_true=br_sum; if (br_sum<0.000001) br_sum=1.0; for(ijetset=0;ijetsetgetParentId()==ipar){ double br=jetsetdecays[ijetset]->getBranchingFraction(); int i,daugs[5]; EvtId cdaugs[5]; for(i=0;i<5;i++){ if(igetNDaug()){ daugs[i]=EvtPDL::getStdHep( jetsetdecays[ijetset]->getDaugs()[i]); cdaugs[i]=EvtPDL::chargeConj(jetsetdecays[ijetset]->getDaugs()[i]); } else{ daugs[i]=0; } } int channel; channel=EvtDecayTable::findChannel(EvtPDL::chargeConj(ipar), jetsetdecays[ijetset]->getModelName(), jetsetdecays[ijetset]->getNDaug(), cdaugs, jetsetdecays[ijetset]->getNArg(), jetsetdecays[ijetset]->getArgsStr()); if (jetsetdecays[ijetset]->getModelName()=="PYTHIA"){ if (first) { first=0; WritePythiaEntryHeader(outdec, //EvtPDL::getLundKC(iparname), EvtPDL::getStdHep(iparname), iparname, EvtPDL::name(iparname), EvtPDL::chg3(iparname), 0,0,EvtPDL::getMeanMass(ipar), EvtPDL::getWidth(ipar), EvtPDL::getMeanMass(ipar)-EvtPDL::getMinMass(ipar), EvtPDL::getctau(ipar),1,br_sum_true); } int dflag=2; if (EvtPDL::getStdHep(ipar)<0) { dflag=3; for(i=0;igetNDaug();i++){ daugs[i]=EvtPDL::getStdHep(cdaugs[i]); } } /* RS PYTHIA allows to introduce new particles via a call to PYUPDA so no need for this check any more //now lets check to make sure that jetset, lucomp, knows //about all particles! int unknown=0; for(i=0;igetNDaug();i++){ if (pycomp_(&daugs[i])==0) { unknown=1; report(ERROR,"EvtGen") << "Pythia (pycomp) does not " << "know the particle:"<< EvtPDL::name(jetsetdecays[ijetset]->getDaugs()[i])<getParentId())<<" -> "; for(i=0;igetNDaug();i++){ report(ERROR,"") << EvtPDL::name(jetsetdecays[ijetset]->getDaugs()[i])<<" "; } report(ERROR,"")<=0) { // dflag=1; //report(INFO,"EvtGen") << EvtPDL::name(iparname) << " dflag=1 because channel>=0"<=0)){ if (1){ // RS changed format to new PYTHIA one outdec << " "; outdec.width(5); outdec <getArgs()[0]; outdec.width(12); if (fabs(br)<0.000000001) { outdec <<"0.00000"; } else{ outdec <