Skip to content

Commit

Permalink
refactor: LinCircle constructor and no use of fill function (#2006)
Browse files Browse the repository at this point in the history
Defining a constructor makes the fillLineCircle function redundant
  • Loading branch information
CarloVarni authored Apr 3, 2023
1 parent 1f7443e commit f44d3b1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 50 deletions.
12 changes: 6 additions & 6 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ SeedFinder<external_spacepoint_t, platform_t>::getCompatibleDoublets(
iDeltaR2;

// fill output vectors
linCircleVec.push_back(fillLineCircle(
{deltaZ * iDeltaR, iDeltaR, Er, uT, vT, xNewFrame, yNewFrame}));
linCircleVec.emplace_back(deltaZ * iDeltaR, iDeltaR, Er, uT, vT,
xNewFrame, yNewFrame);
spacePointData.setDeltaR(otherSP->index(),
std::sqrt(deltaR2 + (deltaZ * deltaZ)));
outVec.push_back(otherSP.get());
Expand All @@ -315,8 +315,8 @@ SeedFinder<external_spacepoint_t, platform_t>::getCompatibleDoublets(
iDeltaR2;

// fill output vectors
linCircleVec.push_back(fillLineCircle(
{deltaZ * iDeltaR, iDeltaR, Er, uT, vT, xNewFrame, yNewFrame}));
linCircleVec.emplace_back(deltaZ * iDeltaR, iDeltaR, Er, uT, vT,
xNewFrame, yNewFrame);
spacePointData.setDeltaR(otherSP->index(),
std::sqrt(deltaR2 + (deltaZ * deltaZ)));
outVec.push_back(otherSP.get());
Expand Down Expand Up @@ -349,8 +349,8 @@ SeedFinder<external_spacepoint_t, platform_t>::getCompatibleDoublets(
iDeltaR2;

// fill output vectors
linCircleVec.push_back(fillLineCircle(
{deltaZ * iDeltaR, iDeltaR, Er, uT, vT, xNewFrame, yNewFrame}));
linCircleVec.emplace_back(deltaZ * iDeltaR, iDeltaR, Er, uT, vT,
xNewFrame, yNewFrame);
spacePointData.setDeltaR(otherSP->index(),
std::sqrt(deltaR2 + (deltaZ * deltaZ)));
outVec.push_back(otherSP.get());
Expand Down
24 changes: 11 additions & 13 deletions Core/include/Acts/Seeding/SeedFinderUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
namespace Acts {
/// @brief A partial description of a circle in u-v space.
struct LinCircle {
float cotTheta;
float iDeltaR;
float Er;
float U;
float V;
float x;
float y;
LinCircle() = default;
LinCircle(float ct, float idr, float er, float u, float v, float X, float Y)
: cotTheta(ct), iDeltaR(idr), Er(er), U(u), V(v), x(X), y(Y) {}

float cotTheta{0.};
float iDeltaR{0.};
float Er{0.};
float U{0.};
float V{0.};
float x{0.};
float y{0.};
};

/// @brief Transform two spacepoints to a u-v space circle.
Expand Down Expand Up @@ -68,12 +72,6 @@ void transformCoordinates(Acts::SpacePointData& spacePointData,
std::vector<LinCircle>& linCircleVec,
callable_t&& extractFunction);

/// @brief Fills LineCircle object for a SP dublet in u-v frame.
///
/// @param[in] lineCircleVariables Vector contaning LineCircle variables
inline LinCircle fillLineCircle(
const std::array<float, 7>& lineCircleVariables);

/// @brief Check the compatibility of spacepoint coordinates in xyz assuming the Bottom-Middle direction with the strip meassument details
///
/// @tparam external_spacepoint_t The external spacepoint type.
Expand Down
46 changes: 15 additions & 31 deletions Core/include/Acts/Seeding/SeedFinderUtils.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline LinCircle transformCoordinates(const external_spacepoint_t& sp,
float deltaR2 = (xNewFrame * xNewFrame + yNewFrame * yNewFrame);
float iDeltaR2 = 1. / (deltaX * deltaX + deltaY * deltaY);
float iDeltaR = std::sqrt(iDeltaR2);
int bottomFactor = 1 * (int(!bottom)) - 1 * (int(bottom));
int bottomFactor = bottom ? -1 : 1;
float cotTheta = deltaZ * iDeltaR * bottomFactor;

// conformal transformation u=x/(x²+y²) v=y/(x²+y²) transform the
Expand All @@ -62,8 +62,7 @@ inline LinCircle transformCoordinates(const external_spacepoint_t& sp,
iDeltaR2;

sp.setDeltaR(std::sqrt(deltaR2 + (deltaZ * deltaZ)));

return fillLineCircle({cotTheta, iDeltaR, Er, U, V, xNewFrame, yNewFrame});
return LinCircle(cotTheta, iDeltaR, Er, U, V, xNewFrame, yNewFrame);
}

template <typename external_spacepoint_t>
Expand Down Expand Up @@ -91,11 +90,6 @@ inline void transformCoordinates(Acts::SpacePointData& spacePointData,
const external_spacepoint_t& spM, bool bottom,
std::vector<LinCircle>& linCircleVec,
callable_t&& extractFunction) {
std::vector<std::size_t> indexes(vec.size());
for (unsigned int i(0); i < indexes.size(); i++) {
indexes[i] = i;
}

auto [xM, yM, zM, rM, varianceRM, varianceZM] = extractFunction(spM);

// resize + operator[] is faster then reserve and push_back
Expand All @@ -104,6 +98,8 @@ inline void transformCoordinates(Acts::SpacePointData& spacePointData,
float cosPhiM = xM / rM;
float sinPhiM = yM / rM;

int bottomFactor = bottom ? -1 : 1;

for (std::size_t idx(0); idx < vec.size(); ++idx) {
auto& sp = vec[idx];
auto [xSP, ySP, zSP, rSP, varianceRSP, varianceZSP] = extractFunction(*sp);
Expand All @@ -122,7 +118,6 @@ inline void transformCoordinates(Acts::SpacePointData& spacePointData,
float iDeltaR2 = 1. / deltaR2;
float iDeltaR = std::sqrt(iDeltaR2);
//
int bottomFactor = 1 * (int(!bottom)) - 1 * (int(bottom));
// cot_theta = (deltaZ/deltaR)
float cotTheta = deltaZ * iDeltaR * bottomFactor;
// transformation of circle equation (x,y) into linear equation (u,v)
Expand All @@ -134,35 +129,24 @@ inline void transformCoordinates(Acts::SpacePointData& spacePointData,
float U = xNewFrame * iDeltaR2;
float V = yNewFrame * iDeltaR2;
// error term for sp-pair without correlation of middle space point
float Er = ((varianceZM + sp->varianceZ()) +
(cotTheta * cotTheta) * (varianceRM + sp->varianceR())) *
float Er = ((varianceZM + varianceZSP) +
(cotTheta * cotTheta) * (varianceRM + varianceRSP)) *
iDeltaR2;

linCircleVec[idx] =
fillLineCircle({cotTheta, iDeltaR, Er, U, V, xNewFrame, yNewFrame});
// Fill Line Circle
linCircleVec[idx].cotTheta = cotTheta;
linCircleVec[idx].iDeltaR = iDeltaR;
linCircleVec[idx].Er = Er;
linCircleVec[idx].U = U;
linCircleVec[idx].V = V;
linCircleVec[idx].x = xNewFrame;
linCircleVec[idx].y = yNewFrame;

spacePointData.setDeltaR(sp->index(),
std::sqrt(deltaR2 + (deltaZ * deltaZ)));
}
}

inline LinCircle fillLineCircle(
const std::array<float, 7>& lineCircleVariables) {
auto [cotTheta, iDeltaR, Er, U, V, xNewFrame, yNewFrame] =
lineCircleVariables;

// VERY frequent (SP^3) access
LinCircle l{};
l.cotTheta = cotTheta;
l.iDeltaR = iDeltaR;
l.U = U;
l.V = V;
l.Er = Er;
l.x = xNewFrame;
l.y = yNewFrame;

return l;
}

template <typename external_spacepoint_t>
inline bool xyzCoordinateCheck(
Acts::SpacePointData& spacePointData,
Expand Down

0 comments on commit f44d3b1

Please sign in to comment.