88 if ( ( whichtrack >=
ntracks ) || ( whichtrack < 0 ) )
90 cout <<
"asked for associates of track " << whichtrack <<
" while there are only "
91 <<
ntracks <<
" tracks in list " << endl;
95 double m_2pi = 2.0 *
M_PI;
98 if ( 5 == debug ) temphel->
print();
100 double lmax = temphel->
Lmax();
108 double rmin = fabs( temphel->
D0() );
109 double rmax, pc, rc, rhel;
112 rmax = fabs( temphel->
D0() + 2.0 / temphel->
Omega() );
113 double xc = temphel->
Xc();
114 double yc = temphel->
Yc();
115 pc = atan2( yc, xc );
116 rc = fabs( temphel->
D0() + 1.0 / temphel->
Omega() );
117 rhel = fabs( 1.0 / temphel->
Omega() );
122 pc = temphel->
Phi0();
128 std::cout <<
"==Test add hit phi: rmin >?" << rmin <<
" gvin " << gvin <<
" rmax >?"
129 << rmax <<
" gvout " << gvout << std::endl;
132 if ( ( rmin < gvin ) && ( rmax > gvout ) )
135 if ( 5 == debug ) std::cout <<
" case A (exiter) " << std::endl;
138 double lstep = m_2pi * rhel / 16.;
139 if ( lstep > 10. ) lstep = 10.;
140 double xl = temphel->
Xh( len );
141 double yl = temphel->
Yh( len );
142 double phil = atan2( yl, xl );
143 double rl = sqrt( xl * xl + yl * yl );
145 double philast = phil;
148 while ( ( notout ) && ( nstep < 20 ) )
152 xl = temphel->
Xh( len );
153 yl = temphel->
Yh( len );
154 phil = atan2( yl, xl );
155 rl = sqrt( xl * xl + yl * yl );
156 if ( ( rl < gvin ) && ( !isin ) ) { philast = phil; }
157 else if ( ( rl > gvin ) && ( !isin ) )
165 double deltap = phil - philast;
166 if ( deltap >
M_PI ) phil -= m_2pi;
167 if ( deltap < -
M_PI ) phil += m_2pi;
169 if ( rl > gvout ) notout = 0;
170 if ( phil < phim ) phim = phil;
171 if ( phil > phip ) phip = phil;
175 else if ( ( rmin > gvin ) && ( rmax > gvout ) )
177 if ( 5 == debug ) std::cout <<
" case B (albedo) " << std::endl;
180 double lstep = m_2pi * rhel / 16.;
181 if ( lstep > 10. ) lstep = 10.;
182 double xl = temphel->
Xh( len );
183 double yl = temphel->
Yh( len );
184 double phil = atan2( yl, xl );
185 double rl = sqrt( xl * xl + yl * yl );
189 double deltap, dp1, dp2;
191 double philast = phil;
192 while ( ( rl < gvout ) && ( nstep < 20 ) )
196 xl = temphel->
Xh( len );
197 yl = temphel->
Yh( len );
198 phil = atan2( yl, xl );
199 rl = sqrt( xl * xl + yl * yl );
200 deltap = phil - philast;
201 if ( deltap >
M_PI ) phil -= m_2pi;
202 if ( deltap < -
M_PI ) phil += m_2pi;
204 if ( phil < phim ) phim = phil;
205 if ( phil > phip ) phip = phil;
207 dp1 = fabs( phis - phim );
208 dp2 = fabs( phip - phis );
210 if ( dp2 > dp1 ) deltap = dp2;
211 phim = phis - deltap;
212 phip = phis + deltap;
214 else if ( ( rmin < gvin ) && ( rmax < gvout ) )
217 if ( 5 == debug ) std::cout <<
" case C (looper) " << std::endl;
220 double alp = asin( rhel / rc );
228 double lstep = m_2pi * rhel / 16.;
229 if ( lstep > 10. ) lstep = 10.;
231 std::cout <<
"ini step " << m_2pi * rhel / 16. <<
" lstep " << lstep <<
"cm"
233 double xl = temphel->
Xh( len );
234 double yl = temphel->
Yh( len );
235 double phil = atan2( yl, xl );
236 double rl = sqrt( xl * xl + yl * yl );
238 double philast = phil;
241 while ( ( notout ) && ( nstep < 33 ) )
245 xl = temphel->
Xh( len );
246 yl = temphel->
Yh( len );
247 phil = atan2( yl, xl );
248 rl = sqrt( xl * xl + yl * yl );
250 { std::cout << nstep <<
" rl " << rl <<
" gvin " << gvin <<
" isin " << isin; }
251 if ( ( rl < gvin ) && ( !isin ) ) { philast = phil; }
252 else if ( ( rl > gvin ) && ( !isin ) )
260 double deltap = phil - philast;
261 if ( deltap >
M_PI ) phil -= m_2pi;
262 if ( deltap < -
M_PI ) phil += m_2pi;
264 if ( rl < gvin ) notout = 0;
265 if ( phil < phim ) phim = phil;
266 if ( phil > phip ) phip = phil;
269 if ( len >
M_PI * rhel * 0.75 )
273 std::cout <<
" len " << len <<
" >pi*R_helix " <<
M_PI * rhel <<
" rhel " << rhel
274 <<
" break" << std::endl;
280 std::cout <<
" philast " << philast <<
" phim " << phim <<
" phip " << phip
281 <<
" len " << len << std::endl;
287 else if ( ( rmin > gvin ) && ( rmax < gvout ) )
292 double alp = asin( rhel / rc );
301 if ( 5 == debug ) { std::cout <<
"add hits phim " << phim <<
" phip " << phip << std::endl; }
305 if ( 5 == debug ) std::cout <<
"===== try to add hits:" << std::endl;
313 std::cout <<
" len<0 " << temphel->
Doca_Len() <<
" continue" << std::endl;
322 temphit->
print( std::cout );
323 std::cout <<
" pull " << temphit->
pull( *temphel ) <<
" nsig "
333 double pw = temphit->
pw();
334 if ( ( phip - pw ) > m_2pi ) pw += m_2pi;
335 if ( ( phim - pw ) < -m_2pi ) pw -= m_2pi;
338 std::cout <<
"phi wire " << pw <<
" phim " << phim <<
" phip " << phip <<
" len "
341 if ( ( pw > phim ) && ( pw < phip ) )
345 std::cout <<
" used " << temphit->
GetUsedOnHel() <<
" pull "
346 << fabs( temphit->
pull( *temphel ) ) <<
" <? nSig "
350 double pull = temphit->
pull( *temphel );
356 int layer = temphit->
Layer();
362 <<
" len " << temphel->
Doca_Len() <<
" >? lmax " << lmax <<
" >? maxTkLen "
374 if ( ( ( len > 0.0 ) && ( len < lmax ) ) ||
383 temphit->
print( std::cout );
384 std::cout <<
"Added " << std::endl;