190 double abs1 = getRadiusOfCurvature(mytracks.
getFirstPerigee(), bfield1);
193 const double sgnr1 = abs1>0 ? 1. : -1.;
194 const double sgnr2 = abs2>0 ? 1. : -1.;
197 const std::pair<Amg::Vector3D,Amg::Vector3D> centersofcurv
201#ifdef TRK2DDISTANCESEEDER_DEBUG
202 ATH_MSG_DEBUG(
" Center of track number 1: " << centersofcurv.first <<
" center of track 2 " << centersofcurv.second );
205 const double distance2d = dist2d(centersofcurv.first,centersofcurv.second);
207 abs1 = std::abs(abs1);
208 abs2 = std::abs(abs2);
211#ifdef TRK2DDISTANCESEEDER_DEBUG
213 ATH_MSG_DEBUG(
"phitanpoca1: " << phitanpoca1 <<
" phitanpoca2: " << phitanpoca2 );
226 if (distance2d > (abs1+abs2)) {
228#ifdef TRK2DDISTANCESEEDER_DEBUG
232 phi1 = safeAtan2(centersofcurv.second.y()-centersofcurv.first.y(),
233 centersofcurv.second.x()-centersofcurv.first.x());
238 phi2=oppositeangle(phi1);
242 phi1=oppositeangle(phi1);
246 phi1=takenearest(phi1,phitanpoca1);
247 phi2=takenearest(phi2,phitanpoca2);
254 if (fabs(abs2-abs1)>=distance2d) {
256#ifdef TRK2DDISTANCESEEDER_DEBUG
263#ifdef TRK2DDISTANCESEEDER_DEBUG
266 phi1 = safeAtan2(centersofcurv.second.y()-centersofcurv.first.y(),
267 centersofcurv.second.x()-centersofcurv.first.x());
272#ifdef TRK2DDISTANCESEEDER_DEBUG
277 phi1 = safeAtan2(-(centersofcurv.second.y()-centersofcurv.first.y()),
278 -(centersofcurv.second.x()-centersofcurv.first.x()));
284 phi2=oppositeangle(phi2);
288 phi1=oppositeangle(phi1);
291 phi1=takenearest(setphipoca(phi1),setphipoca(phitanpoca1));
292 phi2=takenearest(setphipoca(phi2),setphipoca(phitanpoca2));
293 phi1poca = setphipoca(phi1);
294 phi2poca = setphipoca(phi2);
299 const double projection2=(square(abs1)-square(abs2)-square(distance2d))/2./distance2d;
300 const double cosinus2=projection2/sgnr2/abs2;
303#ifdef TRK2DDISTANCESEEDER_DEBUG
304 const double projection1=(square(abs2)-square(abs1)-square(distance2d))/2./distance2d;
305 const double cosinus1=projection1/sgnr1/abs1;
306 ATH_MSG_DEBUG(
"projection1: " << projection1 <<
" cosinus1 " << cosinus1
307 <<
"projection2: " << projection2 <<
" cosinus2 " << cosinus2 );
310 const double phibase2 =
311 safeAtan2(centersofcurv.second.y() - centersofcurv.first.y(),
312 centersofcurv.second.x() - centersofcurv.first.x());
314 const double addtophi2=
317#ifdef TRK2DDISTANCESEEDER_DEBUG
318 ATH_MSG_DEBUG(
" phibase2 is : " << phibase2 <<
" add to phi " << addtophi2 );
321 const std::pair<double,double> possiblephiontrack2(phibase2+addtophi2,phibase2-addtophi2);
323#ifdef TRK2DDISTANCESEEDER_DEBUG
324 ATH_MSG_DEBUG(
"the two phis are: " << possiblephiontrack2.first <<
" and " << possiblephiontrack2.second );
327 const std::pair<double,double>
328 possiblecosphitrack1((centersofcurv.second.x()-centersofcurv.first.x()
329 +sgnr2*abs2*std::cos(possiblephiontrack2.first))/sgnr1/abs1,
330 (centersofcurv.second.x()-centersofcurv.first.x()
331 +sgnr2*abs2*std::cos(possiblephiontrack2.second))/sgnr1/abs1);
333 const std::pair<double,double>
334 possiblesigntrack1(sgnr1*(centersofcurv.second.y()-centersofcurv.first.y()
335 +sgnr2*abs2*std::sin(possiblephiontrack2.first))>0?1.:-1.,
336 sgnr1*(centersofcurv.second.y()-centersofcurv.first.y()
337 +sgnr2*abs2*std::sin(possiblephiontrack2.second))>0?1.:-1.);
339 const std::pair<double,double>
340 possiblephiontrack1(possiblesigntrack1.first*safeAcos(possiblecosphitrack1.first),
341 possiblesigntrack1.second*safeAcos(possiblecosphitrack1.second));
344 const std::pair<PointOnTrack,PointOnTrack>
346 takenearest(setphipoca(possiblephiontrack1.first),
347 setphipoca(phitanpoca1))),
349 takenearest(setphipoca(possiblephiontrack1.second),
350 setphipoca(phitanpoca1))));
352 const std::pair<PointOnTrack,PointOnTrack>
354 takenearest(setphipoca(possiblephiontrack2.first),
355 setphipoca(phitanpoca2))),
357 takenearest(setphipoca(possiblephiontrack2.second),
358 setphipoca(phitanpoca2))));
361 const std::pair<Amg::Vector3D,Amg::Vector3D>
362 possiblepoints1(getSeedPoint(possiblepointsontrack1.first.getPerigee(),centersofcurv.first,
363 abs1*sgnr1,possiblepointsontrack1.first.getPhiPoint()),
364 getSeedPoint(possiblepointsontrack1.second.getPerigee(),centersofcurv.first,
365 abs1*sgnr1,possiblepointsontrack1.second.getPhiPoint()));
367 const std::pair<Amg::Vector3D,Amg::Vector3D>
368 possiblepoints2(getSeedPoint(possiblepointsontrack2.first.getPerigee(),centersofcurv.second,
369 abs2*sgnr2,possiblepointsontrack2.first.getPhiPoint()),
370 getSeedPoint(possiblepointsontrack2.second.getPerigee(),centersofcurv.second,
371 abs2*sgnr2,possiblepointsontrack2.second.getPhiPoint()));
374#ifdef TRK2DDISTANCESEEDER_DEBUG
375 ATH_MSG_DEBUG(
"Point 1a: x " << possiblepoints1.first.x() <<
" y " << possiblepoints1.first.y() );
376 ATH_MSG_DEBUG(
"Point 2a: x " << possiblepoints2.first.x() <<
" y " << possiblepoints2.first.y() );
377 ATH_MSG_DEBUG(
"Point 1b: x " << possiblepoints1.second.x() <<
" y " << possiblepoints1.second.y() );
378 ATH_MSG_DEBUG(
"Point 2b: x " << possiblepoints2.second.x() <<
" y " << possiblepoints2.second.y() );
379 ATH_MSG_DEBUG(
"Distance between 1a and 2a:" << fabs(possiblepoints1.first.z()-possiblepoints2.first.z()) <<
380 "Distance between 1a and 2a:" << fabs(possiblepoints1.second.z()-possiblepoints2.second.z()) );
387 if (fabs(possiblepoints1.first.z()-possiblepoints2.first.z())<
388 fabs(possiblepoints1.second.z()-possiblepoints2.second.z()))
390 phi1poca = possiblepointsontrack1.first.getPhiPoint();
391 phi2poca = possiblepointsontrack2.first.getPhiPoint();
393 phi1poca = possiblepointsontrack1.second.getPhiPoint();
394 phi2poca = possiblepointsontrack2.second.getPhiPoint();
399 if (sqrt(possiblepoints1.first.x()*possiblepoints1.first.x()+possiblepoints1.first.y()*possiblepoints1.first.y())<
400 sqrt(possiblepoints2.first.x()*possiblepoints2.first.x()+possiblepoints2.first.y()*possiblepoints2.first.y()))
402 phi1poca = possiblepointsontrack1.first.getPhiPoint();
403 phi2poca = possiblepointsontrack2.first.getPhiPoint();
405 phi1poca = possiblepointsontrack1.second.getPhiPoint();
406 phi2poca = possiblepointsontrack2.second.getPhiPoint();
409 phi1=goFromPhipocaToPhi(phi1poca);
410 phi2=goFromPhipocaToPhi(phi2poca);
415 *twopoints =
TwoPoints (getSeedPoint(centersofcurv.first,
416 abs1*sgnr1,setphipoca(phi1)),
417 getSeedPoint(centersofcurv.second,
418 abs2*sgnr2,setphipoca(phi2)));