10 using namespace Eigen;
54 VtxTrackFinder::VtxTrackFinder(vector<float>& detrad,
unsigned int n_phi,
unsigned int n_d,
unsigned int n_k,
unsigned int n_dzdl,
unsigned int n_z0,
HelixResolution& min_resolution,
HelixResolution& max_resolution,
HelixRange& range) :
HelixHough(n_phi, n_d, n_k, n_dzdl, n_z0, min_resolution, max_resolution, range), using_vertex(
false), vertex_sigma_xy(0.002), vertex_sigma_z(0.005), chi2_cut(3.)
56 for(
unsigned int i=0;i<detrad.size();++i)
65 vector<double> chi2_hits;
67 temp_track.
hits.resize(4, hits[0]);
68 for(
unsigned int i1=0;i1<hits.size();++i1)
70 temp_track.
hits[0] = hits[i1];
71 for(
unsigned int i2=(i1+1);i2<hits.size();++i2)
73 if( (hits[i2].
layer == hits[i1].
layer)){
continue;}
74 temp_track.
hits[1] = hits[i2];
75 for(
unsigned int i3=(i2+1);i3<hits.size();++i3)
77 if((hits[i3].layer == hits[i2].layer) || (hits[i3].layer == hits[i1].layer)){
continue;}
78 temp_track.
hits[2] = hits[i3];
79 for(
unsigned int i4=(i3+1);i4<hits.size();++i4)
81 if( (hits[i4].layer == hits[i3].layer) || (hits[i4].layer == hits[i2].layer) || (hits[i4].layer == hits[i1].layer)){
continue;}
82 temp_track.
hits[3] = hits[i4];
84 vector<unsigned int> tempcomb;
86 tempcomb[0] = temp_track.
hits[0].index;
87 tempcomb[1] = temp_track.
hits[1].index;
88 tempcomb[2] = temp_track.
hits[2].index;
89 tempcomb[3] = temp_track.
hits[3].index;
90 sort(tempcomb.begin(), tempcomb.end());
91 set<vector<unsigned int> >::iterator
it =
combos.find(tempcomb);
92 if(it !=
combos.end()){
continue;}
94 double chi2 =
fitTrack(temp_track, chi2_hits);
96 tracks.push_back(temp_track);
106 unsigned int nt = input.size();
107 for(
unsigned int i=0;i<nt;++i)
109 output.push_back(input[i]);
122 chi2_hit.resize(track.
hits.size(), 0.);
124 MatrixXf
y = MatrixXf::Zero(track.
hits.size(), 1);
125 for(
unsigned int i=0;i<track.
hits.size();i++)
127 y(i, 0) = ( pow(track.
hits[i].x,2) + pow(track.
hits[i].y,2) );
132 MatrixXf
X = MatrixXf::Zero(track.
hits.size(), 3);
133 for(
unsigned int i=0;i<track.
hits.size();i++)
135 X(i, 0) = track.
hits[i].x;
136 X(i, 1) = track.
hits[i].y;
152 MatrixXf Xt = X.transpose();
154 MatrixXf prod = Xt*
X;
155 MatrixXf inv = prod.fullPivLu().inverse();
157 MatrixXf beta = inv*Xt*
y;
159 float cx = beta(0,0)*0.5;
160 float cy = beta(1,0)*0.5;
161 float r = sqrt(cx*cx + cy*cy - beta(2,0));
163 float phi = atan2(cy, cx);
164 float d = sqrt(cx*cx + cy*cy) -
r;
167 MatrixXf diff = y - (X*beta);
168 MatrixXf chi2 = (diff.transpose())*diff;
170 float dx = d*cos(phi);
171 float dy = d*sin(phi);
173 MatrixXf
y2 = MatrixXf::Zero(track.
hits.size(), 1);
174 for(
unsigned int i=0;i<track.
hits.size();i++)
176 y2(i,0) = track.
hits[i].z;
181 MatrixXf
X2 = MatrixXf::Zero(track.
hits.size(), 2);
182 for(
unsigned int i=0;i<track.
hits.size();i++)
184 float D = sqrt( pow(dx - track.
hits[i].x, 2) + pow(dy - track.
hits[i].y,2));
190 if(v >= 0.999999){v = 0.999999;}
221 MatrixXf Xt2 = X2.transpose();
222 MatrixXf prod2 = Xt2*
X2;
223 MatrixXf inv2 = prod2.fullPivLu().inverse();
224 MatrixXf beta2 = inv2*Xt2*
y2;
226 MatrixXf diff2 = y2 - (X2*beta2);
227 MatrixXf chi2_z = (diff2.transpose())*diff2;
229 float z0 = beta2(1,0);
230 float dzdl = beta2(0,0)/sqrt(1. + beta2(0,0)*beta2(0,0));
247 cx = (track.
d+
r)*cos(track.
phi);
248 cy = (track.
d+
r)*sin(track.
phi);
251 for(
unsigned int h=0;
h<track.
hits.size();
h++)
253 float dx1 = track.
hits[
h].x - cx;
254 float dy1 = track.
hits[
h].y - cy;
256 float dx2 = track.
hits[
h].x + cx;
257 float dy2 = track.
hits[
h].y + cy;
259 float xydiff1 = sqrt(dx1*dx1 + dy1*dy1) -
r;
260 float xydiff2 = sqrt(dx2*dx2 + dy2*dy2) -
r;
261 float xydiff = xydiff2;
262 if(fabs(xydiff1) < fabs(xydiff2)){ xydiff = xydiff1; }
271 chi2_hit[
h] += xydiff*xydiff/(ls_xy*ls_xy);
272 chi2_hit[
h] += diff2(
h,0)*diff2(
h,0);
274 chi2_tot += chi2_hit[
h];
277 unsigned int deg_of_freedom = 2*track.
hits.size() - 5;
281 track.
hits.pop_back();
285 return (chi2_tot)/((double)(deg_of_freedom));