28#include "CLHEP/Units/PhysicalConstants.h"
103 double dx(p2.x()-p1.x()), dy(p2.y()-p1.y()), dz(p2.z()-p1.z());
105 theclass->message(
"movePoint1ToZPlaneAndPoint2 Error: Points have same z!!");
108 double s( (
z-p1.z())/dz );
123 double p1r(p1.perp());
124 double dr(p2.perp()-p1r);
126 theclass->message(
"movePoint1ToInfiniteCylinderAndPoint2 Error: Points have same r!!");
129 double s((
r-p1r)/dr);
132 p1[0]= p1.x()*t + p2.x()*s;
134 p1[1]= p1.y()*t + p2.y()*s;
135 p1[2]= p1.z()*t + p2.z()*s;
158 message(
"makePointsNeutral called with null track pointer");
161 const unsigned npars = track->trackParameters()->size();
163 message(
"makePointsNeutral Error: No TrackParameters on track!");
167 return m_d->makePointsNeutral_SinglePar(points,track);
169 points.reserve(track->trackParameters()->size());
174 bool problems(
false);
175 for (; tsos_iter != tsos_end; ++tsos_iter) {
176 if (!
m_d->tracksanity->isSafe(*tsos_iter)) {
183 if (!
m_d->tracksanity->isSafe(trackParam)) {
187 points.push_back(trackParam->
position());
190 messageDebug(
"makePointsNeutral WARNING: Track had one or more track parameters which is unsafe to use in job.");
191 if (points.size()<2) {
192 messageDebug(
"makePointsNeutral ERROR: Track did not have at least two safe parameters.");
207 theclass->messageVerbose(
"makePointsNeutral_SinglePar start");
211 theclass->messageDebug(
"makePointsNeutral_SinglePar called with unsafe track parameter");
221 b =
a +999*CLHEP::m*u;
234 theclass->messageVerbose(
"makePointsNeutral_SinglePar (single track parameter) end");
243 messageVerbose(
"makePointsCharged start with hypo="+
str(hypo)+
", useMEOT="+
str(useMEOT)+
", volume=" +
str(volume));
251 message(
"makePointsCharged ERROR: Null extrapolator tool provided!");
255 message(
"makePointsCharged ERROR: Called with null track pointer");
258 const unsigned npars = track->trackParameters()->size();
260 message(
"makePointsCharged ERROR: No TrackParameters on track!");
264 return m_d->makePointsCharged_SinglePar(points,track,extrapolator,hypo);
266 points.reserve(npars);
267 const EventContext& ctx = Gaudi::Hive::currentContext();
273 bool problems(
false);
274 for (; tsos_iter != tsos_end; ++tsos_iter) {
275 if (!
m_d->tracksanity->isSafe(*tsos_iter))
277 if ((*tsos_iter)->measurementOnTrack()==
nullptr && ( (*tsos_iter)->materialEffectsOnTrack()&&!useMEOT ) )
279 trackParam = (*tsos_iter)->trackParameters();
280 if (!
m_d->tracksanity->isSafe(trackParam))
284 prevpar = trackParam;
285 points.push_back(prevpar->
position());
288 if (!
m_d->addPointsBetweenParameters_Charged(points,track,prevpar,trackParam,extrapolator,hypo))
290 points.push_back(trackParam->
position());
291 prevpar = trackParam;
295 messageDebug(
"WARNING: Problems encountered adding point(s) between track parameters");
298 if (volume && trackParam && !
m_d->outsideIDVolume(trackParam->
position())) {
303 const std::vector<std::unique_ptr<Trk::Surface>> bsurfs =
307 if (!bsurfs.empty()){
310 auto bSurfsIt = bsurfs.begin();
311 for (;bSurfsIt!= bsurfs.end(); ++bSurfsIt){
323 if (!
m_d->addPointsBetweenParameters_Charged(points,track,trackParam,trackPar,extrapolator,hypo))
324 messageDebug(
"WARNING: Problems encountered adding point(s) between track parameters in extending to Volume");
328 messageDebug(
"WARNING: Problems encountered getting boundary surfaces from Volume");
343 if (!trk||!prevpars||!extrapolator)
359 newpars = extrapolator->
extrapolate(Gaudi::Hive::currentContext(),
363 }
catch (
const std::runtime_error& e) {
364 theclass->message(
"Failure trying to use extrapolator for track (Exception thrown: " + QString(e.what())+
")");
368 theclass->message(
"Failure trying to use extrapolator for track");
372 theclass->message(
"Failure trying to use extrapolator for track");
379 return m_d->showExtrapSurfaces;
388 theclass->messageVerbose(
"makePointsCharged_SinglePar start");
391 theclass->message(
"makePointsCharged_SinglePar ERROR: Null extrapolator tool provided!");
396 theclass->messageDebug(
"makePointsCharged_SinglePar called with unsafe track parameter");
401 points.push_back(p0);
405 const double maxdistadded = 2*CLHEP::m;
410 while (distadded<maxdistadded) {
418 theclass->messageDebug(
"makePointsCharged_SinglePar ERROR: Failed to use extrapolator for next point");
419 if (points.size()<2) {
440 theclass->messageVerbose(
"makePointsCharged_SinglePar end");
451 if (distbetween<0.001) {
452 theclass->messageVerbose(
"TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: parameters on top of each other. Skip, but no error.");
461 double olddistsq(1.0e99);
463 const double maxdistadded = std::max(2*CLHEP::m,(par1->
position()-p2).mag()*1.5);
470 theclass->messageVerbose(
"TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: Extrapolation failed.");
474 if (distsq>olddistsq) {
477 theclass->messageVerbose(
"TrackPropagationHelper::Imp::addPointsBetweenParameters_Charged: distq("+
str(distsq)+
")>olddistsq ("+
str(olddistsq)+
") so overshot?");
485 points.push_back(newpars->
position());
493 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