43using std::resetiosflags;
44using std::setiosflags;
48int EvtLunda::nlundadecays=0;
50int EvtLunda::ntable=0;
52int EvtLunda::ncommand=0;
53int EvtLunda::lcommand=0;
54std::string* EvtLunda::commands=0;
59 extern void lundar_(
int *,
int *,
float *,
int *,
int *,
int *,
60 double *,
double *,
double *,
double *);
68 extern void lugive0_(
const char *cnfgstr,
int length);
99 if (nlundadecays==0) {
105 for(i=0;i<nlundadecays;i++){
106 if (lundadecays[i]==
this){
107 lundadecays[i]=lundadecays[nlundadecays-1];
109 if (nlundadecays==0) {
117 report(
ERROR,
"EvtGen") <<
"Error in destroying Lunda model!"<<endl;
145 std::string strpdg=getenv(
"BESEVTGENROOT");
146 strpdg +=
"/share/r_pdg.dat";
148 std::cout<<
"mypdg= "<<strpdg<<std::endl;
150 if(
getNArg()>2){std::cout<<
"Parameter can be 1 or 2, You have "<<
getNArg()<<std::endl; ::abort();}
154 report(
ERROR,
"EvtGen") <<
"EvtLunda finds that you are decaying the"<<endl
155 <<
" aliased particle "
157 <<
" with the Lunda model"<<endl
158 <<
" this does not work, please modify decay table."
160 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
172 return std::string(
"LundaPar");
178 if (ncommand==lcommand){
180 lcommand=10+2*lcommand;
182 std::string* newcommands=
new std::string[lcommand];
186 for(i=0;i<ncommand;i++){
187 newcommands[i]=commands[i];
192 commands=newcommands;
196 commands[ncommand]=cmd;
206 static int iniflag=1;
238 EvtId evtnumstable[100],evtnumparton[100];
239 int stableindex[100],partonindex[100];
248 static double px[4000],py[4000],pz[4000],e[4000];
249 if (iniflag==1)
lundar_(&isr,&iniflag,&xmp,&ndaugjs,kf,km,px,py,pz,e);
261 lundar_(&isr,&iniflag,&xmp,&ndaugjs,kf,km,px,py,pz,e);
264 if(mtg)std::cout<<
"checktag_.decaytag="<<
checktag_.decaytag<<std::endl;
278 for(i=0;i<ndaugjs;i++){
279 if (
abs(kf[i])==11 || kf[i]==92 || kf[i]==22)
continue;
282 report(
ERROR,
"EvtGen") <<
"Lunda returned particle:"<<kf[i]<<endl;
283 report(
ERROR,
"EvtGen") <<
"This can not be translated to evt number"<<endl;
284 report(
ERROR,
"EvtGen") <<
"and the decay will be rejected!"<<endl;
285 report(
ERROR,
"EvtGen") <<
"The decay was of particle:"<<ip<<endl;
287 std::cout<<
"xmp= "<<xmp<<std::endl;
292 if (
abs(kf[i])<=6||kf[i]==21){
293 partonindex[numparton]=i;
298 stableindex[numstable]=i;
308 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
310 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000001;
314 p4[i].
set(e[i],px[i],py[i],pz[i]);
325 if(
abs(esum-xmp)>0.001 ){
326 std::cout<<
"Unexpected final states from Lunda with total energy "<<esum<<
" unequal to "<<xmp<<std::endl;
328 std::cout<<
"xmp= "<<xmp<<std::endl;
333 }
while( more && (
count<10000) && mtg );
337 report(
INFO,
"EvtGen") <<
"Too many loops in EvtLunda!!!"<<endl;
339 for(i=0;i<numstable;i++){
351 for(i=0;i<numstable;i++){
352 p->
getDaug(i)->
init(evtnumstable[i],p4[stableindex[i]]);
355 if ( ndaugFound == 0 ) {
356 report(
ERROR,
"EvtGen") <<
"Lunda has failed to do a decay ";
374 for(i=0;i<numparton;i++){
375 p4string+=p4[partonindex[i]];
380 for(i=0;i<numstable;i++){
381 if (km[stableindex[i]]==0){
382 type[nprimary++]=evtnumstable[i];
392 for(i=0;i<numparton;i++){
393 p4partons[i]=p4[partonindex[i]];
402 for(i=0;i<numstable;i++){
404 if (km[stableindex[i]]==0){
405 p->
getDaug(nprimary++)->
init(evtnumstable[i],p4[stableindex[i]]);
411 for(i=0;i<numstable;i++){
412 if (km[stableindex[i]]!=0){
413 type[nsecond++]=evtnumstable[i];
421 -p4string.
get(2),-p4string.
get(3));
424 for(i=0;i<numstable;i++){
425 if (km[stableindex[i]]!=0){
426 p4[stableindex[i]]=
boostTo(p4[stableindex[i]],p4stringboost);
434 if ( nsecond == 0 ) {
435 report(
ERROR,
"EvtGen") <<
"Jetset has failed to do a decay ";
458 for(i=0;i<ndaug;i++){
479 double beta=acos(p4Psi.
get(3)/p4Psi.
d3mag());
492 if (nlundadecays==ntable){
496 for(i=0;i<ntable;i++){
497 newlundadecays[i]=lundadecays[i];
500 delete [] lundadecays;
501 lundadecays=newlundadecays;
504 lundadecays[nlundadecays++]=jsdecay;
517 for(
int i=0;i<ncommand;i++)
518 lugive0_(commands[i].c_str(),strlen(commands[i].c_str()));
533 for(
int i=0;i< _ndaugs;i++){
539 if(totMass>p->
mass())
goto checkA;
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void lundar_(int *, int *, float *, int *, int *, int *, double *, double *, double *, double *)
void lugive0_(const char *cnfgstr, int length)
DOUBLE_PRECISION count[2]
ostream & report(Severity severity, const char *facility)
void setDaughterSpinDensity(int daughter)
static int inChannelList(EvtId parent, int ndaug, EvtId *daugs)
void LundaInit(int dummy)
std::string commandName()
void decay(EvtParticle *p)
void ExclusiveDecay(EvtParticle *p)
void command(std::string cmd)
void getName(std::string &name)
static int getStdHep(EvtId id)
static EvtId evtIdFromStdHep(int stdhep)
static std::string name(EvtId i)
static double getMass(EvtId i)
static EvtId getId(const std::string &name)
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)
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
void Set(int i, int j, const EvtComplex &rhoij)
void set(int i, double d)