ATLAS Offline Software
Loading...
Searching...
No Matches
TrackPropagationHelper::Imp Class Reference
Collaboration diagram for TrackPropagationHelper::Imp:

Public Member Functions

 Imp (TrackPropagationHelper *tc)
bool outsideIDVolume (const Amg::Vector3D &p) const
void movePoint1ToZPlaneAndPoint2 (Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &z) const
void movePoint1ToInfiniteCylinderAndPoint2 (Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &r) const
bool makePointsNeutral_SinglePar (std::vector< Amg::Vector3D > &points, const Trk::Track *)
bool makePointsCharged_SinglePar (std::vector< Amg::Vector3D > &points, const Trk::Track *, Trk::IExtrapolator *extrapolator, Trk::ParticleHypothesis hypo)
bool addPointsBetweenParameters_Charged (std::vector< Amg::Vector3D > &points, const Trk::Track *, const Trk::TrackParameters *par1, const Trk::TrackParameters *par2, Trk::IExtrapolator *extrapolator, Trk::ParticleHypothesis hypo)
const Trk::TrackParameters * extrapolateToNewPar (Trk::IExtrapolator *extrapolator, const Trk::Track *trk, const Trk::TrackParameters *prevpars, Trk::ParticleHypothesis hypo, const double &dist)

Static Public Member Functions

static double maxPointDistSq (const Amg::Vector3D &)

Public Attributes

TrackPropagationHelper * theclass {}
std::unique_ptr< VP1TrackSanity > tracksanity {}
const double maxInDetr {}
const double maxInDetrsq {}
const double maxz {}
const double fallback_flydist {}
std::vector< Trk::PlaneSurface > surfaces
 For debugging.
bool showExtrapSurfaces

Detailed Description

Definition at line 39 of file TrackPropagationHelper.cxx.

Constructor & Destructor Documentation

◆ Imp()

TrackPropagationHelper::Imp::Imp ( TrackPropagationHelper * tc)
inline

Definition at line 41 of file TrackPropagationHelper.cxx.

42 : theclass(tc),
43 tracksanity(new VP1TrackSanity(tc?tc->systemBase():nullptr)),
44 maxInDetr(1.1*CLHEP::m),
46 maxz(3.5*CLHEP::m),
47 fallback_flydist(10.0*CLHEP::cm),
48 showExtrapSurfaces(VP1QtUtils::environmentVariableIsOn("VP1_TRKSYS_SHOWEXTRAPSURFACES"))
49 {
50 }
static Double_t tc
TrackPropagationHelper * theclass
std::unique_ptr< VP1TrackSanity > tracksanity
static bool environmentVariableIsOn(const QString &name)

Member Function Documentation

◆ addPointsBetweenParameters_Charged()

bool TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged ( std::vector< Amg::Vector3D > & points,
const Trk::Track * trk,
const Trk::TrackParameters * par1,
const Trk::TrackParameters * par2,
Trk::IExtrapolator * extrapolator,
Trk::ParticleHypothesis hypo )

Definition at line 463 of file TrackPropagationHelper.cxx.

466{
467 double distbetween = sqrt((par2->position()-par1->position()).mag2());
468 if (distbetween<0.001) {
469 theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: parameters on top of each other. Skip, but no error.");
470 return true;
471 }
472 // theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: par1="
473 // +str(par1->position())+", par2=" +str(par2->position())+", dist="+str(distbetween));
474
475 Amg::Vector3D p2(par2->position());
476 const Trk::TrackParameters * prevpars = par1;
477
478 double olddistsq(1.0e99);
479 double distadded(0);
480 const double maxdistadded = std::max(2*CLHEP::m,(par1->position()-p2).mag()*1.5);
481 while ( (prevpars->position()-p2).mag()> maxPointDistSq(prevpars->position()) && distadded<maxdistadded ) {
482
483 // theclass->messageVerbose("distadded: "+str(distadded)+", distance left="+str(sqrt((prevpars->position()-p2).mag2()))+", jump="+str(maxPointDistSq(prevpars->position())));
484 const Trk::TrackParameters * newpars = extrapolateToNewPar( extrapolator, trk, prevpars, hypo, maxPointDistSq(prevpars->position()) );
485 if (!newpars){
486 if (prevpars!=par1)
487 delete prevpars;
488 if (VP1Msg::verbose())
489 theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: Extrapolation failed.");
490 return false;
491 }
492 const double distsq = (par2->position()-newpars->position()).mag2();
493 if (distsq>olddistsq) {
494 if (prevpars!=par1)
495 delete prevpars;
496 delete newpars;
497 if (VP1Msg::verbose())
498 theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: distq("+str(distsq)+")>olddistsq ("+str(olddistsq)+") so overshot?");
499 return false;
500 }
501 olddistsq = distsq;
502 // if ((prevpars->position()-newpars->position()).mag2() > 4*maxpointdistsq) {
503 // delete newpars;
504 // return false;
505 // }
506 points.push_back(newpars->position());
507 distadded += (newpars->position()-prevpars->position()).mag();
508 if (prevpars!=par1)
509 delete prevpars;
510 prevpars = newpars;
511 }
512 if (prevpars!=par1)
513 delete prevpars;
514 return (distadded<maxdistadded);
515}
const Trk::TrackParameters * extrapolateToNewPar(Trk::IExtrapolator *extrapolator, const Trk::Track *trk, const Trk::TrackParameters *prevpars, Trk::ParticleHypothesis hypo, const double &dist)
static double maxPointDistSq(const Amg::Vector3D &)
const Amg::Vector3D & position() const
Access method for the position.
static bool verbose()
Definition VP1Msg.h:31
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ extrapolateToNewPar()

const Trk::TrackParameters * TrackPropagationHelper::Imp::extrapolateToNewPar ( Trk::IExtrapolator * extrapolator,
const Trk::Track * trk,
const Trk::TrackParameters * prevpars,
Trk::ParticleHypothesis hypo,
const double & dist )

Definition at line 354 of file TrackPropagationHelper.cxx.

359{
360 if (!trk||!prevpars||!extrapolator)
361 return nullptr;
362
363 Trk::CurvilinearUVT uvt(prevpars->momentum().unit());
364
365
366 Amg::Transform3D t(uvt.curvU(),uvt.curvV(),uvt.curvT(), prevpars->position()+(prevpars->momentum().unit()*dist));
367
368 Trk::PlaneSurface surf(t);
369
370
371 if (showExtrapSurfaces) surfaces.push_back(surf);
372
373
374 const Trk::TrackParameters *newpars(nullptr);
375 try {
376 newpars = extrapolator->extrapolate(Gaudi::Hive::currentContext(),
377 *prevpars,
378 surf,
379 Trk::alongMomentum,false,hypo).release(); // change this to extrapolate current param to surface.
380 } catch (const std::runtime_error& e) {
381 theclass->message("Failure trying to use extrapolator for track (Exception thrown: " + QString(e.what())+")");
382 return nullptr;
383 }
384 if (!newpars) {
385 theclass->message("Failure trying to use extrapolator for track");
386 return nullptr;
387 }
388 if (!newpars) {
389 theclass->message("Failure trying to use extrapolator for track");
390 return nullptr;
391 }
392 return newpars;
393}
std::vector< Trk::PlaneSurface > surfaces
For debugging.
virtual std::unique_ptr< NeutralParameters > extrapolate(const NeutralParameters &parameters, const Surface &sf, PropDirection dir=anyDirection, const BoundaryCheck &bcheck=true) const =0
Main extrapolation Interface starting from neutral parameters and aiming at surface.
const Amg::Vector3D & momentum() const
Access method for the momentum.
Eigen::Affine3d Transform3D
@ alongMomentum

◆ makePointsCharged_SinglePar()

bool TrackPropagationHelper::Imp::makePointsCharged_SinglePar ( std::vector< Amg::Vector3D > & points,
const Trk::Track * track,
Trk::IExtrapolator * extrapolator,
Trk::ParticleHypothesis hypo )

Definition at line 401 of file TrackPropagationHelper.cxx.

403{
404 if (VP1Msg::verbose())
405 theclass->messageVerbose("makePointsCharged_SinglePar start");
406 points.clear();
407 if (!extrapolator) {
408 theclass->message("makePointsCharged_SinglePar ERROR: Null extrapolator tool provided!");
409 return false;
410 }
411 const Trk::TrackParameters * par = *(track->trackParameters()->begin());
412 if (!tracksanity->isSafe(par)) {
413 theclass->messageDebug("makePointsCharged_SinglePar called with unsafe track parameter");
414 return false;
415 }
416
417 Amg::Vector3D p0(par->position());
418 points.push_back(p0);
419 const bool startoutsideID(outsideIDVolume(p0));
420
421 double distadded(0);
422 const double maxdistadded = 2*CLHEP::m;
423 points.reserve(20);//skip a few reallocs
424 const Trk::TrackParameters * prevpars = par;
425 const Trk::TrackParameters * temppars(nullptr);
426
427 while (distadded<maxdistadded) {
428 temppars = extrapolateToNewPar( extrapolator, track, prevpars, hypo, maxPointDistSq(prevpars->position()));
429 if (temppars)
430 distadded += (temppars->position()-prevpars->position()).mag();
431 if (prevpars!=par)
432 delete prevpars;
433 prevpars = nullptr;
434 if (!temppars) {
435 theclass->messageDebug("makePointsCharged_SinglePar ERROR: Failed to use extrapolator for next point");
436 if (points.size()<2) {
437 points.clear();
438 return false;
439 }
440 return true;//Fixme??
441 }
442 Amg::Vector3D p(temppars->position());
443 points.push_back(p);
444 prevpars = temppars;
445 //temppars is overwritten on the next loop
446 if (!startoutsideID && outsideIDVolume(p)) {
447 if (prevpars!=par)
448 delete prevpars;
449 prevpars = nullptr;
450 break;
451 }
452 }
453 if (prevpars!=par)
454 delete prevpars;
455
456 if (VP1Msg::verbose())
457 theclass->messageVerbose("makePointsCharged_SinglePar end");
458 return true;
459
460}
bool outsideIDVolume(const Amg::Vector3D &p) const

◆ makePointsNeutral_SinglePar()

bool TrackPropagationHelper::Imp::makePointsNeutral_SinglePar ( std::vector< Amg::Vector3D > & points,
const Trk::Track * track )

Definition at line 207 of file TrackPropagationHelper.cxx.

208{
209 if (VP1Msg::verbose())
210 theclass->messageVerbose("makePointsNeutral_SinglePar start");
211 points.clear();
212 const Trk::TrackParameters * par = *(track->trackParameters()->begin());
213 if (!tracksanity->isSafe(par)) {
214 theclass->messageDebug("makePointsNeutral_SinglePar called with unsafe track parameter");
215 return false;
216 }
217 Amg::Vector3D u(par->momentum().unit());
218 Amg::Vector3D a(par->position()),b;
219 if (outsideIDVolume(a)) {
220 //We start outside. We just add fallback_flydist. (fixme: warn?)
222 } else {
223 //Make a second point, where trajectory hits maxInDetr,maxz
224 b = a +999*CLHEP::m*u;
225 if (b.z()<-maxz)
227 else
228 if (b.z()>maxz)
230 if (b.perp2()>maxInDetrsq)
232 }
233 points.reserve(2);
234 points.push_back(a);
235 points.push_back(b);
236 if (VP1Msg::verbose())
237 theclass->messageVerbose("makePointsNeutral_SinglePar (single track parameter) end");
238 return true;
239}
static Double_t a
void movePoint1ToZPlaneAndPoint2(Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &z) const
void movePoint1ToInfiniteCylinderAndPoint2(Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &r) const
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ maxPointDistSq()

double TrackPropagationHelper::Imp::maxPointDistSq ( const Amg::Vector3D & )
inlinestatic

all paths return the same number const double absz(fabs(p.z())), absrsq(p.perp2()); if ( (absz<2.75*CLHEP::m) and (absrsq<(1.2*CLHEP::m)*(1.2*CLHEP::m)) ) { if ( (absz<0.67*CLHEP::m) and (absrsq<(0.16*CLHEP::m)*(0.16*CLHEP::m)) ) { return 2*CLHEPcm;//inside pixel } return 2*CLHEPcm;//ID outside pixel }

Definition at line 81 of file TrackPropagationHelper.cxx.

81 {
82 //Vertex region:
92 return 2*CLHEP::cm;//Outside ID
93 }

◆ movePoint1ToInfiniteCylinderAndPoint2()

void TrackPropagationHelper::Imp::movePoint1ToInfiniteCylinderAndPoint2 ( Amg::Vector3D & p1,
const Amg::Vector3D & p2,
const double & r ) const

Definition at line 120 of file TrackPropagationHelper.cxx.

121{
122 //Fixme: what happens here if we don't cross? And how can we be sure
123 //that we don't move FURTHER than the other point? (i.e. if the
124 //infinite line with p1 and p2 crosses, but the segment p1p2 does
125 //not!?
126 double p1r(p1.perp());
127 double dr(p2.perp()-p1r);
128 if (dr==0.0) {
129 theclass->message("movePoint1ToInfiniteCylinderAndPoint2 Error: Points have same r!!");
130 return;
131 }
132 double s((r-p1r)/dr);
133 double t(1.0-s);
134 // p1.set( p1.x()*t + p2.x()*s, p1.y()*t + p2.y()*s, p1.z()*t + p2.z()*s );
135 p1[0]= p1.x()*t + p2.x()*s;
136 //p1[1]= p2.y()*s, p1.z()*t; original
137 p1[1]= p1.y()*t + p2.y()*s; //sroe, compiler warning fix
138 p1[2]= p1.z()*t + p2.z()*s;
139}
int r
Definition globals.cxx:22

◆ movePoint1ToZPlaneAndPoint2()

void TrackPropagationHelper::Imp::movePoint1ToZPlaneAndPoint2 ( Amg::Vector3D & p1,
const Amg::Vector3D & p2,
const double & z ) const

Definition at line 104 of file TrackPropagationHelper.cxx.

105{
106 double dx(p2.x()-p1.x()), dy(p2.y()-p1.y()), dz(p2.z()-p1.z());
107 if (dz==0.0) {
108 theclass->message("movePoint1ToZPlaneAndPoint2 Error: Points have same z!!");
109 return;
110 }
111 double s( (z-p1.z())/dz );
112 // p1.set( p1.x()+dx*s, p1.y()+dy*s, z );
113 p1[0]= p1.x()+dx*s;
114 p1[1]= p1.y()+dy*s;
115 p1[2]= z;
116
117}
#define z

◆ outsideIDVolume()

bool TrackPropagationHelper::Imp::outsideIDVolume ( const Amg::Vector3D & p) const
inline

Definition at line 59 of file TrackPropagationHelper.cxx.

59 {
60 return fabs(p.z())>maxz||p.perp2()>maxInDetrsq;
61 }

Member Data Documentation

◆ fallback_flydist

const double TrackPropagationHelper::Imp::fallback_flydist {}

Definition at line 57 of file TrackPropagationHelper.cxx.

57{};

◆ maxInDetr

const double TrackPropagationHelper::Imp::maxInDetr {}

Definition at line 54 of file TrackPropagationHelper.cxx.

54{};

◆ maxInDetrsq

const double TrackPropagationHelper::Imp::maxInDetrsq {}

Definition at line 55 of file TrackPropagationHelper.cxx.

55{};

◆ maxz

const double TrackPropagationHelper::Imp::maxz {}

Definition at line 56 of file TrackPropagationHelper.cxx.

56{};

◆ showExtrapSurfaces

bool TrackPropagationHelper::Imp::showExtrapSurfaces

Definition at line 96 of file TrackPropagationHelper.cxx.

◆ surfaces

std::vector<Trk::PlaneSurface> TrackPropagationHelper::Imp::surfaces

For debugging.

Definition at line 95 of file TrackPropagationHelper.cxx.

◆ theclass

TrackPropagationHelper* TrackPropagationHelper::Imp::theclass {}

Definition at line 52 of file TrackPropagationHelper.cxx.

52{};

◆ tracksanity

std::unique_ptr<VP1TrackSanity> TrackPropagationHelper::Imp::tracksanity {}

Definition at line 53 of file TrackPropagationHelper.cxx.

53{};

The documentation for this class was generated from the following file: