Skip to content

Commit

Permalink
feat: remove middle SPs in last layer (#1972)
Browse files Browse the repository at this point in the history
This reduces iterations by removing the middle SPs on the last layer since there would be no outer SPs to complete a seed
  • Loading branch information
LuisFelipeCoelho committed Apr 17, 2023
1 parent a511218 commit a5d5d35
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
15 changes: 11 additions & 4 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(

for (const auto& spM : middleSPs) {
float rM = spM->radius();
float zM = spM->z();

// check if spM is outside our radial region of interest
if (m_config.useVariableMiddleSPRange) {
Expand All @@ -99,7 +98,7 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
} else if (not m_config.rRangeMiddleSP.empty()) {
/// get zBin position of the middle SP
auto pVal = std::lower_bound(m_config.zBinEdges.begin(),
m_config.zBinEdges.end(), zM);
m_config.zBinEdges.end(), spM->z());
int zBin = std::distance(m_config.zBinEdges.begin(), pVal);
/// protects against zM at the limit of zBinEdges
zBin == 0 ? zBin : --zBin;
Expand All @@ -120,6 +119,14 @@ void SeedFinder<external_spacepoint_t, platform_t>::createSeedsForGroup(
}
}

// remove middle SPs on the last layer since there would be no outer SPs to
// complete a seed
float zM = spM->z();
if (zM < m_config.zOutermostLayers.first or
zM > m_config.zOutermostLayers.second) {
continue;
}

// Iterate over middle-top dublets
getCompatibleDoublets<Acts::SpacePointCandidateType::TOP>(
state.spacePointData, options, grid, state.topNeighbours, *spM.get(),
Expand Down Expand Up @@ -419,7 +426,7 @@ inline void SeedFinder<external_spacepoint_t, platform_t>::filterCandidates(

// 1+(cot^2(theta)) = 1/sin^2(theta)
float iSinTheta2 = (1. + cotThetaB * cotThetaB);
float sigmaSquaredSPtDependent = iSinTheta2 * options.sigmapT2perRadius;
float sigmaSquaredPtDependent = iSinTheta2 * options.sigmapT2perRadius;
// calculate max scattering for min momentum at the seed's theta angle
// scaling scatteringAngle^2 by sin^2(theta) to convert pT^2 to p^2
// accurate would be taking 1/atan(thetaBottom)-1/atan(thetaTop) <
Expand Down Expand Up @@ -634,7 +641,7 @@ inline void SeedFinder<external_spacepoint_t, platform_t>::filterCandidates(
float iHelixDiameter2 = B2 / S2;
// convert p(T) to p scaling by sin^2(theta) AND scale by 1/sin^4(theta)
// from rad to deltaCotTheta
float p2scatterSigma = iHelixDiameter2 * sigmaSquaredSPtDependent;
float p2scatterSigma = iHelixDiameter2 * sigmaSquaredPtDependent;
if (!std::isinf(m_config.maxPtScattering)) {
// if pT > maxPtScattering, calculate allowed scattering angle using
// maxPtScattering instead of pt.
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Seeding/SeedFinderConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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};

std::vector<size_t> zBinsCustomLooping = {};

// average radiation lengths of material on the length of a seed. used for
Expand Down
9 changes: 5 additions & 4 deletions Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void SeedFinderOrthogonal<external_spacepoint_t>::filterCandidates(

// 1+(cot^2(theta)) = 1/sin^2(theta)
float iSinTheta2 = (1. + cotThetaB * cotThetaB);
float sigmaSquaredSPtDependent = iSinTheta2 * options.sigmapT2perRadius;
float sigmaSquaredPtDependent = iSinTheta2 * options.sigmapT2perRadius;
// calculate max scattering for min momentum at the seed's theta angle
// scaling scatteringAngle^2 by sin^2(theta) to convert pT^2 to p^2
// accurate would be taking 1/atan(thetaBottom)-1/atan(thetaTop) <
Expand Down Expand Up @@ -431,7 +431,7 @@ void SeedFinderOrthogonal<external_spacepoint_t>::filterCandidates(
float iHelixDiameter2 = B2 / S2;
// convert p(T) to p scaling by sin^2(theta) AND scale by 1/sin^4(theta)
// from rad to deltaCotTheta
float p2scatterSigma = iHelixDiameter2 * sigmaSquaredSPtDependent;
float p2scatterSigma = iHelixDiameter2 * sigmaSquaredPtDependent;
if (!std::isinf(m_config.maxPtScattering)) {
// if pT > maxPtScattering, calculate allowed scattering angle using
// maxPtScattering instead of pt.
Expand Down Expand Up @@ -760,11 +760,12 @@ void SeedFinderOrthogonal<external_spacepoint_t>::createSeeds(
}

// remove all middle SPs outside phi and z region of interest
if (middle.z() > m_config.zMax || middle.z() < m_config.zMin) {
if (middle.z() < m_config.zOutermostLayers.first or
middle.z() > m_config.zOutermostLayers.second) {
continue;
}
float spPhi = std::atan2(middle.y(), middle.x());
if (spPhi > m_config.phiMax || spPhi < m_config.phiMin) {
if (spPhi > m_config.phiMax or spPhi < m_config.phiMin) {
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Seeding/SeedFinderOrthogonalConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ struct SeedFinderOrthogonalConfig {
// 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};

// radial range for middle SP
// variable range based on SP radius
bool useVariableMiddleSPRange = true;
Expand Down
2 changes: 2 additions & 0 deletions Examples/Python/python/acts/examples/itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
# variables that do not change for pixel and strip SPs:
zMax = 3000 * u.mm
zMin = -3000 * u.mm
zOutermostLayers = (-2700 * u.mm, 2700 * u.mm)
beamPos = (0 * u.mm, 0 * u.mm)
collisionRegionMin = -200 * u.mm
collisionRegionMax = 200 * u.mm
Expand Down Expand Up @@ -521,6 +522,7 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
collisionRegion=(collisionRegionMin, collisionRegionMax),
r=(None, rMaxSeedFinderConfig),
z=(zMin, zMax),
zOutermostLayers=zOutermostLayers,
)

seedFinderOptionsArg = SeedFinderOptionsArg(bFieldInZ=bFieldInZ, beamPos=beamPos)
Expand Down
23 changes: 20 additions & 3 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
"collisionRegion", # (min,max)
"r", # (min,max)
"z", # (min,max)
"zOutermostLayers", # (min,max)
],
defaults=[None] * 20 + [(None, None)] * 7,
defaults=[None] * 20 + [(None, None)] * 8,
)
SeedFinderOptionsArg = namedtuple(
"SeedFinderOptions", ["beamPos", "bFieldInZ"], defaults=[(None, None), None]
Expand Down Expand Up @@ -211,8 +212,8 @@ def addSeeding(
initialVarInflation : list
List of 6 scale factors to inflate the initial covariance matrix
Defaults (all 1) specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp
seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, arithmeticAverageCotTheta, deltaZMax, maxPtScattering, zBinEdges, skipPreviousTopSP, zBinsCustomLooping, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z)
SeedFinderConfig settings. deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z are ranges specified as a tuple of (min,max). beamPos is specified as (x,y).
seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, arithmeticAverageCotTheta, deltaZMax, maxPtScattering, zBinEdges, skipPreviousTopSP, zBinsCustomLooping, 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)
Defaults specified in Core/include/Acts/Seeding/SeedFinderConfig.hpp
Expand Down Expand Up @@ -530,6 +531,14 @@ def addStandardSeeding(
collisionRegionMax=seedFinderConfigArg.collisionRegion[1],
zMin=seedFinderConfigArg.z[0],
zMax=seedFinderConfigArg.z[1],
zOutermostLayers=(
seedFinderConfigArg.zOutermostLayers[0]
if seedFinderConfigArg.zOutermostLayers[0] is not None
else seedFinderConfigArg.z[0],
seedFinderConfigArg.zOutermostLayers[1]
if seedFinderConfigArg.zOutermostLayers[1] is not None
else seedFinderConfigArg.z[1],
),
maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM,
cotThetaMax=seedFinderConfigArg.cotThetaMax,
sigmaScattering=seedFinderConfigArg.sigmaScattering,
Expand Down Expand Up @@ -675,6 +684,14 @@ def addOrthogonalSeeding(
collisionRegionMax=seedFinderConfigArg.collisionRegion[1],
zMin=seedFinderConfigArg.z[0],
zMax=seedFinderConfigArg.z[1],
zOutermostLayers=(
seedFinderConfigArg.zOutermostLayers[0]
if seedFinderConfigArg.zOutermostLayers[0] is not None
else seedFinderConfigArg.z[0],
seedFinderConfigArg.zOutermostLayers[1]
if seedFinderConfigArg.zOutermostLayers[1] is not None
else seedFinderConfigArg.z[1],
),
maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM,
cotThetaMax=seedFinderConfigArg.cotThetaMax,
sigmaScattering=seedFinderConfigArg.sigmaScattering,
Expand Down
2 changes: 2 additions & 0 deletions Examples/Python/src/TrackFinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void addTrackFinding(Context& ctx) {
ACTS_PYTHON_MEMBER(phiMax);
ACTS_PYTHON_MEMBER(zMin);
ACTS_PYTHON_MEMBER(zMax);
ACTS_PYTHON_MEMBER(zOutermostLayers);
ACTS_PYTHON_MEMBER(rMax);
ACTS_PYTHON_MEMBER(rMin);
ACTS_PYTHON_MEMBER(radLengthPerSeed);
Expand Down Expand Up @@ -147,6 +148,7 @@ void addTrackFinding(Context& ctx) {
ACTS_PYTHON_MEMBER(phiMax);
ACTS_PYTHON_MEMBER(zMin);
ACTS_PYTHON_MEMBER(zMax);
ACTS_PYTHON_MEMBER(zOutermostLayers);
ACTS_PYTHON_MEMBER(rMax);
ACTS_PYTHON_MEMBER(rMin);
ACTS_PYTHON_MEMBER(radLengthPerSeed);
Expand Down

0 comments on commit a5d5d35

Please sign in to comment.