Skip to content

Commit

Permalink
Resolved conflict +catchup with the main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tboldagh committed Jan 13, 2023
2 parents 0deaed0 + 675d992 commit e03ec22
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 33 deletions.
24 changes: 20 additions & 4 deletions Core/include/Acts/Seeding/SpacePointGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
namespace Acts {

struct SpacePointGridConfig {
// magnetic field
float bFieldInZ = 0;
// minimum pT to be found by seedFinder
float minPt = 0;
// maximum extension of sensitive detector layer relevant for seeding as
Expand Down Expand Up @@ -59,7 +57,6 @@ struct SpacePointGridConfig {
using namespace Acts::UnitLiterals;
SpacePointGridConfig config = *this;
config.isInInternalUnits = true;
config.bFieldInZ /= 1000_T;
config.minPt /= 1_MeV;
config.rMax /= 1_mm;
config.zMax /= 1_mm;
Expand All @@ -70,6 +67,24 @@ struct SpacePointGridConfig {
}
};

struct SpacePointGridOptions {
// magnetic field
float bFieldInZ = 0;
bool isInInternalUnits = false;
SpacePointGridOptions toInternalUnits() const {
if (isInInternalUnits) {
throw std::runtime_error(
"Repeated conversion to internal units for SpacePointGridOptions");
}
using namespace Acts::UnitLiterals;
SpacePointGridOptions options = *this;
options.isInInternalUnits = true;
options.bFieldInZ /= 1000_T;

return options;
}
};

template <typename external_spacepoint_t>
using SpacePointGrid = detail::Grid<
std::vector<std::unique_ptr<InternalSpacePoint<external_spacepoint_t>>>,
Expand All @@ -81,7 +96,8 @@ class SpacePointGridCreator {
public:
template <typename external_spacepoint_t>
static std::unique_ptr<SpacePointGrid<external_spacepoint_t>> createGrid(
const Acts::SpacePointGridConfig& _config);
const Acts::SpacePointGridConfig& _config,
const Acts::SpacePointGridOptions& _options);
};
} // namespace Acts
#include "Acts/Seeding/SpacePointGrid.ipp"
14 changes: 10 additions & 4 deletions Core/include/Acts/Seeding/SpacePointGrid.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,30 @@
template <typename SpacePoint>
std::unique_ptr<Acts::SpacePointGrid<SpacePoint>>
Acts::SpacePointGridCreator::createGrid(
const Acts::SpacePointGridConfig& config) {
const Acts::SpacePointGridConfig& config,
const Acts::SpacePointGridOptions& options) {
if (not config.isInInternalUnits) {
throw std::runtime_error(
"SpacePointGridConfig not in ACTS internal units in "
"SpacePointGridCreator::createGrid");
}
if (not options.isInInternalUnits) {
throw std::runtime_error(
"SpacePointGridOptions not in ACTS internal units in "
"SpacePointGridCreator::createGrid");
}
using AxisScalar = Acts::Vector3::Scalar;

int phiBins = 0;
// for no magnetic field, create 100 phi-bins
if (config.bFieldInZ == 0) {
if (options.bFieldInZ == 0) {
phiBins = 100;
} else {
// calculate circle intersections of helix and max detector radius
float minHelixRadius =
config.minPt /
(300. * config.bFieldInZ); // in mm -> R[mm] =pT[GeV] / (3·10−4×B[T]) =
// pT[MeV] / (300 *Bz[kT])
(300. * options.bFieldInZ); // in mm -> R[mm] =pT[GeV] / (3·10−4×B[T])
// = pT[MeV] / (300 *Bz[kT])

// sanity check: if yOuter takes the square root of a negative number
if (minHelixRadius < config.rMax / 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SeedingAlgorithm final : public BareAlgorithm {
Acts::SeedFilterConfig seedFilterConfig;
Acts::SeedFinderConfig<SimSpacePoint> seedFinderConfig;
Acts::SpacePointGridConfig gridConfig;
Acts::SpacePointGridOptions gridOptions;
Acts::SeedFinderOptions seedFinderOptions;

// allow for different values of rMax in gridConfig and seedFinderConfig
Expand Down
7 changes: 4 additions & 3 deletions Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ActsExamples::SeedingAlgorithm::SeedingAlgorithm(
m_cfg.seedFinderConfig);
m_cfg.seedFilterConfig = m_cfg.seedFilterConfig.toInternalUnits();
m_cfg.gridConfig = m_cfg.gridConfig.toInternalUnits();
m_cfg.gridOptions = m_cfg.gridOptions.toInternalUnits();
if (m_cfg.inputSpacePoints.empty()) {
throw std::invalid_argument("Missing space point input collections");
}
Expand Down Expand Up @@ -118,7 +119,7 @@ ActsExamples::SeedingAlgorithm::SeedingAlgorithm(
throw std::invalid_argument("Inconsistent config minPt");
}

if (m_cfg.gridConfig.bFieldInZ != m_cfg.seedFinderOptions.bFieldInZ) {
if (m_cfg.gridOptions.bFieldInZ != m_cfg.seedFinderOptions.bFieldInZ) {
throw std::invalid_argument("Inconsistent config bFieldInZ");
}

Expand Down Expand Up @@ -224,8 +225,8 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute(
auto topBinFinder = std::make_shared<Acts::BinFinder<SimSpacePoint>>(
Acts::BinFinder<SimSpacePoint>(m_cfg.zBinNeighborsTop,
m_cfg.numPhiNeighbors));
auto grid =
Acts::SpacePointGridCreator::createGrid<SimSpacePoint>(m_cfg.gridConfig);
auto grid = Acts::SpacePointGridCreator::createGrid<SimSpacePoint>(
m_cfg.gridConfig, m_cfg.gridOptions);
auto spacePointsGrouping = Acts::BinnedSPGroup<SimSpacePoint>(
spacePointPtrs.begin(), spacePointPtrs.end(), extractGlobalQuantities,
bottomBinFinder, topBinFinder, std::move(grid), rRangeSPExtent,
Expand Down
9 changes: 7 additions & 2 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ def addSeeding(
spacePointGridConfigArg,
logLevel,
)

elif seedingAlgorithm == SeedingAlgorithm.Orthogonal:
logger.info("Using orthogonal seeding")
inputProtoTracks, inputSeeds = addOrthogonalSeeding(
Expand Down Expand Up @@ -524,7 +523,6 @@ def addStandardSeeding(

gridConfig = acts.SpacePointGridConfig(
**acts.examples.defaultKWArgs(
bFieldInZ=seedFinderOptions.bFieldInZ,
minPt=seedFinderConfig.minPt,
rMax=(
seedFinderConfig.rMax
Expand All @@ -547,6 +545,12 @@ def addStandardSeeding(
)
)

gridOptions = acts.SpacePointGridOptions(
**acts.examples.defaultKWArgs(
bFieldInZ=seedFinderOptions.bFieldInZ,
)
)

seedingAlg = acts.examples.SeedingAlgorithm(
level=logLevel,
inputSpacePoints=[spacePoints],
Expand All @@ -559,6 +563,7 @@ def addStandardSeeding(
numPhiNeighbors=seedingAlgorithmConfigArg.numPhiNeighbors,
),
gridConfig=gridConfig,
gridOptions=gridOptions,
seedFilterConfig=seedFilterConfig,
seedFinderConfig=seedFinderConfig,
seedFinderOptions=seedFinderOptions,
Expand Down
14 changes: 11 additions & 3 deletions Examples/Python/src/TrackFinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ void addTrackFinding(Context& ctx) {
auto c = py::class_<Config>(m, "SpacePointGridConfig").def(py::init<>());

ACTS_PYTHON_STRUCT_BEGIN(c, Config);
ACTS_PYTHON_MEMBER(bFieldInZ);
ACTS_PYTHON_MEMBER(minPt);
ACTS_PYTHON_MEMBER(rMax);
ACTS_PYTHON_MEMBER(zMax);
Expand All @@ -208,12 +207,21 @@ void addTrackFinding(Context& ctx) {
ACTS_PYTHON_STRUCT_END();
patchKwargsConstructor(c);
}
{
using Options = Acts::SpacePointGridOptions;
auto c = py::class_<Options>(m, "SpacePointGridOptions").def(py::init<>());

ACTS_PYTHON_STRUCT_BEGIN(c, Options);
ACTS_PYTHON_MEMBER(bFieldInZ);
ACTS_PYTHON_STRUCT_END();
patchKwargsConstructor(c);
}

ACTS_PYTHON_DECLARE_ALGORITHM(
ActsExamples::SeedingAlgorithm, mex, "SeedingAlgorithm", inputSpacePoints,
outputSeeds, outputProtoTracks, seedFilterConfig, seedFinderConfig,
seedFinderOptions, gridConfig, allowSeparateRMax, zBinNeighborsTop,
zBinNeighborsBottom, numPhiNeighbors);
seedFinderOptions, gridConfig, gridOptions, allowSeparateRMax,
zBinNeighborsTop, zBinNeighborsBottom, numPhiNeighbors);

ACTS_PYTHON_DECLARE_ALGORITHM(
ActsExamples::SeedingOrthogonalAlgorithm, mex,
Expand Down
4 changes: 2 additions & 2 deletions Examples/Run/Reconstruction/Common/RecCKFTracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ int runRecCKFTracks(
seedingCfg.gridConfig.minPt = 500._MeV;
seedingCfg.seedFinderConfig.minPt = seedingCfg.gridConfig.minPt;

seedingCfg.gridConfig.bFieldInZ = 1.99724_T;
seedingCfg.gridOptions.bFieldInZ = 1.99724_T;

seedingCfg.seedFinderOptions.bFieldInZ = seedingCfg.gridConfig.bFieldInZ;
seedingCfg.seedFinderOptions.bFieldInZ = seedingCfg.gridOptions.bFieldInZ;
seedingCfg.seedFinderOptions.beamPos = {0_mm, 0_mm};

seedingCfg.seedFinderConfig.impactMax = 3._mm;
Expand Down
4 changes: 2 additions & 2 deletions Examples/Run/Reconstruction/Common/SeedingExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ int runSeedingExample(
seedingCfg.gridConfig.minPt = 500._MeV;
seedingCfg.seedFinderConfig.minPt = seedingCfg.gridConfig.minPt;

seedingCfg.gridConfig.bFieldInZ = 1.99724_T;
seedingCfg.gridOptions.bFieldInZ = 1.99724_T;

seedingCfg.seedFinderOptions.bFieldInZ = seedingCfg.gridConfig.bFieldInZ;
seedingCfg.seedFinderOptions.bFieldInZ = seedingCfg.gridOptions.bFieldInZ;
seedingCfg.seedFinderOptions.beamPos = {0_mm, 0_mm};

seedingCfg.seedFinderConfig.impactMax = 3._mm;
Expand Down
6 changes: 4 additions & 2 deletions Tests/UnitTests/Core/Seeding/SeedFinderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,18 @@ int main(int argc, char** argv) {

// setup spacepoint grid config
Acts::SpacePointGridConfig gridConf;
gridConf.bFieldInZ = options.bFieldInZ;
gridConf.minPt = config.minPt;
gridConf.rMax = config.rMax;
gridConf.zMax = config.zMax;
gridConf.zMin = config.zMin;
gridConf.deltaRMax = config.deltaRMax;
gridConf.cotThetaMax = config.cotThetaMax;
// setup spacepoint grid options
Acts::SpacePointGridOptions gridOpts;
gridOpts.bFieldInZ = options.bFieldInZ;
// create grid with bin sizes according to the configured geometry
std::unique_ptr<Acts::SpacePointGrid<SpacePoint>> grid =
Acts::SpacePointGridCreator::createGrid<SpacePoint>(gridConf);
Acts::SpacePointGridCreator::createGrid<SpacePoint>(gridConf, gridOpts);
auto spGroup = Acts::BinnedSPGroup<SpacePoint>(
spVec.begin(), spVec.end(), ct, bottomBinFinder, topBinFinder,
std::move(grid), rRangeSPExtent, config, options);
Expand Down
6 changes: 4 additions & 2 deletions Tests/UnitTests/Plugins/Cuda/Seeding/SeedFinderCudaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,18 @@ int main(int argc, char** argv) {

// setup spacepoint grid config
Acts::SpacePointGridConfig gridConf;
gridConf.bFieldInZ = options.bFieldInZ;
gridConf.minPt = config.minPt;
gridConf.rMax = config.rMax;
gridConf.zMax = config.zMax;
gridConf.zMin = config.zMin;
gridConf.deltaRMax = config.deltaRMax;
gridConf.cotThetaMax = config.cotThetaMax;
// setup spacepoint grid options
Acts::SpacePointGridOptions gridOpts;
gridOpts.bFieldInZ = options.bFieldInZ;
// create grid with bin sizes according to the configured geometry
std::unique_ptr<Acts::SpacePointGrid<SpacePoint>> grid =
Acts::SpacePointGridCreator::createGrid<SpacePoint>(gridConf);
Acts::SpacePointGridCreator::createGrid<SpacePoint>(gridConf, gridOpts);
auto spGroup = Acts::BinnedSPGroup<SpacePoint>(
spVec.begin(), spVec.end(), ct, bottomBinFinder, topBinFinder,
std::move(grid), rRangeSPExtent, config, options);
Expand Down
8 changes: 5 additions & 3 deletions Tests/UnitTests/Plugins/Cuda/Seeding2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ int main(int argc, char* argv[]) {

// Set up the spacepoint grid configuration.
Acts::SpacePointGridConfig gridConfig;
gridConfig.bFieldInZ = sfOptions.bFieldInZ;
gridConfig.minPt = sfConfig.minPt;
gridConfig.rMax = sfConfig.rMax;
gridConfig.zMax = sfConfig.zMax;
gridConfig.zMin = sfConfig.zMin;
gridConfig.deltaRMax = sfConfig.deltaRMax;
gridConfig.cotThetaMax = sfConfig.cotThetaMax;
gridConfig = gridConfig.toInternalUnits();
// Set up the spacepoint grid options
Acts::SpacePointGridOptions gridOpts;
gridOpts.bFieldInZ = sfOptions.bFieldInZ;

// Covariance tool, sets covariances per spacepoint as required.
auto ct = [=](const TestSpacePoint& sp, float, float,
Expand All @@ -120,8 +122,8 @@ int main(int argc, char* argv[]) {

// Create a grid with bin sizes according to the configured geometry, and
// split the spacepoints into groups according to that grid.
auto grid =
Acts::SpacePointGridCreator::createGrid<TestSpacePoint>(gridConfig);
auto grid = Acts::SpacePointGridCreator::createGrid<TestSpacePoint>(
gridConfig, gridOpts);
auto spGroup = Acts::BinnedSPGroup<TestSpacePoint>(
spView.begin(), spView.end(), ct, bottomBinFinder, topBinFinder,
std::move(grid), rRangeSPExtent, sfConfig, sfOptions);
Expand Down
16 changes: 10 additions & 6 deletions Tests/UnitTests/Plugins/Sycl/Seeding/SeedFinderSyclTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,19 @@ auto setupSeedFinderOptions() {
template <typename external_spacepoint_t>
auto setupSpacePointGridConfig(
const Acts::SeedFinderConfig<external_spacepoint_t>& config,
const Acts::SeedFinderOptions& options) -> Acts::SpacePointGridConfig {
const Acts::SeedFinderOptions& options)
-> std::pair<Acts::SpacePointGridConfig, Acts::SpacePointGridOptions> {
Acts::SpacePointGridConfig gridConf{};
gridConf.bFieldInZ = options.bFieldInZ;
gridConf.minPt = config.minPt;
gridConf.rMax = config.rMax;
gridConf.zMax = config.zMax;
gridConf.zMin = config.zMin;
gridConf.deltaRMax = config.deltaRMax;
gridConf.cotThetaMax = config.cotThetaMax;
return gridConf;

Acts::SpacePointGridOptions gridOpts{};
gridOpts.bFieldInZ = options.bFieldInZ;
return std::make_pair(gridConf, gridOpts);
}

auto main(int argc, char** argv) -> int {
Expand Down Expand Up @@ -186,10 +189,11 @@ auto main(int argc, char** argv) -> int {
Acts::Vector2 covariance(sp.varianceR, sp.varianceZ);
return std::make_pair(position, covariance);
};
auto gridConfig =
setupSpacePointGridConfig(config, options).toInternalUnits();
auto [gridConfig, gridOpts] = setupSpacePointGridConfig(config, options);
gridConfig = gridConfig.toInternalUnits();
gridOpts = gridOpts.toInternalUnits();
std::unique_ptr<Acts::SpacePointGrid<SpacePoint>> grid =
Acts::SpacePointGridCreator::createGrid<SpacePoint>(gridConfig);
Acts::SpacePointGridCreator::createGrid<SpacePoint>(gridConfig, gridOpts);

auto spGroup = Acts::BinnedSPGroup<SpacePoint>(
spVec.begin(), spVec.end(), globalTool, bottomBinFinder, topBinFinder,
Expand Down

0 comments on commit e03ec22

Please sign in to comment.