36 {
37
38
39
40
41
43
44 for(int iline=0;iline<8;iline++){
45 linefit[iline]._pointCol.push_back( *(_recStereoHit[0]) );
46 linefit[iline]._pointCol.push_back( *(_recStereoHit[1]) );
47 linefit[iline]._pointCol.push_back( *(_recStereoHit[2]) );
48 }
50 for(int i =0;i<3;i++){
51 cout<<" the first 3 hits ("<<i<<" "<< _recStereoHit[i]->getLayerId()<<","<<_recStereoHit[i]->getWireId()<<")"<<endl;
52 cout<<" left "<<(_recStereoHit[i])->getsAmb(0)<<" "<<(_recStereoHit[i])->getzAmb(0)<<endl;
53 cout<<" right "<<(_recStereoHit[i])->getsAmb(1)<<" "<<(_recStereoHit[i])->getzAmb(1)<<endl;
54 }
55 }
56
57 linefit[0]._pointCol[0].setAmb(0);
58 linefit[0]._pointCol[1].setAmb(0);
59 linefit[0]._pointCol[2].setAmb(0);
60
61 linefit[1]._pointCol[0].setAmb(0);
62 linefit[1]._pointCol[1].setAmb(0);
63 linefit[1]._pointCol[2].setAmb(1);
64
65 linefit[2]._pointCol[0].setAmb(0);
66 linefit[2]._pointCol[1].setAmb(1);
67 linefit[2]._pointCol[2].setAmb(0);
68
69 linefit[3]._pointCol[0].setAmb(0);
70 linefit[3]._pointCol[1].setAmb(1);
71 linefit[3]._pointCol[2].setAmb(1);
72
73
74 linefit[4]._pointCol[0].setAmb(1);
75 linefit[4]._pointCol[1].setAmb(0);
76 linefit[4]._pointCol[2].setAmb(0);
77
78 linefit[5]._pointCol[0].setAmb(1);
79 linefit[5]._pointCol[1].setAmb(0);
80 linefit[5]._pointCol[2].setAmb(1);
81
82 linefit[6]._pointCol[0].setAmb(1);
83 linefit[6]._pointCol[1].setAmb(1);
84 linefit[6]._pointCol[2].setAmb(0);
85
86 linefit[7]._pointCol[0].setAmb(1);
87 linefit[7]._pointCol[1].setAmb(1);
88 linefit[7]._pointCol[2].setAmb(1);
89
90 for(int i=0;i<8;i++){
91 linefit[i]._ambig.push_back( linefit[i]._pointCol[0].getAmbig() );
92 linefit[i]._ambig.push_back( linefit[i]._pointCol[1].getAmbig() );
93 linefit[i]._ambig.push_back( linefit[i]._pointCol[2].getAmbig() );
94 if(
m_debug>0) cout<<
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^begin line "<<i<<endl;
96
97 int line_size=3;
98 for(int j=3;j<_hitSize;j++){
99 double chi_last=linefit[i]._chi;
100 double k_last=linefit[i]._k;
101 double b_last=linefit[i]._b;
102 if(
m_debug>0) cout<<
"last "<<j<<
" chi k b "<<chi_last<<
" "<<k_last<<
" "<<b_last<<endl;
103 linefit[i]._pointCol.push_back( *(_recStereoHit[j]) );
104
105
106
107 linefit[i]._pointCol[line_size].setAmb(0);
108 if(
m_debug>0) cout<<
"Add point left "<<
"("<<linefit[i]._pointCol[line_size].getLayerId()<<
","<<linefit[i]._pointCol[line_size].getWireId()<<
") "<<linefit[i]._pointCol[line_size].getStyle()<<
" "<<linefit[i]._pointCol[line_size].getsPos()<<
" "<<linefit[i]._pointCol[line_size].getzPos()<<endl;
110 double chil=linefit[i]._chi;
111 double kl=linefit[i]._k;
112 double bl=linefit[i]._b;
113 if (linefit[i]._pointCol[line_size].getsPos()==-99) {
114 chil = 9999;
115 }
116 if(
m_debug>0) cout<<
"left "<<line_size<<
" chi k b "<<chil<<
" "<<kl<<
" "<<bl<<endl;
117
118 linefit[i]._pointCol[line_size].setAmb(1);
119 if(
m_debug>0) cout<<
"Add point right "<<
"("<<linefit[i]._pointCol[line_size].getLayerId()<<
","<<linefit[i]._pointCol[line_size].getWireId()<<
") "<<linefit[i]._pointCol[line_size].getStyle()<<
" "<<linefit[i]._pointCol[line_size].getsPos()<<
" "<<linefit[i]._pointCol[line_size].getzPos()<<endl;
121 double chir=linefit[i]._chi;
122 double kr=linefit[i]._k;
123 double br=linefit[i]._b;
124 if (linefit[i]._pointCol[line_size].getsPos()==-99) {
125 chir = 9999;
126 }
127 if(
m_debug>0) cout<<
"right "<<line_size<<
" chi k b "<<chir<<
" "<<kr<<
" "<<br<<endl;
128
129 if(chil<chir) {
130 linefit[i]._pointCol[line_size].setAmb(0);
131 linefit[i]._chi=chil;
132 linefit[i]._k=kl;
133 linefit[i]._b=bl;
134 linefit[i]._ambig.push_back(0);
135
136 }
137 else linefit[i]._ambig.push_back(1);
138 line_size++;
139
140
141 int same_ambig = 1;
142 for(int ihit=0;ihit<line_size;ihit++){
143 int ambighit = linefit[i]._pointCol[ihit].getAmbig();
144 int ambigTruth = linefit[i]._pointCol[ihit].getLrTruth();
145 int layer =linefit[i]._pointCol[ihit].getLayerId();
146 int wire=linefit[i]._pointCol[ihit].getWireId();
147
148
149
150
151
152 }
153
154
155
156 double dChi = chi_last-linefit[i]._chi;
157 double dChi_n = (linefit[i]._chi)/(line_size-1)-(chi_last/line_size);
158 if(
m_debug>0) cout<<
"dChi: "<<dChi<<endl;
159 if(
m_debug>0) cout<<
"dChi/n: "<<dChi_n<<endl;
161
162 if( fabs(dChi_n) > 25.)
163
164
165
166 {
167 linefit[i]._pointCol.pop_back();
168 linefit[i]._chi=chi_last;
169 linefit[i]._k=k_last;
170 linefit[i]._b=b_last;
171 linefit[i]._ambig.at(j)=-999;
172 line_size--;
173 }
174 }
175
176 if( (linefit[i]._pointCol[0].getsPos()==-99) || (linefit[i]._pointCol[1].getsPos()==-99) || (linefit[i]._pointCol[2].getsPos()==-99) ) {
177 linefit[i]._chi=99999;
178 }
179 }
181 for(int i=0;i<8;i++){
182 if(
m_debug>0) cout<<
"Line :"<<i<<
" chis: "<<linefit[i]._chi<<
" k,b: "<<linefit[i]._k<<
" "<<linefit[i]._b<<endl;
183 int ambig_correct = 0;
184 for(int j=0;j<_hitSize;j++){
185 int ambig = linefit[i]._ambig.at(j);
186 int layer= _recStereoHit.at(j)->getLayerId();
187 int wire= _recStereoHit.at(j)->getWireId();
188 int style= _recStereoHit.at(j)->getStyle();
189 double l=-99;
190 if (ambig!=-999) l= _recStereoHit.at(j)->getsAmb(ambig);
191 double z=-99;
192 if (ambig!=-999) z= _recStereoHit.at(j)->getzAmb(ambig);
193
194 if (l==-99 && z==-99) ambig=-999;
195 if(
m_debug>0) cout<<
"("<<layer<<
" ,"<<wire<<
") style "<<style<<
" ambig "<<ambig<<
" s "<<l<<
" z "<<z<<endl;
196 if(i==0) {
197 _recStereoHit[j]->setAmb(ambig);
198 if( ambig ==-999) _recStereoHit[j]->setflag(-999);
199 int ambigTruth = _recStereoHit.at(j)->getLrTruth();
200 if (ambigTruth == -1) ambigTruth=1;
201 else if (ambigTruth == 1) ambigTruth=0;
202 if(ambig ==ambigTruth) ambig_correct++;
203
204 _pro_correct = (double)ambig_correct/(double)_hitSize;
205 }
206 }
207 }
208 _tanl=linefit[0]._k;
209 _z0=linefit[0]._b;
210 if(
m_debug>0) cout<<
"z0 tanl : "<<_z0<<
" "<<_tanl<<endl;
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293}
bool compare_zsfit(const HoughZsFit::Line &a, const HoughZsFit::Line &b)
void leastFit(Line &linefit, int N)