Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Use traccc unit and constant definitions everywhere #866

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions benchmarks/common/benchmarks/toy_detector_benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "traccc/simulation/smearing_writer.hpp"

// Detray include(s).
#include "detray/definitions/units.hpp"
#include "detray/detectors/bfield.hpp"
#include "detray/io/frontend/detector_reader.hpp"
#include "detray/io/frontend/detector_writer.hpp"
Expand Down Expand Up @@ -73,7 +72,7 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
using b_field_t = covfie::field<detray::bfield::const_bknd_t<scalar_type>>;

static constexpr traccc::vector3 B{0, 0,
2 * detray::unit<traccc::scalar>::T};
2 * traccc::unit<traccc::scalar>::T};

ToyDetectorBenchmark() {

Expand Down Expand Up @@ -110,8 +109,8 @@ class ToyDetectorBenchmark : public benchmark::Fixture {

// Smearing value for measurements
traccc::measurement_smearer<traccc::default_algebra> meas_smearer(
50 * detray::unit<traccc::scalar>::um,
50 * detray::unit<traccc::scalar>::um);
50 * traccc::unit<traccc::scalar>::um,
50 * traccc::unit<traccc::scalar>::um);

// Type declarations
using writer_type = traccc::smearing_writer<
Expand All @@ -134,7 +133,7 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
apply_propagation_config(sim.get_config().propagation);
// Set constrained step size to 1 mm
sim.get_config().propagation.stepping.step_constraint =
1.f * detray::unit<float>::mm;
1.f * traccc::unit<float>::mm;

sim.run();

Expand All @@ -155,17 +154,17 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
toy_cfg.n_brl_layers(4u).n_edc_layers(7u).do_check(false);

// @TODO: Increase the material budget again
toy_cfg.module_mat_thickness(0.11f * detray::unit<traccc::scalar>::mm);
toy_cfg.module_mat_thickness(0.11f * traccc::unit<traccc::scalar>::mm);

return toy_cfg;
}

void apply_propagation_config(detray::propagation::config& cfg) const {
// Configure the propagation for the toy detector
cfg.navigation.search_window = {3, 3};
cfg.navigation.overstep_tolerance = -300.f * detray::unit<float>::um;
cfg.navigation.min_mask_tolerance = 1e-5f * detray::unit<float>::mm;
cfg.navigation.max_mask_tolerance = 3.f * detray::unit<float>::mm;
cfg.navigation.overstep_tolerance = -300.f * traccc::unit<float>::um;
cfg.navigation.min_mask_tolerance = 1e-5f * traccc::unit<float>::mm;
cfg.navigation.max_mask_tolerance = 3.f * traccc::unit<float>::mm;
cfg.navigation.mask_tolerance_scalor = 0.05f;
}

Expand Down
4 changes: 2 additions & 2 deletions core/include/traccc/finding/finding_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#pragma once

// traccc include(s).
#include "traccc/definitions/common.hpp"
#include "traccc/definitions/primitives.hpp"

// detray include(s).
#include "detray/definitions/pdg_particle.hpp"
#include "detray/definitions/units.hpp"
#include "detray/propagator/propagation_config.hpp"

namespace traccc {
Expand All @@ -35,7 +35,7 @@ struct finding_config {
/// Minimum step length that track should make to reach the next surface. It
/// should be set higher than the overstep tolerance not to make it stay on
/// the same surface
float min_step_length_for_next_surface = 0.5f * detray::unit<float>::mm;
float min_step_length_for_next_surface = 0.5f * traccc::unit<float>::mm;
/// Maximum step counts that track can make to reach the next surface
unsigned int max_step_counts_for_next_surface = 100;

Expand Down
2 changes: 1 addition & 1 deletion core/include/traccc/fitting/fitting_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#pragma once

// Local include(s).
#include "traccc/definitions/common.hpp"
#include "traccc/definitions/primitives.hpp"

// detray include(s).
#include "detray/definitions/pdg_particle.hpp"
#include "detray/definitions/units.hpp"
#include "detray/propagator/propagation_config.hpp"

namespace traccc {
Expand Down
12 changes: 6 additions & 6 deletions core/include/traccc/seeding/track_params_estimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class track_params_estimation
const spacepoint_collection_types::host& spacepoints,
const seed_collection_types::host& seeds, const vector3& bfield,
const std::array<traccc::scalar, traccc::e_bound_size>& stddev = {
0.02f * detray::unit<traccc::scalar>::mm,
0.03f * detray::unit<traccc::scalar>::mm,
1.f * detray::unit<traccc::scalar>::degree,
1.f * detray::unit<traccc::scalar>::degree,
0.01f / detray::unit<traccc::scalar>::GeV,
1.f * detray::unit<traccc::scalar>::ns}) const override;
0.02f * traccc::unit<traccc::scalar>::mm,
0.03f * traccc::unit<traccc::scalar>::mm,
1.f * traccc::unit<traccc::scalar>::degree,
1.f * traccc::unit<traccc::scalar>::degree,
0.01f / traccc::unit<traccc::scalar>::GeV,
1.f * traccc::unit<traccc::scalar>::ns}) const override;

private:
/// The memory resource to use in the algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ struct track_params_estimation
const seed_collection_types::const_view& seeds_view,
const vector3& bfield,
const std::array<traccc::scalar, traccc::e_bound_size>& = {
0.02f * detray::unit<traccc::scalar>::mm,
0.03f * detray::unit<traccc::scalar>::mm,
1.f * detray::unit<traccc::scalar>::degree,
1.f * detray::unit<traccc::scalar>::degree,
0.01f / detray::unit<traccc::scalar>::GeV,
1.f * detray::unit<traccc::scalar>::ns}) const override;
0.02f * traccc::unit<traccc::scalar>::mm,
0.03f * traccc::unit<traccc::scalar>::mm,
1.f * traccc::unit<traccc::scalar>::degree,
1.f * traccc::unit<traccc::scalar>::degree,
0.01f / traccc::unit<traccc::scalar>::GeV,
1.f * traccc::unit<traccc::scalar>::ns}) const override;

private:
/// Memory resource used by the algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ struct track_params_estimation
const seed_collection_types::const_view& seeds_view,
const vector3& bfield,
const std::array<traccc::scalar, traccc::e_bound_size>& = {
0.02f * detray::unit<traccc::scalar>::mm,
0.03f * detray::unit<traccc::scalar>::mm,
1.f * detray::unit<traccc::scalar>::degree,
1.f * detray::unit<traccc::scalar>::degree,
0.01f / detray::unit<traccc::scalar>::GeV,
1.f * detray::unit<traccc::scalar>::ns}) const override;
0.02f * traccc::unit<traccc::scalar>::mm,
0.03f * traccc::unit<traccc::scalar>::mm,
1.f * traccc::unit<traccc::scalar>::degree,
1.f * traccc::unit<traccc::scalar>::degree,
0.01f / traccc::unit<traccc::scalar>::GeV,
1.f * traccc::unit<traccc::scalar>::ns}) const override;

private:
/// Memory resource used by the algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ struct track_params_estimation
const seed_collection_types::const_view& seeds_view,
const vector3& bfield,
const std::array<traccc::scalar, traccc::e_bound_size>& stddev = {
0.02f * detray::unit<traccc::scalar>::mm,
0.03f * detray::unit<traccc::scalar>::mm,
1.f * detray::unit<traccc::scalar>::degree,
1.f * detray::unit<traccc::scalar>::degree,
0.01f / detray::unit<traccc::scalar>::GeV,
1.f * detray::unit<traccc::scalar>::ns}) const override;
0.02f * traccc::unit<traccc::scalar>::mm,
0.03f * traccc::unit<traccc::scalar>::mm,
1.f * traccc::unit<traccc::scalar>::degree,
1.f * traccc::unit<traccc::scalar>::degree,
0.01f / traccc::unit<traccc::scalar>::GeV,
1.f * traccc::unit<traccc::scalar>::ns}) const override;

private:
// Private member variables
Expand Down
4 changes: 1 addition & 3 deletions examples/options/include/traccc/options/track_finding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
#pragma once

// Project include(s).
#include "traccc/definitions/common.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/options/details/config_provider.hpp"
#include "traccc/options/details/interface.hpp"
#include "traccc/options/details/value_array.hpp"

// detray include(s).
#include "detray/definitions/units.hpp"

// System include(s).
#include <limits>

Expand Down
24 changes: 11 additions & 13 deletions examples/options/src/generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
// Project include(s).
#include "traccc/options/generation.hpp"

#include "traccc/definitions/common.hpp"
#include "traccc/examples/utils/printable.hpp"
#include "traccc/utils/particle.hpp"
#include "traccc/utils/ranges.hpp"

// Detray include(s).
#include "detray/definitions/units.hpp"

// System include(s).
#include <sstream>

Expand Down Expand Up @@ -65,10 +63,10 @@ generation::generation() : interface("Particle Generation Options") {

void generation::read(const po::variables_map &vm) {

vertex *= detray::unit<float>::mm;
vertex_stddev *= detray::unit<float>::mm;
mom_range *= detray::unit<float>::GeV;
phi_range *= detray::unit<float>::degree;
vertex *= traccc::unit<float>::mm;
vertex_stddev *= traccc::unit<float>::mm;
mom_range *= traccc::unit<float>::GeV;
phi_range *= traccc::unit<float>::degree;

// The eta and theta range can not be specified at the same time
if (vm.count("gen-eta") && !vm["gen-eta"].defaulted() &&
Expand All @@ -78,7 +76,7 @@ void generation::read(const po::variables_map &vm) {
} else if (vm.count("gen-eta") && !vm["gen-eta"].defaulted()) {
theta_range = eta_to_theta_range(eta_range);
} else if (vm.count("gen-theta") && !vm["gen-theta"].defaulted()) {
theta_range *= detray::unit<float>::degree;
theta_range *= traccc::unit<float>::degree;
eta_range = theta_to_eta_range(theta_range);
}

Expand All @@ -93,27 +91,27 @@ std::unique_ptr<configuration_printable> generation::as_printable() const {
cat->add_child(std::make_unique<configuration_kv_pair>(
"Number of particles", std::to_string(gen_nparticles)));
std::ostringstream vertex_ss;
vertex_ss << vertex / detray::unit<float>::mm << " mm";
vertex_ss << vertex / traccc::unit<float>::mm << " mm";
cat->add_child(
std::make_unique<configuration_kv_pair>("Vertex", vertex_ss.str()));
std::ostringstream vertex_dev_ss;
vertex_dev_ss << vertex_stddev / detray::unit<float>::mm << " mm";
vertex_dev_ss << vertex_stddev / traccc::unit<float>::mm << " mm";
cat->add_child(std::make_unique<configuration_kv_pair>(
"Vertex standard deviation", vertex_dev_ss.str()));
std::ostringstream mom_range_ss;
mom_range_ss << mom_range / detray::unit<float>::GeV << " GeV";
mom_range_ss << mom_range / traccc::unit<float>::GeV << " GeV";
cat->add_child(std::make_unique<configuration_kv_pair>("Momentum range",
mom_range_ss.str()));
std::ostringstream phi_range_ss;
phi_range_ss << phi_range / detray::unit<float>::degree << " deg";
phi_range_ss << phi_range / traccc::unit<float>::degree << " deg";
cat->add_child(std::make_unique<configuration_kv_pair>("Phi range",
phi_range_ss.str()));
std::ostringstream eta_range_ss;
eta_range_ss << eta_range;
cat->add_child(std::make_unique<configuration_kv_pair>("Eta range",
eta_range_ss.str()));
std::ostringstream theta_range_ss;
theta_range_ss << theta_range / detray::unit<float>::degree << " deg";
theta_range_ss << theta_range / traccc::unit<float>::degree << " deg";
cat->add_child(std::make_unique<configuration_kv_pair>(
"Theta range", theta_range_ss.str()));
cat->add_child(std::make_unique<configuration_kv_pair>(
Expand Down
20 changes: 9 additions & 11 deletions examples/options/src/telescope_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
// Project include(s).
#include "traccc/options/telescope_detector.hpp"

#include "traccc/definitions/common.hpp"
#include "traccc/examples/utils/printable.hpp"

// Detray include(s).
#include "detray/definitions/units.hpp"

// System include(s).
#include <sstream>

Expand Down Expand Up @@ -49,10 +47,10 @@ telescope_detector::telescope_detector()

void telescope_detector::read(const po::variables_map &) {

thickness *= detray::unit<float>::mm;
spacing *= detray::unit<float>::mm;
smearing *= detray::unit<float>::um;
half_length *= detray::unit<float>::mm;
thickness *= traccc::unit<float>::mm;
spacing *= traccc::unit<float>::mm;
smearing *= traccc::unit<float>::um;
half_length *= traccc::unit<float>::mm;
}

std::unique_ptr<configuration_printable> telescope_detector::as_printable()
Expand All @@ -65,15 +63,15 @@ std::unique_ptr<configuration_printable> telescope_detector::as_printable()
"Number of planes", std::to_string(n_planes)));
cat->add_child(std::make_unique<configuration_kv_pair>(
"Slab thickness",
std::to_string(thickness / detray::unit<float>::mm) + " mm"));
std::to_string(thickness / traccc::unit<float>::mm) + " mm"));
cat->add_child(std::make_unique<configuration_kv_pair>(
"Spacing", std::to_string(spacing / detray::unit<float>::mm) + " mm"));
"Spacing", std::to_string(spacing / traccc::unit<float>::mm) + " mm"));
cat->add_child(std::make_unique<configuration_kv_pair>(
"Smearing",
std::to_string(thickness / detray::unit<float>::um) + " um"));
std::to_string(thickness / traccc::unit<float>::um) + " um"));
cat->add_child(std::make_unique<configuration_kv_pair>(
"Half length",
std::to_string(half_length / detray::unit<float>::mm) + " mm"));
std::to_string(half_length / traccc::unit<float>::mm) + " mm"));
std::ostringstream align_ss;
align_ss << align_vector;
cat->add_child(std::make_unique<configuration_kv_pair>("Alignment axis",
Expand Down
30 changes: 14 additions & 16 deletions examples/options/src/track_propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
// Project include(s).
#include "traccc/options/track_propagation.hpp"

#include "traccc/definitions/common.hpp"
#include "traccc/examples/utils/printable.hpp"

// Detray include(s).
#include <detray/definitions/units.hpp>

// System include(s).
#include <format>
#include <limits>
Expand Down Expand Up @@ -63,10 +61,10 @@ track_propagation::track_propagation()

void track_propagation::read(const po::variables_map &) {

m_config.stepping.step_constraint *= detray::unit<float>::mm;
m_config.navigation.overstep_tolerance *= detray::unit<float>::um;
m_config.navigation.min_mask_tolerance *= detray::unit<float>::mm;
m_config.navigation.max_mask_tolerance *= detray::unit<float>::mm;
m_config.stepping.step_constraint *= traccc::unit<float>::mm;
m_config.navigation.overstep_tolerance *= traccc::unit<float>::um;
m_config.navigation.min_mask_tolerance *= traccc::unit<float>::mm;
m_config.navigation.max_mask_tolerance *= traccc::unit<float>::mm;
m_config.navigation.search_window = m_search_window;
}

Expand All @@ -81,24 +79,24 @@ std::unique_ptr<configuration_printable> track_propagation::as_printable()
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Min mask tolerance",
std::to_string(m_config.navigation.min_mask_tolerance /
detray::unit<float>::mm) +
traccc::unit<float>::mm) +
" mm"));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Max mask tolerance",
std::to_string(m_config.navigation.max_mask_tolerance /
detray::unit<float>::mm) +
traccc::unit<float>::mm) +
" mm"));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Mask tolerance scalar",
std::to_string(m_config.navigation.mask_tolerance_scalor)));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Path tolerance", std::to_string(m_config.navigation.path_tolerance /
detray::unit<float>::um) +
traccc::unit<float>::um) +
" um"));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Overstep tolerance",
std::to_string(m_config.navigation.overstep_tolerance /
detray::unit<float>::um) +
traccc::unit<float>::um) +
" um"));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Search window",
Expand All @@ -109,26 +107,26 @@ std::unique_ptr<configuration_printable> track_propagation::as_printable()

cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Min step size", std::to_string(m_config.stepping.min_stepsize /
detray::unit<float>::mm) +
traccc::unit<float>::mm) +
" mm"));
cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Runge-Kutta tolerance", std::to_string(m_config.stepping.rk_error_tol /
detray::unit<float>::mm) +
traccc::unit<float>::mm) +
" mm"));
cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Max step updates", std::to_string(m_config.stepping.max_rk_updates)));
cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Step size constraint",
std::to_string(m_config.stepping.step_constraint /
detray::unit<float>::mm) +
traccc::unit<float>::mm) +
" mm"));
cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Path limit",
std::to_string(m_config.stepping.path_limit / detray::unit<float>::m) +
std::to_string(m_config.stepping.path_limit / traccc::unit<float>::m) +
" m"));
cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Min step size", std::to_string(m_config.stepping.min_stepsize /
detray::unit<float>::mm) +
traccc::unit<float>::mm) +
" mm"));
cat_tsp->add_child(std::make_unique<configuration_kv_pair>(
"Enable Bethe energy loss",
Expand Down
Loading
Loading