23 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHel.hh"
24 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHit.hh"
31 double DcxHel::half_pi=1.570796327;
35 double DcxHel::ktopt =0.0120;
42 (
double D0,
double Phi0,
double Omega,
double Z0,
double Tanl,
43 double T0,
int Code,
int Mode,
double X,
double Y){
44 omin=0.000005; omega=Omega; ominfl=1;
if(fabs(omega)<omin){ominfl=0;}
49 xref=
X; yref=Y; t0=T0;
50 cphi0=
cos(phi0); sphi0=
sin(phi0);
51 x0=
X0(); y0=
Y0(); xc=Xc(); yc=Yc();
53 decode(code,qd0,qphi0,qomega,qz0,qtanl,qt0,nfree);
54 mode=Mode; turnflag=0;
58 (
float D0,
float Phi0,
float Omega,
float Z0,
float Tanl,
59 float T0,
int Code,
int Mode,
float X,
float Y){
60 omin=0.000005; omega=Omega; ominfl=1;
if(fabs(omega)<omin){ominfl=0;}
65 xref=
X; yref=Y; t0=T0;
66 cphi0=
cos(phi0); sphi0=
sin(phi0);
67 x0=
X0(); y0=
Y0(); xc=Xc(); yc=Yc();
69 decode(code,qd0,qphi0,qomega,qz0,qtanl,qt0,nfree);
70 mode=Mode; turnflag=0;
77 double DcxHel::Xc()
const{
79 return (
X0()-sphi0/omega);
85 double DcxHel::Yc()
const{
87 return (
Y0()+cphi0/omega);
94 return (xref-sphi0*d0);
98 return (yref+cphi0*d0);
101 double DcxHel::Xh(
double l)
const{
103 double phit=phi0+omega*
l;
104 return (xc+
sin(phit)/omega);
106 return (x0+cphi0*l-0.5*l*l*omega*sphi0);
110 double DcxHel::Yh(
double l)
const{
112 double phit=phi0+omega*
l;
113 return (yc-
cos(phit)/omega);
115 return (y0+sphi0*l+0.5*l*l*omega*cphi0);
119 double DcxHel::Zh(
double l)
const{
124 if(ominfl){
return DcxHel::ktopt/fabs(omega);}
125 else{
return 1000000.0;}
128 double DcxHel::Px(
double l)
const{
129 if(ominfl){
double phit=phi0+omega*
l;
return DcxHel::ktopt*
cos(phit)/fabs(omega);}
130 else{
return 1000.0*cphi0;}
133 double DcxHel::Py(
double l)
const{
134 if(ominfl){
double phit=phi0+omega*
l;
return DcxHel::ktopt*
sin(phit)/fabs(omega);}
135 else{
return 1000.0*sphi0;}
138 double DcxHel::Pz(
double l)
const{
139 if(ominfl){
return DcxHel::ktopt*tanl/fabs(omega);}
140 else{
return 1000.0*tanl;}
143 double DcxHel::Ptot(
double l)
const{
144 if(ominfl){
return DcxHel::ktopt*
sqrt(1.0+tanl*tanl)/fabs(omega);}
145 else{
return 1000.0*
sqrt(1.0+tanl*tanl);}
148 double DcxHel::Lmax()
const{
151 double rmax=1.0/fabs(omega);
152 double dmax=fabs(d0)+2.0*rmax;
160 void DcxHel::SetMode(
int n){
mode=
n;}
161 void DcxHel::SetRef(
double x,
double y){xref=
x; yref=
y;}
163 void DcxHel::SetOmega(
int Qomega){
164 nfree=nfree+deltaq(qomega,Qomega);
165 code=code+deltaq(qomega,Qomega)*100;
168 void DcxHel::SetPhi0(
int Qphi0){
169 nfree=nfree+deltaq(qphi0,Qphi0);
170 code=code+deltaq(qphi0,Qphi0)*10;
173 void DcxHel::SetD0(
int Qd0){
174 nfree=nfree+deltaq(qd0,Qd0);
175 code=code+deltaq(qd0,Qd0);
178 void DcxHel::SetTanl(
int Qtanl){
179 nfree=nfree+deltaq(qtanl,Qtanl);
180 code=code+deltaq(qtanl,Qtanl)*10000;
183 void DcxHel::SetZ0(
int Qz0){
184 nfree=nfree+deltaq(qz0,Qz0);
185 code=code+deltaq(qz0,Qz0)*1000;
188 void DcxHel::SetT0(
int Qt0) {
189 nfree=nfree+deltaq(qt0, Qt0);
190 code=code+deltaq(qt0, Qt0)*100000;
203 int& i3,
int& i4,
int& i5,
int& i6,
int&
n)
206 temp=temp/1000000; temp=kode-1000000*
temp;
207 i6=temp/100000; temp=temp-100000*i6;
208 i5=temp/10000; temp=temp-10000*i5;
209 i4=temp/1000; temp=temp-1000*i4;
210 i3=temp/100; temp=temp-100*i3;
211 i2=temp/10; i1=temp-10*i2;
213 if(i6==1){n++;}
else{i6=0;};
214 if(i5==1){n++;}
else{i5=0;};
215 if(i4==1){n++;}
else{i4=0;};
216 if(i3==1){n++;}
else{i3=0;};
217 if(i2==1){n++;}
else{i2=0;};
218 if(i1==1){n++;}
else{i1=0;};
225 omega=rhs.Omega(); phi0=rhs.Phi0(); d0=rhs.D0(); t0=rhs.T0();
226 tanl=rhs.Tanl(); z0=rhs.Z0();
227 cphi0=rhs.CosPhi0(); sphi0=rhs.SinPhi0();
228 x0=rhs.X0(); y0=rhs.Y0(); xc=rhs.Xc(); yc=rhs.Yc();
229 xref=rhs.Xref(); yref=rhs.Yref();
230 qomega=rhs.Qomega(); qphi0=rhs.Qphi0(); qd0=rhs.Qd0(); qt0=rhs.Qt0();
231 qtanl=rhs.Qtanl(); qz0=rhs.Qz0();
232 mode=rhs.Mode(); nfree=rhs.Nfree();
233 code=rhs.Code(); ominfl=rhs.Ominfl(); omin=rhs.Omin();
234 turnflag=rhs.GetTurnFlag();
238 DcxHel::Doca(
double wx,
double wy,
double wz,
239 double xi,
double yi,
double zi )
243 CLHEP::Hep3Vector ivec(xi,yi,zi);
244 wvec=CLHEP::Hep3Vector(wx,wy,wz);
249 double lnew,t1,t2,dphi,dlen=1000.0; len=0.0;
int itry=2;
252 double circut, circum=10000.;
253 if (ominfl){circum=
DcxHel::twoPi/fabs(omega);} circut=0.50*circum;
256 t1=-xc+xd; t2=yc-yd;
phi=atan2(t1,t2);
268 if ((lnew>circut)&&(turnflag))lnew-=circum;
275 dlen=fabs(lnew-len); len=lnew;
277 if (fabs(zh) > 250.0)
break;
278 if ( (0.0==wx) && (0.0==wy) )
break;
if (dlen < 0.000001)
break; itry--;
279 }
else{len=(xi-xref)*cphi0+(yi-yref)*sphi0; zh=z0+tanl*len;
phi=phi0;
break;}
282 xh=Xh(len); yh=Yh(len); CLHEP::Hep3Vector hvec(xh,yh,zh);
284 double lamb=atan(tanl); cosl=
cos(lamb); sinl=
sin(lamb);
286 tvec=CLHEP::Hep3Vector(tx,ty,tz);
287 CLHEP::Hep3Vector vvec=wvec.cross(tvec);
288 vhat=vvec.unit(); vx=vhat.x(); vy=vhat.y(); vz=vhat.z();
290 dvec=ivec-hvec;
double doca=dvec*vhat;
292 double f1=dvec*tvec;
double f2=wvec*tvec;
double f3=dvec*wvec;
293 f0=(f1-f2*
f3)/(1.0-f2*f2);
294 if (doca>0.0){samb=-1;}
else{samb=+1;}
295 double wirephi=atan2(yd,xd);
297 eang=normalize(
phi-wirephi);
298 if (fabs(eang)<half_pi){wamb=samb;}
else{wamb=-samb;}
299 if (fabs(zh) > 250.0)doca=1000.0;
304 DcxHel::derivatives(
const DcxHit&
hit)
306 double doca=Doca(hit);
307 std::vector<float>
temp(nfree+1);
310 if((
mode==0)&&(doca<0.0)) {fac=-fac;}
311 if(
mode==0) {temp[0]=fabs(temp[0]);}
313 if(qd0){
double dddd0=-vx*sphi0+vy*cphi0; bump++; temp[bump]=dddd0*fac;}
316 double dddp0=-(yh-y0+f0*ty)*vx+(xh-x0+f0*tx)*vy;
317 dddp0=dddp0*(1.0+d0*omega);
318 bump++; temp[bump]=dddp0*fac;
320 if(qomega){
double dddom;
322 dddom=((len*
cos(
phi)-xh+x0)*vx+(len*
sin(
phi)-yh+y0)*vy)/omega;
325 else{dddom=0.5*len*len*(-vx*sphi0+vy*cphi0);}
326 bump++; temp[bump]=dddom*fac;
328 if(qz0){
double dddz0=vz; bump++; temp[bump]=dddz0*fac;}
329 if(qtanl){
double ddds=vz*len; bump++; temp[bump]=ddds*fac;}
330 if(qt0){bump++; temp[bump]=-hit.v();}
337 <<
" phi0 = " << phi0
338 <<
" omega = " << omega
340 <<
" tanl = " << tanl
342 <<
" code = " << code
343 <<
" mode = " <<
mode
344 <<
" ominfl = " << ominfl
345 <<
" nfree = " << nfree
350 <<
" xref = " << xref
351 <<
" yref = " << yref
357 if ( (fabs(d0)+2.0/fabs(omega)) > 80.0)
return;
358 double lturn=
DcxHel::twoPi/fabs(omega);
double zturn=Zh(lturn);
360 if (fabs(zturn) < fabs(z0)){
361 z0=zturn; tanl=-tanl; omega=-omega; d0=-d0;
363 cphi0=
cos(phi0); sphi0=
sin(phi0); x0=
X0(); y0=
Y0();
368 double DcxHel::normalize(
double angle) {
nocap nocap const skelname & operator=(const skelname &)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Sin< T >::type sin(const T &t)
Cos< T >::type cos(const T &t)
bool decode(bool &, std::string const &)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)