Skip to content

Commit

Permalink
refactor!: move SSS coordinate information to spacePointData (#2004)
Browse files Browse the repository at this point in the history
This PR moves the calculation of `topStripVector` and `bottomStripVector` to `spacePointData`, so we can calculate these values only once per event, since these values are calculated for ~95% of the input space points anyway.

@CarloVarni
  • Loading branch information
LuisFelipeCoelho authored Apr 14, 2023
1 parent 08ef3cc commit 1251038
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 59 deletions.
52 changes: 15 additions & 37 deletions Core/include/Acts/EventData/SpacePointData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,14 @@ class SpacePointData {
void clear();

///
bool hasDynamicVariable() const { return not m_topHalfStripLength.empty(); }
bool hasDynamicVariable() const { return not m_topStripVector.empty(); }

const float& getTopHalfStripLength(std::size_t idx) const {
return m_topHalfStripLength[idx];
const Acts::Vector3& getTopStripVector(std::size_t idx) const {
return m_topStripVector[idx];
}

const float& getBottomHalfStripLength(std::size_t idx) const {
return m_bottomHalfStripLength[idx];
}

const Acts::Vector3& getTopStripDirection(std::size_t idx) const {
return m_topStripDirection[idx];
}

const Acts::Vector3& getBottomStripDirection(std::size_t idx) const {
return m_bottomStripDirection[idx];
const Acts::Vector3& getBottomStripVector(std::size_t idx) const {
return m_bottomStripVector[idx];
}

const Acts::Vector3& getStripCenterDistance(std::size_t idx) const {
Expand All @@ -79,20 +71,12 @@ class SpacePointData {
return m_topStripCenterPosition[idx];
}

void setTopHalfStripLength(std::size_t idx, const float& value) {
m_topHalfStripLength[idx] = value;
}

void setBottomHalfStripLength(std::size_t idx, const float& value) {
m_bottomHalfStripLength[idx] = value;
}

void setTopStripDirection(std::size_t idx, const Acts::Vector3& value) {
m_topStripDirection[idx] = value;
void setTopStripVector(std::size_t idx, const Acts::Vector3& value) {
m_topStripVector[idx] = value;
}

void setBottomStripDirection(std::size_t idx, const Acts::Vector3& value) {
m_bottomStripDirection[idx] = value;
void setBottomStripVector(std::size_t idx, const Acts::Vector3& value) {
m_bottomStripVector[idx] = value;
}

void setStripCenterDistance(std::size_t idx, const Acts::Vector3& value) {
Expand All @@ -109,10 +93,8 @@ class SpacePointData {
std::vector<float> m_deltaR{};

/// dynamic variables
std::vector<float> m_topHalfStripLength{};
std::vector<float> m_bottomHalfStripLength{};
std::vector<Acts::Vector3> m_topStripDirection{};
std::vector<Acts::Vector3> m_bottomStripDirection{};
std::vector<Acts::Vector3> m_topStripVector{};
std::vector<Acts::Vector3> m_bottomStripVector{};
std::vector<Acts::Vector3> m_stripCenterDistance{};
std::vector<Acts::Vector3> m_topStripCenterPosition{};
};
Expand Down Expand Up @@ -142,10 +124,8 @@ inline void SpacePointData::resize(std::size_t n, bool resizeDynamic) {
m_deltaR.resize(n, 0.);

if (resizeDynamic) {
m_topHalfStripLength.resize(n, 0.);
m_bottomHalfStripLength.resize(n, 0.);
m_topStripDirection.resize(n, {0, 0, 0});
m_bottomStripDirection.resize(n, {0, 0, 0});
m_topStripVector.resize(n, {0, 0, 0});
m_bottomStripVector.resize(n, {0, 0, 0});
m_stripCenterDistance.resize(n, {0, 0, 0});
m_topStripCenterPosition.resize(n, {0, 0, 0});
}
Expand All @@ -156,10 +136,8 @@ inline void SpacePointData::clear() {
m_quality.clear();
m_deltaR.clear();
// dynamicvariables
m_topHalfStripLength.clear();
m_bottomHalfStripLength.clear();
m_topStripDirection.clear();
m_bottomStripDirection.clear();
m_topStripVector.clear();
m_bottomStripVector.clear();
m_stripCenterDistance.clear();
m_topStripCenterPosition.clear();
}
Expand Down
24 changes: 10 additions & 14 deletions Core/include/Acts/Seeding/SeedFinderUtils.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,19 @@ inline bool xyzCoordinateCheck(

std::size_t index = sp.index();

const float& topHalfStripLength = spacePointData.getTopHalfStripLength(index);
const float& bottomHalfStripLength =
spacePointData.getBottomHalfStripLength(index);
const Acts::Vector3& topStripDirection =
spacePointData.getTopStripDirection(index);
const Acts::Vector3& bottomStripDirection =
spacePointData.getBottomStripDirection(index);
// prepare variables
const Acts::Vector3& topStripVector = spacePointData.getTopStripVector(index);
const Acts::Vector3& bottomStripVector =
spacePointData.getBottomStripVector(index);
const Acts::Vector3& stripCenterDistance =
spacePointData.getStripCenterDistance(index);

// prepare variables
double xTopStripVector = topHalfStripLength * topStripDirection[0];
double yTopStripVector = topHalfStripLength * topStripDirection[1];
double zTopStripVector = topHalfStripLength * topStripDirection[2];
double xBottomStripVector = bottomHalfStripLength * bottomStripDirection[0];
double yBottomStripVector = bottomHalfStripLength * bottomStripDirection[1];
double zBottomStripVector = bottomHalfStripLength * bottomStripDirection[2];
const double& xTopStripVector = topStripVector[0];
const double& yTopStripVector = topStripVector[1];
const double& zTopStripVector = topStripVector[2];
const double& xBottomStripVector = bottomStripVector[0];
const double& yBottomStripVector = bottomStripVector[1];
const double& zBottomStripVector = bottomStripVector[2];

// cross product between top strip vector and spacepointPosition
double d1[3] = {yTopStripVector * spacepointPosition[2] -
Expand Down
22 changes: 14 additions & 8 deletions Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,20 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute(
const auto& collection = spacePointsGrouping.grid().at(grid_glob_bin);
for (const auto& sp : collection) {
std::size_t index = sp->index();
state.spacePointData.setTopHalfStripLength(
index, m_cfg.seedFinderConfig.getTopHalfStripLength(sp->sp()));
state.spacePointData.setBottomHalfStripLength(
index, m_cfg.seedFinderConfig.getBottomHalfStripLength(sp->sp()));
state.spacePointData.setTopStripDirection(
index, m_cfg.seedFinderConfig.getTopStripDirection(sp->sp()));
state.spacePointData.setBottomStripDirection(
index, m_cfg.seedFinderConfig.getBottomStripDirection(sp->sp()));

const float topHalfStripLength =
m_cfg.seedFinderConfig.getTopHalfStripLength(sp->sp());
const float bottomHalfStripLength =
m_cfg.seedFinderConfig.getBottomHalfStripLength(sp->sp());
const Acts::Vector3 topStripDirection =
m_cfg.seedFinderConfig.getTopStripDirection(sp->sp());
const Acts::Vector3 bottomStripDirection =
m_cfg.seedFinderConfig.getBottomStripDirection(sp->sp());

state.spacePointData.setTopStripVector(
index, topHalfStripLength * topStripDirection);
state.spacePointData.setBottomStripVector(
index, bottomHalfStripLength * bottomStripDirection);
state.spacePointData.setStripCenterDistance(
index, m_cfg.seedFinderConfig.getStripCenterDistance(sp->sp()));
state.spacePointData.setTopStripCenterPosition(
Expand Down

0 comments on commit 1251038

Please sign in to comment.