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::TrackParametersextrapolateToNewPar (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

TrackPropagationHelpertheclass {}
std::unique_ptr< VP1TrackSanitytracksanity {}
const double maxInDetr {}
const double maxInDetrsq {}
const double maxz {}
const double fallback_flydist {}
std::vector< Trk::PlaneSurfacesurfaces
 For debugging.
bool showExtrapSurfaces

Detailed Description

Definition at line 37 of file TrackPropagationHelper.cxx.

Constructor & Destructor Documentation

◆ Imp()

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

Definition at line 39 of file TrackPropagationHelper.cxx.

40 : theclass(tc),
41 tracksanity(new VP1TrackSanity(tc?tc->systemBase():nullptr)),
42 maxInDetr(1.1*CLHEP::m),
44 maxz(3.5*CLHEP::m),
45 fallback_flydist(10.0*CLHEP::cm),
46 showExtrapSurfaces(VP1QtUtils::environmentVariableIsOn("VP1_TRKSYS_SHOWEXTRAPSURFACES"))
47 {
48 }
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 447 of file TrackPropagationHelper.cxx.

450{
451 double distbetween = sqrt((par2->position()-par1->position()).mag2());
452 if (distbetween<0.001) {
453 theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: parameters on top of each other. Skip, but no error.");
454 return true;
455 }
456 // theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: par1="
457 // +str(par1->position())+", par2=" +str(par2->position())+", dist="+str(distbetween));
458
459 Amg::Vector3D p2(par2->position());
460 const Trk::TrackParameters * prevpars = par1;
461
462 double olddistsq(1.0e99);
463 double distadded(0);
464 const double maxdistadded = std::max(2*CLHEP::m,(par1->position()-p2).mag()*1.5);
465 while ( (prevpars->position()-p2).mag()> maxPointDistSq(prevpars->position()) && distadded<maxdistadded ) {
466
467 // theclass->messageVerbose("distadded: "+str(distadded)+", distance left="+str(sqrt((prevpars->position()-p2).mag2()))+", jump="+str(maxPointDistSq(prevpars->position())));
468 const Trk::TrackParameters * newpars = extrapolateToNewPar( extrapolator, trk, prevpars, hypo, maxPointDistSq(prevpars->position()) );
469 if (!newpars){
470 if (VP1Msg::verbose())
471 theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: Extrapolation failed.");
472 return false;
473 }
474 const double distsq = (par2->position()-newpars->position()).mag2();
475 if (distsq>olddistsq) {
476 delete newpars;
477 if (VP1Msg::verbose())
478 theclass->messageVerbose("TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: distq("+str(distsq)+")>olddistsq ("+str(olddistsq)+") so overshot?");
479 return false;
480 }
481 olddistsq = distsq;
482 // if ((prevpars->position()-newpars->position()).mag2() > 4*maxpointdistsq) {
483 // delete newpars;
484 // return false;
485 // }
486 points.push_back(newpars->position());
487 distadded += (newpars->position()-prevpars->position()).mag();
488 if (prevpars!=par1)
489 delete prevpars;
490 prevpars = newpars;
491 }
492 if (prevpars!=par1)
493 delete prevpars;
494 return (distadded<maxdistadded);
495}
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 338 of file TrackPropagationHelper.cxx.

343{
344 if (!trk||!prevpars||!extrapolator)
345 return nullptr;
346
347 Trk::CurvilinearUVT uvt(prevpars->momentum().unit());
348
349
350 Amg::Transform3D t(uvt.curvU(),uvt.curvV(),uvt.curvT(), prevpars->position()+(prevpars->momentum().unit()*dist));
351
352 Trk::PlaneSurface surf(t);
353
354
355 if (showExtrapSurfaces) surfaces.push_back(surf);
356
357
358 const Trk::TrackParameters *newpars(nullptr);
359 try {
360 newpars = extrapolator->extrapolate(Gaudi::Hive::currentContext(),
361 *prevpars,
362 surf,
363 Trk::alongMomentum,false,hypo).release(); // change this to extrapolate current param to surface.
364 } catch (const std::runtime_error& e) {
365 theclass->message("Failure trying to use extrapolator for track (Exception thrown: " + QString(e.what())+")");
366 return nullptr;
367 }
368 if (!newpars) {
369 theclass->message("Failure trying to use extrapolator for track");
370 return nullptr;
371 }
372 if (!newpars) {
373 theclass->message("Failure trying to use extrapolator for track");
374 return nullptr;
375 }
376 return newpars;
377}
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 385 of file TrackPropagationHelper.cxx.

387{
388 if (VP1Msg::verbose())
389 theclass->messageVerbose("makePointsCharged_SinglePar start");
390 points.clear();
391 if (!extrapolator) {
392 theclass->message("makePointsCharged_SinglePar ERROR: Null extrapolator tool provided!");
393 return false;
394 }
395 const Trk::TrackParameters * par = *(track->trackParameters()->begin());
396 if (!tracksanity->isSafe(par)) {
397 theclass->messageDebug("makePointsCharged_SinglePar called with unsafe track parameter");
398 return false;
399 }
400
401 Amg::Vector3D p0(par->position());
402 points.push_back(p0);
403 const bool startoutsideID(outsideIDVolume(p0));
404
405 double distadded(0);
406 const double maxdistadded = 2*CLHEP::m;
407 points.reserve(20);//skip a few reallocs
408 const Trk::TrackParameters * prevpars = par;
409 const Trk::TrackParameters * temppars(nullptr);
410
411 while (distadded<maxdistadded) {
412 temppars = extrapolateToNewPar( extrapolator, track, prevpars, hypo, maxPointDistSq(prevpars->position()));
413 if (temppars)
414 distadded += (temppars->position()-prevpars->position()).mag();
415 if (prevpars!=par)
416 delete prevpars;
417 prevpars = nullptr;
418 if (!temppars) {
419 theclass->messageDebug("makePointsCharged_SinglePar ERROR: Failed to use extrapolator for next point");
420 if (points.size()<2) {
421 points.clear();
422 return false;
423 }
424 return true;//Fixme??
425 }
426 Amg::Vector3D p(temppars->position());
427 points.push_back(p);
428 prevpars = temppars;
429 temppars = nullptr;
430 if (!startoutsideID && outsideIDVolume(p)) {
431 if (prevpars!=par)
432 delete prevpars;
433 prevpars = nullptr;
434 break;
435 }
436 }
437 if (prevpars!=par)
438 delete prevpars;
439
440 if (VP1Msg::verbose())
441 theclass->messageVerbose("makePointsCharged_SinglePar end");
442 return true;
443
444}
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 205 of file TrackPropagationHelper.cxx.

206{
207 if (VP1Msg::verbose())
208 theclass->messageVerbose("makePointsNeutral_SinglePar start");
209 points.clear();
210 const Trk::TrackParameters * par = *(track->trackParameters()->begin());
211 if (!tracksanity->isSafe(par)) {
212 theclass->messageDebug("makePointsNeutral_SinglePar called with unsafe track parameter");
213 return false;
214 }
215 Amg::Vector3D u(par->momentum().unit());
216 Amg::Vector3D a(par->position()),b;
217 if (outsideIDVolume(a)) {
218 //We start outside. We just add fallback_flydist. (fixme: warn?)
220 } else {
221 //Make a second point, where trajectory hits maxInDetr,maxz
222 b = a +999*CLHEP::m*u;
223 if (b.z()<-maxz)
225 else
226 if (b.z()>maxz)
228 if (b.perp2()>maxInDetrsq)
230 }
231 points.reserve(2);
232 points.push_back(a);
233 points.push_back(b);
234 if (VP1Msg::verbose())
235 theclass->messageVerbose("makePointsNeutral_SinglePar (single track parameter) end");
236 return true;
237}
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 79 of file TrackPropagationHelper.cxx.

79 {
80 //Vertex region:
90 return 2*CLHEP::cm;//Outside ID
91 }

◆ movePoint1ToInfiniteCylinderAndPoint2()

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

Definition at line 118 of file TrackPropagationHelper.cxx.

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

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

◆ outsideIDVolume()

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

Definition at line 57 of file TrackPropagationHelper.cxx.

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

Member Data Documentation

◆ fallback_flydist

const double TrackPropagationHelper::Imp::fallback_flydist {}

Definition at line 55 of file TrackPropagationHelper.cxx.

55{};

◆ maxInDetr

const double TrackPropagationHelper::Imp::maxInDetr {}

Definition at line 52 of file TrackPropagationHelper.cxx.

52{};

◆ maxInDetrsq

const double TrackPropagationHelper::Imp::maxInDetrsq {}

Definition at line 53 of file TrackPropagationHelper.cxx.

53{};

◆ maxz

const double TrackPropagationHelper::Imp::maxz {}

Definition at line 54 of file TrackPropagationHelper.cxx.

54{};

◆ showExtrapSurfaces

bool TrackPropagationHelper::Imp::showExtrapSurfaces

Definition at line 94 of file TrackPropagationHelper.cxx.

◆ surfaces

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

For debugging.

Definition at line 93 of file TrackPropagationHelper.cxx.

◆ theclass

TrackPropagationHelper* TrackPropagationHelper::Imp::theclass {}

Definition at line 50 of file TrackPropagationHelper.cxx.

50{};

◆ tracksanity

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

Definition at line 51 of file TrackPropagationHelper.cxx.

51{};

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