//=============================================================================
// decay particle
//=============================================================================
void EvtBToDDalitzCPK::decay( EvtParticle * p ) 
{
  if ( _flag == 1 ) {
    // PHSP
    p -> initializePhaseSpace( getNDaug() , getDaugs() ) ;
    vertex ( 0. ) ;
  }
  else if ( _flag == 2 ) {
    // SVS
    p->initializePhaseSpace(getNDaug(),getDaugs());
    
    EvtParticle *v;
    v = p->getDaug(0);
    double massv = v->mass();
    EvtVector4R momv = v->getP4();
    EvtVector4R moms = p->getDaug(1)->getP4();
    double m_parent = p->mass();
    EvtVector4R p4_parent = momv+moms;
    
    double norm=massv/(momv.d3mag()*m_parent);
    p4_parent = norm*p4_parent;
    vertex(0,p4_parent*(v->epsParent(0)));
    vertex(1,p4_parent*(v->epsParent(1)));
    vertex(2,p4_parent*(v->epsParent(2)));
  }
}
void EvtTauVectornu::decay(EvtParticle *p){

  static EvtId TAUM=EvtPDL::getId("tau-");
  p->initializePhaseSpace(getNDaug(),getDaugs());

  EvtParticle *v, *nut;
  v=p->getDaug(0);
  nut=p->getDaug(1);
  double mvec = v->mass();
  EvtVector4C tau1, tau2;

  if (p->getId()==TAUM) {
    tau1=EvtLeptonVACurrent(nut->spParentNeutrino(),p->sp(0));
    tau2=EvtLeptonVACurrent(nut->spParentNeutrino(),p->sp(1));
  }
  else{
    tau1=EvtLeptonVACurrent(p->sp(0),nut->spParentNeutrino());
    tau2=EvtLeptonVACurrent(p->sp(1),nut->spParentNeutrino());
  }

  double norm=mvec*sqrt(mvec);
  
  vertex(0,0,norm*tau1*(v->epsParent(0).conj()));
  vertex(0,1,norm*tau1*(v->epsParent(1).conj()));
  vertex(0,2,norm*tau1*(v->epsParent(2).conj()));
  vertex(1,0,norm*tau2*(v->epsParent(0).conj()));
  vertex(1,1,norm*tau2*(v->epsParent(1).conj()));
  vertex(1,2,norm*tau2*(v->epsParent(2).conj()));
  
  return;

}
Example #3
0
void EvtPropSLPole::decay( EvtParticle *p ){

  if(! _isProbMaxSet){

     EvtId parnum,mesnum,lnum,nunum;

     parnum = getParentId();
     mesnum = getDaug(0);
     lnum = getDaug(1);
     nunum = getDaug(2);

     double mymaxprob = calcMaxProb(parnum,mesnum,
                           lnum,nunum,SLPoleffmodel);

     setProbMax(mymaxprob);

     _isProbMaxSet = true;

  }

  double minKstMass = EvtPDL::getMinMass(p->getDaug(0)->getId());
  double maxKstMass = EvtPDL::getMaxMass(p->getDaug(0)->getId());

  EvtIntervalFlatPdf flat(minKstMass, maxKstMass);
  EvtPdfGen<EvtPoint1D> gen(flat);
  EvtPoint1D point = gen(); 
 
  double massKst = point.value();

  p->getDaug(0)->setMass(massKst);
  p->initializePhaseSpace(getNDaug(),getDaugs());

//  EvtVector4R p4meson = p->getDaug(0)->getP4();

  calcamp->CalcAmp(p,_amp2,SLPoleffmodel); 

  EvtParticle *mesonPart = p->getDaug(0);
  
  double meson_BWAmp = calBreitWigner(mesonPart, point);  

  int list[2];
  list[0]=0; list[1]=0;
  _amp2.vertex(0,0,_amp2.getAmp(list)*meson_BWAmp);
  list[0]=0; list[1]=1;
  _amp2.vertex(0,1,_amp2.getAmp(list)*meson_BWAmp);

  list[0]=1; list[1]=0;
  _amp2.vertex(1,0,_amp2.getAmp(list)*meson_BWAmp);
  list[0]=1; list[1]=1;
  _amp2.vertex(1,1,_amp2.getAmp(list)*meson_BWAmp);

  list[0]=2; list[1]=0;
  _amp2.vertex(2,0,_amp2.getAmp(list)*meson_BWAmp);
  list[0]=2; list[1]=1;
  _amp2.vertex(2,1,_amp2.getAmp(list)*meson_BWAmp);
     
  
  return;

}
Example #4
0
void EvtbsToLLLL::decay( EvtParticle *p ){
  
  double         mu = getArg(0);        // the scale parameter
  int            Nf = (int) getArg(1);  // number of "effective" flavors
  int      res_swch = (int) getArg(2);  // resonant switching parametr
  int           ias = (int) getArg(3);  // switching parametr for \alpha_s(M_Z)
  double      CKM_A = getArg(4); 
  double CKM_lambda = getArg(5); 
  double CKM_barrho = getArg(6); 
  double CKM_bareta = getArg(7);

  p->initializePhaseSpace(getNDaug(),getDaugs());

  _calcamp->CalcAmp(p,_amp2, _mntffmodel, _wilscoeff, mu, Nf, res_swch, ias, 
                    CKM_A,CKM_lambda,CKM_barrho,CKM_bareta);

//  EvtGenReport(NOTICE,"EvtGen") << "\n The function EvtbTosllMSExt::decay(...) passed with arguments:"
//                        << "\n mu = " << mu << " Nf =" << Nf 
//                        << " res_swch = " << res_swch 
//                        << " ias = " << ias 
//                        << " CKM_A = " << CKM_A
//                        << " CKM_lambda = " << CKM_lambda
//                        << " CKM_barrho = " << CKM_barrho
//                        << " CKM_bareta = " << CKM_bareta 
//                        << " ReA7 = " << ReA7
//                        << " ImA7 = " << ImA7
//                        << " ReA10 = " << ReA10
//                        << " ImA10 = " << ImA10 << std::endl;

}
Example #5
0
void EvtISGW2::decay( EvtParticle *p ) {

    p->initializePhaseSpace(getNDaug(),getDaugs());

    calcamp->CalcAmp(p,_amp2,isgw2ffmodel);

}
Example #6
0
void EvtB2MuMuMuNu::decay( EvtParticle *p ){

  p->initializePhaseSpace(getNDaug(),getDaugs());

  _calcamp->CalcAmp(p,_amp2, _msffmodel);

}
Example #7
0
void EvtVSSMix::decay( EvtParticle *p ){

  //added by Lange Jan4,2000
  static EvtId B0=EvtPDL::getId("B0");
  static EvtId B0B=EvtPDL::getId("anti-B0");

  p->initializePhaseSpace(getNDaug(),getDaugs());
  EvtParticle *s1,*s2;
  s1 = p->getDaug(0);
  s2 = p->getDaug(1);
  EvtVector4R s1mom = s1->getP4();

  double t1,t2,dm;

  s1->setLifetime();
  s2->setLifetime();

  t1=s1->getLifetime();
  t2=s2->getLifetime();

  //dm should probably be a parameter to this model.

  dm=getArg(0)/EvtConst::c;

  EvtId d1,d2;

  d1=s1->getId();
  d2=s2->getId();

  double mix_amp=0.;
  if (d1==B0&&d2==B0B) mix_amp=cos(0.5*dm*(t1-t2));
  if (d1==B0B&&d2==B0) mix_amp=cos(0.5*dm*(t1-t2));
  if (d1==B0&&d2==B0) mix_amp=sin(0.5*dm*(t1-t2));
  if (d1==B0B&&d2==B0B) mix_amp=sin(0.5*dm*(t1-t2));

  double norm=1.0/s1mom.d3mag();

  vertex(0,norm*mix_amp*s1mom*(p->eps(0)));
  vertex(1,norm*mix_amp*s1mom*(p->eps(1)));
  vertex(2,norm*mix_amp*s1mom*(p->eps(2)));

  return ;
}
Example #8
0
void EvtEtaDalitz::decay( EvtParticle *p){

  p->initializePhaseSpace(getNDaug(),getDaugs());

  EvtVector4R mompi0 = p->getDaug(2)->getP4();
  double masspip = p->getDaug(0)->mass();
  double masspim = p->getDaug(1)->mass();
  double masspi0 = p->getDaug(2)->mass();
  double m_eta = p->mass();

  double y;

  //The decay amplitude coems from Layter et al PRD 7 2565 (1973).

  y=(mompi0.get(0)-masspi0)*(3.0/(m_eta-masspip-masspim-masspi0))-1.0;

  EvtComplex amp(sqrt(1.0-1.07*y),0.0);

  vertex(amp);

  return ;
   
}
Example #9
0
void EvtSSSCP::decay( EvtParticle *p ){

  //added by Lange Jan4,2000
  static EvtId B0=EvtPDL::getId("B0");
  static EvtId B0B=EvtPDL::getId("anti-B0");

  double t;
  EvtId other_b;

  EvtCPUtil::getInstance()->OtherB(p,t,other_b,0.5);

  p->initializePhaseSpace(getNDaug(),getDaugs());


  EvtComplex amp;

  EvtComplex A,Abar;
  
  A=EvtComplex(getArg(3)*cos(getArg(4)),getArg(3)*sin(getArg(4)));
  Abar=EvtComplex(getArg(5)*cos(getArg(6)),getArg(5)*sin(getArg(6)));
   
  if (other_b==B0B){
    amp=A*cos(getArg(1)*t/(2*EvtConst::c))+
      EvtComplex(cos(-2.0*getArg(0)),sin(-2.0*getArg(0)))*
      getArg(2)*EvtComplex(0.0,1.0)*Abar*sin(getArg(1)*t/(2*EvtConst::c));
  }
  if (other_b==B0){
    amp=A*EvtComplex(cos(2.0*getArg(0)),sin(2.0*getArg(0)))*
      EvtComplex(0.0,1.0)*sin(getArg(1)*t/(2*EvtConst::c))+       
      getArg(2)*Abar*cos(getArg(1)*t/(2*EvtConst::c));
  }
  
  vertex(amp);
  
  return ;
}
Example #10
0
void EvtVVP::decay(EvtParticle *p){

  p->initializePhaseSpace(getNDaug(),getDaugs());

  EvtParticle *v,*ph;

  v = p->getDaug(0);
  ph = p->getDaug(1);

  EvtVector3C epsp[3];
  EvtVector3C epsv[3];
  EvtVector3C epsph[2];

  epsp[0]=p->eps(0).vec();
  epsp[1]=p->eps(1).vec();
  epsp[2]=p->eps(2).vec();

  epsv[0]=v->eps(0).vec().conj();
  epsv[1]=v->eps(1).vec().conj();
  epsv[2]=v->eps(2).vec().conj();

  epsph[0]=ph->epsParentPhoton(0).vec().conj();
  epsph[1]=ph->epsParentPhoton(1).vec().conj();

  int i,j,k;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      for(k=0;k<2;k++){
	vertex(i,j,k,epsp[i].cross(epsv[j])*epsph[k]);
      }
    }
  }

  return;

}
Example #11
0
void EvtD0gammaDalitz::decay( EvtParticle* part )
{
  // Check if the D is from a B+- -> D0 K+- decay with the appropriate model.
  EvtParticle* parent = part->getParent(); // If there are no mistakes, should be B+ or B-.
  if (parent != 0 && EvtDecayTable::getInstance()->getDecayFunc( parent )->getName() == "BTODDALITZCPK" )
  {
    EvtId parId = parent->getId();
    if ( ( parId == _BP ) || ( parId == _BM ) ||
         ( parId == _B0 ) || ( parId == _B0B) )
    {
      _bFlavor = parId;
    }
    else
    {
      reportInvalidAndExit();
    }
  }
  else
  {
    reportInvalidAndExit();
  }

  // Read the D decay parameters from the B decay model.
  // Gamma angle in rad.
  double gamma = EvtDecayTable::getInstance()->getDecayFunc( parent )->getArg( 0 );
  // Strong phase in rad.
  double delta = EvtDecayTable::getInstance()->getDecayFunc( parent )->getArg( 1 );
  // Ratio between B->D0K and B->D0barK
  double rB    = EvtDecayTable::getInstance()->getDecayFunc( parent )->getArg( 2 );

  // Same structure for all of these decays.
  part->initializePhaseSpace( getNDaug(), getDaugs() );
  EvtVector4R pA = part->getDaug( _d1 )->getP4();
  EvtVector4R pB = part->getDaug( _d2 )->getP4();
  EvtVector4R pC = part->getDaug( _d3 )->getP4();

  // Squared invariant masses.
  double mSqAB = ( pA + pB ).mass2();
  double mSqAC = ( pA + pC ).mass2();
  double mSqBC = ( pB + pC ).mass2();

  EvtComplex amp( 1.0, 0.0 );

  // Direct and conjugated amplitudes.
  EvtComplex ampDir;
  EvtComplex ampCnj;

  if ( _isKsPiPi )
  {
    // Direct and conjugated Dalitz points.
    EvtDalitzPoint pointDir( _mKs, _mPi, _mPi, mSqAB, mSqBC, mSqAC );
    EvtDalitzPoint pointCnj( _mKs, _mPi, _mPi, mSqAC, mSqBC, mSqAB );

    // Direct and conjugated amplitudes.
    ampDir = dalitzKsPiPi( pointDir );
    ampCnj = dalitzKsPiPi( pointCnj );
  }
  else
  {
    // Direct and conjugated Dalitz points.
    EvtDalitzPoint pointDir( _mKs, _mK, _mK, mSqAB, mSqBC, mSqAC );
    EvtDalitzPoint pointCnj( _mKs, _mK, _mK, mSqAC, mSqBC, mSqAB );

    // Direct and conjugated amplitudes.
    ampDir = dalitzKsKK( pointDir );
    ampCnj = dalitzKsKK( pointCnj );
  }

  if ( _bFlavor == _BP || _bFlavor == _B0 )
  {
    amp = ampCnj + rB * exp( EvtComplex( 0., delta + gamma ) ) * ampDir;
  }
  else
  {
    amp = ampDir + rB * exp( EvtComplex( 0., delta - gamma ) ) * ampCnj;
  }

  vertex( amp );

  return;

}
Example #12
0
void EvtKstarnunu::decay(EvtParticle *p){
  
  static EvtId NUE=EvtPDL::getId("nu_e");
  static EvtId NUM=EvtPDL::getId("nu_mu");
  static EvtId NUT=EvtPDL::getId("nu_tau");
  static EvtId NUEB=EvtPDL::getId("anti-nu_e");
  static EvtId NUMB=EvtPDL::getId("anti-nu_mu");
  static EvtId NUTB=EvtPDL::getId("anti-nu_tau");

  p->initializePhaseSpace(getNDaug(),getDaugs());
  
  double m_b = p->mass();

  EvtParticle *meson, *neutrino1, *neutrino2;
  meson = p->getDaug(0);
  neutrino1 = p->getDaug(1);
  neutrino2 = p->getDaug(2);
  EvtVector4R momnu1 = neutrino1->getP4();
  EvtVector4R momnu2 = neutrino2->getP4();
  EvtVector4R momkstar = meson->getP4();
  
  double v0_0, a1_0, a2_0;
  double m2v0, a1_b, a2_b;
  v0_0 = 0.47;
  a1_0 = 0.37;
  a2_0 = 0.40;
  m2v0 = 5.*5.;
  a1_b = -0.023;
  a2_b = 0.034;

  EvtVector4R q = momnu1+momnu2;
  double q2 = q.mass2();   

  double v0, a1, a2;
  v0 = v0_0/(1-q2/m2v0);
  a1 = a1_0*(1+a1_b*q2);
  a2 = a2_0*(1+a2_b*q2);

  EvtVector4R p4b; p4b.set(m_b,0.,0.,0.);  // Do calcs in mother rest frame
  
  double m_k = meson->mass();

  EvtTensor4C tds=(-2*v0/(m_b+m_k))*dual(EvtGenFunctions::directProd(p4b,momkstar))
    - EvtComplex(0.0,1.0)*
    ( (m_b+m_k)*a1*EvtTensor4C::g()
      - (a2/(m_b+m_k))*EvtGenFunctions::directProd(p4b-momkstar,p4b+momkstar)); 
  
  EvtVector4C l;

  if (getDaug(1)==NUE||getDaug(1)==NUM||getDaug(1)==NUT) {
        l=EvtLeptonVACurrent(neutrino1->spParentNeutrino(),
			     neutrino2->spParentNeutrino());
  }
  if (getDaug(1)==NUEB||getDaug(1)==NUMB||getDaug(1)==NUTB) {
        l=EvtLeptonVACurrent(neutrino2->spParentNeutrino(),
			     neutrino1->spParentNeutrino());
  }

  EvtVector4C et0,et1,et2; 
  et0 = tds.cont1( meson->epsParent(0).conj() );
  et1 = tds.cont1( meson->epsParent(1).conj() );
  et2 = tds.cont1( meson->epsParent(2).conj() );

  vertex(0,l*et0);
  vertex(1,l*et1);
  vertex(2,l*et2);

  return;
}
Example #13
0
//======================================================
void EvtBcVNpi::decay( EvtParticle *root_particle ) {
   ++nCall;
//     cout<<"BcVNpi::decay()"<<endl;
    root_particle->initializePhaseSpace(getNDaug(),getDaugs());

    EvtVector4R
	    p4b(root_particle->mass(), 0., 0., 0.),                  // Bc momentum
	    p4meson=root_particle->getDaug(0)->getP4(),     		   // J/psi momenta
	    Q=p4b-p4meson;
    double Q2=Q.mass2();


// check pi-mesons and calculate hadronic current
    EvtVector4C hardCur;
//     bool foundHadCurr=false;
    if( getNDaug() == 2) {
      hardCur = wcurr->WCurrent( root_particle->getDaug(1)->getP4() );
//       foundHadCurr=true;
    }
    else if( getNDaug() == 3) {
      hardCur = wcurr->WCurrent( root_particle->getDaug(1)->getP4() , 
				 root_particle->getDaug(2)->getP4() 
			       );
//       foundHadCurr=true;   
    }
    else if( getNDaug() == 4) {
      hardCur = wcurr->WCurrent( root_particle->getDaug(1)->getP4() , 
				 root_particle->getDaug(2)->getP4(), 
				 root_particle->getDaug(3)->getP4() 
			       );
//       foundHadCurr=true;         
    }
    else if( getNDaug() == 6) // Bc -> psi pi+ pi+ pi- pi- pi+ from [Kuhn, Was, hep-ph/0602162
    {

		hardCur = wcurr->WCurrent(root_particle->getDaug(1)->getP4(),
					  root_particle->getDaug(2)->getP4(),
					  root_particle->getDaug(3)->getP4(),
					  root_particle->getDaug(4)->getP4(),
					  root_particle->getDaug(5)->getP4()
				 );
// 		foundHadCurr=true;
    }	
    else {
	    report(Severity::Error,"EvtGen") << "Have not yet implemented this final state in BCNPI model" << endl;
	    report(Severity::Error,"EvtGen") << "Ndaug="<<getNDaug() << endl;
	    int id;
	    for ( id=0; id<(getNDaug()-1); id++ ) 
	    report(Severity::Error,"EvtGen") << "Daug " << id << " "<<EvtPDL::name(getDaug(id)).c_str() << endl;
	    ::abort();
    };  

// calculate Bc -> V W form-factors
	double a1f, a2f, vf, a0f;
	double m_meson = root_particle->getDaug(0)->mass();
	double m_b = root_particle->mass();
	ffmodel->getvectorff(root_particle->getId(),
				root_particle->getDaug(0)->getId(),
				Q2,
				m_meson,
				&a1f, 
				&a2f, 
				&vf, 
				&a0f);
	double a3f = ((m_b+m_meson)/(2.0*m_meson))*a1f -
	      ((m_b-m_meson)/(2.0*m_meson))*a2f;

// calculate Bc -> V W current
	EvtTensor4C H;
	H = a1f*(m_b+m_meson)*EvtTensor4C::g();
	H.addDirProd((-a2f/(m_b+m_meson))*p4b,p4b+p4meson);
	H+=EvtComplex(0.0,vf/(m_b+m_meson))*dual(EvtGenFunctions::directProd(p4meson+p4b,p4b-p4meson));
	H.addDirProd((a0f-a3f)*2.0*(m_meson/Q2)*p4b,p4b-p4meson);
	EvtVector4C  Heps=H.cont2(hardCur);
	
	for(int i=0; i<4; i++) {
		EvtVector4C  eps=root_particle->getDaug(0)->epsParent(i).conj(); // psi-meson polarization vector
		EvtComplex amp=eps*Heps;
		vertex(i,amp);
	};

}
void EvtHypNonLepton::decay(EvtParticle* parent) {

    parent->initializePhaseSpace(getNDaug(),getDaugs());
    calcAmp(&_amp2,parent);

}
Example #15
0
void EvtVectorIsr::decay( EvtParticle *p ){

  //the elctron mass
  double electMass=EvtPDL::getMeanMass(EvtPDL::getId("e-"));

  static EvtId gammaId=EvtPDL::getId("gamma");

  EvtParticle *phi;
  EvtParticle *gamma;

  //4-mom of the two colinear photons to the decay of the vphoton
  EvtVector4R p4softg1(0.,0.,0.,0.);
  EvtVector4R p4softg2(0.,0.,0.,0.);


  //get pointers to the daughters set
  //get masses/initial phase space - will overwrite the
  //p4s below to get the kinematic distributions correct
  p->initializePhaseSpace(getNDaug(),getDaugs());
  phi=p->getDaug(0);
  gamma=p->getDaug(1);

  //Generate soft colinear photons and the electron and positron energies after emission.
  //based on method of AfkQed and notes of Vladimir Druzhinin.
  //
  //function ckhrad(eb,q2m,r1,r2,e01,e02,f_col)
  //eb:      energy of incoming electrons in CM frame
  //q2m:     minimum invariant mass of the virtual photon after soft colinear photon emission
  //returned arguments
  //e01,e02: energies of e+ and e- after soft colinear photon emission
  //fcol:    weighting factor for Born cross section for use in an accept/reject test.


  double wcm=p->mass();
  double eb=0.5*wcm;

  //TO guarantee the collinear photons are softer than the ISR photon, require q2m > m*wcm
  double q2m=phi->mass()*wcm;
  double f_col(0.);
  double e01(0.);
  double e02(0.);
  double ebeam=eb;
  double wcm_new = wcm;
  double s_new = wcm*wcm;

  double fran = 1.;
  double f = 0;
  int m = 0;
  double largest_f=0;//only used when determining max weight for this vector particle mass
    
  if (!firstorder){
    while (fran > f){
      m++;    
    
      int n=0;
      while (f_col == 0.){
	n++;
	ckhrad(eb,q2m,e01,e02,f_col);
	if (n > 10000){
	  report(Severity::Info,"EvtGen") << "EvtVectorIsr is having problems. Called ckhrad 10000 times.\n";
	  assert(0);
	}
      }
    
      //Effective beam energy after soft photon emission (neglecting electron mass)
      ebeam = sqrt(e01*e02);
      wcm_new = 2*ebeam;
      s_new = wcm_new*wcm_new;
    
      //The Vector mass should never be greater than wcm_new
      if (phi->mass() > wcm_new){
	report(Severity::Info,"EvtGen") << "EvtVectorIsr finds Vector mass="<<phi->mass()<<" > Weff=" << wcm_new<<".  Should not happen\n";
	assert(0);
      }
 
      //Determine Born cross section @ wcm_new for e+e- -> gamma V.  We aren't interested in the absolute normalization
      //Just the functional dependence. Assuming a narrow resonance when determining cs_Born
      double cs_Born = 1.;
      if (EvtPDL::getMaxRange(phi->getId()) > 0.) {
	double x0 = 1 - EvtPDL::getMeanMass(phi->getId())*EvtPDL::getMeanMass(phi->getId())/s_new;
      
	//L = log(s/(electMass*electMass)  
	double L = 2.*log(wcm_new/electMass);
      
	// W(x0) is actually 2*alpha/pi times the following
	double W = (L-1.)*(1. - x0 +0.5*x0*x0);
      
	//Born cross section is actually 12*pi*pi*Gammaee/EvtPDL::getMeanMass(phi->getId()) times the following
	//(we'd need the full W(x0) as well)
	cs_Born = W/s_new;
      }
    
      f = cs_Born*f_col;

      //if fmax was set properly, f should NEVER be larger than fmax
      if (f > fmax && fmax > 0.){
	  report(Severity::Info,"EvtGen") << "EvtVectorIsr finds a problem with fmax, the maximum weight setting\n"
	     << "fmax is the third decay argument in the .dec file. VectorIsr attempts to set it reasonably if it wasn't provided\n"
	     << "To determine a more appropriate value, build GeneratorQAApp, and set the third argument for this decay <0.\n"
	     << "If you haven't been providing the first 2 arguments, set them to be 1. 1.). The program will report\n"
	     << "the largest weight it finds.  You should set fmax to be slightly larger.\n"
	     << "Alternatively try the following values for various vector particles: "
	     << "phi->1.15   J/psi-psi(4415)->0.105\n"
	     << "The current value of f and fmax for " << EvtPDL::name(phi->getId()) << " are " << f << "  " << fmax << "\n"
	     << "Will now assert\n";
	assert(0);
      }
 

      if (fmax > 0.) {
	fran = fmax*EvtRandom::Flat(0.0,1.0);
      }
    
      else {
	//determine max weight for this vector particle mass
	if (f>largest_f) {
	  largest_f = f;
	  report(Severity::Info,"EvtGen")  << m << " " <<  EvtPDL::name(phi->getId()) << " "
	       << "vector_mass " 
	       << " " << EvtPDL::getMeanMass(phi->getId()) << "  fmax should be at least " << largest_f 
	       << ".        f_col cs_B = " << f_col << " " << cs_Born 
	       << std::endl;
	}
	if (m%10000 == 0) {  
	  report(Severity::Info,"EvtGen") << m << " " <<  EvtPDL::name(phi->getId()) << " "
	       << "vector_mass " 
	       << " " << EvtPDL::getMeanMass(phi->getId()) << "  fmax should be at least " << largest_f 
	       << ".        f_col cs_B = " << f_col << " " << cs_Born 
	       << std::endl;
	}
      
	f_col = 0.;
	f = 0.;
	//determine max weight for this vector particle mass
      }
    
      if (m > 100000){
      
	if (fmax > 0.) report(Severity::Info,"EvtGen") << "EvtVectorIsr is having problems. Check the fmax value - the 3rd argument in the .dec file\n"
					     << "Recommended values for various vector particles: "
					     << "phi->1.15   J/psi-psi(4415)->0.105   "
					     << "Upsilon(1S,2S,3S)->0.14\n";
	assert(0);
      }
    }//while (fran > f)
  
  }//if (firstorder)
  
  //Compute parameters for boost to/from the system after colinear radiation

  double bet_l;
  double gam_l;
  double betgam_l;
  
  double csfrmn_new;
  double csbkmn_new;

  if (firstorder){
    bet_l = 0.;
    gam_l = 1.;
    betgam_l = 0.;
    csfrmn_new = csfrmn;
    csbkmn_new = csbkmn;
  } else {  
    double xx       = e02/e01;
    double sq_xx    = sqrt(xx);
    bet_l    = (1.-xx)/(1.+xx);
    gam_l    = (1.+xx)/(2.*sq_xx);
    betgam_l = (1.-xx)/(2.*sq_xx);
  
    //Boost photon cos_theta limits in lab to limits in the system after colinear rad
    csfrmn_new=(csfrmn - bet_l)/(1. - bet_l*csfrmn);
    csbkmn_new=(csbkmn - bet_l)/(1. - bet_l*csbkmn);
  }
 
//    //generate kinematics according to Bonneau-Martin article
//    //Nucl. Phys. B27 (1971) 381-397

  // For backward compatibility with .dec files before SP5, the backward cos limit for
  //the ISR photon is actually given as *minus* the actual limit. Sorry, this wouldn't be
  //my choice.  -Joe

   //gamma momentum in the vpho restframe *after* soft colinear radiation
  double pg = (s_new - phi->mass()*phi->mass())/(2.*wcm_new);


  //calculate the beta of incoming electrons after  colinear rad in the frame where e= and e- have equal momentum
  double beta=electMass/ebeam; //electMass/Ebeam = 1/gamma
  beta=sqrt(1. - beta*beta);   //sqrt (1 - (1/gamma)**2)

  double ymax=log((1.+beta*csfrmn_new)/(1.-beta*csfrmn_new));
  double ymin=log((1.-beta*csbkmn_new)/(1.+beta*csbkmn_new));

  // photon theta distributed as  2*beta/(1-beta**2*cos(theta)**2)
  double y=(ymax-ymin)*EvtRandom::Flat(0.0,1.0) + ymin;
  double cs=exp(y);
  cs=(cs - 1.)/(cs + 1.)/beta;
  double sn=sqrt(1-cs*cs);

  double fi=EvtRandom::Flat(EvtConst::twoPi);

  //four-vector for the phi
  double phi_p0 = sqrt(phi->mass()*phi->mass()+pg*pg);
  double phi_p3 = -pg*cs;


  //boost back to frame before colinear radiation.
  EvtVector4R p4phi(gam_l*phi_p0 + betgam_l*phi_p3,
		    -pg*sn*cos(fi),
		    -pg*sn*sin(fi),
		    betgam_l*phi_p0 + gam_l*phi_p3);

  double isr_p0 = pg;
  double isr_p3 = -phi_p3;
  EvtVector4R p4gamma(gam_l*isr_p0 + betgam_l*isr_p3,
		      -p4phi.get(1),
		      -p4phi.get(2),
		      betgam_l*isr_p0 + gam_l*isr_p3);

  
  //four-vectors of the collinear photons
  if (!firstorder) {
    p4softg1.set(0, eb-e02);    p4softg1.set(3, e02-eb);
    p4softg2.set(0, eb-e01);    p4softg2.set(3, eb-e01);
  }
  
  //save momenta for particles
  phi->init( getDaug(0),p4phi);
  gamma->init( getDaug(1),p4gamma);


  //add the two colinear photons as vphoton daughters
  EvtPhotonParticle *softg1=new EvtPhotonParticle;;
  EvtPhotonParticle *softg2=new EvtPhotonParticle;;
  softg1->init(gammaId,p4softg1);
  softg2->init(gammaId,p4softg2);
  softg1->addDaug(p);
  softg2->addDaug(p);

  //try setting the spin density matrix of the phi
  //get polarization vector for phi in its parents restframe.
  EvtVector4C phi0=phi->epsParent(0);
  EvtVector4C phi1=phi->epsParent(1);
  EvtVector4C phi2=phi->epsParent(2);

  //get polarization vector for a photon in its parents restframe.
  EvtVector4C gamma0=gamma->epsParentPhoton(0);
  EvtVector4C gamma1=gamma->epsParentPhoton(1);

  EvtComplex r1p=phi0*gamma0;
  EvtComplex r2p=phi1*gamma0;
  EvtComplex r3p=phi2*gamma0;


  EvtComplex r1m=phi0*gamma1;
  EvtComplex r2m=phi1*gamma1;
  EvtComplex r3m=phi2*gamma1;

  EvtComplex rho33=r3p*conj(r3p)+r3m*conj(r3m);
  EvtComplex rho22=r2p*conj(r2p)+r2m*conj(r2m);
  EvtComplex rho11=r1p*conj(r1p)+r1m*conj(r1m);

  EvtComplex rho13=r3p*conj(r1p)+r3m*conj(r1m);
  EvtComplex rho12=r2p*conj(r1p)+r2m*conj(r1m);
  EvtComplex rho23=r3p*conj(r2p)+r3m*conj(r2m);

  EvtComplex rho31=conj(rho13);
  EvtComplex rho32=conj(rho23);
  EvtComplex rho21=conj(rho12);


  EvtSpinDensity rho;
  rho.setDim(3);

  rho.set(0,0,rho11);
  rho.set(0,1,rho12);
  rho.set(0,2,rho13);
  rho.set(1,0,rho21);
  rho.set(1,1,rho22);
  rho.set(1,2,rho23);
  rho.set(2,0,rho31);
  rho.set(2,1,rho32);
  rho.set(2,2,rho33);

  setDaughterSpinDensity(0);
  phi->setSpinDensityForward(rho);

  return ;
}