41using std::resetiosflags;
42using std::setiosflags;
45int EvtJetSet::njetsetdecays = 0;
47int EvtJetSet::ntable = 0;
49int EvtJetSet::ncommand = 0;
50int EvtJetSet::lcommand = 0;
51std::string* EvtJetSet::commands = 0;
58extern void jetset1_(
int*,
double*,
int*,
int*,
int*,
double*,
double*,
double*,
double* );
62extern void lugive_(
const char* cnfgstr,
int length );
77 if ( njetsetdecays == 0 )
84 for ( i = 0; i < njetsetdecays; i++ )
86 if ( jetsetdecays[i] ==
this )
88 jetsetdecays[i] = jetsetdecays[njetsetdecays - 1];
90 if ( njetsetdecays == 0 )
99 report(
ERROR,
"EvtGen" ) <<
"Error in destroying JetSet model!" << endl;
115 report(
ERROR,
"EvtGen" ) <<
"EvtJetSet finds that you are decaying the" << endl
117 <<
" with the JetSet model" << endl
118 <<
" this does not work, please modify decay table." << endl;
119 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
130 if ( ncommand == lcommand )
133 lcommand = 10 + 2 * lcommand;
135 std::string* newcommands =
new std::string[lcommand];
139 for ( i = 0; i < ncommand; i++ ) { newcommands[i] = commands[i]; }
143 commands = newcommands;
146 commands[ncommand] = cmd;
158 if (
lucomp_( &istdheppar ) == 0 )
173 EvtId evtnumstable[100], evtnumparton[100];
174 int stableindex[100], partonindex[100];
182 double px[100], py[100], pz[100], e[100];
190 jetset1_( &ip, &
mp, &ndaugjs, kf, km, px, py, pz, e );
195 for ( i = 0; i < ndaugjs; i++ )
200 report(
ERROR,
"EvtGen" ) <<
"JetSet returned particle:" << kf[i] << endl;
201 report(
ERROR,
"EvtGen" ) <<
"This can not be translated to evt number" << endl;
202 report(
ERROR,
"EvtGen" ) <<
"and the decay will be rejected!" << endl;
203 report(
ERROR,
"EvtGen" ) <<
"The decay was of particle:" << ip << endl;
207 if (
abs( kf[i] ) <= 6 || kf[i] == 21 )
209 partonindex[numparton] = i;
215 stableindex[numstable] = i;
224 if ( px[i] * px[i] + py[i] * py[i] + pz[i] * pz[i] >= e[i] * e[i] )
225 { e[i] = sqrt( px[i] * px[i] + py[i] * py[i] + pz[i] * pz[i] ) + 0.0000000000001; }
227 p4[i].
set( e[i], px[i], py[i], pz[i] );
232 more = ( channel != -1 );
236 }
while ( more && (
count < 10000 ) );
240 report(
INFO,
"EvtGen" ) <<
"Too many loops in EvtJetSet!!!" << endl;
242 for ( i = 0; i < numstable; i++ )
244 report(
INFO,
"EvtGen" ) <<
"Daug(" << i <<
")"
249 if ( numparton == 0 )
254 for ( i = 0; i < numstable; i++ )
256 p->
getDaug( i )->
init( evtnumstable[i], p4[stableindex[i]] );
259 if ( ndaugFound == 0 )
261 report(
ERROR,
"EvtGen" ) <<
"Jetset has failed to do a decay ";
267 fixPolarizations( p );
278 for ( i = 0; i < numparton; i++ ) { p4string += p4[partonindex[i]]; }
282 for ( i = 0; i < numstable; i++ )
284 if ( km[stableindex[i]] == 0 ) {
type[nprimary++] = evtnumstable[i]; }
293 for ( i = 0; i < numparton; i++ ) { p4partons[i] = p4[partonindex[i]]; }
299 for ( i = 0; i < numstable; i++ )
302 if ( km[stableindex[i]] == 0 )
303 { p->
getDaug( nprimary++ )->
init( evtnumstable[i], p4[stableindex[i]] ); }
307 for ( i = 0; i < numstable; i++ )
309 if ( km[stableindex[i]] != 0 ) {
type[nsecond++] = evtnumstable[i]; }
315 -p4string.
get( 3 ) );
318 for ( i = 0; i < numstable; i++ )
320 if ( km[stableindex[i]] != 0 )
322 p4[stableindex[i]] =
boostTo( p4[stableindex[i]], p4stringboost );
332 report(
ERROR,
"EvtGen" ) <<
"Jetset has failed to do a decay ";
338 fixPolarizations( p );
344void EvtJetSet::fixPolarizations(
EvtParticle* p ) {
354 for ( i = 0; i < ndaug; i++ )
362 rho.
Set( 0, 0, 0.5 );
363 rho.
Set( 0, 1, 0.0 );
364 rho.
Set( 0, 2, 0.0 );
366 rho.
Set( 1, 0, 0.0 );
367 rho.
Set( 1, 1, 1.0 );
368 rho.
Set( 1, 2, 0.0 );
370 rho.
Set( 2, 0, 0.0 );
371 rho.
Set( 2, 1, 0.0 );
372 rho.
Set( 2, 2, 0.5 );
376 double alpha = atan2( p4Psi.
get( 2 ), p4Psi.
get( 1 ) );
377 double beta = acos( p4Psi.
get( 3 ) / p4Psi.
d3mag() );
387 if ( njetsetdecays == ntable )
392 for ( i = 0; i < ntable; i++ ) { newjetsetdecays[i] = jetsetdecays[i]; }
393 ntable = 2 * ntable + 10;
394 delete[] jetsetdecays;
395 jetsetdecays = newjetsetdecays;
398 jetsetdecays[njetsetdecays++] = jsdecay;
401void EvtJetSet::WriteJetSetEntryHeader( ofstream& outdec,
int lundkc,
EvtId evtnum,
402 std::string name,
int chg,
int cchg,
int spin2,
403 double mass,
double width,
double maxwidth,
404 double ctau,
int stable,
double rawbrfrsum ) {
414 if ( ctau > 1000000.0 ) ctau = 0.0;
416 strcpy( sname, name.c_str() );
420 while ( sname[i] != 0 ) { i++; }
424 if ( evtnum.
getId() >= 0 )
426 if ( sname[i - 1] ==
'+' || sname[i - 1] ==
'-' )
431 if ( sname[i - 1] ==
'+' || sname[i - 1] ==
'-' )
437 if ( sname[i - 1] ==
'0' && sname[i - 2] !=
'_' &&
438 !( sname[0] ==
'c' && sname[1] ==
'h' ) )
445 if ( i > namelength )
447 for ( j = 1; j < namelength; j++ ) { sname[j] = sname[j + i - namelength]; }
448 sname[namelength] = 0;
453 if ( evtnum.
getId() >= 0 )
462 outdec << setw( 5 ) << lundkc <<
" ";
463 outdec.width( namelength );
464 outdec << setiosflags( ios::left ) << sname << resetiosflags( ios::left );
465 outdec << setw( 3 ) << chg;
466 outdec << setw( 3 ) << cchg;
468 if ( evtnum.
getId() >= 0 )
471 else { outdec << 1; }
473 else { outdec << 0; }
474 outdec.setf( ios::fixed );
475 outdec.precision( 5 );
476 outdec << setw( 12 ) <<
mass;
477 outdec << setw( 12 ) << width;
479 if ( fabs( width ) < 0.0000000001 ) { outdec << 0.0; }
480 else { outdec << maxwidth; }
481 outdec << setw( 14 ) << ctau;
483 if ( evtnum.
getId() >= 0 )
485 if ( ctau > 1.0 || rawbrfrsum < 0.000001 ) { stable = 0; }
492void EvtJetSet::WriteJetSetParticle( ofstream& outdec,
EvtId ipar,
EvtId iparname,
499 for ( ijetset = 0; ijetset < njetsetdecays; ijetset++ )
502 if ( jetsetdecays[ijetset]->
getParentId() == ipar )
503 { br_sum += jetsetdecays[ijetset]->getBranchingFraction(); }
507 { br_sum += jetsetdecays[ijetset]->getBranchingFraction(); }
510 double br_sum_true = br_sum;
512 if ( br_sum < 0.000001 ) br_sum = 1.0;
514 for ( ijetset = 0; ijetset < njetsetdecays; ijetset++ )
516 if ( jetsetdecays[ijetset]->
getParentId() == ipar )
519 double br = jetsetdecays[ijetset]->getBranchingFraction();
524 for ( i = 0; i < 5; i++ )
527 if ( i < jetsetdecays[ijetset]->
getNDaug() )
532 else { daugs[i] = 0; }
539 jetsetdecays[ijetset]->
getNDaug(), cdaugs, jetsetdecays[ijetset]->
getNArg(),
542 if ( jetsetdecays[ijetset]->
getModelName() ==
"JETSET" )
560 for ( i = 0; i < jetsetdecays[ijetset]->getNDaug(); i++ )
567 for ( i = 0; i < jetsetdecays[ijetset]->getNDaug(); i++ )
569 if (
lucomp_( &daugs[i] ) == 0 )
573 <<
"JetSet (lucomp) does not "
574 <<
"know the particle:"
581 if (
lucomp_( &istdheppar ) == 0 )
585 <<
"JetSet (lucomp) does not "
586 <<
"know the particle:" <<
EvtPDL::name( ipar ).c_str() << endl;
591 report(
ERROR,
"EvtGen" ) <<
"Therfore the decay:" << endl;
594 for ( i = 0; i < jetsetdecays[ijetset]->getNDaug(); i++ )
600 report(
ERROR,
"EvtGen" ) <<
"Will not be generated." << endl;
624 outdec << (int)jetsetdecays[ijetset]->
getArgs()[0];
626 if ( fabs( br ) < 0.000000001 ) { outdec <<
"0.00000"; }
627 else { outdec << br / br_sum; }
646void EvtJetSet::MakeJetSetFile(
char* fname ) {
655 outdec.open( fname );
664 for ( lundkc = 1; lundkc <= 500; lundkc++ )
674 ipar = EvtId( iipar, iipar );
678 if ( realId.
isAlias() != 0 )
continue;
686 WriteJetSetParticle( outdec, ipar, ipar, first );
690 if ( ipar2 != ipar ) { WriteJetSetParticle( outdec, ipar2, ipar, first ); }
705 WriteJetSetEntryHeader( outdec, lundkc, EvtId( -1, -1 ),
" ", 0, 0, 0,
715 static int first = 1;
722 report(
INFO,
"EvtGen" ) <<
"Will initialize JetSet." << endl;
726 char hostBuffer[100];
728 if ( gethostname( hostBuffer, 100 ) != 0 )
730 report(
ERROR,
"EvtGen" ) <<
" couldn't get hostname." << endl;
731 strncpy( hostBuffer,
"hostnameNotFound", 100 );
736 int thePid = getpid();
738 if (
sprintf( pid,
"%d", thePid ) == 0 )
740 report(
ERROR,
"EvtGen" ) <<
" couldn't get process ID." << endl;
741 strncpy( pid,
"666", 100 );
744 strcpy( fname,
"jet.d-" );
745 strcat( fname, hostBuffer );
746 strcat( fname,
"-" );
747 strcat( fname, pid );
749 MakeJetSetFile( fname );
752 if ( 0 == getenv(
"EVTSAVEJETD" ) )
755 strcpy( delcmd,
"rm -f " );
756 strcat( delcmd, fname );
762 for ( i = 0; i < ncommand; i++ )
763 {
lugive_( commands[i].c_str(), strlen( commands[i].c_str() ) ); }
765 report(
INFO,
"EvtGen" ) <<
"Done initializing JetSet." << endl;
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
EvtDecayBase * EvtDecayBasePtr
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 *)
EvtDecayBase * EvtDecayBasePtr
DOUBLE_PRECISION count[3]
ostream & report(Severity severity, const char *facility)
std::string * getArgsStr()
std::string getModelName()
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)