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;
58 double *,
double *,
double *,
double *);
71 double *,
double *,
double *,
double *);
101 if (njetsetdecays==0) {
107 for(i=0;i<njetsetdecays;i++){
108 if (jetsetdecays[i]==
this){
109 jetsetdecays[i]=jetsetdecays[njetsetdecays-1];
111 if (njetsetdecays==0) {
119 report(
ERROR,
"EvtGen") <<
"Error in destroying Pythia model!"<<endl;
151 report(
ERROR,
"EvtGen") <<
"EvtPythia finds that you are decaying the"<<endl
152 <<
" aliased particle "
154 <<
" with the Pythia model"<<endl
155 <<
" this does not work, please modify decay table."
157 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
169 return std::string(
"JetSetPar");
176 if (ncommand==lcommand){
178 lcommand=10+2*lcommand;
180 std::string* newcommands=
new std::string[lcommand];
184 for(i=0;i<ncommand;i++){
185 newcommands[i]=commands[i];
190 commands=newcommands;
194 commands[ncommand]=cmd;
201 double *px,
double *py,
double *pz,
double *e)
231 EvtId evtnumstable[100],evtnumparton[100];
232 int stableindex[100],partonindex[100];
240 double px[100],py[100],pz[100],e[100];
253 for(i=0;i<ndaugjs;i++){
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;
265 if (
abs(kf[i])<=6||kf[i]==21){
266 partonindex[numparton]=i;
271 stableindex[numstable]=i;
281 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
283 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000000001;
287 p4[i].
set(e[i],px[i],py[i],pz[i]);
299 }
while( more && (count<10000) );
303 report(
INFO,
"EvtGen") <<
"Too many loops in EvtPythia!!!"<<endl;
305 for(i=0;i<numstable;i++){
317 for(i=0;i<numstable;i++){
318 p->
getDaug(i)->
init(evtnumstable[i],p4[stableindex[i]]);
332 for(i=0;i<numparton;i++){
333 p4string+=p4[partonindex[i]];
338 for(i=0;i<numstable;i++){
339 if (km[stableindex[i]]==0){
340 type[nprimary++]=evtnumstable[i];
350 for(i=0;i<numparton;i++){
351 p4partons[i]=p4[partonindex[i]];
360 for(i=0;i<numstable;i++){
362 if (km[stableindex[i]]==0){
363 p->
getDaug(nprimary++)->
init(evtnumstable[i],p4[stableindex[i]]);
369 for(i=0;i<numstable;i++){
370 if (km[stableindex[i]]!=0){
371 type[nsecond++]=evtnumstable[i];
379 for(i=0;i<numstable;i++){
380 if (km[stableindex[i]]!=0){
381 p4[stableindex[i]]=
boostTo(p4[stableindex[i]],p4string);
407 for(i=0;i<ndaug;i++){
428 double beta=acos(p4Psi.
get(3)/p4Psi.
d3mag());
441 if (njetsetdecays==ntable){
445 for(i=0;i<ntable;i++){
446 newjetsetdecays[i]=jetsetdecays[i];
449 delete [] jetsetdecays;
450 jetsetdecays=newjetsetdecays;
453 jetsetdecays[njetsetdecays++]=jsdecay;
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){
476 if (ctau>1000000.0) ctau=0.0;
478 strcpy(sname,name.c_str());
488 if(evtnum.
getId()>=0) {
489 if (sname[i-1]==
'+'||sname[i-1]==
'-'){
493 if (sname[i-1]==
'+'||sname[i-1]==
'-'){
498 if (sname[i-1]==
'0' && sname[i-2]!=
'_' && !(sname[0]==
'c' && sname[1]==
'h')){
505 for(j=1;j<namelength;j++){
506 sname[j]=sname[j+i-namelength];
512 for(j=0;j<=namelength;j++)
515 while (ccsname[i]!=
' '){
517 if(ccsname[i]==0)
break;
527 if(evtnum.
getId()>=0) {
536 outdec <<
" " << setw(9) << lundkc;
538 outdec.width(namelength);
539 outdec << setiosflags(ios::left)
545 outdec.width(namelength);
552 outdec << resetiosflags(ios::left);
553 outdec << setw(3) << chg;
554 outdec << setw(3) << cchg;
556 if (evtnum.
getId()>=0) {
567 outdec.setf(ios::fixed,ios::floatfield);
569 outdec << setw(12) <<
mass;
570 outdec.setf(ios::fixed,ios::floatfield);
571 outdec << setw(12) << width;
572 outdec.setf(ios::fixed,ios::floatfield);
574 if (fabs(width)<0.0000000001) {
581 outdec.setf(ios::scientific,ios::floatfield);
585 if (evtnum.
getId()>=0) {
586 if (ctau>1.0 || rawbrfrsum<0.000001) {
601void EvtPythia::WritePythiaParticle(ofstream &outdec,
EvtId ipar,
602 EvtId iparname,
int &first){
608 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
622 double br_sum_true=br_sum;
624 if (br_sum<0.000001) br_sum=1.0;
626 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
636 if(i<jetsetdecays[ijetset]->
getNDaug()){
638 jetsetdecays[ijetset]->
getDaugs()[i]);
652 jetsetdecays[ijetset]->
getNArg(),
659 WritePythiaEntryHeader(outdec,
675 for(i=0;i<jetsetdecays[ijetset]->
getNDaug();i++){
739 outdec <<(int)jetsetdecays[ijetset]->
getArgs()[0];
741 if (fabs(br)<0.000000001) {
766EvtPythia::diquark(
int ID)
804EvtPythia::NominalMass(
int ID)
929void EvtPythia::MakePythiaFile(
char* fname){
948 for(lundkc=1;lundkc<500;lundkc++){
956 ipar=
EvtId(iipar,iipar);
960 if ( realId.
isAlias() != 0 )
continue;
974 WritePythiaParticle(outdec,ipar,ipar,first);
981 WritePythiaParticle(outdec,ipar2,ipar,first);
985 WritePythiaEntryHeader(outdec,
1003 ipar=
EvtId(iipar,iipar);
1011 WritePythiaParticle(outdec,ipar,ipar,first);
1018 WritePythiaParticle(outdec,ipar2,ipar,first);
1022 WritePythiaEntryHeader(outdec,
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()));
1059 char hostBuffer[100];
1061 if ( gethostname( hostBuffer, 100 ) != 0 ){
1062 report(
ERROR,
"EvtGen") <<
" couldn't get hostname." << endl;
1063 strncpy( hostBuffer,
"hostnameNotFound", 100 );
1068 int thePid=getpid();
1070 if ( sprintf( pid,
"%d", thePid ) == 0 ){
1071 report(
ERROR,
"EvtGen") <<
" couldn't get process ID." << endl;
1072 strncpy( pid,
"666", 100 );
1075 strcpy(fname,
"jet.d-");
1076 strcat(fname,hostBuffer);
1080 MakePythiaFile(fname);
1084 if (0==getenv(
"EVTSAVEJETD")){
1086 strcpy(delcmd,
"rm -f ");
1087 strcat(delcmd,fname);
1091 report(
INFO,
"EvtGen") <<
"Done initializing Pythia."<<endl;
double abs(const EvtComplex &c)
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
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)