17#include "GaudiKernel/ThreadLocalContext.h"
29#include "CLHEP/Units/PhysicalConstants.h"
104 double dx(p2.x()-p1.x()), dy(p2.y()-p1.y()), dz(p2.z()-p1.z());
106 theclass->message(
"movePoint1ToZPlaneAndPoint2 Error: Points have same z!!");
109 double s( (
z-p1.z())/dz );
124 double p1r(p1.perp());
125 double dr(p2.perp()-p1r);
127 theclass->message(
"movePoint1ToInfiniteCylinderAndPoint2 Error: Points have same r!!");
130 double s((
r-p1r)/dr);
133 p1[0]= p1.x()*t + p2.x()*s;
135 p1[1]= p1.y()*t + p2.y()*s;
136 p1[2]= p1.z()*t + p2.z()*s;
159 message(
"makePointsNeutral called with null track pointer");
162 const unsigned npars = track->trackParameters()->size();
164 message(
"makePointsNeutral Error: No TrackParameters on track!");
168 return m_d->makePointsNeutral_SinglePar(points,track);
170 points.reserve(track->trackParameters()->size());
175 bool problems(
false);
176 for (; tsos_iter != tsos_end; ++tsos_iter) {
177 if (!
m_d->tracksanity->isSafe(*tsos_iter)) {
184 if (!
m_d->tracksanity->isSafe(trackParam)) {
188 points.push_back(trackParam->
position());
191 messageDebug(
"makePointsNeutral WARNING: Track had one or more track parameters which is unsafe to use in job.");
192 if (points.size()<2) {
193 messageDebug(
"makePointsNeutral ERROR: Track did not have at least two safe parameters.");
208 theclass->messageVerbose(
"makePointsNeutral_SinglePar start");
212 theclass->messageDebug(
"makePointsNeutral_SinglePar called with unsafe track parameter");
222 b =
a +999*CLHEP::m*u;
235 theclass->messageVerbose(
"makePointsNeutral_SinglePar (single track parameter) end");
244 messageVerbose(
"makePointsCharged start with hypo="+
str(hypo)+
", useMEOT="+
str(useMEOT)+
", volume=" +
str(volume));
252 message(
"makePointsCharged ERROR: Null extrapolator tool provided!");
256 message(
"makePointsCharged ERROR: Called with null track pointer");
259 const unsigned npars = track->trackParameters()->size();
261 message(
"makePointsCharged ERROR: No TrackParameters on track!");
265 return m_d->makePointsCharged_SinglePar(points,track,extrapolator,hypo);
267 points.reserve(npars);
268 const EventContext& ctx = Gaudi::Hive::currentContext();
274 bool problems(
false);
275 for (; tsos_iter != tsos_end; ++tsos_iter) {
276 if (!
m_d->tracksanity->isSafe(*tsos_iter))
278 if ((*tsos_iter)->measurementOnTrack()==
nullptr && ( (*tsos_iter)->materialEffectsOnTrack()&&!useMEOT ) )
280 trackParam = (*tsos_iter)->trackParameters();
281 if (!
m_d->tracksanity->isSafe(trackParam))
285 prevpar = trackParam;
286 points.push_back(prevpar->
position());
289 if (!
m_d->addPointsBetweenParameters_Charged(points,track,prevpar,trackParam,extrapolator,hypo))
291 points.push_back(trackParam->
position());
292 prevpar = trackParam;
296 messageDebug(
"WARNING: Problems encountered adding point(s) between track parameters");
299 if (volume && trackParam && !
m_d->outsideIDVolume(trackParam->
position())) {
304 const std::vector<std::unique_ptr<Trk::Surface>> bsurfs =
308 if (!bsurfs.empty()){
311 auto bSurfsIt = bsurfs.begin();
312 for (;bSurfsIt!= bsurfs.end(); ++bSurfsIt){
324 if (!
m_d->addPointsBetweenParameters_Charged(points,track,trackParam,trackPar,extrapolator,hypo))
325 messageDebug(
"WARNING: Problems encountered adding point(s) between track parameters in extending to Volume");
329 messageDebug(
"WARNING: Problems encountered getting boundary surfaces from Volume");
344 if (!trk||!prevpars||!extrapolator)
360 newpars = extrapolator->
extrapolate(Gaudi::Hive::currentContext(),
364 }
catch (
const std::runtime_error& e) {
365 theclass->message(
"Failure trying to use extrapolator for track (Exception thrown: " + QString(e.what())+
")");
369 theclass->message(
"Failure trying to use extrapolator for track");
373 theclass->message(
"Failure trying to use extrapolator for track");
380 return m_d->showExtrapSurfaces;
389 theclass->messageVerbose(
"makePointsCharged_SinglePar start");
392 theclass->message(
"makePointsCharged_SinglePar ERROR: Null extrapolator tool provided!");
397 theclass->messageDebug(
"makePointsCharged_SinglePar called with unsafe track parameter");
402 points.push_back(p0);
406 const double maxdistadded = 2*CLHEP::m;
411 while (distadded<maxdistadded) {
419 theclass->messageDebug(
"makePointsCharged_SinglePar ERROR: Failed to use extrapolator for next point");
420 if (points.size()<2) {
441 theclass->messageVerbose(
"makePointsCharged_SinglePar end");
452 if (distbetween<0.001) {
453 theclass->messageVerbose(
"TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: parameters on top of each other. Skip, but no error.");
462 double olddistsq(1.0e99);
464 const double maxdistadded = std::max(2*CLHEP::m,(par1->
position()-p2).mag()*1.5);
471 theclass->messageVerbose(
"TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: Extrapolation failed.");
475 if (distsq>olddistsq) {
478 theclass->messageVerbose(
"TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: distq("+
str(distsq)+
")>olddistsq ("+
str(olddistsq)+
") so overshot?");
486 points.push_back(newpars->
position());
494 return (distadded<maxdistadded);
DataModel_detail::const_iterator< DataVector > const_iterator
const Trk::TrackParameters * extrapolateToNewPar(Trk::IExtrapolator *extrapolator, const Trk::Track *trk, const Trk::TrackParameters *prevpars, Trk::ParticleHypothesis hypo, const double &dist)
std::vector< Trk::PlaneSurface > surfaces
For debugging.
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)
bool makePointsCharged_SinglePar(std::vector< Amg::Vector3D > &points, const Trk::Track *, Trk::IExtrapolator *extrapolator, Trk::ParticleHypothesis hypo)
TrackPropagationHelper * theclass
void movePoint1ToZPlaneAndPoint2(Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &z) const
bool outsideIDVolume(const Amg::Vector3D &p) const
Imp(TrackPropagationHelper *tc)
std::unique_ptr< VP1TrackSanity > tracksanity
bool makePointsNeutral_SinglePar(std::vector< Amg::Vector3D > &points, const Trk::Track *)
const double fallback_flydist
static double maxPointDistSq(const Amg::Vector3D &)
void movePoint1ToInfiniteCylinderAndPoint2(Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &r) const
bool makePointsCharged(std::vector< Amg::Vector3D > &points, const Trk::Track *, Trk::IExtrapolator *extrapolator, Trk::ParticleHypothesis hypo=Trk::nonInteracting, bool useMEOT=false, const Trk::Volume *volume=0)
TrackPropagationHelper(IVP1System *sys)
bool makePointsNeutral(std::vector< Amg::Vector3D > &points, const Trk::Track *)
std::vector< Trk::PlaneSurface > & getExtrapolationSurfaces() const
bool showExtrapolationSurfaces() const
~TrackPropagationHelper()
simple class that constructs the curvilinear vectors curvU and curvV from a given momentum direction ...
const Amg::Vector3D & curvU() const
Access methods.
const Amg::Vector3D & curvT() const
const Amg::Vector3D & curvV() const
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
Pure Absract Base Class for Volume bounds.
virtual std::vector< std::unique_ptr< Trk::Surface > > decomposeToSurfaces(const Amg::Transform3D &transform)=0
Method to decompose the Bounds into Surfaces, the Volume can turn them into BoundarySurfaces.
Base class for all volumes inside the tracking realm, it defines the interface for inherited Volume c...
const Amg::Transform3D & transform() const
Return methods for geometry transform.
const VolumeBounds & volumeBounds() const
returns the volumeBounds()
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
void messageVerbose(const QString &) const
void message(const QString &) const
IVP1System * systemBase() const
void messageDebug(const QString &) const
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters