279 if(m_debug) std::cout<<
" helixPat "<<helixPat<<std::endl;
280 if(m_debug) std::cout<<
" layer "<<layer<<
" cell "<<cell<<std::endl;
289 std::cout<<
" cellId in "<<cellId_in<<
" out "<<cellId_out <<std::endl;
290 cout <<
"cell = " << cell <<
", cellId_in = " << cellId_in <<
", cellId_out = " << cellId_out << endl;
292 if (passCellRequired &&(cell < cellId_in && cell > cellId_out))
return -999.;
299 int innerOrOuter = 1;
301 double fltTrack = 0.1 * m_mdcGeomSvc -> Layer(layer)->Radius();
303 std::cout<<
" cell_IO "<<cell_IO<<std::endl;
304 std::cout<<
" fltTrack "<<fltTrack<<std::endl;
313 std::cout<<
" sag "<<m_wireTraj->
sag()<<std::endl;
314 std::cout<<
" east -------- "<< start_In->x()<<
","<<start_In->y()<<
","<<start_In->z()<<std::endl;
321 double zWire = cell_IO.z();
324 if(m_debug) std::cout<<
" zWire "<<zWire<<
" zEndDC "<<sWire->
zEndDC()<<std::endl;
327 double fltWire = sqrt( (pos_in.x()-start_In->x())*(pos_in.x()-start_In->x()) +
328 (pos_in.y()-start_In->y())*(pos_in.y()-start_In->y()) +
329 (pos_in.z()-start_In->z())*(pos_in.z()-start_In->z()) );
330 trkPoca =
new TrkPoca(*trajHelix, fltTrack, *trajWire, fltWire);
333 double hitLen = trkPoca->
flt2();
334 double startLen = trajWire->
lowRange() - 5.;
335 double endLen = trajWire->
hiRange() + 5.;
336 if(hitLen < startLen || hitLen > endLen) {
337 if(m_debug) std::cout<<
"WARNING MdcUtilitySvc::docaPatPar() isBeyondEndflange! hitLen="<<hitLen <<
" startLen="<<startLen<<
" endLen "<<endLen<<std::endl;
342 if(m_debug) std::cout<<
" doca "<<
doca<<std::endl;
426 int charge,type,nCell;
427 double dr0,phi0,kappa,dz0,tanl;
428 double ALPHA_loc,rho,phi,cosphi0,sinphi0,x_hc,y_hc,z_hc;
429 double dphi0,IO_phi,C_alpha,xx,yy;
430 double inlow,inup,outlow,outup,phi_in,phi_out,phi_bin;
431 double rCize1,rCize2,rLay,
length,phioffset,slant,shift;
432 double m_crio[2], phi_io[2], stphi[2],phioff[2],dphi[2];
440 ALPHA_loc = 1000/(2.99792458*Bz());
441 charge = ( kappa >=0 ) ? 1 : -1 ;
442 rho = ALPHA_loc/kappa ;
444 phi = fmod(phi0 + 4*
pi , 2*
pi);
446 sinphi0 = (1.0 - cosphi0 ) * (1.0 + cosphi0 );
447 sinphi0 = sqrt(( sinphi0 > 0.) ? sinphi0 : 0.);
448 if( phi >
pi ) sinphi0 = -sinphi0 ;
450 x_hc = 0. + ( dr0 + rho ) * cosphi0;
451 y_hc = 0. + ( dr0 + rho ) * sinphi0;
458 double m_c_perp(hcenter.perp());
459 Hep3Vector m_c_unit((
HepPoint3D)hcenter.unit());
462 dphi0 = fmod(IO.phi()+4*
pi, 2*
pi) - phi;
463 IO_phi = fmod(IO.phi()+4*
pi, 2*
pi);
465 if(dphi0 >
pi) dphi0 -= 2*
pi;
466 else if(dphi0 < -
pi) dphi0 += 2*
pi;
468 phi_io[0] = -(1+charge)*
pi/2 - charge*dphi0;
469 phi_io[1] = phi_io[0]+1.5*
pi;
472 bool outFlag =
false;
486 m_crio[0] = rLay - rCize1 ;
487 m_crio[1] = rLay + rCize2 ;
491 Hep3Vector iocand[2];
492 Hep3Vector cell_IO[2];
494 for(
int ii =0; ii<2; ii++){
496 double cos_alpha = (m_c_perp*m_c_perp + m_crio[ii]*m_crio[ii] - rho*rho)
497 / ( 2 * m_c_perp * m_crio[ii] );
498 if(fabs(cos_alpha)>1&&(ii==0)){
502 if(fabs(cos_alpha)>1&&(ii==1)){
503 cos_alpha = (m_c_perp*m_c_perp + m_crio[0]*m_crio[0] - rho*rho)
504 / ( 2 * m_c_perp * m_crio[0] );
505 C_alpha = 2*
pi - acos( cos_alpha);
507 C_alpha = acos( cos_alpha );
510 iocand[ii] = m_c_unit;
511 iocand[ii].rotateZ( charge*sign*C_alpha );
512 iocand[ii] *= m_crio[ii];
514 xx = iocand[ii].x() - x_hc ;
515 yy = iocand[ii].y() - y_hc ;
517 dphi[ii] = atan2(yy,xx) - phi0 - 0.5*
pi*(1-charge);
518 dphi[ii] = fmod( dphi[ii] + 8.0*
pi,2*
pi);
521 if( dphi[ii] < phi_io[0] ) {
523 }
else if( dphi[ii] > phi_io[1] ){
527 cell_IO[ii] =
Hel(piv, dr0, phi, ALPHA_loc, kappa,dz0, dphi[ii], tanl);
530 if( (cell_IO[ii].
x()==0 ) && (cell_IO[ii].y()==0) && (cell_IO[ii].z()==0))
continue;
534 cellId_in = cellId_out = -1 ;
535 phi_in = cell_IO[0].phi();
536 phi_in = fmod ( phi_in + 4 *
pi, 2 *
pi );
537 phi_out = cell_IO[1].phi();
538 phi_out = fmod ( phi_out + 4 *
pi, 2 *
pi );
539 phi_bin = 2.0 *
pi / nCell ;
542 stphi[0] = shift * phi_bin * (0.5 - cell_IO[0].z()/
length);
543 stphi[1] = shift * phi_bin * (0.5 - cell_IO[1].z()/
length);
546 phioff[0] = phioffset + stphi[0];
547 phioff[1] = phioffset + stphi[1];
549 for(
int kk = 0; kk<nCell ; kk++){
551 inlow = phioff[0] + phi_bin*kk - phi_bin*0.5;
552 inlow = fmod( inlow + 4.0 *
pi , 2.0 *
pi);
553 inup = phioff[0] + phi_bin*kk + phi_bin*0.5;
554 inup = fmod( inup + 4.0 *
pi , 2.0 *
pi);
555 outlow = phioff[1] + phi_bin*kk - phi_bin*0.5;
556 outlow = fmod( outlow + 4.0 *
pi ,2.0 *
pi);
557 outup = phioff[1] + phi_bin*kk + phi_bin*0.5;
558 outup = fmod( outup + 4.0 *
pi , 2.0 *
pi);
560 if((phi_in>=inlow && phi_in<=inup)) cellId_in = kk;
561 if((phi_out>=outlow&&phi_out<outup)) cellId_out = kk;
563 if((phi_in>=inlow&&phi_in<2.0*
pi)||(phi_in>=0.0&&phi_in<inup)) cellId_in = kk;
566 if((phi_out>=outlow&&phi_out<=2.0*
pi)||(phi_out>=0.0&&phi_out<outup)) cellId_out = kk;
570 return (cellId_in==cellId_out);