Skip to content

Commit

Permalink
feat: Add ability to skip grid bins in SP grouping and add ITk "fast"…
Browse files Browse the repository at this point in the history
… tracking config for seeding (#2166)

This PR adds the ITk fastTracking configuration for the seeding, which includes:
- A new feature in `binnedSPGroup` that allow us to skip z bins for middle SPs in the search for neighbours SPs
- A new flag in the python ITk configuration for high occupancy seeding
  • Loading branch information
LuisFelipeCoelho committed Aug 7, 2023
1 parent 3f4cbab commit 14b0cea
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 16 deletions.
13 changes: 10 additions & 3 deletions Core/include/Acts/Seeding/BinnedSPGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class BinnedSPGroupIterator {
void findNotEmptyBin();

private:
/// The group, it contains the grid and the bin finders
// The group, it contains the grid and the bin finders
Acts::detail::RefHolder<BinnedSPGroup<external_spacepoint_t>> m_group;
/// Max Local Bins - limits of the grid
// Max Local Bins - limits of the grid
std::array<std::size_t, 2> m_max_localBins;
/// Current Local Bins
// Current Local Bins
std::array<std::size_t, 2> m_current_localBins{0, 0};
};

Expand Down Expand Up @@ -113,6 +113,10 @@ class BinnedSPGroup {
return *m_grid.get();
}

std::size_t skipZMiddleBin() {
return m_skipZMiddleBin;
}

private:
// grid with ownership of all InternalSpacePoint
std::unique_ptr<Acts::SpacePointGrid<external_spacepoint_t>> m_grid;
Expand All @@ -122,7 +126,10 @@ class BinnedSPGroup {
std::shared_ptr<const BinFinder<external_spacepoint_t>> m_topBinFinder;
std::shared_ptr<const BinFinder<external_spacepoint_t>> m_bottomBinFinder;

// Order of z bins to loop over when searching for SPs
std::vector<size_t> m_bins;
// Number of Z bins to skip the search for middle SP
std::size_t m_skipZMiddleBin;
};

} // namespace Acts
Expand Down
8 changes: 5 additions & 3 deletions Core/include/Acts/Seeding/BinnedSPGroup.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Acts::BinnedSPGroupIterator<external_spacepoint_t>::BinnedSPGroupIterator(
Acts::BinnedSPGroup<external_spacepoint_t>& group, std::size_t index)
: m_group(group), m_max_localBins(m_group->m_grid->numLocalBins()) {
m_max_localBins[INDEX::PHI] += 1;
m_current_localBins[INDEX::Z] = m_group->skipZMiddleBin();
if (index == m_group->m_grid->size()) {
m_current_localBins = m_max_localBins;
} else {
Expand All @@ -30,7 +31,7 @@ Acts::BinnedSPGroupIterator<external_spacepoint_t>::operator++() {
// if we were on the edge, go up one phi bin and reset z bin
if (++m_current_localBins[INDEX::Z] == m_max_localBins[INDEX::Z]) {
++m_current_localBins[INDEX::PHI];
m_current_localBins[INDEX::Z] = 0;
m_current_localBins[INDEX::Z] = m_group->skipZMiddleBin();
}

// Get the next not-empty bin in the grid
Expand Down Expand Up @@ -94,7 +95,6 @@ Acts::BinnedSPGroupIterator<external_spacepoint_t>::findNotEmptyBin() {
std::size_t zBinIndex = m_group->m_bins[zBin];
std::size_t index =
m_group->m_grid->globalBinFromLocalBins({phiBin, zBinIndex});

// Check if there are entries in this bin
if (m_group->m_grid->at(index).empty()) {
continue;
Expand All @@ -106,7 +106,7 @@ Acts::BinnedSPGroupIterator<external_spacepoint_t>::findNotEmptyBin() {
return;
}
// Reset z-index
m_current_localBins[INDEX::Z] = 0;
m_current_localBins[INDEX::Z] = m_group->skipZMiddleBin();
}

// Could find nothing ... setting this to end()
Expand Down Expand Up @@ -172,6 +172,7 @@ Acts::BinnedSPGroup<external_spacepoint_t>::BinnedSPGroup(
// store x,y,z values in extent
rRangeSPExtent.extend({spX, spY, spZ});

// remove SPs outside z and phi region
if (spZ > zMax || spZ < zMin) {
continue;
}
Expand Down Expand Up @@ -219,6 +220,7 @@ Acts::BinnedSPGroup<external_spacepoint_t>::BinnedSPGroup(
m_bottomBinFinder = botBinFinder;
m_topBinFinder = tBinFinder;

m_skipZMiddleBin = config.skipZMiddleBinSearch;
m_bins = config.zBinsCustomLooping;
if (m_bins.empty()) {
std::size_t nZbins = m_grid->numLocalBins()[1];
Expand Down
11 changes: 7 additions & 4 deletions Core/include/Acts/Seeding/SeedFinderConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ struct SeedFinderConfig {
float rMinMiddle = 60.f * Acts::UnitConstants::mm;
float rMaxMiddle = 120.f * Acts::UnitConstants::mm;

// z of last layers to avoid iterations
std::pair<float, float> zOutermostLayers{-2700 * Acts::UnitConstants::mm,
2700 * Acts::UnitConstants::mm};

// cut to the maximum value of delta z between SPs
float deltaZMax =
std::numeric_limits<float>::infinity() * Acts::UnitConstants::mm;
Expand Down Expand Up @@ -116,11 +120,10 @@ struct SeedFinderConfig {
// which will make seeding very slow!
float rMin = 33 * Acts::UnitConstants::mm;

// z of last layers to avoid iterations
std::pair<float, float> zOutermostLayers{-2700 * Acts::UnitConstants::mm,
2700 * Acts::UnitConstants::mm};

// Order of z bins to loop over when searching for SPs
std::vector<size_t> zBinsCustomLooping = {};
// Number of Z bins to skip the search for middle SPs
std::size_t skipZMiddleBinSearch = 0;

// average radiation lengths of material on the length of a seed. used for
// scattering.
Expand Down
5 changes: 3 additions & 2 deletions Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute(
spacePointPtrs.reserve(nSpacePoints);
for (const auto& isp : m_inputSpacePoints) {
for (const auto& spacePoint : (*isp)(ctx)) {
// since the event store owns the space points, their pointers should be
// stable and we do not need to create local copies.
// since the event store owns the space
// points, their pointers should be stable and
// we do not need to create local copies.
spacePointPtrs.push_back(&spacePoint);
}
}
Expand Down
37 changes: 35 additions & 2 deletions Examples/Python/python/acts/examples/itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ def buildITkGeometry(
)


def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
def itkSeedingAlgConfig(
inputSpacePointsType: InputSpacePointsType, highOccupancyConfig=False
):
assert isinstance(inputSpacePointsType, InputSpacePointsType)

# variables that do not change for pixel and strip SPs:
Expand All @@ -309,7 +311,7 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
collisionRegionMin = -200 * u.mm
collisionRegionMax = 200 * u.mm
maxSeedsPerSpM = 4
cotThetaMax = 27.2899
cotThetaMax = 27.2899 # (4.0 eta) --> 27.2899 = 1/tan(2*arctan(exp(-4)))
sigmaScattering = 2
radLengthPerSeed = 0.0975
minPt = 900 * u.MeV
Expand Down Expand Up @@ -439,6 +441,14 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
maxSeedsPerSpMConf = 5
maxQualitySeedsPerSpMConf = 5
useDeltaRorTopRadius = True

if highOccupancyConfig == True:
rMaxGridConfig = 250 * u.mm
deltaRMax = 200 * u.mm
zBinsCustomLooping = [1, 11, 2, 10, 3, 9, 6, 4, 8, 5, 7]
# variables that are only used for highOccupancyConfig configuration:
skipZMiddleBinSearch = 2

elif inputSpacePointsType is InputSpacePointsType.StripSpacePoints:
outputSeeds = "StripSeeds"
allowSeparateRMax = True
Expand Down Expand Up @@ -491,6 +501,27 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
maxQualitySeedsPerSpMConf = 100
useDeltaRorTopRadius = False

if highOccupancyConfig == True:
minPt = 1000 * u.MeV
collisionRegionMin = -150 * u.mm
collisionRegionMax = 150 * u.mm
rRangeMiddleSP = [
[40.0, 80.0],
[40.0, 200.0],
[70.0, 200.0],
[70.0, 200.0],
[70.0, 250.0],
[70.0, 250.0],
[70.0, 250.0],
[70.0, 200.0],
[70.0, 200.0],
[40.0, 200.0],
[40.0, 80.0],
]
useVariableMiddleSPRange = False
else:
skipZMiddleBinSearch = 0

# fill namedtuples
seedFinderConfigArg = SeedFinderConfigArg(
maxSeedsPerSpM=maxSeedsPerSpM,
Expand All @@ -506,6 +537,7 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
maxPtScattering=maxPtScattering,
zBinEdges=zBinEdges,
zBinsCustomLooping=zBinsCustomLooping,
skipZMiddleBinSearch=skipZMiddleBinSearch,
rRangeMiddleSP=rRangeMiddleSP,
useVariableMiddleSPRange=useVariableMiddleSPRange,
binSizeR=binSizeR,
Expand Down Expand Up @@ -538,6 +570,7 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
)
spacePointGridConfigArg = SpacePointGridConfigArg(
rMax=rMaxGridConfig,
deltaRMax=deltaRMax,
zBinEdges=zBinEdges,
phiBinDeflectionCoverage=phiBinDeflectionCoverage,
phi=(phiMin, phiMax),
Expand Down
6 changes: 4 additions & 2 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"maxPtScattering",
"zBinEdges",
"zBinsCustomLooping",
"skipZMiddleBinSearch",
"rRangeMiddleSP",
"useVariableMiddleSPRange",
"binSizeR",
Expand All @@ -56,7 +57,7 @@
"z", # (min,max)
"zOutermostLayers", # (min,max)
],
defaults=[None] * 19 + [(None, None)] * 8,
defaults=[None] * 20 + [(None, None)] * 8,
)
SeedFinderOptionsArg = namedtuple(
"SeedFinderOptions", ["beamPos", "bFieldInZ"], defaults=[(None, None), None]
Expand Down Expand Up @@ -201,7 +202,7 @@ def addSeeding(
initialVarInflation : list
List of 6 scale factors to inflate the initial covariance matrix
Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp
seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, arithmeticAverageCotTheta, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers)
seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, arithmeticAverageCotTheta, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, skipZMiddleBinSearch, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers)
SeedFinderConfig settings. deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers are ranges specified as a tuple of (min,max). beamPos is specified as (x,y).
Defaults specified in Core/include/Acts/Seeding/SeedFinderConfig.hpp
seedFinderOptionsArg : SeedFinderOptionsArg(bFieldInZ, beamPos)
Expand Down Expand Up @@ -544,6 +545,7 @@ def addStandardSeeding(
maxPtScattering=seedFinderConfigArg.maxPtScattering,
zBinEdges=seedFinderConfigArg.zBinEdges,
zBinsCustomLooping=seedFinderConfigArg.zBinsCustomLooping,
skipZMiddleBinSearch=seedFinderConfigArg.skipZMiddleBinSearch,
rRangeMiddleSP=seedFinderConfigArg.rRangeMiddleSP,
useVariableMiddleSPRange=seedFinderConfigArg.useVariableMiddleSPRange,
binSizeR=seedFinderConfigArg.binSizeR,
Expand Down
1 change: 1 addition & 0 deletions Examples/Python/src/TrackFinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void addTrackFinding(Context& ctx) {
ACTS_PYTHON_MEMBER(zBinEdges);
ACTS_PYTHON_MEMBER(interactionPointCut);
ACTS_PYTHON_MEMBER(zBinsCustomLooping);
ACTS_PYTHON_MEMBER(skipZMiddleBinSearch);
ACTS_PYTHON_MEMBER(useVariableMiddleSPRange);
ACTS_PYTHON_MEMBER(deltaRMiddleMinSPRange);
ACTS_PYTHON_MEMBER(deltaRMiddleMaxSPRange);
Expand Down

0 comments on commit 14b0cea

Please sign in to comment.