21 const Acts::BoundTrackParameters& idParameters,
22 const Acts::BoundTrackParameters& msParameters,
23 const Acts::Logger&
logger,
24 const double boundTolerance) {
26 ACTS_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Calculate difference parameters between \n"
27 <<idParameters<<
"\n\n and \n\n"<<msParameters);
28 Acts::BoundVector diffPars = msParameters.parameters() -idParameters.parameters();
30 const Acts::Surface& idSurf{idParameters.referenceSurface()};
31 const Acts::Surface& msSurf{msParameters.referenceSurface()};
33 std::optional<Acts::BoundMatrix> msCov{msParameters.covariance()};
34 const std::optional<Acts::BoundMatrix>& idCov{idParameters.covariance()};
36 if (idSurf.geometryId() != msSurf.geometryId() ||
37 (idSurf.geometryId() == Acts::GeometryIdentifier{} &&
38 idSurf.getSharedPtr() != msSurf.getSharedPtr())) {
39 switch (msSurf.type()) {
40 using enum Acts::Surface::SurfaceType;
42 if (
static_cast<const Acts::DiscBounds&
>(msSurf.bounds()).rMax() - msParameters.get<Acts::eBoundLoc0>() > boundTolerance) {
43 ACTS_VERBOSE(__func__<<
"() "<<__LINE__<<
" - The parameters are too far apart from the bounds ");
48 using enum Acts::CylinderBounds::BoundValues;
49 if (
static_cast<const Acts::CylinderBounds&
>(msSurf.bounds()).get(eHalfLengthZ) -
50 std::abs(msParameters.get<Acts::eBoundLoc1>()) > boundTolerance) {
51 ACTS_VERBOSE(__func__<<
"() "<<__LINE__<<
" - The parameters are too far apart from the bounds ");
56 ACTS_WARNING(__func__<<
"() "<<__LINE__<<
" - Surface type "<<msSurf.type()<<
" is not implemented");
61 const Acts::Intersection3D idIsect = idSurf.intersect(tgContext,
62 msParameters.position(tgContext),
63 msParameters.direction(),
64 Acts::BoundaryTolerance::Infinite()).closest();
65 if (!idIsect.isValid()) {
66 ACTS_WARNING(__func__<<
"() "<<__LINE__<<
" - The propgation of "<<msParameters<<
" to "
67 <<idSurf.geometryId()<<
", "<<idSurf.bounds()<<
" failed.");
70 auto locPos = idSurf.globalToLocal(tgContext, idIsect.position(), msParameters.direction());
72 ACTS_WARNING(__func__<<
"() "<<__LINE__<<
" - Local to global of "<<
Amg::toString(idIsect.position())
73 <<
" is not on "<<idSurf.geometryId()<<
", "<<idSurf.bounds()<<
".");
77 diffPars[Acts::eBoundLoc0] = (*locPos)[Acts::eX] - idParameters.get<Acts::eBoundLoc0>();
78 diffPars[Acts::eBoundLoc1] = (*locPos)[Acts::eY] - idParameters.get<Acts::eBoundLoc1>();
81 (*msCov) = idSurf.freeToBoundJacobian(tgContext, idIsect.position(), msParameters.direction()) *
82 msSurf.boundToFreeJacobian(tgContext, msParameters.position(tgContext),
83 msParameters.direction()) * (*msCov);
86 std::optional<Acts::BoundMatrix> diffCov{};
88 diffCov = idCov.value_or(Acts::BoundMatrix::Zero()) +
89 msCov.value_or(Acts::BoundMatrix::Zero());
92 if (idSurf.type() == Acts::Surface::SurfaceType::Disc) {
93 diffPars[Acts::eBoundLoc1] =
deltaPhi(msParameters.get<Acts::eBoundLoc1>(),
94 idParameters.get<Acts::eBoundLoc1>());
95 }
else if (idSurf.type() == Acts::Surface::SurfaceType::Cylinder) {
96 using enum Acts::CylinderBounds::BoundValues;
98 const double R =
static_cast<const Acts::CylinderBounds&
>(idSurf.bounds()).get(eR);
99 diffPars[Acts::eBoundLoc0] =
deltaPhi(msParameters.get<Acts::eBoundLoc0>() / R,
100 idParameters.get<Acts::eBoundLoc0>() / R) * R;
102 Acts::BoundTrackParameters retPars{idSurf.getSharedPtr(),
105 Acts::copySign(diffPars, diffPars[Acts::eBoundTheta]),
106 diffCov, msParameters.particleHypothesis()};
107 ACTS_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Successfully created \n"<<retPars);
129 const Acts::Logger&
logger) {
130 switch (pars.referenceSurface().type()) {
131 using enum Acts::Surface::SurfaceType;
133 return pars.get<Acts::eBoundLoc1>();
135 using enum Acts::CylinderBounds::BoundValues;
136 const double R =
static_cast<const Acts::CylinderBounds&
>(pars.referenceSurface().bounds()).get(eR);
137 return pars.get<Acts::eBoundLoc0>() / R;
139 ACTS_WARNING(__func__<<
"() "<<__LINE__<<
" Surface type "<<pars.referenceSurface().type()
140 <<
" is not implemented");
std::optional< Acts::BoundTrackParameters > makeDiffParameters(const Acts::GeometryContext &tgContext, const Acts::BoundTrackParameters &idParameters, const Acts::BoundTrackParameters &msParameters, const Acts::Logger &logger, const double boundTolerance=Acts::UnitConstants::km)
Calculates the difference parameters between the ID and the MS If the parameters are expressed on dif...