42using std::resetiosflags;
43using std::setiosflags;
47int EvtJetSet::njetsetdecays=0;
49int EvtJetSet::ntable=0;
51int EvtJetSet::ncommand=0;
52int EvtJetSet::lcommand=0;
53std::string* EvtJetSet::commands=0;
61 extern void jetset1_(
int *,
double *,
int *,
int *,
int *,
62 double *,
double *,
double *,
double *);
66 extern void lugive_(
const char *cnfgstr,
int length);
84 if (njetsetdecays==0) {
90 for(i=0;i<njetsetdecays;i++){
91 if (jetsetdecays[i]==
this){
92 jetsetdecays[i]=jetsetdecays[njetsetdecays-1];
94 if (njetsetdecays==0) {
102 report(
ERROR,
"EvtGen") <<
"Error in destroying JetSet model!"<<endl;
134 report(
ERROR,
"EvtGen") <<
"EvtJetSet finds that you are decaying the"<<endl
135 <<
" aliased particle "
137 <<
" with the JetSet model"<<endl
138 <<
" this does not work, please modify decay table."
140 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
152 return std::string(
"JetSetPar");
159 if (ncommand==lcommand){
161 lcommand=10+2*lcommand;
163 std::string* newcommands=
new std::string[lcommand];
167 for(i=0;i<ncommand;i++){
168 newcommands[i]=commands[i];
173 commands=newcommands;
177 commands[ncommand]=cmd;
207 EvtId evtnumstable[100],evtnumparton[100];
208 int stableindex[100],partonindex[100];
216 double px[100],py[100],pz[100],e[100];
230 for(i=0;i<ndaugjs;i++){
233 report(
ERROR,
"EvtGen") <<
"JetSet returned particle:"<<kf[i]<<endl;
234 report(
ERROR,
"EvtGen") <<
"This can not be translated to evt number"<<endl;
235 report(
ERROR,
"EvtGen") <<
"and the decay will be rejected!"<<endl;
236 report(
ERROR,
"EvtGen") <<
"The decay was of particle:"<<ip<<endl;
241 if (
abs(kf[i])<=6||kf[i]==21){
242 partonindex[numparton]=i;
247 stableindex[numstable]=i;
257 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
259 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000000001;
263 p4[i].
set(e[i],px[i],py[i],pz[i]);
278 }
while( more && (
count<10000) );
281 report(
INFO,
"EvtGen") <<
"Too many loops in EvtJetSet!!!"<<endl;
283 for(i=0;i<numstable;i++){
295 for(i=0;i<numstable;i++){
296 p->
getDaug(i)->
init(evtnumstable[i],p4[stableindex[i]]);
299 if ( ndaugFound == 0 ) {
300 report(
ERROR,
"EvtGen") <<
"Jetset has failed to do a decay ";
316 for(i=0;i<numparton;i++){
317 p4string+=p4[partonindex[i]];
322 for(i=0;i<numstable;i++){
323 if (km[stableindex[i]]==0){
324 type[nprimary++]=evtnumstable[i];
334 for(i=0;i<numparton;i++){
335 p4partons[i]=p4[partonindex[i]];
344 for(i=0;i<numstable;i++){
346 if (km[stableindex[i]]==0){
347 p->
getDaug(nprimary++)->
init(evtnumstable[i],p4[stableindex[i]]);
353 for(i=0;i<numstable;i++){
354 if (km[stableindex[i]]!=0){
355 type[nsecond++]=evtnumstable[i];
363 -p4string.
get(2),-p4string.
get(3));
366 for(i=0;i<numstable;i++){
367 if (km[stableindex[i]]!=0){
368 p4[stableindex[i]]=
boostTo(p4[stableindex[i]],p4stringboost);
376 if ( nsecond == 0 ) {
377 report(
ERROR,
"EvtGen") <<
"Jetset has failed to do a decay ";
400 for(i=0;i<ndaug;i++){
421 double beta=acos(p4Psi.
get(3)/p4Psi.
d3mag());
434 if (njetsetdecays==ntable){
438 for(i=0;i<ntable;i++){
439 newjetsetdecays[i]=jetsetdecays[i];
442 delete [] jetsetdecays;
443 jetsetdecays=newjetsetdecays;
446 jetsetdecays[njetsetdecays++]=jsdecay;
453void EvtJetSet::WriteJetSetEntryHeader(ofstream &outdec,
int lundkc,
454 EvtId evtnum,std::string name,
455 int chg,
int cchg,
int spin2,
double mass,
456 double width,
double maxwidth,
double ctau,
457 int stable,
double rawbrfrsum){
468 if (ctau>1000000.0) ctau=0.0;
470 strcpy(sname,name.c_str());
480 if(evtnum.
getId()>=0) {
481 if (sname[i-1]==
'+'||sname[i-1]==
'-'){
485 if (sname[i-1]==
'+'||sname[i-1]==
'-'){
490 if (sname[i-1]==
'0' && sname[i-2]!=
'_' && !(sname[0]==
'c' && sname[1]==
'h')){
497 for(j=1;j<namelength;j++){
498 sname[j]=sname[j+i-namelength];
505 if(evtnum.
getId()>=0) {
513 outdec << setw(5) << lundkc <<
" ";
514 outdec.width(namelength);
515 outdec << setiosflags(ios::left) << sname << resetiosflags(ios::left);
516 outdec << setw(3) << chg;
517 outdec << setw(3) << cchg;
519 if (evtnum.
getId()>=0) {
530 outdec.setf(ios::fixed);
532 outdec << setw(12) <<
mass;
533 outdec << setw(12) << width;
535 if (fabs(width)<0.0000000001) {
541 outdec << setw(14) << ctau;
543 if (evtnum.
getId()>=0) {
544 if (ctau>1.0 || rawbrfrsum<0.000001) {
554void EvtJetSet::WriteJetSetParticle(ofstream &outdec,
EvtId ipar,
555 EvtId iparname,
int &first){
561 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
575 double br_sum_true=br_sum;
577 if (br_sum<0.000001) br_sum=1.0;
579 for(ijetset=0;ijetset<njetsetdecays;ijetset++){
589 if(i<jetsetdecays[ijetset]->
getNDaug()){
591 jetsetdecays[ijetset]->
getDaugs()[i]);
605 jetsetdecays[ijetset]->
getNArg(),
612 WriteJetSetEntryHeader(outdec,
627 for(i=0;i<jetsetdecays[ijetset]->
getNDaug();i++){
636 for(i=0;i<jetsetdecays[ijetset]->
getNDaug();i++){
639 report(
ERROR,
"EvtGen") <<
"JetSet (lucomp) does not "
640 <<
"know the particle:"<<
649 report(
ERROR,
"EvtGen") <<
"JetSet (lucomp) does not "
650 <<
"know the particle:"<<
657 report(
ERROR,
"EvtGen") <<
"Therfore the decay:"<<endl;
659 for(i=0;i<jetsetdecays[ijetset]->
getNDaug();i++){
663 report(
ERROR,
"EvtGen")<<
"Will not be generated."<<endl;
685 outdec <<(int)jetsetdecays[ijetset]->
getArgs()[0];
687 if (fabs(br)<0.000000001) {
712void EvtJetSet::MakeJetSetFile(
char* fname){
730 for(lundkc=1;lundkc<=500;lundkc++){
738 ipar=
EvtId(iipar,iipar);
742 if ( realId.
isAlias() != 0 )
continue;
749 WriteJetSetParticle(outdec,ipar,ipar,first);
756 WriteJetSetParticle(outdec,ipar2,ipar,first);
760 WriteJetSetEntryHeader(outdec,
775 WriteJetSetEntryHeader(outdec,
776 lundkc,
EvtId(-1,-1),
" ",
793 report(
INFO,
"EvtGen") <<
"Will initialize JetSet."<<endl;
797 char hostBuffer[100];
799 if ( gethostname( hostBuffer, 100 ) != 0 ){
800 report(
ERROR,
"EvtGen") <<
" couldn't get hostname." << endl;
801 strncpy( hostBuffer,
"hostnameNotFound", 100 );
808 if ( sprintf( pid,
"%d", thePid ) == 0 ){
809 report(
ERROR,
"EvtGen") <<
" couldn't get process ID." << endl;
810 strncpy( pid,
"666", 100 );
813 strcpy(fname,
"jet.d-");
814 strcat(fname,hostBuffer);
818 MakeJetSetFile(fname);
821 if (0==getenv(
"EVTSAVEJETD")){
823 strcpy(delcmd,
"rm -f ");
824 strcat(delcmd,fname);
830 for(i=0;i<ncommand;i++){
831 lugive_(commands[i].c_str(),strlen(commands[i].c_str()));
835 report(
INFO,
"EvtGen") <<
"Done initializing JetSet."<<endl;
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void lugive_(const char *cnfgstr, int length)
void evtjetsetinit_(char *fname, int len)
void jetset1_(int *, double *, int *, int *, int *, double *, double *, double *, double *)
DOUBLE_PRECISION count[3]
ostream & report(Severity severity, const char *facility)
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)
void command(std::string cmd)
void decay(EvtParticle *p)
void getName(std::string &name)
std::string commandName()
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)
void Set(int i, int j, const EvtComplex &rhoij)
void set(int i, double d)