Skip to content

Commit

Permalink
test sorting in transformCoordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisFelipeCoelho committed Feb 2, 2023
1 parent a5cf168 commit 14824a4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 24 deletions.
40 changes: 31 additions & 9 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,16 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
state.linCircleBottom.clear();
state.linCircleTop.clear();

// initialize original index locations
std::vector<size_t> idxB(state.compatBottomSP.size());
std::iota(idxB.begin(), idxB.end(), 0);
std::vector<size_t> idxT(state.compatTopSP.size());
std::iota(idxT.begin(), idxT.end(), 0);

transformCoordinates(state.compatBottomSP, *spM, true,
state.linCircleBottom);
transformCoordinates(state.compatTopSP, *spM, false, state.linCircleTop);
state.linCircleBottom, idxB);
transformCoordinates(state.compatTopSP, *spM, false, state.linCircleTop,
idxT);

state.topSpVec.clear();
state.curvatures.clear();
Expand All @@ -278,7 +285,8 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
break;
}

auto lb = state.linCircleBottom[b];
auto lb = state.linCircleBottom[idxB[b]];
// auto lb = state.linCircleBottom[b];
seedFilterState.zOrigin = lb.Zo;
float cotThetaB = lb.cotTheta;
float Vb = lb.V;
Expand Down Expand Up @@ -310,7 +318,11 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
state.curvatures.clear();
state.impactParameters.clear();
for (size_t t = t0; t < numTopSP; t++) {
auto lt = state.linCircleTop[t];
// std::cout << "Test " << t << " " << idxT[t] <<
//std::endl;

auto lt = state.linCircleTop[idxT[t]];
// auto lt = state.linCircleTop[t];

float cotThetaT = lt.cotTheta;
float rMxy = 0.;
Expand Down Expand Up @@ -356,7 +368,9 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
rotationTermsUVtoXY[0] * Sb + rotationTermsUVtoXY[1] * Cb,
cosTheta * std::sqrt(1 + A0 * A0)};

auto spB = state.compatBottomSP[b];
auto spB = state.compatBottomSP[idxB[b]];
// auto spB =
//state.compatBottomSP[b];
double rBTransf[3];
if (!xyzCoordinateCheck(m_config, spB, positionBottom,
m_config.toleranceParam, rBTransf)) {
Expand All @@ -371,7 +385,9 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
rotationTermsUVtoXY[0] * St + rotationTermsUVtoXY[1] * Ct,
cosTheta * std::sqrt(1 + A0 * A0)};

auto spT = state.compatTopSP[t];
auto spT = state.compatTopSP[idxT[t]];
// auto spT =
//state.compatTopSP[t];
double rTTransf[3];
if (!xyzCoordinateCheck(m_config, spT, positionTop,
m_config.toleranceParam, rTTransf)) {
Expand Down Expand Up @@ -517,7 +533,8 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
}

if (Im <= m_config.impactMax) {
state.topSpVec.push_back(state.compatTopSP[t]);
state.topSpVec.push_back(state.compatTopSP[idxT[t]]);
// state.topSpVec.push_back(state.compatTopSP[t]);
// inverse diameter is signed depending if the curvature is
// positive/negative in phi
state.curvatures.push_back(B / std::sqrt(S2));
Expand All @@ -533,8 +550,13 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
}
if (!state.topSpVec.empty()) {
m_config.seedFilter->filterSeeds_2SpFixed(
*state.compatBottomSP[b], *spM, state.topSpVec, state.curvatures,
state.impactParameters, seedFilterState, state.seedsPerSpM);
*state.compatBottomSP[idxB[b]], *spM, state.topSpVec,
state.curvatures, state.impactParameters, seedFilterState,
state.seedsPerSpM);
// m_config.seedFilter->filterSeeds_2SpFixed(
// *state.compatBottomSP[b], *spM,
//state.topSpVec, state.curvatures, state.impactParameters,
//seedFilterState, state.seedsPerSpM);
}
}
m_config.seedFilter->filterSeeds_1SpFixed(
Expand Down
10 changes: 8 additions & 2 deletions Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,14 @@ void SeedFinderOrthogonal<external_spacepoint_t>::filterCandidates(
std::vector<LinCircle> linCircleTop;
linCircleTop.reserve(top.size());

transformCoordinates(bottom, middle, true, linCircleBottom);
transformCoordinates(top, middle, false, linCircleTop);
// initialize original index locations
std::vector<size_t> idxB(bottom.size());
std::iota(idxB.begin(), idxB.end(), 0);
std::vector<size_t> idxT(top.size());
std::iota(idxT.begin(), idxT.end(), 0);

transformCoordinates(bottom, middle, true, linCircleBottom, idxB);
transformCoordinates(top, middle, false, linCircleTop, idxT);

std::vector<float> tanLM;
std::vector<float> tanMT;
Expand Down
5 changes: 3 additions & 2 deletions Core/include/Acts/Seeding/SeedFinderUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ template <typename external_spacepoint_t>
void transformCoordinates(
std::vector<InternalSpacePoint<external_spacepoint_t>*>& vec,
InternalSpacePoint<external_spacepoint_t>& spM, bool bottom,
std::vector<LinCircle>& linCircleVec);
std::vector<LinCircle>& linCircleVec, std::vector<size_t>& idx);

template <typename external_spacepoint_t, typename callable_t>
void transformCoordinates(std::vector<external_spacepoint_t*>& vec,
external_spacepoint_t& spM, bool bottom,
std::vector<LinCircle>& linCircleVec,
callable_t&& extractFunction);
callable_t&& extractFunction,
std::vector<size_t>& idx);

/// @brief Check the compatibility of spacepoint coordinates in xyz assuming the Bottom-Middle direction with the strip meassument details
///
Expand Down
29 changes: 18 additions & 11 deletions Core/include/Acts/Seeding/SeedFinderUtils.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ template <typename external_spacepoint_t>
void transformCoordinates(
std::vector<InternalSpacePoint<external_spacepoint_t>*>& vec,
InternalSpacePoint<external_spacepoint_t>& spM, bool bottom,
std::vector<LinCircle>& linCircleVec) {
std::vector<LinCircle>& linCircleVec, std::vector<size_t>& idx) {
auto extractFunction =
[](const InternalSpacePoint<external_spacepoint_t>& obj)
-> std::array<float, 6> {
Expand All @@ -72,14 +72,15 @@ void transformCoordinates(
};

return transformCoordinates<InternalSpacePoint<external_spacepoint_t>>(
vec, spM, bottom, linCircleVec, extractFunction);
vec, spM, bottom, linCircleVec, extractFunction, idx);
}

template <typename external_spacepoint_t, typename callable_t>
void transformCoordinates(std::vector<external_spacepoint_t*>& vec,
external_spacepoint_t& spM, bool bottom,
std::vector<LinCircle>& linCircleVec,
callable_t&& extractFunction) {
callable_t&& extractFunction,
std::vector<size_t>& idx) {
auto [xM, yM, zM, rM, varianceRM, varianceZM] = extractFunction(spM);

float cosPhiM = xM / rM;
Expand Down Expand Up @@ -132,15 +133,21 @@ void transformCoordinates(std::vector<external_spacepoint_t*>& vec,

sp->setDeltaR(std::sqrt((x * x) + (y * y) + (deltaZ * deltaZ)));
}

// sort indexes based on comparing values in invHelixDiameterVec
std::sort(idx.begin(), idx.end(), [&linCircleVec](size_t i1, size_t i2) {
return linCircleVec[i1].cotTheta < linCircleVec[i2].cotTheta;
});

// sort the SP in order of cotTheta
std::sort(vec.begin(), vec.end(),
[](external_spacepoint_t* a, external_spacepoint_t* b) -> bool {
return (a->cotTheta() < b->cotTheta());
});
std::sort(linCircleVec.begin(), linCircleVec.end(),
[](const LinCircle& a, const LinCircle& b) -> bool {
return (a.cotTheta < b.cotTheta);
});
// std::sort(vec.begin(), vec.end(),
// [](external_spacepoint_t* a, external_spacepoint_t* b) -> bool {
// return (a->cotTheta() < b->cotTheta());
// });
// std::sort(linCircleVec.begin(), linCircleVec.end(),
// [](const LinCircle& a, const LinCircle& b) -> bool {
// return (a.cotTheta < b.cotTheta);
// });
}

template <typename external_spacepoint_t, typename sp_range_t>
Expand Down

0 comments on commit 14824a4

Please sign in to comment.