コード例 #1
0
ファイル: plane.cpp プロジェクト: AshwinChandlapur/perception
QVec Plane::coefficientsToRotation(const QVec &planeVector, const QVec &initialRots)
{
    QVec v = planeVector;

    // Compute R_x
    float RX = normAngle(atan2(v(1), -v(2)));
		if (abs(RX-initialRots(0)) >= M_PIl)
    {
        if (RX > 0)
            RX -= M_PIl;
        else
            RX += M_PIl;
    }

    // Compute R_y
    QMat m = Rot3D(-RX, 0, 0);
    v = m * v;
    const float RY = normAngle(-atan2(v(0), -v(2)));

    return QVec::vec3(RX, RY, initialRots(2));
}
コード例 #2
0
int mkmom(double*x,double*tfact,double*xp1,double*xp2,REAL*pvect)
{
  int i,k,l;
  int nx=0;
  double  fct0, fct1, fct2;
  REAL  pIn[2][4]={{0,0,0,0},{0,0,0,0}};
  REAL  pXY[2][4]={{0,1,0,0},{0,0,1,0}};
    
  REAL  xcos, xfi, parfi;
  double cosmin, cosmax, parcos;
  REAL ytilda=0; 
  
  int  i__2;
  REAL d__1;

  REAL ff, al;
  REAL  xx, bes; 
  double fct;
 
  double stilda;
  REAL rstilda,  pcmtilda, xtilda; 
  int  ns;

  REAL psy1, psy2, x1,x2;

  double  smin, smax;
  REAL  amass[DEPTH][2];

  int nvpole;
  int nvpos;

  REAL hsum[2], hdif;

  REAL fct_1__;
  int nsing;
  
  iDecay memDecay;
    
  sing_struct singar[200];

  *tfact = tfact0;
/* **   MOMENTS */
    if(nout_int==1)
    { 
       REAL s=pm[0]+pm[1], d=pm[0]-pm[1], p=sqrt((pm[2]-s)*(pm[2]+ s)*(pm[2]-d)*(pm[2]+d))/(2*pm[2]);
       REAL e1=sqrt(p*p+pm[0]*pm[0]), e2=sqrt(p*p+pm[1]*pm[1]);
       REAL y1= log( (pcm +sqrt(pm[0]*pm[0]+pcm*pcm))/(e1+p) );
       REAL y2=-log( (pcm +sqrt(pm[1]*pm[1]+pcm*pcm))/(e2+p) );
       if(pm[0]>0) { REAL y=  log( pm[0]/(e1+p)); if(y2<y) y2=y; }
       if(pm[1]>0) { REAL y= -log( pm[1]/(e2+p)); if(y1>y) y1=y; }
       for(i=0;i<12;i++)pvect[i]=0;
       pvect[0]=e1; pvect[3]=p;
       pvect[4]=e2; pvect[7]=-p;
       pvect[8]=pm[2];
       *tfact=389379660.0*M_PI/(2*p*pm[2]*sqrt_S*sqrt_S);
       if(sf_num[0] && sf_num[1]) { ytilda=x[0]*y1+ (1-x[0])*y2;    *tfact*=(y1-y2);}   
        else if(sf_num[0]) ytilda=y2; else if(sf_num[1]) ytilda=y1; else  return 1;
       LorRot(ytilda,3,pvect);
       *xp1=sf_num[0]? pvect[3]/pcm:1;
       *xp2=sf_num[1]?-pvect[7]/pcm:1;
       
       LorRot(rapidity,3,pvect);
       return 0;
    }
    if (nin_int == 2) 
    {   REAL y1,y2;
	if (sf_num[0] || sf_num[1]) 
	{
	    nsing = 0;
	    getreg_(&nsing, singar, 0., 1., nss);
	    bes =  beta[0]+ beta[1];
	    if (bes >= 1) al = 1; else if (nsing)  al = 0.5; else al = 0;

	    xx = x[nx++];
	    if (xx < al) 
	    {
		xx /= al;
		regfun_(2,nsing,singar,ssmin,ssmax,xx,&stilda,&fct1);
	    } else 
	    {   
		if(xx==al) xx=1;else xx = (1 - xx) / (1 - al);
		stilda=stop-pow(xx*pow(stop-ssmin,bes)+(1-xx)*pow(stop-ssmax,bes),1/bes);
		regfct_(2,nsing,singar,ssmin,ssmax,stilda,&fct1);
	    }
	    fct1 /= stop-sbot;
	    if (bes < 1) 
	    {
		ff = pow(1 - ssmin/stop, bes) - pow(1 - ssmax/stop, bes);
		fct2 = ff / bes * pow( 1 - stilda/stop, 1 - bes);
		*tfact *= ff/ (al * fct2 / fct1 + (1 - al));
	    } else  *tfact *= fct1;
	    
            xtilda=(stilda-sbot)/(stop-sbot);

	    if (sf_num[0] && sf_num[1]) 
	    { REAL yy = log(1/xtilda); 
		xx = x[nx++];
		if (beta[0] < 1 && beta[1] < 1) 
		{
		    al = beta[1]/(beta[0]+beta[1]);
		    if (xx < al) 
		    {
			xx /= al;
			psy1 = pow(xx, 1 / beta[0]);
			psy2 = 1 - psy1;
		    } else 
		    {
			if(xx==al) xx=1; else xx = (1 - xx) / (1 - al);
			psy2 = pow(xx, 1 / beta[1]);
			psy1 = 1 - psy2;
		    }
		    y1 = yy * psy1;
		    y2 = yy * psy2;

		    *tfact *=pow(divy_(y1),beta[0]-1)*pow(divy_(y2),beta[1]-1)/
		    	     (pow(psy1,1-beta[0])+pow(psy2,1-beta[1]));

		    if (bes < 1)  *tfact *= pow( divy_(yy),1-bes);
		     else          *tfact *= bes*pow(yy,bes-1);
		} else if (beta[0] < 1) 
		{
		    psy1 = pow(xx,  1 / beta[0]);
		    y1 = yy * psy1;
		    y2 = yy * (1 - psy1);
		    *tfact *=  pow(yy, *beta)*pow(divy_(y1),beta[0]-1);
		} else if (beta[1] < 1) 
		{
		    psy2 = pow(xx,  1 / beta[1]);
		    y2 = yy * psy2;
		    y1 = yy * (1 - psy2);
		    *tfact *= pow(yy,beta[1])*pow(divy_(y2),beta[1]-1);
		} else 
		{
		    y1 = yy * xx;
		    y2 = yy - y1;
		    *tfact *= yy;
		}
		x1 = exp(-y1);
		x2 = exp(-y2);
                ytilda=(y2-y1)/2;
	    } else if (sf_num[0]) 
	    {   REAL e2=sqrt(pm[1]*pm[1]+pcm*pcm);
		x1 = xtilda;
		x2 = 1;
                ytilda=0.5*log((e2+(2*x1-1)*pcm)/(e2+pcm));
	    } else 
	    {   REAL e1=sqrt(pm[0]*pm[0]+pcm*pcm);
		x1 = 1;
		x2 = xtilda;
                ytilda=-0.5*log((e1+(2*x2-1)*pcm)/(e1+pcm));
	    }
	} else 
	{
	    x1 = 1;
	    x2 = 1;
	    stilda = sqrt_S*sqrt_S;
            ytilda=0;
	}
        rstilda = sqrt(stilda);
        pcmtilda=cmfun(rstilda,pm[0],pm[1]);
	pIn[0][3]=pcmtilda;
	pIn[1][3]=-pcmtilda;

     
/*  *sf_fact= *tfact/tfact0; */
    }
/* *  FILLING ZERO COMPONENTS FOR in-PARTICLES */

    for (k = 0; k < nin_int; ++k) pvFill(pm[k],pIn[k],k+1,pvect);
	 
    if (nin_int == 2)   *tfact /= 4*pcmtilda *rstilda; else 
    { rstilda = pm[0]; *tfact /= rstilda * 2; ytilda=0;} 
     
/* *    X & Y AXISES */

    pvFill(0,pXY[0],nvposx,pvect);
    pvFill(0,pXY[1],nvposy,pvect);  

    nvpos = nvpos0;
    nvpole =nvpos++;
    
    
    
/* *    MASS INTEGRATION */

    for (i = 0; i < nout1; ++i) 
    {   REAL sval= i? amass[lnkbab[i]][lnkleg[i]]: rstilda;   

       	for (k = 0; k < 2; ++k) 
	{
	    if (kinmtc_1[i].lvout[k][1]) 
	    { double sqmass;
	      REAL  xx=x[nx++];
	        d__1=  k?  sval - amass[i][0] : sval - summas[i][1];
		         
	        smax = d__1 * d__1;
		
		d__1 = summas[i][k];
		smin = d__1 * d__1;

		if (nmscut[i][k]) rancor_(&smin, &smax,0., 1., nmscut[i][k]);
		
		if (smin >= smax)  {*tfact = 0; return 0;}
		
		if (nmsreg[i][k] )
		{
		    nsing = 0;
		    getreg_(&nsing, singar, 0., 1.,nmsreg[i][k]);
		    regfun_(2,nsing,singar,smin,smax,xx,&sqmass,&fct);
		} else
		{
		    sqmass = xx * smax + (1 - xx) * smin;
		    fct = smax - smin;
		} 
		amass[i][k] = sqrt(sqmass);
		*tfact *= fct;
	    }
	    else amass[i][k]= summas[i][k];
	}
    }

    lvtonv(kinmtc_1[0].lvin, 0 , nvin[0],pvect); /*very stupid*/ 

        
    for (i = 0; i < nout1; ++i)  /*  MAIN CYCLE */
    {   int ns___=nsph[i]-1;
        double Emax[2];
	if (i == 0 && nin_int == 1)  xcos = 0.1 /* was fixed  0.1 */; 
                               else  xcos = x[nx++];
	al = 0;
	l = 0;
	if (i == 0 || (i == 1 && nin_int == 1)) 
	{
	    xfi = 0.1;  /* was fixed  0.1;    */
            for(;l<=ns___;l++)
	    {  al +=  sph_inf[i][l].sph_we;
	       if (xcos <= al) ns___ = l;
	    }
	    xcos = (al - xcos) / sph_inf[i][ns___].sph_we;
	} else 
	{
	    xfi = x[nx++];
            for(;l<=ns___;l++)
            {
	       al += sph_inf[i][l].sph_we;
	       if (xfi <= al) ns___ = l;
	    }
	    xfi = (al - xfi) /sph_inf[i][ns___].sph_we;
	}
	lvtonv( sph_inf[i][ns___].lvpole,nin_int, nvpole,pvect);

	decay_0(nvin[i], amass[i][0], amass[i][1], &fct0, Emax,&memDecay,pvect);
	if(fct0==0) {*tfact=0; return 0;}
	if(!isfinite(fct0))
	{ printf("mkmom infinite factor\n");
	  *tfact=0;
	  return 0;
	}  
	decay_1(nvpole, hsum, &hdif,&memDecay,pvect);

	cosmin = -1;
	cosmax = 1;
	nsing = 0;
	for (k = 0; k < 2; ++k) 
	{   int ncM=sph_inf[i][ns___].ncscut[k];
	    int ncT=sph_inf[i][ns___].tcscut[k];
	    d__1 = ((k << 1) - 1) / hdif;
            getreg_(&nsing,singar,hsum[k],d__1,sph_inf[i][ns___].ncsreg[k]);
            if(ncM) rancor_(&cosmin,&cosmax,hsum[k],d__1,ncM);
            if(ncT) rancor_t(&cosmax,hsum[k],d__1,Emax[k], pm[sph_inf[i][ns___].lvpole[0]-1],pcmtilda, 
                            amass[i][k], invcut_1[ncT-1].cvmin );
	    if (cosmin >= cosmax) {*tfact = 0; return 0;}
	}
	regfun_(sph_inf[i][ns___].itypep,nsing,singar,cosmin,cosmax,xcos,&parcos,&fct);
	fct_1__ = sph_inf[i][ns___].sph_we / fct;
	parfi = (xfi * 2 - 1) * M_PI;
	decay_3(nvposy, parcos, parfi, nvout[i][0], nvout[i][1],&memDecay,pvect);

	
	i__2 = nsph[i];
	for (ns = 0; ns < i__2; ++ns)  if (ns != ns___)
	{
	    lvtonv(sph_inf[i][ns].lvpole, nin_int, nvpole,pvect);
	    decay_1(nvpole, hsum, &hdif,&memDecay,pvect);
	    decay_2(nvout[i][1], &parcos,&memDecay,pvect);
	    cosmin = -1;
	    cosmax = 1;
	    nsing = 0;
	    for (k = 0; k < 2; ++k) 
	    {   int ncM=sph_inf[i][ns].ncscut[k];
                int ncT=sph_inf[i][ns].tcscut[k];
		d__1 = ((k << 1) - 1) / hdif;
		getreg_(&nsing,singar,hsum[k],d__1,sph_inf[i][ns].ncsreg[k]);
		if(ncM) rancor_(&cosmin,&cosmax,hsum[k],d__1,ncM);
                if(ncT) rancor_t(&cosmax,hsum[k],d__1,Emax[k], pm[sph_inf[i][ns___].lvpole[0]-1],pcmtilda, 
                            amass[i][k], invcut_1[ncT-1].cvmin );

		if (cosmin>=parcos || parcos>=cosmax){*tfact=0; return 0;}
	    }
	    regfct_(sph_inf[i][ns].itypep,nsing,singar,cosmin,cosmax,parcos, &fct);
	    fct_1__ += sph_inf[i][ns].sph_we/ fct;
	}
	*tfact = *tfact * fct0 / fct_1__;
    }
    if(nin_int==2)
    { *xp1=sf_num[0]? x1:1;
      *xp2=sf_num[1]? x2:1;
      LorRot(rapidity+ytilda,nin_int+nout_int,pvect);
      AzimuthRot(drandXX()*2*M_PI,nout_int, pvect+8);        
    } else 
    { 
        Rot3D(2*(drandXX()-0.5),drandXX()*2*M_PI,drandXX()*M_PI,nout_int,pvect+4); 
        LorRot(rapidity,nin_int+nout_int,pvect);
    }
    
    if(!isfinite(*tfact))
    {  fprintf(stderr,"mkmom: infinite factor\n");
       *tfact=0;
      return 0;
    }

    for(i=0;i<(nin_int+nout_int)*4;i++) if(!isfinite(pvect[i])) {*tfact=0; return 0;}

    return 0;
}