16 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxTrackCandidatesToTracks.hh"
17 #include "RecoTracker/RoadSearchHelixMaker/interface/Dcxmatinv.hh"
18 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxFittedHel.hh"
19 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHit.hh"
20 #include "RecoTracker/RoadSearchHelixMaker/interface/Dcxprobab.hh"
40 double DcxTrackCandidatesToTracks::half_pi=1.570796327;
43 DcxTrackCandidatesToTracks::DcxTrackCandidatesToTracks(){
44 edm::LogInfo(
"RoadSearch") <<
"DcxTrackCandidatesToTracks null constructor - does nothing" ;}
51 for (
unsigned int i=0;
i<listohits.size(); ++
i) {
52 if (!listohits[
i]->stereo()){
53 double rhit=
sqrt(listohits[
i]->
x()*listohits[
i]->
x()+listohits[
i]->
y()*listohits[
i]->
y());
54 if ( (rhit<rmin) ){rmin=rhit;}
56 for (
unsigned int j=0;
j<listohits.size(); ++
j) {
57 for (
unsigned int k=0;
k<listohits.size(); ++
k) {
58 if ( ( ( 1==listohits[
i]->Layer())||( 3==listohits[
i]->Layer()) )
59 && ( ( 9==listohits[
j]->Layer())||(11==listohits[
j]->Layer()) )
60 && ( (17==listohits[
k]->Layer())||(19==listohits[
k]->Layer()) ) ){
61 makecircle(listohits[
i]->
x(),listohits[
i]->
y(),listohits[
j]->
x(),listohits[
j]->
y(),
62 listohits[
k]->
x(),listohits[
k]->
y());
63 double xc=xc_cs;
double yc=yc_cs;
double rc=rc_cs;
64 double d0=
sqrt(xc*xc+yc*yc)-rc;
67 if ( (fabs(s3)>0.1) ){
69 double phi0h=atan2(yc,xc)+s3*half_pi;
71 DcxHel make_a_circ(d0h,phi0h,omegah,0.0,0.0);
72 std::vector<DcxHit*> axlist;
73 check_axial( listohits, axlist, make_a_circ);
74 int n_axial=axlist.size();
75 for (
unsigned int l=0;
l<listohits.size(); ++
l) {
76 for (
unsigned int m=0;
m<listohits.size(); ++
m) {
77 if ( ((2==listohits[
l]->Layer())||(4==listohits[
l]->Layer())) &&
78 ((12==listohits[
m]->Layer())||(10==listohits[
m]->Layer())) ){
79 double z1=find_z_at_cyl(make_a_circ,listohits[
l]);
80 double z2=find_z_at_cyl(make_a_circ,listohits[
m]);
81 double l1=find_l_at_z(z1,make_a_circ,listohits[
l]);
82 double l2=find_l_at_z(z2,make_a_circ,listohits[
m]);
83 double tanl=(z1-z2)/(l1-l2);
double z0=z1-tanl*l1;
84 DcxHel make_a_hel(d0h,phi0h,omegah,z0,tanl);
85 std::vector<DcxHit*> outlist = axlist;
86 check_stereo( listohits, outlist, make_a_hel);
87 int n_stereo=outlist.size()-n_axial;
88 if ((n_stereo>2)&&(n_axial>6)){
89 DcxFittedHel real_fit(outlist,make_a_hel);
90 if (real_fit.Prob()>0.001){
92 edm::LogInfo(
"RoadSearch") <<
"ntrk xprob pt nax nst d0 phi0 omega z0 tanl " << ntrk <<
" " << real_fit.Prob()
93 <<
" " << real_fit.Pt() <<
" " << n_axial <<
" " << n_stereo
94 <<
" " << real_fit.D0() <<
" " << real_fit.Phi0() <<
" " << real_fit.Omega()
95 <<
" " << real_fit.Z0() <<
" " << real_fit.Tanl() ;
99 paraVector[0] = real_fit.Omega();
100 paraVector[1] = half_pi - atan(real_fit.Tanl());
101 paraVector[2] = real_fit.Phi0();
102 paraVector[3] = - real_fit.D0();
103 paraVector[4] = real_fit.Z0();
127 tscp.theState().curvilinearError()));
129 for (
unsigned int n=0;
n<outlist.size(); ++
n){outlist[
n]->SetUsedOnHel(ntrk);}
144 DcxTrackCandidatesToTracks::~DcxTrackCandidatesToTracks( ){ }
146 void DcxTrackCandidatesToTracks::makecircle(
double x1_cs,
double y1_cs,
double x2_cs,
147 double y2_cs,
double x3_cs,
double y3_cs){
148 x1t_cs=x1_cs-x3_cs; y1t_cs=y1_cs-y3_cs; r1s_cs=x1t_cs*x1t_cs+y1t_cs*y1t_cs;
149 x2t_cs=x2_cs-x3_cs; y2t_cs=y2_cs-y3_cs; r2s_cs=x2t_cs*x2t_cs+y2t_cs*y2t_cs;
150 double rho=x1t_cs*y2t_cs-x2t_cs*y1t_cs;
153 fac_cs=
sqrt(x1t_cs*x1t_cs+y1t_cs*y1t_cs);
154 xc_cs=x2_cs+y1t_cs*rc_cs/fac_cs;
155 yc_cs=y2_cs-x1t_cs*rc_cs/fac_cs;
158 xc_cs=fac_cs*(r1s_cs*y2t_cs-r2s_cs*y1t_cs);
159 yc_cs=fac_cs*(r2s_cs*x1t_cs-r1s_cs*x2t_cs);
160 rc_cs=
sqrt(xc_cs*xc_cs+yc_cs*yc_cs); xc_cs+=x3_cs; yc_cs+=y3_cs;
163 f1_cs=x1_cs*yc_cs-y1_cs*xc_cs; f2_cs=x2_cs*yc_cs-y2_cs*xc_cs;
164 f3_cs=x3_cs*yc_cs-y3_cs*xc_cs;
165 if ((f1_cs<0.0)&&(f2_cs<0.0)&&(f3_cs<0.0))s3_cs=1.0;
166 if ((f1_cs>0.0)&&(f2_cs>0.0)&&(f3_cs>0.0))s3_cs=-1.0;
169 void DcxTrackCandidatesToTracks::check_axial( std::vector<DcxHit*> &listohits, std::vector<DcxHit*> &outlist, DcxHel make_a_hel){
170 for (
unsigned int i=0;
i<listohits.size(); ++
i) {
171 DcxHit* try_me = listohits[
i];
172 if ((!try_me->stereo())&&(!try_me->GetUsedOnHel())){
173 double doca = try_me->residual(make_a_hel);
177 if (fabs(doca)<0.100)outlist.push_back(try_me);
182 void DcxTrackCandidatesToTracks::check_stereo( std::vector<DcxHit*> &listohits, std::vector<DcxHit*> &outlist, DcxHel make_a_hel){
183 for (
unsigned int i=0;
i<listohits.size(); ++
i) {
184 DcxHit* try_me = listohits[
i];
185 if ((try_me->stereo())&&(!try_me->GetUsedOnHel())){
186 double doca = try_me->residual(make_a_hel);
190 if (fabs(doca)<0.100)outlist.push_back(try_me);
195 double DcxTrackCandidatesToTracks::find_z_at_cyl(DcxHel he, DcxHit* hi){
197 x0_wr=hi->x(); y0_wr=hi->y(); sx_wr=hi->wx(); sy_wr=hi->wy();
198 xc_cl=he.Xc(); yc_cl=he.Yc(); r_cl=fabs(1.0/he.Omega());
199 double cx=x0_wr-xc_cl;
double cy=y0_wr-yc_cl;
200 double a=sx_wr*sx_wr+sy_wr*sy_wr;
double b=2.0*(sx_wr*cx+sy_wr*cy);
201 double c=(cx*cx+cy*cy-r_cl*r_cl);
202 double bsq=b*
b;
double fac=4.0*a*
c;
double ta=2.0*
a;
204 double sfac=
sqrt(bsq-fac);
double z1=-(b-sfac)/ta;
double z2=-(b+sfac)/ta;
205 if (fabs(z1) < fabs(z2)){
213 double DcxTrackCandidatesToTracks::find_l_at_z(
double zi, DcxHel he, DcxHit* hi){
214 double omega=he.Omega(), d0=he.D0();
215 double xl = hi->x()+zi*hi->wx()/hi->wz();
216 double yl = hi->y()+zi*hi->wy()/hi->wz();
217 double rl =
sqrt(xl*xl+yl*yl);
218 double orcsq=(1.0+d0*omega)*(1.0+d0*omega);
219 double orlsq=(rl*omega)*(rl*omega);
220 double cphil=(1.0+orcsq-orlsq)/(2.0*(1.0+d0*omega));
221 double phil1=acos(cphil);
222 double l1=fabs(phil1/omega);
std::vector< Track > TrackCollection
collection of Tracks
ROOT::Math::SVector< double, 5 > AlgebraicVector5
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation