Example #1
0
EvtSpinDensity EvtAmp::getForwardSpinDensity(EvtSpinDensity *rho_list,int i){

  EvtSpinDensity rho;

  rho.setDim(dstates[i]);

  int k;

  if (dstates[i]==1) {

    rho.set(0,0,EvtComplex(1.0,0.0));

    return rho;

  }

  EvtAmp ampprime;

  ampprime=(*this);

  if (_pstates!=1){
    ampprime=ampprime.contract(0,rho_list[0]);
  }

  for(k=0;k<i;k++){

    if (dstates[k]!=1){
      ampprime=ampprime.contract(_dnontrivial[k],rho_list[k+1]);
    }
      
  }

  return ampprime.contract(_dnontrivial[i],(*this));

}
Example #2
0
EvtSpinDensity EvtAmp::getBackwardSpinDensity(EvtSpinDensity *rho_list){

  EvtSpinDensity rho;

  rho.setDim(_pstates);

  if (_pstates==1){
    rho.set(0,0,EvtComplex(1.0,0.0));
    return rho;
  }

  int k;

  EvtAmp ampprime;

  ampprime=(*this);

  for(k=0;k<_ndaug;k++){
   
    if (dstates[k]!=1){
      ampprime=ampprime.contract(_dnontrivial[k],rho_list[k+1]);
    }
  }

  return ampprime.contract(0,(*this));

}
Example #3
0
void EvtSVPHelAmp::SVPHel(EvtParticle *parent,EvtAmp& amp,EvtId n_v1,EvtId n_v2,
			  const EvtComplex& hp,const EvtComplex& hm){

  //  Routine to decay a vector into a vector and scalar.  Started
  //  by ryd on Oct 17, 1996.

  // This routine is adopted from EvtSVVHel and since there is
  // a photon that can not have helicity 0 this is put in by 
  // setting the h0 amplitude to 0.
  EvtComplex h0=EvtComplex(0.0,0.0);
    
  int tndaug = 2;
  EvtId tdaug[2];
  tdaug[0] = n_v1;
  tdaug[1] = n_v2;

  parent->initializePhaseSpace(tndaug,tdaug);

  EvtParticle *v1,*v2;
  v1 = parent->getDaug(0);
  v2 = parent->getDaug(1);

  EvtVector4R momv1 = v1->getP4();

  EvtVector3R v1dir(momv1.get(1),momv1.get(2),momv1.get(3));
  v1dir=v1dir/v1dir.d3mag();

  EvtComplex a=-0.5*(hp+hm);
  EvtComplex b=EvtComplex(0.0,0.5)*(hp-hm);
  EvtComplex c=h0+0.5*(hp+hm);

  EvtTensor3C M=a*EvtTensor3C::id()+
    b*EvtGenFunctions::eps(v1dir)+
    c*EvtGenFunctions::directProd(v1dir,v1dir);

  EvtVector3C t0=M.cont1(v1->eps(0).vec().conj());
  EvtVector3C t1=M.cont1(v1->eps(1).vec().conj());
  EvtVector3C t2=M.cont1(v1->eps(2).vec().conj());
   
  EvtVector3C eps0=v2->epsParentPhoton(0).vec().conj();
  EvtVector3C eps1=v2->epsParentPhoton(1).vec().conj();

  amp.vertex(0,0,t0*eps0);
  amp.vertex(0,1,t0*eps1);
  //amp.vertex(0,2,t1*eps0*0.);

  amp.vertex(1,0,t1*eps0);
  amp.vertex(1,1,t1*eps1);
  //amp.vertex(1,2,t1*eps0*0.);

  amp.vertex(2,0,t2*eps0);
  amp.vertex(2,1,t2*eps1);
  //amp.vertex(2,2,t1*eps0*0.);

  return ;

}
double EvtSemiLeptonicAmp::CalcMaxProb( EvtId parent, EvtId meson, 
					EvtId lepton, EvtId nudaug,
                     EvtSemiLeptonicFF *FormFactors ) {

  //This routine takes the arguements parent, meson, and lepton
  //number, and a form factor model, and returns a maximum
  //probability for this semileptonic form factor model.  A
  //brute force method is used.  The 2D cos theta lepton and
  //q2 phase space is probed.

  //Start by declaring a particle at rest.

  //It only makes sense to have a scalar parent.  For now. 
  //This should be generalized later.

  EvtScalarParticle *scalar_part;
  EvtParticle *root_part;

  scalar_part=new EvtScalarParticle;

  //cludge to avoid generating random numbers!
  scalar_part->noLifeTime();

  EvtVector4R p_init;
  
  p_init.set(EvtPDL::getMass(parent),0.0,0.0,0.0);
  scalar_part->init(parent,p_init);
  root_part=(EvtParticle *)scalar_part;
  root_part->setDiagonalSpinDensity();      

  EvtParticle *daughter, *lep, *trino;
  
  EvtAmp amp;

  EvtId listdaug[3];
  listdaug[0] = meson;
  listdaug[1] = lepton;
  listdaug[2] = nudaug;

  amp.init(parent,3,listdaug);

  root_part->makeDaughters(3,listdaug);
  daughter=root_part->getDaug(0);
  lep=root_part->getDaug(1);
  trino=root_part->getDaug(2);

  //cludge to avoid generating random numbers!
  daughter->noLifeTime();
  lep->noLifeTime();
  trino->noLifeTime();


  //Initial particle is unpolarized, well it is a scalar so it is 
  //trivial
  EvtSpinDensity rho;
  rho.setDiag(root_part->getSpinStates());
  
  double mass[3];
  
  double m = root_part->mass();
  
  EvtVector4R p4meson, p4lepton, p4nu, p4w;
  double q2min;
  double q2max;

  double q2, elepton, plepton;
  int i,j;
  double erho,prho,costl;

  double maxfoundprob = 0.0;
  double prob = -10.0;
  int massiter;

  for (massiter=0;massiter<3;massiter++){

    mass[0] = EvtPDL::getMeanMass(meson);
    mass[1] = EvtPDL::getMeanMass(lepton);
    mass[2] = EvtPDL::getMeanMass(nudaug);
    if ( massiter==1 ) {
      mass[0] = EvtPDL::getMinMass(meson);
    }
    if ( massiter==2 ) {
      mass[0] = EvtPDL::getMaxMass(meson);
      if ( (mass[0]+mass[1]+mass[2])>m) mass[0]=m-mass[1]-mass[2]-0.00001; 
    }

    q2min = mass[1]*mass[1];
    q2max = (m-mass[0])*(m-mass[0]);
    
    //loop over q2

    for (i=0;i<25;i++) {
      q2 = q2min + ((i+0.5)*(q2max-q2min))/25.0;
      
      erho = ( m*m + mass[0]*mass[0] - q2 )/(2.0*m);
      
      prho = sqrt(erho*erho-mass[0]*mass[0]);
      
      p4meson.set(erho,0.0,0.0,-1.0*prho);
      p4w.set(m-erho,0.0,0.0,prho);
      
      //This is in the W rest frame
      elepton = (q2+mass[1]*mass[1])/(2.0*sqrt(q2));
      plepton = sqrt(elepton*elepton-mass[1]*mass[1]);
      
      double probctl[3];

      for (j=0;j<3;j++) {
	
        costl = 0.99*(j - 1.0);
	
	//These are in the W rest frame. Need to boost out into
	//the B frame.
        p4lepton.set(elepton,0.0,
		  plepton*sqrt(1.0-costl*costl),plepton*costl);
        p4nu.set(plepton,0.0,
		 -1.0*plepton*sqrt(1.0-costl*costl),-1.0*plepton*costl);

	EvtVector4R boost((m-erho),0.0,0.0,1.0*prho);
        p4lepton=boostTo(p4lepton,boost);
        p4nu=boostTo(p4nu,boost);

	//Now initialize the daughters...

        daughter->init(meson,p4meson);
        lep->init(lepton,p4lepton);
        trino->init(nudaug,p4nu);

        CalcAmp(root_part,amp,FormFactors);

	//Now find the probability at this q2 and cos theta lepton point
        //and compare to maxfoundprob.

	//Do a little magic to get the probability!!
	prob = rho.normalizedProb(amp.getSpinDensity());

	probctl[j]=prob;
      }

      //probclt contains prob at ctl=-1,0,1.
      //prob=a+b*ctl+c*ctl^2

      double a=probctl[1];
      double b=0.5*(probctl[2]-probctl[0]);
      double c=0.5*(probctl[2]+probctl[0])-probctl[1];

      prob=probctl[0];
      if (probctl[1]>prob) prob=probctl[1];
      if (probctl[2]>prob) prob=probctl[2];

      if (fabs(c)>1e-20){
	double ctlx=-0.5*b/c;
	if (fabs(ctlx)<1.0){
	  double probtmp=a+b*ctlx+c*ctlx*ctlx;
	  if (probtmp>prob) prob=probtmp;
	} 

      }

      if ( prob > maxfoundprob ) {
	maxfoundprob = prob; 
      }

    }
    if ( EvtPDL::getWidth(meson) <= 0.0 ) {
      //if the particle is narrow dont bother with changing the mass.
      massiter = 4;
    }

  }
  root_part->deleteTree();  

  maxfoundprob *=1.1;
  return maxfoundprob;
  
}
Example #5
0
void EvtDecayAmp::makeDecay(EvtParticle* p, bool recursive){

  //original default value
  int ntimes=10000;
  
  int more;

  EvtSpinDensity rho;
  double prob,prob_max;

  _amp2.init(p->getId(),getNDaug(),getDaugs());

  do{

    _daugsDecayedByParentModel=false;
    _weight = 1.0;
    decay(p);

    rho=_amp2.getSpinDensity();

    prob=p->getSpinDensityForward().normalizedProb(rho);

    if (prob<0.0) {
      EvtGenReport(EVTGEN_ERROR,"EvtGen")<<"Negative prob:"<<p->getId().getId()
			    <<" "<<p->getChannel()<<endl;

      EvtGenReport(EVTGEN_ERROR,"EvtGen") << "rho_forward:"<<endl;
      EvtGenReport(EVTGEN_ERROR,"EvtGen") << p->getSpinDensityForward();
      EvtGenReport(EVTGEN_ERROR,"EvtGen") << "rho decay:"<<endl;
      EvtGenReport(EVTGEN_ERROR,"EvtGen") << rho <<endl;
    }

    if (prob!=prob) {

      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Forward density matrix:"<<endl;
      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << p->getSpinDensityForward();

      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Decay density matrix:"<<endl;
      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << rho;

      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "prob:"<<prob<<endl;
      
      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Particle:"
			     <<EvtPDL::name(p->getId()).c_str()<<endl;
      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "channel        :"<<p->getChannel()<<endl;
      EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Momentum:" << p->getP4() << " " << p->mass() << endl;
      if( p->getParent()!=0){
	EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "parent:"
			       <<EvtPDL::name(
				p->getParent()->getId()).c_str()<<endl;
	EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "parent channel        :"
			       <<p->getParent()->getChannel()<<endl;

        size_t i;
	EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "parent daughters  :";
        for (i=0;i<p->getParent()->getNDaug();i++){
	  EvtGenReport(EVTGEN_DEBUG,"") << EvtPDL::name(
			    p->getParent()->getDaug(i)->getId()).c_str()
				 << " ";
        }
	EvtGenReport(EVTGEN_DEBUG,"") << endl;

	EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "daughters  :";
        for (size_t i=0;i<p->getNDaug();i++){
	  EvtGenReport(EVTGEN_DEBUG,"") << EvtPDL::name(
			    p->getDaug(i)->getId()).c_str()
				 << " ";
        }
	EvtGenReport(EVTGEN_DEBUG,"") << endl;

	EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "daughter momenta  :" << endl;;
        for (size_t i=0;i<p->getNDaug();i++){
	  EvtGenReport(EVTGEN_DEBUG,"") << p->getDaug(i)->getP4() << " " << p->getDaug(i)->mass();
	  EvtGenReport(EVTGEN_DEBUG,"") << endl;
        }

      }
    }


    prob/=_weight;

    prob_max = getProbMax(prob);
    p->setDecayProb(prob/prob_max);

    more=prob<EvtRandom::Flat(prob_max);
    
    ntimes--;

  }while(ntimes&&more);

  if (ntimes==0){
    EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Tried accept/reject: 10000" 
			   <<" times, and rejected all the times!"<<endl;
   
    EvtGenReport(EVTGEN_DEBUG,"EvtGen")<<p->getSpinDensityForward()<<endl;
    EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Is therefore accepting the last event!"<<endl;
    EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "Decay of particle:"<<
      EvtPDL::name(p->getId()).c_str()<<"(channel:"<<
      p->getChannel()<<") with mass "<<p->mass()<<endl;
    
    for(size_t ii=0;ii<p->getNDaug();ii++){
      EvtGenReport(EVTGEN_DEBUG,"EvtGen") <<"Daughter "<<ii<<":"<<
	EvtPDL::name(p->getDaug(ii)->getId()).c_str()<<" with mass "<<
	p->getDaug(ii)->mass()<<endl;
    }				   
  }

  EvtSpinDensity rho_list[10];

  rho_list[0]=p->getSpinDensityForward();

  EvtAmp ampcont;

  if (_amp2._pstates!=1){
    ampcont=_amp2.contract(0,p->getSpinDensityForward());
  }
  else{
    ampcont=_amp2;
  }


  // it may be that the parent decay model has already
  // done the decay - this should be rare and the
  // model better know what it is doing..
  
  if ( !daugsDecayedByParentModel() ){

    if(recursive) {   
    
      for(size_t i=0;i<p->getNDaug();i++){

	rho.setDim(_amp2.dstates[i]);
      
	if (_amp2.dstates[i]==1) {
	  rho.set(0,0,EvtComplex(1.0,0.0));
	}
	else{
	  rho=ampcont.contract(_amp2._dnontrivial[i],_amp2);
	}
	
	if (!rho.check()) {
	  
	  EvtGenReport(EVTGEN_ERROR,"EvtGen") << "-------start error-------"<<endl;
	  EvtGenReport(EVTGEN_ERROR,"EvtGen")<<"forward rho failed Check:"<<
	    EvtPDL::name(p->getId()).c_str()<<" "<<p->getChannel()<<" "<<i<<endl;
	  
	  p->printTree();

	  for (size_t idaug = 0; idaug < p->getNDaug(); idaug++) {
	    EvtParticle* daughter = p->getDaug(idaug);
	    if (daughter != 0) {daughter->printTree();}
	  }

	  EvtParticle* pParent = p->getParent();
	  if (pParent != 0) {
	    EvtGenReport(EVTGEN_ERROR,"EvtGen")<<"Parent:"<<EvtPDL::name(pParent->getId()).c_str()<<endl;

	    EvtParticle* grandParent = pParent->getParent();

	    if (grandParent != 0) {
	      EvtGenReport(EVTGEN_ERROR,"EvtGen")<<"GrandParent:"<<EvtPDL::name(grandParent->getId()).c_str()<<endl;
	    }
	  }

	  EvtGenReport(EVTGEN_ERROR,"EvtGen") << " EvtSpinDensity rho: " << rho;
	  
	  _amp2.dump();

	  for(size_t ii=0;ii<i+1;ii++){
	    EvtGenReport(EVTGEN_ERROR,"EvtGen") << "rho_list[" << ii << "] = " << rho_list[ii];
	  }

	  EvtGenReport(EVTGEN_ERROR,"EvtGen") << "-------Done with error-------"<<endl;  

	}
      
	p->getDaug(i)->setSpinDensityForward(rho);
	p->getDaug(i)->decay();
	
	rho_list[i+1]=p->getDaug(i)->getSpinDensityBackward();
	
	if (_amp2.dstates[i]!=1){
	ampcont=ampcont.contract(_amp2._dnontrivial[i],rho_list[i+1]);
	}
      
	
      }
      
      p->setSpinDensityBackward(_amp2.getBackwardSpinDensity(rho_list));
      
      
      if (!p->getSpinDensityBackward().check()) {
	
	EvtGenReport(EVTGEN_ERROR,"EvtGen")<<"rho_backward failed Check"<<
	  p->getId().getId()<<" "<<p->getChannel()<<endl;
      
	EvtGenReport(EVTGEN_ERROR,"EvtGen") << p->getSpinDensityBackward();
      
      }
    }    
  }


  if (getPHOTOS() || EvtRadCorr::alwaysRadCorr()) {
    int n_daug_orig=p->getNDaug();
    EvtRadCorr::doRadCorr(p);
    int n_daug_new=p->getNDaug();
    for (int i=n_daug_orig;i<n_daug_new;i++){
      p->getDaug(i)->decay();
    }
  }

}
Example #6
0
EvtSpinDensity EvtAmp::contract(int k,const EvtAmp& amp2){

  int i,j,l;

  EvtComplex temp;
  EvtSpinDensity rho;

  rho.setDim(_nstate[k]);

  int allloop = 1;
  int indflag,ii;
  for (i=0;i<_nontrivial;i++) {
     allloop *= _nstate[i];
  }

  int index[10];
  int index1[10];
  //  int l;
  for(i=0;i<_nstate[k];i++){

    for(j=0;j<_nstate[k];j++){
      if (_nontrivial==0) {
	report(Severity::Error,"EvtGen")<<"Should not be here1 EvtAmp!"<<endl;
        rho.set(0,0,EvtComplex(1.0,0.0)); 
        return rho;
      }

      for (ii=0;ii<10;ii++) {
	index[ii] = 0;
	index1[ii] = 0;
      }
      index[k] = i;
      index1[k] = j;

      temp = EvtComplex(0.0);

      for ( l=0;l<int(allloop/_nstate[k]);l++) {

	temp+=getAmp(index)*conj(amp2.getAmp(index1));
	indflag = 0;
	for ( ii=0;ii<_nontrivial;ii++) {
          if ( ii!= k) {
	    if ( indflag == 0 ) {
	      if ( index[ii] == (_nstate[ii]-1) ) {
		index[ii] = 0;
		index1[ii] = 0;
	      }
	      else {
		indflag = 1;
		index[ii] += 1;
		index1[ii] += 1;
	      }
	    }
	  }
	}
      }
      rho.set(i,j,temp);
      
    }
  }

  return rho;
}
Example #7
0
EvtAmp EvtAmp::contract(int k,const EvtSpinDensity& rho){

  EvtAmp temp;
  
  int i,j;
  temp._ndaug=_ndaug;
  temp._pstates=_pstates;
  temp._nontrivial=_nontrivial;

  for(i=0;i<_ndaug;i++){
    temp.dstates[i]=dstates[i];
    temp._dnontrivial[i]=_dnontrivial[i];
  }

  if (_nontrivial==0) {
    report(Severity::Error,"EvtGen")<<"Should not be here EvtAmp!"<<endl;
  }


  for(i=0;i<_nontrivial;i++){
    temp._nstate[i]=_nstate[i];
  }


  EvtComplex c;

  int index[10];
  for (i=0;i<10;i++) {
     index[i] = 0;
  }

  int allloop = 1;
  int indflag,ii;
  for (i=0;i<_nontrivial;i++) {
     allloop *= _nstate[i];
  }

  for ( i=0;i<allloop;i++) {

     c = EvtComplex(0.0);
     int tempint = index[k];
     for (j=0;j<_nstate[k];j++) {
       index[k] = j;
       c+=rho.get(j,tempint)*getAmp(index);
     }
     index[k] = tempint;
       
     temp.setAmp(index,c);

     indflag = 0;
     for ( ii=0;ii<_nontrivial;ii++) {
       if ( indflag == 0 ) {
	 if ( index[ii] == (_nstate[ii]-1) ) {
	   index[ii] = 0;
	 }
	 else {
	   indflag = 1;
	   index[ii] += 1;
	 }
       }
     }

  }
  return temp;

}
Example #8
0
void EvtEvalHelAmp::evalAmp( EvtParticle *p, EvtAmp& amp){

  //find theta and phi of the first daughter
  
  EvtVector4R pB=p->getDaug(0)->getP4();

  double theta=acos(pB.get(3)/pB.d3mag());
  double phi=atan2(pB.get(2),pB.get(1));

  double c=sqrt((_JA2+1)/(4*EvtConst::pi));

  int ia,ib,ic;

  double prob1=0.0;

  for(ia=0;ia<_nA;ia++){
    for(ib=0;ib<_nB;ib++){
      for(ic=0;ic<_nC;ic++){
	_amp[ia][ib][ic]=0.0;
	if (abs(_lambdaB2[ib]-_lambdaC2[ic])<=_JA2) {
	  double dfun=EvtdFunction::d(_JA2,_lambdaA2[ia],
				      _lambdaB2[ib]-_lambdaC2[ic],theta);

	  _amp[ia][ib][ic]=c*_HBC[ib][ic]*
	    exp(EvtComplex(0.0,phi*0.5*(_lambdaA2[ia]-_lambdaB2[ib]+
	  				_lambdaC2[ic])))*dfun;
	}
	prob1+=real(_amp[ia][ib][ic]*conj(_amp[ia][ib][ic]));
      }
    }
  }

  setUpRotationMatrices(p,theta,phi);

  applyRotationMatrices();

  double prob2=0.0;

  for(ia=0;ia<_nA;ia++){
    for(ib=0;ib<_nB;ib++){
      for(ic=0;ic<_nC;ic++){
	prob2+=real(_amp[ia][ib][ic]*conj(_amp[ia][ib][ic]));
	if (_nA==1){
	  if (_nB==1){
	    if (_nC==1){
	      amp.vertex(_amp[ia][ib][ic]);
	    }
	    else{
	      amp.vertex(ic,_amp[ia][ib][ic]);
	    }
	  }
	  else{
	    if (_nC==1){
	      amp.vertex(ib,_amp[ia][ib][ic]);
	    }
	    else{
	      amp.vertex(ib,ic,_amp[ia][ib][ic]);
	    }
	  }
	}else{
	  if (_nB==1){
	    if (_nC==1){
	      amp.vertex(ia,_amp[ia][ib][ic]);
	    }
	    else{
	      amp.vertex(ia,ic,_amp[ia][ib][ic]);
	    }
	  }
	  else{
	    if (_nC==1){
	      amp.vertex(ia,ib,_amp[ia][ib][ic]);
	    }
	    else{
	      amp.vertex(ia,ib,ic,_amp[ia][ib][ic]);
	    }
	  }
	}
      }
    }
  }

  if (fabs(prob1-prob2)>0.000001*prob1){
    report(Severity::Info,"EvtGen") << "prob1,prob2:"<<prob1<<" "<<prob2<<endl;
    ::abort();
  }
    
  return ;

}
void EvtSemiLeptonicScalarAmp::CalcAmp( EvtParticle *parent,
					EvtAmp& amp,
					EvtSemiLeptonicFF *FormFactors ) {

  static EvtId EM=EvtPDL::getId("e-");
  static EvtId MUM=EvtPDL::getId("mu-");
  static EvtId TAUM=EvtPDL::getId("tau-");
  static EvtId EP=EvtPDL::getId("e+");
  static EvtId MUP=EvtPDL::getId("mu+");
  static EvtId TAUP=EvtPDL::getId("tau+");
  
  //Add the lepton and neutrino 4 momenta to find q2

  EvtVector4R q = parent->getDaug(1)->getP4() 
                    + parent->getDaug(2)->getP4();
  double q2 = (q.mass2());

  double fpf,f0f;
  double mesonmass = parent->getDaug(0)->mass();
  double parentmass = parent->mass();

  FormFactors->getscalarff(parent->getId(),
                           parent->getDaug(0)->getId(),
                           q2,
                           mesonmass,
                           &fpf, 
                           &f0f);


  EvtVector4R p4b;
  p4b.set(parent->mass(),0.0,0.0,0.0);
  EvtVector4R p4meson = parent->getDaug(0)->getP4();
  double mdiffoverq2;
  mdiffoverq2 = parentmass*parentmass - mesonmass*mesonmass;
  mdiffoverq2 = mdiffoverq2 / q2;

  EvtVector4C l1,l2;

  EvtId l_num = parent->getDaug(1)->getId();
  EvtVector4C tds;

  if (l_num==EM||l_num==MUM||l_num==TAUM){

    tds = EvtVector4C(fpf*(p4b+p4meson - (mdiffoverq2*(p4b-p4meson)))+
		    + f0f*mdiffoverq2*(p4b-p4meson));

    l1=EvtLeptonVACurrent(parent->getDaug(1)->spParent(0),
                          parent->getDaug(2)->spParentNeutrino());
    l2=EvtLeptonVACurrent(parent->getDaug(1)->spParent(1),
                          parent->getDaug(2)->spParentNeutrino());
  }
  else{
    if (l_num==EP||l_num==MUP||l_num==TAUP){

      tds = EvtVector4C(fpf*(p4b+p4meson - (mdiffoverq2*(p4b-p4meson)))+
		    + f0f*mdiffoverq2*(p4b-p4meson));

      l1=EvtLeptonVACurrent(parent->getDaug(2)->spParentNeutrino(),
			    parent->getDaug(1)->spParent(0));
      l2=EvtLeptonVACurrent(parent->getDaug(2)->spParentNeutrino(),
			    parent->getDaug(1)->spParent(1));
    }
    else{
      EvtGenReport(EVTGEN_ERROR,"EvtGen") << "dfnb89agngri wrong lepton number\n";
    }
  }

  amp.vertex(0,l1*tds);
  amp.vertex(1,l2*tds);

}
void EvtB2MuMuMuNuAmp::CalcAmp(EvtParticle *parent, 
                               EvtAmp& amp,
			       EvtbTosllMSFF   *formFactorsms){ 
                            
    
  // Check the charge conservation in the reaction 
  int charge[4];
  charge[0] = (EvtPDL::chg3(parent->getDaug(0)->getId()))/3;
  charge[1] = (EvtPDL::chg3(parent->getDaug(1)->getId()))/3;
  charge[2] = (EvtPDL::chg3(parent->getDaug(2)->getId()))/3;
  charge[3] = (EvtPDL::chg3(parent->getDaug(3)->getId()))/3;
  if(abs(charge[0]+charge[1]+charge[2]+charge[3])!=1){
     EvtGenReport(EVTGEN_ERROR,"EvtGen") 
            << "\n\n The function EvtB2MuMuMuNuAmp::CalcAmp(...)"
            << "\n Error in the daughters charge definition!"
            << "\n charge1 = " << charge[0] 
            << "\t KF code1 = " << EvtPDL::getLundKC(parent->getDaug(0)->getId())
            << "\n charge2 = " << charge[1]
            << "\t KF code2 = " << EvtPDL::getLundKC(parent->getDaug(1)->getId())
            << "\n charge3 = " << charge[2]
            << "\t KF code3 = " << EvtPDL::getLundKC(parent->getDaug(2)->getId())
            << "\n charge4 = " << charge[3]
            << "\t KF code4 = " << EvtPDL::getLundKC(parent->getDaug(3)->getId())
            << "\n number of daughters = " << parent->getNDaug()
            << std::endl;
     ::abort();
  }
  
  
  // Daughter's positions in the matrix element
  int il1, il2, il3, il4;  //   Mu^+(k_1), Mu^-(k_2), \bar Nu_{Mu}(k_3) and Mu^-(k_4)
                           //or Mu^-(k_1), Mu^+(k_2),      Nu_{Mu}(k_3) and Mu^+(k_4)
                           //   This is the "canonical set" for current matrix element.
                           
  il1 = -101; //initialization of the daughter's positions 
  il2 = -102;
  il3 = -103; 
  il4 = -104;                        
  
  // Daughter's positions for the decay 
  //                   B^-(p) -> Mu^+(k_1) Mu^-(k_2) \bar Nu_{Mu}(k_3) Mu^-(k_4).
  if(charge[0]+charge[1]+charge[2]+charge[3] == -1){
     int ll;
     int min_charge, min_charge_il;
     min_charge    = charge[0];
     min_charge_il = 0;
     for(ll = 1; ll < 4; ll++){
        if(min_charge > charge[ll]){ 
               min_charge = charge[ll];
               min_charge_il = ll;
        }              
     }
     il2 = min_charge_il;                        // this is Mu^-(k_2)  
     if(il2 > 2){
       EvtGenReport(EVTGEN_ERROR,"EvtGen") 
            << "\n\n The function EvtB2MuMuMuNuAmp::CalcAmp(...)"
            << "\n Error in the particles distribution!"
            << "\n il2 = "          << il2
            << "\n min_charge = "   << min_charge
            << "\n total charge = -1 = " << (charge[0]+charge[1]+charge[2]+charge[3])
            << std::endl;
       ::abort();
     }       
     for(ll = il2 + 1; ll < 4; ll++){
        if(charge[ll] == -1) il4 = ll;           // this is  Mu^-(k_4)
        }          
     for(ll = 0; ll < 4; ll++){
        if(charge[ll] == +1) il1 = ll;           // this is  Mu^+(k_1)
        }           
     for(ll = 0; ll < 4; ll++){
        if(charge[ll] == 0) il3 = ll;            // this is  \bar Nu_{Mu}(k_3)
        }               
  }

  // Daughter's positions for the decay 
  //                   B^+(p) -> Mu^-(k_1) Mu^+(k_2) Nu_{Mu}(k_3) Mu^+(k_4).
  if(charge[0]+charge[1]+charge[2]+charge[3] == 1){
     int ll;
     int max_charge, max_charge_il;
     max_charge    = charge[0];
     max_charge_il = 0;
     for(ll = 1; ll < 4; ll++){
        if(max_charge < charge[ll]){ 
               max_charge = charge[ll];
               max_charge_il = ll;
        }              
     }
     il2 = max_charge_il;                        // this is Mu^+(k_2)  
     if(il2 > 2){
       EvtGenReport(EVTGEN_ERROR,"EvtGen") 
            << "\n\n The function EvtB2MuMuMuNuAmp::CalcAmp(...)"
            << "\n Error in the particles distribution!"
            << "\n il2 = "          << il2
            << "\n max_charge = "   << max_charge
            << "\n total charge = +1 = " << (charge[0]+charge[1]+charge[2]+charge[3])
            << std::endl;
       ::abort();
     }       
     for(ll = il2 + 1; ll < 4; ll++){
        if(charge[ll] == 1) il4 = ll;            // this is  Mu^+(k_4)
        }          
     for(ll = 0; ll < 4; ll++){
        if(charge[ll] == -1) il1 = ll;           // this is  Mu^-(k_1)
        }           
     for(ll = 0; ll < 4; ll++){
        if(charge[ll] == 0) il3 = ll;            // this is  Nu_{Mu}(k_3)
        }               
  }

  
  if((il1 < 0)||(il2 < 0)|| (il3 < 0) || (il4 < 0)){
     EvtGenReport(EVTGEN_ERROR,"EvtGen") 
            << "\n\n The function EvtB2MuMuMuNuAmp::CalcAmp(...)"
            << "\n ilX < 0 !!!"
            << "\n il1 = " << il1
            << "\t il2 = " << il2
            << "\t il3 = " << il3
            << "\t il4 = " << il4
            << std::endl;
     ::abort();     
  }
  
  // Output for program work check.
  // Need to comment in the final version!
//  EvtGenReport(EVTGEN_ERROR,"EvtGen") 
//            << "\n il1 = " << il1
//            << "\t il2 = " << il2
//            << "\t il3 = " << il3
//            << "\t il4 = " << il4
//            << std::endl;
   //END of the daughter's positions initialization           
            
  
  // Kinematics initialization          
  
  EvtComplex unit1(1.0,0.0); // real unit
  EvtComplex uniti(0.0,1.0); // imaginary unit  

  double M1 = parent->mass();                // B-meson mass, GeV
  double ml = parent->getDaug(il1)->mass();  // mass of muon, GeV
  
  // Id and 4-momentums of the particles
  
  EvtId idparent = parent->getId(); // B-meson Id
  
  EvtVector4R p;                    // B-meson 4-momentum
  p.set(0.0,0.0,0.0,0.0);
  
  
  EvtId id_L1, id_L2, id_L3, id_L4; // leptonic Id
  
  EvtVector4R k_1;  // 4-momentum of mu^+ in the    B^- rest frame; (il1)
  EvtVector4R k_2;  // 4-momentum of mu^- in the    B^- rest frame; (il2) 
  EvtVector4R k_3;  // 4-momentum of \bar nu in the B^- rest frame; (il3)
  EvtVector4R k_4;  // 4-momentum of mu^- in the    B^- rest frame; (il4)

  k_1.set(0.0,0.0,0.0,0.0);
  k_2.set(0.0,0.0,0.0,0.0);
  k_3.set(0.0,0.0,0.0,0.0);
  k_4.set(0.0,0.0,0.0,0.0);

  EvtVector4R q_fierst;     // q = k_1 + k_2 4-momentum in the B-rest frame
  EvtVector4R k_fierst;     // k = k_3 + k_4 4-momentum in the B-rest frame
  double q2_fierst;         // Mandelstam variable s=q^2
  double k2_fierst;         // Mandelstam variable t=k^2

  EvtVector4R q_second;     // q = k_1 + k_4 4-momentum in the B-rest frame
  EvtVector4R k_second;     // k = k_3 + k_2 4-momentum in the B-rest frame
  double q2_second;         // Mandelstam variable s=q^2
  double k2_second;         // Mandelstam variable t=k^2

  p = parent->getP4Restframe();     // B-meson 4-momentum in the B-rest frame

  k_1 = parent->getDaug(il1)->getP4();
  k_2 = parent->getDaug(il2)->getP4();
  k_3 = parent->getDaug(il3)->getP4();
  k_4 = parent->getDaug(il4)->getP4();
  
  q_fierst = k_1 + k_2;
  k_fierst = k_3 + k_4;
  q2_fierst = q_fierst.mass2();
  k2_fierst = k_fierst.mass2(); 
  
  q_second = k_1 + k_4;
  k_second = k_3 + k_2; 
  q2_second = q_second.mass2();
  k2_second = k_second.mass2(); 
  
  
  // For "B^-" - and "B^+" - mesons amplitudeы separately calculations 
  static EvtIdSet bmesons("B-","B_c-");
  static EvtIdSet bbarmesons("B+","B_c+");
  
//  // Information for test of 4-momentum.
//  // Need to comment in the final version!
//  EvtGenReport(EVTGEN_ERROR,"EvtGen") 
//            << "\n 4-momentum initialization  test"
//            << "\n k_1 = " << k_1
//            << "\n k_2 = " << k_2
//            << "\n k_3 = " << k_3
//            << "\n k_4 = " << k_4
//            << "\n q_fierst = " << q_fierst
//            << "\n q_second = " << q_second
//            << "\n k_fierst = " << k_fierst
//            << "\n k_second = " << k_second
//            << std::endl; 

  
  //
  // I. VMD Contribution
  //
  
  double M2[4];   //intermediate vector mesons mass for VMD contribution
  // M2[0] = EvtPDL::getMass(EvtPDL::getId(std::string("rho0")));  // Rho^0
  // M2[1] = EvtPDL::getMass(EvtPDL::getId(std::string("omega"))); // Omega^0
  // M2[2] = M2[0];  // GeV Rho^0
  // M2[3] = M2[1];  // GeV Omega^0
  M2[0] = 0.77526; // GeV Rho^0
  M2[1] = 0.78265; // GeV Omega^0
  M2[2] = M2[0];  // GeV Rho^0
  M2[3] = M2[1];  // GeV Omega^0
  
  double Width2[4]; //intermediate vector mesons width for VMD contribution
  // Width2[0] = EvtPDL::getWidth(EvtPDL::getId(std::string("rho0")));  // Rho^0
  // Width2[1] = EvtPDL::getWidth(EvtPDL::getId(std::string("omega"))); // Omega^0
  // Width2[2] = Width2[0];  // GeV Rho^0
  // Width2[3] = Width2[1];  // GeV Omega^0
  Width2[0] = 0.1491;   // GeV Rho^0
  Width2[1] = 0.00849;  // GeV Omega^0
  Width2[2] = Width2[0];  // GeV Rho^0
  Width2[3] = Width2[1];  // GeV Omega^0
  
  double fV2[4]; //intermediate vector mesons leptonic constant for VMD contribution
                 // see D.Melikhov, N.Nikitin. PRD70, 114028 (2004)
  fV2[0] = 5.04; // GeV Rho^0    
  fV2[1] = 17.1; // GeV Omega^0
  fV2[2] = 5.04; // GeV Rho^0    
  fV2[3] = 17.1; // GeV Omega^0
  
  // For taking the form factors values
  
  // B -> V intermediate vector mesons
  // transition form-factors for VMD contribution
  // 0 -- Rho^0 for k2_fierst
  // 1 -- Omega^0 for k2_fierst
  // 2 -- Rho^0 for k2_second
  // 3 -- Omega^0 for k2_second
  double a1[4],a2[4],a3[4],a0[4],v[4],t1[4],t2[4],t3[4];  
                                         
  
  EvtId B_meson_for_FF     = EvtPDL::getId(std::string("B0"));
  EvtId rho_meson_for_FF   = EvtPDL::getId(std::string("rho0"));
  EvtId omega_meson_for_FF = EvtPDL::getId(std::string("omega"));
  
  formFactorsms->getVectorFF(B_meson_for_FF, rho_meson_for_FF, k2_fierst,
                             a1[0],a2[0],a0[0],v[0],t1[0],t2[0],t3[0]);
                             
  formFactorsms->getVectorFF(B_meson_for_FF, omega_meson_for_FF, k2_fierst,
                             a1[1],a2[1],a0[1],v[1],t1[1],t2[1],t3[1]);
                             
  formFactorsms->getVectorFF(B_meson_for_FF, rho_meson_for_FF, k2_second,
                             a1[2],a2[2],a0[2],v[2],t1[2],t2[2],t3[2]);
                             
  formFactorsms->getVectorFF(B_meson_for_FF, omega_meson_for_FF, k2_second,
                             a1[3],a2[3],a0[3],v[3],t1[3],t2[3],t3[3]);
                                
   int aa;
   for(aa = 0; aa < 4; aa++){
          a3[aa] = ((M1 + M2[aa])*a1[aa] - (M1 - M2[aa])*a2[aa])/(2.0*M2[aa]);
       }                         
  
//  // Information for test of VMD contribution.
//  // Need to comment in the final version!
//  EvtGenReport(EVTGEN_ERROR,"EvtGen") 
//            << "\n VMD Contribution test"
//            << "\n M(Bu) = " << M1 << " GeV;"
//            << "\n M(Rho) = " << M2[0] << " GeV;"
//            << "\t M(Omega) = " << M2[1] << " GeV;"
//            << "\t Gamma(Rho) = " << Width2[0] << " Gev;"
//            << "\t Gamma(Omega) = " << Width2[1] << " Gev."
//            << "\n\n a1[0] = " << a1[0]
//            << "\t  a2[0] = " << a2[0]
//            << "\t  a0[0] = " << a0[0]
//            << "\t  a3[0] = " << a3[0]
//            << "\t   v[0] = " <<  v[0]
//            << "\n\n a1[1] = " << a1[1]
//            << "\t  a2[1] = " << a2[1]
//            << "\t  a0[1] = " << a0[1]
//            << "\t  a3[1] = " << a3[1]
//            << "\t   v[1] = " <<  v[1]
//            << "\n\n a1[2] = " << a1[2]
//            << "\t  a2[2] = " << a2[2]
//            << "\t  a0[2] = " << a0[2]
//            << "\t  a3[2] = " << a3[2]
//            << "\t   v[2] = " <<  v[2]
//            << "\n\n a1[3] = " << a1[3]
//            << "\t  a2[3] = " << a2[3]
//            << "\t  a0[3] = " << a0[3]
//            << "\t  a3[3] = " << a3[3]
//            << "\t   v[3] = " <<  v[3]
//            << std::endl; 
  
  
  
  // Tensor structures for VMD contribution
  EvtTensor4C Tvmd_fierst, Tvmd_second; 
  
  
  //
  // II. Electromagnetic foton emission from B-meson contribution 
  //                     (EM contribution)  
  //
  
  // EM form factors
  // 0 -- u-quark emission for q2_fierst
  // 1 -- b-quark emission for q2_fierst
  // 2 -- u-quark emission for q2_second
  // 3 -- b-quark emission for q2_second
  double v_em[4];
  double MBstar = 5.325; // GeV
  
  v_em[0] = 4.0*MBstar*FF_B2BstarGamma_fromU(q2_fierst)/(3.0*(M1 + MBstar));
  v_em[1] = 2.0*MBstar*FF_B2BstarGamma_fromB(q2_fierst)/(3.0*(M1 + MBstar));
  v_em[2] = 4.0*MBstar*FF_B2BstarGamma_fromU(q2_second)/(3.0*(M1 + MBstar));
  v_em[3] = 2.0*MBstar*FF_B2BstarGamma_fromB(q2_second)/(3.0*(M1 + MBstar));
  
  // Tensor structures for EM contribution
  EvtTensor4C Tem_fierst, Tem_second; 
  
  
  //
  // ***
  //
  
  
  
  // Leptonic currents 
  //   L1 = (\bar mu \gamma^{\mu} (1 - \gamma^5) nu) 
  //                             or (\bar nu \gamma^{\mu} (1 - \gamma^5) mu)
  //   L2 = (\bar mu \gamma^{\nu} mu)
  EvtVector4C L1_fierst, L2_fierst;
  EvtVector4C L1_second, L2_second;

  
  int i1, i2, i3, i4;  // leptonic spin structures counters
  int leptonicspin[4]; // array for the saving of the leptonic spin configuration



  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // +                Contribution for B- decay               +
  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  if (bmesons.contains(idparent)){
  
  Tvmd_fierst = 0.0*EvtTensor4C::g();  
  for(aa = 0; aa < 2; aa++){
      EvtComplex coeff_vmd;
      
      double Re_vmd, Im_vmd, znam_vmd;
      Re_vmd = q2_fierst - M2[aa]*M2[aa];
      Im_vmd = Width2[aa]*M2[aa];
      znam_vmd = fV2[aa]*(Re_vmd*Re_vmd + Im_vmd*Im_vmd);
      coeff_vmd = unit1*Re_vmd/znam_vmd - uniti*Im_vmd/znam_vmd;
      
      double vaa, a2aa, a3aa;
      vaa  = 2.0*v[aa]/(M1 + M2[aa]);
      a2aa = a2[aa]/(M1 + M2[aa]);
      a3aa = 2.0*M2[aa]*(a3[aa] - a0[aa])/k2_fierst;
           
      Tvmd_fierst = Tvmd_fierst 
        +coeff_vmd*(0.0*EvtTensor4C::g()
        -(unit1*vaa*dual(EvtGenFunctions::directProd(p,q_fierst)))
        -uniti*a1[aa]*(M1 + M2[aa])*EvtTensor4C::g()
        +uniti*a2aa*EvtGenFunctions::directProd((p + q_fierst),p)
        +uniti*a3aa*EvtGenFunctions::directProd((p - q_fierst),p));
      }
 
  Tvmd_second = 0.0*EvtTensor4C::g();
  for(aa = 2; aa < 4; aa++){
      EvtComplex coeff_vmd;
      
      double Re_vmd, Im_vmd, znam_vmd;
      Re_vmd = q2_second - M2[aa]*M2[aa];
      Im_vmd = Width2[aa]*M2[aa];
      znam_vmd = fV2[aa]*(Re_vmd*Re_vmd + Im_vmd*Im_vmd);
      coeff_vmd = unit1*Re_vmd/znam_vmd - uniti*Im_vmd/znam_vmd;
      
      double vaa, a2aa, a3aa;
      vaa  = 2.0*v[aa]/(M1 + M2[aa]);
      a2aa = a2[aa]/(M1 + M2[aa]);
      a3aa = 2.0*M2[aa]*(a3[aa] - a0[aa])/k2_second;
      
      Tvmd_second = Tvmd_second  
        +coeff_vmd*(0.0*EvtTensor4C::g()
        -unit1*vaa*dual(EvtGenFunctions::directProd(p,q_second))
        -uniti*a1[aa]*(M1 + M2[aa])*EvtTensor4C::g()
        +uniti*a2aa*EvtGenFunctions::directProd((p + q_second),p)
        +uniti*a3aa*EvtGenFunctions::directProd((p - q_second),p));
      }
      
  Tem_fierst = 0.0*EvtTensor4C::g(); 
  for(aa = 0; aa < 2; aa++){
      double fBstar = 0.2; // GeV
      double coeff;
      coeff = fBstar/(q2_fierst*(k2_fierst - MBstar*MBstar));
      Tem_fierst = Tem_fierst - coeff*v_em[aa]*dual(EvtGenFunctions::directProd(p,k_fierst)); 
     }  
     
  Tem_second = 0.0*EvtTensor4C::g(); 
  for(aa = 2; aa < 4; aa++){
      double fBstar = 0.2; // GeV
      double coeff;
      coeff = fBstar/(q2_fierst*(k2_fierst - MBstar*MBstar));
      Tem_second = Tem_second - coeff*v_em[aa]*dual(EvtGenFunctions::directProd(p,k_second)); 
     }     
      
  // Amplitude calculation
  for(i2=0;i2<2;i2++){
    leptonicspin[0] = i2;
    for(i1=0;i1<2;i1++){
      leptonicspin[1] = i1;
      for(i4=0;i4<2;i4++){
        leptonicspin[2] = i4;
        i3 = 0;                  // neutrino spin structure!
        leptonicspin[3] = i3;
        
        //(\bar mu(k_4) \gamma^{\mu} (1 - \gamma^5) nu(- k_3))
        L1_fierst = EvtLeptonVACurrent(parent->getDaug(il4)->spParent(i4),
                                       parent->getDaug(il3)->spParentNeutrino());
        
        
        //(\bar mu(k_2) \gamma^{\mu} mu(- k_1))
        L2_fierst = EvtLeptonVCurrent(parent->getDaug(il2)->spParent(i2),
                                       parent->getDaug(il1)->spParent(i1));
        
        
        //(\bar mu(k_2) \gamma^{\mu} (1 - \gamma^5) nu(- k_3))
        L1_second = EvtLeptonVACurrent(parent->getDaug(il2)->spParent(i2),
                                       parent->getDaug(il3)->spParentNeutrino());
        
        
        //(\bar mu(k_4) \gamma^{\mu} mu(- k_1))
        L2_second = EvtLeptonVCurrent(parent->getDaug(il4)->spParent(i4),
                                       parent->getDaug(il1)->spParent(i1));
         
        // VMD                               
        EvtVector4C Evmd_fierst, Evmd_second;
        Evmd_fierst=Tvmd_fierst.cont2(L2_fierst);
        Evmd_second=Tvmd_second.cont2(L2_second);
        
        // EM
        EvtVector4C Eem_fierst, Eem_second;
        Eem_fierst=Tem_fierst.cont2(L1_fierst);
        Eem_second=Tem_second.cont2(L1_second);
           
        // Bremsstrahlung   
        EvtComplex Ebrst_fierst, Ebrst_second;
        double fB = 0.20; // GeV leptonic constant of B^{\pm} mesons
        Ebrst_fierst = uniti*fB*L2_fierst*L1_fierst/q2_fierst;
        Ebrst_second = uniti*fB*L2_second*L1_second/q2_second;
        
        amp.vertex(leptonicspin, L1_fierst*Evmd_fierst + L2_fierst*Eem_fierst + Ebrst_fierst 
                               - L1_second*Evmd_second - L2_second*Eem_second - Ebrst_second);
                               
         if(q2_fierst < 4.0*ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }                      
          if(q2_second < 4.0*ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }  
           if(k2_fierst < ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }                      
          if(k2_second < ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }                                                                    
          
        }  // End of the operator "for(i4=0;i4<2;i4++)"
      }    // End of the operator "for(i1=0;i1<2;i1++)"
    }      // End of the operator "for(i2=0;i2<2;i2++)"
      
   }  // End of the operator: "if (bmesons.contains(idparent))"

   
   else { // Start of the operator "else N1" 
  // ++++++++++++++++++++++++++++++++++++++++++++++++++
  // +           Contribution for B+ decay            +
  // ++++++++++++++++++++++++++++++++++++++++++++++++++
  if (bbarmesons.contains(idparent)){
  
  Tvmd_fierst = 0.0*EvtTensor4C::g();  
  for(aa = 0; aa < 2; aa++){
      EvtComplex coeff_vmd;
      
      double Re_vmd, Im_vmd, znam_vmd;
      Re_vmd = q2_fierst - M2[aa]*M2[aa];
      Im_vmd = Width2[aa]*M2[aa];
      znam_vmd = fV2[aa]*(Re_vmd*Re_vmd + Im_vmd*Im_vmd);
      coeff_vmd = unit1*Re_vmd/znam_vmd - uniti*Im_vmd/znam_vmd;
      
      double vaa, a2aa, a3aa;
      vaa  = 2.0*v[aa]/(M1 + M2[aa]);
      a2aa = a2[aa]/(M1 + M2[aa]);
      a3aa = 2.0*M2[aa]*(a3[aa] - a0[aa])/k2_fierst;
            
      Tvmd_fierst = Tvmd_fierst 
        +coeff_vmd*(0.0*EvtTensor4C::g()
        +unit1*vaa*dual(EvtGenFunctions::directProd(p,q_fierst))
        -uniti*a1[aa]*(M1 + M2[aa])*EvtTensor4C::g()
        +uniti*a2aa*EvtGenFunctions::directProd((p + q_fierst),p)
        +uniti*a3aa*EvtGenFunctions::directProd((p - q_fierst),p));
      }
 
  Tvmd_second = 0.0*EvtTensor4C::g();
  for(aa = 2; aa < 4; aa++){
      EvtComplex coeff_vmd;
      
      double Re_vmd, Im_vmd, znam_vmd;
      Re_vmd = q2_second - M2[aa]*M2[aa];
      Im_vmd = Width2[aa]*M2[aa];
      znam_vmd = fV2[aa]*(Re_vmd*Re_vmd + Im_vmd*Im_vmd);
      coeff_vmd = unit1*Re_vmd/znam_vmd - uniti*Im_vmd/znam_vmd;
      
      double vaa, a2aa, a3aa;
      vaa  = 2.0*v[aa]/(M1 + M2[aa]);
      a2aa = a2[aa]/(M1 + M2[aa]);
      a3aa = 2.0*M2[aa]*(a3[aa] - a0[aa])/k2_second;
   
      Tvmd_second = Tvmd_second  
        +coeff_vmd*(0.0*EvtTensor4C::g()
        +unit1*vaa*dual(EvtGenFunctions::directProd(p,q_second))
        -uniti*a1[aa]*(M1 + M2[aa])*EvtTensor4C::g()
        +uniti*a2aa*EvtGenFunctions::directProd((p + q_second),p)
        +uniti*a3aa*EvtGenFunctions::directProd((p - q_second),p));
      }
      
  Tem_fierst = 0.0*EvtTensor4C::g(); 
  for(aa = 0; aa < 2; aa++){
      double fBstar = 0.0 - 0.2; // GeV
      double coeff;
      coeff = fBstar/(q2_fierst*(k2_fierst - MBstar*MBstar));
      Tem_fierst = Tem_fierst + coeff*v_em[aa]*dual(EvtGenFunctions::directProd(p,k_fierst)); 
     }  
     
  Tem_second = 0.0*EvtTensor4C::g(); 
  for(aa = 2; aa < 4; aa++){
      double fBstar = 0.0 - 0.2; // GeV
      double coeff;
      coeff = fBstar/(q2_fierst*(k2_fierst - MBstar*MBstar));
      Tem_second = Tem_second + coeff*v_em[aa]*dual(EvtGenFunctions::directProd(p,k_second)); 
     }        
      
  // Amplitude calculation
  for(i2=0;i2<2;i2++){
    leptonicspin[0] = i2;
    for(i1=0;i1<2;i1++){
      leptonicspin[1] = i1;
      for(i4=0;i4<2;i4++){
        leptonicspin[2] = i4;
        i3 = 0;                  // neutrino spin structure!
        leptonicspin[3] = i3;
        
        //(\bar nu(k_3) \gamma^{\mu} (1 - \gamma^5) mu(- k_4))
        L1_fierst = EvtLeptonVACurrent(parent->getDaug(il3)->spParentNeutrino(),
                                       parent->getDaug(il4)->spParent(i4));
        
        
        //(\bar mu(k_1) \gamma^{\mu} mu(- k_2))
        L2_fierst = EvtLeptonVCurrent(parent->getDaug(il1)->spParent(i1),
                                       parent->getDaug(il2)->spParent(i2));
        
        
        //(\bar nu(k_3) \gamma^{\mu} (1 - \gamma^5) mu(- k_2))
        L1_second = EvtLeptonVACurrent(parent->getDaug(il3)->spParentNeutrino(),
                                       parent->getDaug(il2)->spParent(i2));
        
        
        //(\bar mu(k_1) \gamma^{\mu} mu(- k_4))
        L2_second = EvtLeptonVCurrent(parent->getDaug(il1)->spParent(i1),
                                       parent->getDaug(il4)->spParent(i4));
         
        // VMD        
        EvtVector4C Evmd_fierst, Evmd_second;
        Evmd_fierst=Tvmd_fierst.cont2(L2_fierst);
        Evmd_second=Tvmd_second.cont2(L2_second);
        
        // EM
        EvtVector4C Eem_fierst, Eem_second;
        Eem_fierst=Tem_fierst.cont2(L1_fierst);
        Eem_second=Tem_second.cont2(L1_second);
           
        // Bremsstrahlung                                                               
        EvtComplex Ebrst_fierst, Ebrst_second;
        double fB = 0.20; // GeV leptonic constant of B^{\pm} mesons
        Ebrst_fierst = uniti*fB*L2_fierst*L1_fierst/q2_fierst;
        Ebrst_second = uniti*fB*L2_second*L1_second/q2_second;
        
        
        amp.vertex(leptonicspin, L1_fierst*Evmd_fierst + L2_fierst*Eem_fierst + Ebrst_fierst 
                               - L1_second*Evmd_second - L2_second*Eem_second - Ebrst_second);
                               
         if(q2_fierst < 4.0*ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }                      
          if(q2_second < 4.0*ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }  
           if(k2_fierst < ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }                      
          if(k2_second < ml*ml)
            {
               amp.vertex(leptonicspin, unit1*0.0);
            }                          
          
        }  // End of the operator "for(i4=0;i4<2;i4++)"
      }    // End of the operator "for(i1=0;i1<2;i1++)"
    }      // End of the operator "for(i2=0;i2<2;i2++)"
      
   }  // End of the operator: "if (bbarmesons.contains(idparent))"
   
   else{ // Start of the operator "else N2"
         EvtGenReport(EVTGEN_ERROR,"EvtGen") 
             << "\n\n The function EvtB2MuMuMuNuAmp::CalcAmp(...)"
             << "\n Wrong B-meson number"
             << "\n B-meson KF code = " << EvtPDL::getLundKC(parent->getId())
             << std::endl;
         ::abort();    
   }  // End of the operator "else N2" 

   }  // End of the operator "else N1" 
}