Skip to content

Commit

Permalink
Merge branch 'main' into refactor/vtx-templates-part13-lin-concept
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Mar 1, 2024
2 parents cd84bb0 + 16e558f commit 179cc83
Show file tree
Hide file tree
Showing 22 changed files with 201 additions and 212 deletions.
2 changes: 2 additions & 0 deletions Core/include/Acts/Definitions/PdgParticle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ enum PdgParticle : std::int32_t {
ePionZero = 111,
ePionPlus = 211,
ePionMinus = -ePionPlus,
eKaonPlus = 321,
eKaonMinus = -eKaonPlus,
eNeutron = 2112,
eAntiNeutron = -eNeutron,
eProton = 2212,
Expand Down
9 changes: 9 additions & 0 deletions Core/include/Acts/EventData/ParticleHypothesis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class SinglyChargedParticleHypothesis
static SinglyChargedParticleHypothesis electron() {
return SinglyChargedParticleHypothesis(PdgParticle::eElectron);
}
static SinglyChargedParticleHypothesis kaon() {
return SinglyChargedParticleHypothesis(PdgParticle::eKaonPlus);
}
static SinglyChargedParticleHypothesis proton() {
return SinglyChargedParticleHypothesis(PdgParticle::eProton);
}
Expand Down Expand Up @@ -106,6 +109,9 @@ class NonNeutralChargedParticleHypothesis
static NonNeutralChargedParticleHypothesis electron() {
return SinglyChargedParticleHypothesis::electron();
}
static NonNeutralChargedParticleHypothesis kaon() {
return SinglyChargedParticleHypothesis::kaon();
}
static NonNeutralChargedParticleHypothesis proton() {
return SinglyChargedParticleHypothesis::proton();
}
Expand Down Expand Up @@ -147,6 +153,9 @@ class ParticleHypothesis : public GenericParticleHypothesis<AnyCharge> {
static ParticleHypothesis electron() {
return SinglyChargedParticleHypothesis::electron();
}
static ParticleHypothesis kaon() {
return SinglyChargedParticleHypothesis::kaon();
}
static ParticleHypothesis proton() {
return SinglyChargedParticleHypothesis::proton();
}
Expand Down
43 changes: 27 additions & 16 deletions Core/include/Acts/Vertexing/GaussianGridTrackDensity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,43 @@ namespace Acts {
/// The position of the highest track density (of either a single
/// bin or the sum of a certain region) can be determined.
/// Single tracks can be cached and removed from the overall density.
///
/// @tparam mainGridSize The size of the z-axis 1-dim main density grid
/// @tparam trkGridSize The 2(!)-dim grid size of a single track, i.e.
/// a single track is modelled as a (trkGridSize x trkGridSize) grid
/// in the d0-z0 plane. Note: trkGridSize has to be an odd value.
template <int mainGridSize = 2000, int trkGridSize = 15>
class GaussianGridTrackDensity {
// Assert odd trkGridSize
static_assert(trkGridSize % 2);
// Assert bigger main grid than track grid
static_assert(mainGridSize > trkGridSize);

public:
using MainGridVector = Eigen::Matrix<float, mainGridSize, 1>;
using TrackGridVector = Eigen::Matrix<float, trkGridSize, 1>;
using MainGridVector = Eigen::Matrix<float, Eigen::Dynamic, 1>;
using TrackGridVector = Eigen::Matrix<float, Eigen::Dynamic, 1>;

/// The configuration struct
struct Config {
/// @param zMinMax_ The minimum and maximum z-values (in mm) that
/// should be covered by the main 1-dim density grid along
/// the z-axis
/// @tparam mainGridSize The size of the z-axis 1-dim main density grid
/// @tparam trkGridSize The 2(!)-dim grid size of a single track, i.e.
/// a single track is modelled as a (trkGridSize x trkGridSize) grid
/// in the d0-z0 plane. Note: trkGridSize has to be an odd value.
/// @note The value of @p zMinMax_ together with @p mainGridSize determines the
/// overall bin size to be used as seen below
Config(float zMinMax_ = 100) : zMinMax(zMinMax_) {
Config(float zMinMax_ = 100, int mainGridSize_ = 2000,
int trkGridSize_ = 15)
: mainGridSize(mainGridSize_),
trkGridSize(trkGridSize_),
zMinMax(zMinMax_) {
binSize = 2. * zMinMax / mainGridSize;

if (trkGridSize % 2 == 0) {
throw std::runtime_error(
"GaussianGridTrackDensity: trkGridSize has to be an odd value!");
}
if (mainGridSize < trkGridSize) {
throw std::runtime_error(
"GaussianGridTrackDensity: mainGridSize has to be bigger than "
"trkGridSize!");
}
}

int mainGridSize;
int trkGridSize;

// Min and max z value of big grid
float zMinMax; // mm

Expand Down Expand Up @@ -105,6 +116,8 @@ class GaussianGridTrackDensity {
void removeTrackGridFromMainGrid(int zBin, const TrackGridVector& trkGrid,
MainGridVector& mainGrid) const;

const Config& config() const { return m_cfg; }

private:
/// @brief Helper function that actually adds the track to the
/// main density grid
Expand Down Expand Up @@ -176,5 +189,3 @@ class GaussianGridTrackDensity {
};

} // namespace Acts

#include "Acts/Vertexing/GaussianGridTrackDensity.ipp"
33 changes: 10 additions & 23 deletions Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,18 @@ namespace Acts {
/// density vector) needs to be calculated. All track contributions along the
/// beam axis (main density grid) a superimposed and the z-value of the bin
/// with the highest track density is returned as a vertex candidate.
/// @tparam mainGridSize The size of the z-axis 1-dim main density grid
/// @tparam trkGridSize The 2(!)-dim grid size of a single track, i.e.
/// a single track is modelled as a (trkGridSize x trkGridSize) grid
/// in the d0-z0 plane. Note: trkGridSize has to be an odd value.
template <int mainGridSize = 2000, int trkGridSize = 15>
class GridDensityVertexFinder final : public IVertexFinder {
// Assert odd trkGridSize
static_assert(trkGridSize % 2);
// Assert bigger main grid than track grid
static_assert(mainGridSize > trkGridSize);

using GridDensity = GaussianGridTrackDensity<mainGridSize, trkGridSize>;

public:
using MainGridVector = typename GridDensity::MainGridVector;
using TrackGridVector = typename GridDensity::TrackGridVector;
using MainGridVector = GaussianGridTrackDensity::MainGridVector;
using TrackGridVector = GaussianGridTrackDensity::TrackGridVector;

/// @brief The Config struct
struct Config {
///@param zMinMax min and max z value of big z-axis grid
Config(float zMinMax = 100)
: gridDensity(typename GridDensity::Config(zMinMax)) {}
///@param gDensity The grid density
Config(const GridDensity& gDensity) : gridDensity(gDensity) {}
Config(GaussianGridTrackDensity gDensity) : gridDensity(gDensity) {}

// The grid density object
GridDensity gridDensity;
GaussianGridTrackDensity gridDensity;

// Cache the main grid and the density contributions (trackGrid and z-bin)
// for every single track.
Expand All @@ -82,8 +67,10 @@ class GridDensityVertexFinder final : public IVertexFinder {
///
/// Only needed if cacheGridStateForTrackRemoval == true
struct State {
State(MainGridVector mainGrid_) : mainGrid(std::move(mainGrid_)) {}

// The main density grid
MainGridVector mainGrid = MainGridVector::Zero();
MainGridVector mainGrid;
// Map to store z-bin and track grid (i.e. the density contribution of
// a single track to the main grid) for every single track
std::map<InputTrack, std::pair<int, TrackGridVector>> binAndTrackGridMap;
Expand Down Expand Up @@ -115,7 +102,9 @@ class GridDensityVertexFinder final : public IVertexFinder {

IVertexFinder::State makeState(
const Acts::MagneticFieldContext& /*mctx*/) const override {
return IVertexFinder::State{State{}};
return IVertexFinder::State{
std::in_place_type<State>,
MainGridVector{m_cfg.gridDensity.config().mainGridSize}};
}

void setTracksToRemove(
Expand Down Expand Up @@ -151,5 +140,3 @@ class GridDensityVertexFinder final : public IVertexFinder {
};

} // namespace Acts

#include "GridDensityVertexFinder.ipp"
3 changes: 3 additions & 0 deletions Core/src/Definitions/ParticleData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ std::optional<std::string_view> Acts::pdgToShortAbsString(PdgParticle pdg) {
if (pdg == ePionPlus) {
return "pi";
}
if (pdg == eKaonPlus) {
return "K";
}
if (pdg == eNeutron) {
return "n";
}
Expand Down
2 changes: 2 additions & 0 deletions Core/src/TrackFitting/GlobalChiSquareFitterError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class GlobalChiSquareFitterErrorCategory : public std::error_category {
return "Gx2f: aMatrix is not invertible.";
case GlobalChiSquareFitterError::DidNotConverge:
return "Gx2f: Did not converge in 'nUpdateMax' updates.";
case GlobalChiSquareFitterError::NotEnoughMeasurements:
return "Gx2f: Not enough measurements.";
default:
return "unknown";
}
Expand Down
2 changes: 2 additions & 0 deletions Core/src/Vertexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ target_sources(
TrackDensityVertexFinder.cpp
GaussianTrackDensity.cpp
ImpactPointEstimator.cpp
GaussianGridTrackDensity.cpp
GridDensityVertexFinder.cpp
)
Loading

0 comments on commit 179cc83

Please sign in to comment.