Skip to content

Commit

Permalink
Merge branch 'acts-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zzalscv2 authored Jun 14, 2024
2 parents e3202c2 + 6c943bf commit a4c1d2c
Show file tree
Hide file tree
Showing 21 changed files with 1,439 additions and 117 deletions.
21 changes: 15 additions & 6 deletions Core/include/Acts/Detector/Blueprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Common.hpp"
#include "Acts/Detector/ProtoBinning.hpp"
#include "Acts/Geometry/Extent.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Utilities/BinningData.hpp"
#include "Acts/Utilities/StringHelpers.hpp"
Expand Down Expand Up @@ -48,15 +49,17 @@ struct Node final {
/// @param bv the boundary values
/// @param bss the binning values
/// @param cs the children of the node
/// @param e the estimated extent of the node (optional)
Node(const std::string& n, const Transform3& t, VolumeBounds::BoundsType bt,
const std::vector<ActsScalar>& bv, const std::vector<BinningValue>& bss,
std::vector<std::unique_ptr<Node>> cs = {})
std::vector<std::unique_ptr<Node>> cs = {}, const Extent& e = Extent())
: name(n),
transform(t),
boundsType(bt),
boundaryValues(bv),
children(std::move(cs)),
binning(bss) {
binning(bss),
extent(e) {
for_each(children.begin(), children.end(),
[this](std::unique_ptr<Node>& c) { c->parent = this; });
}
Expand All @@ -68,22 +71,25 @@ struct Node final {
/// @param bt the boundary type
/// @param bv the boundary values
/// @param isb the internal structure builder (optional)
/// @param e the estimated extent of the node (optional)
Node(const std::string& n, const Transform3& t, VolumeBounds::BoundsType bt,
const std::vector<ActsScalar>& bv,
std::shared_ptr<const IInternalStructureBuilder> isb = nullptr)
std::shared_ptr<const IInternalStructureBuilder> isb = nullptr,
const Extent& e = Extent())
: name(n),
transform(t),
boundsType(bt),
boundaryValues(bv),
internalsBuilder(std::move(isb)) {}
internalsBuilder(std::move(isb)),
extent(e) {}

/// Name identification of this node
std::string name = "";
/// Transform definition of this node
Transform3 transform = Transform3::Identity();
/// Boundary definition of this node
VolumeBounds::BoundsType boundsType = VolumeBounds::eOther;
/// The boundary type
VolumeBounds::BoundsType boundsType = VolumeBounds::eOther;
/// The associated values
std::vector<ActsScalar> boundaryValues = {};
/// Parent node - nullptr for root only
const Node* parent = nullptr;
Expand All @@ -106,6 +112,9 @@ struct Node final {
/// Internal structure builder - for leaf nodes
std::shared_ptr<const IInternalStructureBuilder> internalsBuilder = nullptr;

/// An optional extent object
Extent extent = Extent();

/// @brief Check if it is a leaf node
bool isLeaf() const { return children.empty(); }

Expand Down
12 changes: 12 additions & 0 deletions Core/include/Acts/Geometry/Extent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ class Extent {
/// @param max the maximum parameter
void set(BinningValue bValue, ActsScalar min, ActsScalar max);

/// Set a min value for a dedicated binning value
///
/// @param bValue the binning identification
/// @param min the minimum parameter
void setMin(BinningValue bValue, ActsScalar min);

/// Set a max value for a dedicated binning value
///
/// @param bValue the binning identification
/// @param max the maximum parameter
void setMax(BinningValue bValue, ActsScalar max);

/// (re-)Set the envelope
///
/// @param envelope new envelope to be set
Expand Down
9 changes: 1 addition & 8 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,7 @@ void SeedFinder<external_spacepoint_t, grid_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 ||
zM > m_config.zOutermostLayers.second) {
continue;
}

const float zM = spM->z();
const float uIP = -1. / rM;
const float cosPhiM = -spM->x() * uIP;
const float sinPhiM = -spM->y() * uIP;
Expand Down
5 changes: 0 additions & 5 deletions Core/include/Acts/Seeding/SeedFinderConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ struct SeedFinderConfig {
float deltaRMiddleMinSPRange = 10. * Acts::UnitConstants::mm;
float deltaRMiddleMaxSPRange = 10. * Acts::UnitConstants::mm;

/// Vector containing minimum and maximum z boundaries for cutting middle
/// space-points
std::pair<float, float> zOutermostLayers{-2700 * Acts::UnitConstants::mm,
2700 * Acts::UnitConstants::mm};

/// Seeding parameters used to define the cuts on space-point doublets

/// Minimum radial distance between two doublet components (prefer
Expand Down
14 changes: 14 additions & 0 deletions Core/src/Geometry/Extent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ void Acts::Extent::set(BinningValue bValue, ActsScalar min, ActsScalar max) {
m_constrains.set(bValue);
}

void Acts::Extent::setMin(BinningValue bValue, ActsScalar min) {
ActsScalar minval = min;
if (bValue == binR && minval < 0.) {
minval = 0.;
}
m_range[bValue].setMin(0u, minval);
m_constrains.set(bValue);
}

void Acts::Extent::setMax(BinningValue bValue, ActsScalar max) {
m_range[bValue].setMax(0u, max);
m_constrains.set(bValue);
}

void Acts::Extent::setEnvelope(const ExtentEnvelope& envelope) {
m_envelope = envelope;
}
Expand Down
14 changes: 0 additions & 14 deletions Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,6 @@ ActsExamples::SeedingAlgorithm::SeedingAlgorithm(
throw std::invalid_argument("Inconsistent config zBinNeighborsBottom");
}

if (!m_cfg.seedFinderConfig.zBinsCustomLooping.empty()) {
// check if zBinsCustomLooping contains numbers from 1 to the total number
// of bin in zBinEdges
for (std::size_t i = 1; i != m_cfg.gridConfig.zBinEdges.size(); i++) {
if (std::find(m_cfg.seedFinderConfig.zBinsCustomLooping.begin(),
m_cfg.seedFinderConfig.zBinsCustomLooping.end(),
i) == m_cfg.seedFinderConfig.zBinsCustomLooping.end()) {
throw std::invalid_argument(
"Inconsistent config zBinsCustomLooping does not contain the same "
"bins as zBinEdges");
}
}
}

if (m_cfg.seedFinderConfig.useDetailedDoubleMeasurementInfo) {
m_cfg.seedFinderConfig.getTopHalfStripLength.connect(
[](const void*, const SimSpacePoint& sp) -> float {
Expand Down
24 changes: 18 additions & 6 deletions Examples/Python/python/acts/examples/itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def itkSeedingAlgConfig(
# 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 All @@ -319,6 +318,7 @@ def itkSeedingAlgConfig(
maxPtScattering = float("inf") * u.GeV
zBinEdges = [
-3000.0,
-2700.0,
-2500.0,
-1400.0,
-925.0,
Expand All @@ -329,9 +329,11 @@ def itkSeedingAlgConfig(
925.0,
1400.0,
2500.0,
2700.0,
3000.0,
] # zBinEdges enables non-equidistant binning in z, in case the binning is not defined the edges are evaluated automatically using equidistant binning
rRangeMiddleSP = [
[40.0, 90.0],
[40.0, 90.0],
[40.0, 200.0],
[46.0, 200.0],
Expand All @@ -343,6 +345,7 @@ def itkSeedingAlgConfig(
[46.0, 200.0],
[40.0, 200.0],
[40.0, 90.0],
[40.0, 90.0],
] # if useVariableMiddleSPRange is set to false, the vector rRangeMiddleSP can be used to define a fixed r range for each z bin: {{rMin, rMax}, ...}. If useVariableMiddleSPRange is set to false and the vector is empty, the cuts won't be applied
useVariableMiddleSPRange = True # if useVariableMiddleSPRange is true, the values in rRangeMiddleSP will be calculated based on r values of the SPs and deltaRMiddleSPRange
binSizeR = 1 * u.mm
Expand Down Expand Up @@ -390,32 +393,35 @@ def itkSeedingAlgConfig(
interactionPointCut = True
impactMax = 2 * u.mm
zBinsCustomLooping = [
1,
2,
3,
4,
5,
12,
11,
10,
9,
8,
6,
5,
7,
6,
8,
] # enable custom z looping when searching for SPs, must contain numbers from 1 to the total number of bin in zBinEdges
zBinNeighborsTop = [
[0, 0],
[-1, 0],
[-2, 0],
[-1, 0],
[-1, 0],
[-1, 0],
[-1, 1],
[0, 1],
[0, 1],
[0, 1],
[0, 2],
[0, 1],
[0, 0],
] # allows to specify the number of neighbors desired for each bin, [-1,1] means one neighbor on the left and one on the right, if the vector is empty the algorithm returns the 8 surrounding bins
zBinNeighborsBottom = [
[0, 0],
[0, 1],
[0, 1],
[0, 1],
Expand All @@ -427,6 +433,7 @@ def itkSeedingAlgConfig(
[-1, 0],
[-1, 0],
[-1, 0],
[0, 0],
]
deltaRMiddleMinSPRange = 10 * u.mm
deltaRMiddleMaxSPRange = 10 * u.mm
Expand Down Expand Up @@ -458,17 +465,20 @@ def itkSeedingAlgConfig(
zBinNeighborsTop = [
[0, 0],
[-1, 0],
[-2, 0],
[-1, 0],
[-1, 0],
[-1, 0],
[-1, 1],
[0, 1],
[0, 1],
[0, 1],
[0, 2],
[0, 1],
[0, 0],
]
zBinNeighborsBottom = [
[0, 0],
[0, 1],
[0, 1],
[0, 1],
Expand All @@ -480,6 +490,7 @@ def itkSeedingAlgConfig(
[-1, 0],
[-1, 0],
[-1, 0],
[0, 0],
]
deltaRMiddleMinSPRange = 30 * u.mm
deltaRMiddleMaxSPRange = 150 * u.mm
Expand All @@ -496,6 +507,7 @@ def itkSeedingAlgConfig(
collisionRegionMin = -150 * u.mm
collisionRegionMax = 150 * u.mm
rRangeMiddleSP = [
[40.0, 80.0],
[40.0, 80.0],
[40.0, 200.0],
[70.0, 200.0],
Expand All @@ -507,6 +519,7 @@ def itkSeedingAlgConfig(
[70.0, 200.0],
[40.0, 200.0],
[40.0, 80.0],
[40.0, 80.0],
]
useVariableMiddleSPRange = False

Expand Down Expand Up @@ -537,7 +550,6 @@ def itkSeedingAlgConfig(
collisionRegion=(collisionRegionMin, collisionRegionMax),
r=(None, rMaxSeedFinderConfig),
z=(zMin, zMax),
zOutermostLayers=zOutermostLayers,
)

seedFinderOptionsArg = SeedFinderOptionsArg(bFieldInZ=bFieldInZ, beamPos=beamPos)
Expand Down
31 changes: 3 additions & 28 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@
"collisionRegion", # (min,max)
"r", # (min,max)
"z", # (min,max)
"zOutermostLayers", # (min,max)
],
defaults=[None] * 18 + [(None, None)] * 8,
defaults=[None] * 18 + [(None, None)] * 7,
)
SeedFinderOptionsArg = namedtuple(
"SeedFinderOptions", ["beamPos", "bFieldInZ"], defaults=[(None, None), None]
Expand Down Expand Up @@ -257,8 +256,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, deltaZMax, maxPtScattering, zBinEdges, 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).
seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z)
SeedFinderConfig settings. deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z.
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 @@ -618,18 +617,6 @@ 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 @@ -776,18 +763,6 @@ 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
Loading

0 comments on commit a4c1d2c

Please sign in to comment.